Merge android12-gs-pixel-5.10-sc-v2 into android12-gs-pixel-5.10-sc-qpr3

SBMerger: 410055097
Change-Id: Id340c0165335247e9565d53e7d54ffe323bc9931
Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
diff --git a/drivers/edgetpu/edgetpu-dmabuf.c b/drivers/edgetpu/edgetpu-dmabuf.c
index f98aafe..276da72 100644
--- a/drivers/edgetpu/edgetpu-dmabuf.c
+++ b/drivers/edgetpu/edgetpu-dmabuf.c
@@ -723,7 +723,7 @@
 			  __func__, ret);
 		goto err_release_map;
 	}
-	arg->device_address = dmap->map.device_address;
+	arg->device_address = tpu_addr;
 	mutex_unlock(&group->lock);
 	dma_buf_put(dmabuf);
 	return 0;
diff --git a/drivers/edgetpu/edgetpu-kci.c b/drivers/edgetpu/edgetpu-kci.c
index bfa356f..9339953 100644
--- a/drivers/edgetpu/edgetpu-kci.c
+++ b/drivers/edgetpu/edgetpu-kci.c
@@ -507,6 +507,8 @@
 int edgetpu_kci_reinit(struct edgetpu_kci *kci)
 {
 	struct edgetpu_mailbox *mailbox = kci->mailbox;
+	struct edgetpu_mailbox_manager *mgr;
+	unsigned long flags;
 	int ret;
 
 	if (!mailbox)
@@ -521,6 +523,13 @@
 					QUEUE_SIZE);
 	if (ret)
 		return ret;
+
+	mgr = mailbox->etdev->mailbox_manager;
+	/* Restore KCI irq handler */
+	write_lock_irqsave(&mgr->mailboxes_lock, flags);
+	mailbox->handle_irq = edgetpu_kci_handle_irq;
+	write_unlock_irqrestore(&mgr->mailboxes_lock, flags);
+
 	edgetpu_mailbox_init_doorbells(mailbox);
 	edgetpu_mailbox_enable(mailbox);
 
@@ -529,6 +538,16 @@
 
 void edgetpu_kci_cancel_work_queues(struct edgetpu_kci *kci)
 {
+	struct edgetpu_mailbox_manager *mgr;
+	unsigned long flags;
+
+	if (kci->mailbox) {
+		mgr = kci->mailbox->etdev->mailbox_manager;
+		/* Remove IRQ handler to stop responding to interrupts */
+		write_lock_irqsave(&mgr->mailboxes_lock, flags);
+		kci->mailbox->handle_irq = NULL;
+		write_unlock_irqrestore(&mgr->mailboxes_lock, flags);
+	}
 	/* Cancel workers that may send KCIs. */
 	cancel_work_sync(&kci->usage_work);
 	/* Cancel KCI and reverse KCI workers. */