summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuma copybara merger <zuma-automerger@google.com>2023-07-07 05:56:05 +0000
committerCopybara-Service <copybara-worker@google.com>2023-07-06 23:27:42 -0700
commit37cbd846ec90a15c48da22663509f824cfaa2dd5 (patch)
treed8b04b619e298942acc6ed309b9829ee70f2ae0c
parentfb9aca91f2b733ed0d6231aec22bedc4ae9da6b4 (diff)
downloadrio-37cbd846ec90a15c48da22663509f824cfaa2dd5.tar.gz
edgetpu: move ctx activation to group activation The problem is the context activation/deactivation calls could be called when the device is powered off when a group is marked as non-detachable. To fix this we always do context activation / deactivation on wakelock acquirement / releasing instead of on domain attaching / detaching. Test: Astress Bug: 277256378 edgetpu: rio: LPM patch to fix FRC clock timing violation Bug: 287661979 (cherry picked from commit 584af84078d0a02399a71f92040fac2e2ce2d88e) Signed-off-by: Zuma copybara merger <zuma-automerger@google.com> GitOrigin-RevId: b2c243b9351955c18780b887b3790e38b133e494 Change-Id: I1202f29697ab69543ddc3f83770919c57ab972e4
-rw-r--r--drivers/edgetpu/edgetpu-device-group.c7
-rw-r--r--drivers/edgetpu/edgetpu-google-iommu.c7
-rw-r--r--drivers/edgetpu/rio-pm.c10
3 files changed, 17 insertions, 7 deletions
diff --git a/drivers/edgetpu/edgetpu-device-group.c b/drivers/edgetpu/edgetpu-device-group.c
index 3e94dcd..2b97d87 100644
--- a/drivers/edgetpu/edgetpu-device-group.c
+++ b/drivers/edgetpu/edgetpu-device-group.c
@@ -33,6 +33,7 @@
#include "edgetpu-kci.h"
#include "edgetpu-mapping.h"
#include "edgetpu-mmu.h"
+#include "edgetpu-soc.h"
#include "edgetpu-sw-watchdog.h"
#include "edgetpu-wakelock.h"
#include "edgetpu.h"
@@ -83,6 +84,7 @@ static int edgetpu_group_activate(struct edgetpu_device_group *group)
return 0;
mailbox_id = edgetpu_group_context_id_locked(group);
+ edgetpu_soc_activate_context(group->etdev, mailbox_id);
ret = edgetpu_mailbox_activate(group->etdev, mailbox_id, group->mbox_attr.client_priv,
group->vcid, !group->activated);
if (ret) {
@@ -116,6 +118,11 @@ static void edgetpu_group_deactivate(struct edgetpu_device_group *group)
edgetpu_sw_wdt_dec_active_ref(group->etdev);
mailbox_id = edgetpu_group_context_id_locked(group);
edgetpu_mailbox_deactivate(group->etdev, mailbox_id);
+ /*
+ * Deactivate the context to prevent speculative accesses from being issued to a disabled
+ * context.
+ */
+ edgetpu_soc_deactivate_context(group->etdev, mailbox_id);
}
/*
diff --git a/drivers/edgetpu/edgetpu-google-iommu.c b/drivers/edgetpu/edgetpu-google-iommu.c
index 4bf836f..a432783 100644
--- a/drivers/edgetpu/edgetpu-google-iommu.c
+++ b/drivers/edgetpu/edgetpu-google-iommu.c
@@ -19,7 +19,6 @@
#include "edgetpu-internal.h"
#include "edgetpu-mapping.h"
#include "edgetpu-mmu.h"
-#include "edgetpu-soc.h"
#if !defined(EDGETPU_NUM_PREALLOCATED_DOMAINS)
#define EDGETPU_NUM_PREALLOCATED_DOMAINS 0
@@ -555,7 +554,6 @@ int edgetpu_mmu_attach_domain(struct edgetpu_dev *etdev,
goto err_detach;
}
- edgetpu_soc_activate_context(etdev, pasid);
etiommu->gdomains[pasid] = gdomain;
etdomain->pasid = pasid;
return 0;
@@ -575,11 +573,6 @@ void edgetpu_mmu_detach_domain(struct edgetpu_dev *etdev,
if (pasid <= 0 || pasid >= EDGETPU_NCONTEXTS)
return;
- /*
- * Deactivate the context before domain detaching to prevent speculative accesses from being
- * issued to a disabled context.
- */
- edgetpu_soc_deactivate_context(etdev, pasid);
etiommu->gdomains[pasid] = NULL;
etdomain->pasid = IOMMU_PASID_INVALID;
iommu_aux_detach_device(etdomain->gdomain->domain, etdev->dev);
diff --git a/drivers/edgetpu/rio-pm.c b/drivers/edgetpu/rio-pm.c
index c50949a..bba5e18 100644
--- a/drivers/edgetpu/rio-pm.c
+++ b/drivers/edgetpu/rio-pm.c
@@ -83,6 +83,7 @@ static void rio_patch_lpm(struct edgetpu_dev *etdev)
EDGETPU_LPM_IMEM_OPS_SET(etdev, 200, 0x0bc95001);
EDGETPU_LPM_IMEM_OPS_SET(etdev, 201, 0x14171018);
EDGETPU_LPM_IMEM_OPS_SET(etdev, 202, 0x02001118);
+
/* psm_1_state_table_0_trans_1_next_state */
edgetpu_dev_write_32_sync(etdev, 0x1c2020, 0x00000000);
/* psm_1_state_table_0_trans_1_seq_addr */
@@ -93,6 +94,15 @@ static void rio_patch_lpm(struct edgetpu_dev *etdev)
edgetpu_dev_write_32_sync(etdev, 0x1c2034, 0x00000001);
/* trigger_csr_events_en_5_hi */
edgetpu_dev_write_32_sync(etdev, 0x1c012c, 0x00000003);
+
+ /*
+ * FRC clocking fix for b/287661979.
+ *
+ * Increases the delay between cluster clock enablement and logic
+ * retention/restore activation.
+ */
+ EDGETPU_LPM_IMEM_OPS_SET(etdev, 3, 0x21261101);
+ EDGETPU_LPM_IMEM_OPS_SET(etdev, 4, 0x11111005);
}
static int rio_lpm_up(struct edgetpu_dev *etdev)