summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Prajapati <nishantpjpt@google.com>2021-11-18 09:55:27 +0530
committerSermin Aydin <sermin@google.com>2022-01-11 03:07:56 +0000
commite3c8f9749cf0312782e159253187fab5dbb88c86 (patch)
tree0d2cefbcfc8a3df3ab7981d96a61aef15e3f2742
parent51ec41e0208a9cf8456f9ae4374aa2217839c2db (diff)
downloadedgetpu-android-gs-raviole-5.10-android12L.tar.gz
Unregister KCI irq handler while cancelling KCI work queues to avoid serving interrupt in case of device in power down state. Bug: 210571509 Note:206717576,204847583 Signed-off-by: Nishant Prajapati <nishantpjpt@google.com> Change-Id: Ia77c0470c82bae39086b498f31a598b996a715eb
-rw-r--r--drivers/edgetpu/edgetpu-kci.c19
1 files changed, 19 insertions, 0 deletions
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_init(struct edgetpu_mailbox_manager *mgr,
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 @@ int edgetpu_kci_reinit(struct edgetpu_kci *kci)
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 @@ int edgetpu_kci_reinit(struct edgetpu_kci *kci)
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. */