summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurora zuma automerger <aurora-zuma-automerger@google.com>2023-02-21 12:44:14 +0000
committerCopybara-Service <copybara-worker@google.com>2023-02-21 23:43:12 -0800
commit1f96601aed9b8837e5155eb38f80d05a2220302e (patch)
tree4bd999b78ab04f2d8288d1d79df983430b8cd375
parente291a019ae3f59479203fbf5ece6456f7bba7627 (diff)
downloadzuma-1f96601aed9b8837e5155eb38f80d05a2220302e.tar.gz
gxp: [Copybara Auto Merge] Merge branch 'zuma' into 'android14-gs-pixel-5.15'
gxp: stop mapping core->TPU queues gxp: get core_count by counting bits Bug: 270097855 gxp: set SSMT to bypass in both mode Bug: 269855604 gxp: Skip gxp_vd_block_unready if gxp_vd_block_ready was not executed Bug: 268427254 gcip: remove redundant else in pm.c GCIP_MAIN_REV_ID: 834934c87c0130a0c02e930a45f5414dd852ca85 GitOrigin-RevId: 42dccad0cb767c46e6a45d3ac6ba1750fbffdec6 Change-Id: I6ab56afeb1ace081ad1222dfbb905e3238f74f6e
-rw-r--r--gcip-kernel-driver/drivers/gcip/gcip-pm.c3
-rw-r--r--gxp-client.c5
-rw-r--r--gxp-common-platform.c15
-rw-r--r--gxp-dma-iommu.c3
-rw-r--r--gxp-ssmt.c28
-rw-r--r--gxp-ssmt.h14
-rw-r--r--gxp-vd.c9
7 files changed, 49 insertions, 28 deletions
diff --git a/gcip-kernel-driver/drivers/gcip/gcip-pm.c b/gcip-kernel-driver/drivers/gcip/gcip-pm.c
index 43d9654..54589e0 100644
--- a/gcip-kernel-driver/drivers/gcip/gcip-pm.c
+++ b/gcip-kernel-driver/drivers/gcip/gcip-pm.c
@@ -228,8 +228,7 @@ void gcip_pm_shutdown(struct gcip_pm *pm, bool force)
if (pm->count) {
if (!force)
goto unlock;
- else
- dev_warn(pm->dev, "Force shutdown with power up count: %d", pm->count);
+ dev_warn(pm->dev, "Force shutdown with power up count: %d", pm->count);
}
gcip_pm_try_power_down(pm);
diff --git a/gxp-client.c b/gxp-client.c
index 7c96e9a..a776542 100644
--- a/gxp-client.c
+++ b/gxp-client.c
@@ -65,10 +65,7 @@ void gxp_client_destroy(struct gxp_client *client)
if (client->vd) {
if (gxp->before_unmap_tpu_mbx_queue)
gxp->before_unmap_tpu_mbx_queue(gxp, client);
- /*
- * TODO(b/237624453): remove '|| 1' once the MCU supports DSP->TPU interop
- */
- if (gxp_is_direct_mode(gxp) || 1)
+ if (gxp_is_direct_mode(gxp))
gxp_dma_unmap_tpu_buffer(gxp,
client->vd->domain,
client->mbx_desc);
diff --git a/gxp-common-platform.c b/gxp-common-platform.c
index de3417c..2a3515f 100644
--- a/gxp-common-platform.c
+++ b/gxp-common-platform.c
@@ -9,6 +9,7 @@
#include <linux/platform_data/sscoredump.h>
#endif
+#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/file.h>
@@ -893,8 +894,8 @@ static int map_tpu_mbx_queue(struct gxp_client *client,
down_read(&gxp->vd_semaphore);
- core_count = client->vd->num_cores;
phys_core_list = client->vd->core_list;
+ core_count = hweight_long(phys_core_list);
mbx_info = kmalloc(
sizeof(struct edgetpu_ext_mailbox_info) +
@@ -977,8 +978,7 @@ static int gxp_map_tpu_mbx_queue(struct gxp_client *client,
int ret = 0;
if (!gxp->tpu_dev.mbx_paddr) {
- dev_err(gxp->dev, "%s: TPU is not available for interop\n",
- __func__);
+ dev_err(gxp->dev, "TPU is not available for interop\n");
return -EINVAL;
}
@@ -1014,8 +1014,7 @@ static int gxp_map_tpu_mbx_queue(struct gxp_client *client,
goto out_unlock_client_semaphore;
}
- /* TODO(b/237624453): remove '|| 1' once the MCU supports DSP->TPU interop */
- if (gxp_is_direct_mode(gxp) || 1) {
+ if (gxp_is_direct_mode(gxp)) {
ret = map_tpu_mbx_queue(client, &ibuf);
if (ret)
goto err_fput_tpu_file;
@@ -1030,7 +1029,8 @@ static int gxp_map_tpu_mbx_queue(struct gxp_client *client,
goto out_unlock_client_semaphore;
err_unmap_tpu_mbx_queue:
- unmap_tpu_mbx_queue(client, &ibuf);
+ if (gxp_is_direct_mode(gxp))
+ unmap_tpu_mbx_queue(client, &ibuf);
err_fput_tpu_file:
fput(client->tpu_file);
client->tpu_file = NULL;
@@ -1068,8 +1068,7 @@ static int gxp_unmap_tpu_mbx_queue(struct gxp_client *client,
if (gxp->before_unmap_tpu_mbx_queue)
gxp->before_unmap_tpu_mbx_queue(gxp, client);
- /* TODO(b/237624453): remove '|| 1' once the MCU supports DSP->TPU interop */
- if (gxp_is_direct_mode(gxp) || 1)
+ if (gxp_is_direct_mode(gxp))
unmap_tpu_mbx_queue(client, &ibuf);
fput(client->tpu_file);
diff --git a/gxp-dma-iommu.c b/gxp-dma-iommu.c
index 94a78b3..87bb649 100644
--- a/gxp-dma-iommu.c
+++ b/gxp-dma-iommu.c
@@ -90,8 +90,7 @@ static int gxp_dma_ssmt_program(struct gxp_dev *gxp,
gxp_ssmt_set_core_vid(&mgr->ssmt, core, pasid);
}
} else {
- for (core = 0; core < GXP_NUM_CORES; core++)
- gxp_ssmt_set_core_bypass(&mgr->ssmt, core);
+ gxp_ssmt_set_bypass(&mgr->ssmt);
}
return 0;
}
diff --git a/gxp-ssmt.c b/gxp-ssmt.c
index f44fc6a..657f4e8 100644
--- a/gxp-ssmt.c
+++ b/gxp-ssmt.c
@@ -11,12 +11,12 @@
#include "gxp-internal.h"
#include "gxp-ssmt.h"
-static inline void ssmt_set_vid_for_sid(void __iomem *ssmt, uint vid, uint sid)
+static inline void ssmt_set_vid_for_idx(void __iomem *ssmt, uint vid, uint idx)
{
/* NS_READ_STREAM_VID_<sid> */
- writel(vid, ssmt + 0x1000u + 0x4u * sid);
+ writel(vid, ssmt + 0x1000u + 0x4u * idx);
/* NS_WRITE_STREAM_VID_<sid> */
- writel(vid, ssmt + 0x1200u + 0x4u * sid);
+ writel(vid, ssmt + 0x1200u + 0x4u * idx);
}
int gxp_ssmt_init(struct gxp_dev *gxp, struct gxp_ssmt *ssmt)
@@ -69,7 +69,25 @@ void gxp_ssmt_set_core_vid(struct gxp_ssmt *ssmt, uint core, uint vid)
int i;
for (i = 0; i < ARRAY_SIZE(sids); i++) {
- ssmt_set_vid_for_sid(ssmt->idma_ssmt_base, vid, sids[i]);
- ssmt_set_vid_for_sid(ssmt->inst_data_ssmt_base, vid, sids[i]);
+ ssmt_set_vid_for_idx(ssmt->idma_ssmt_base, vid, sids[i]);
+ ssmt_set_vid_for_idx(ssmt->inst_data_ssmt_base, vid, sids[i]);
+ }
+}
+
+void gxp_ssmt_set_bypass(struct gxp_ssmt *ssmt)
+{
+ u32 mode;
+ uint core, i;
+
+ mode = readl(ssmt->idma_ssmt_base + SSMT_CFG_OFFSET);
+ if (mode == SSMT_MODE_CLIENT) {
+ for (i = 0; i < MAX_NUM_CONTEXTS; i++) {
+ ssmt_set_vid_for_idx(ssmt->idma_ssmt_base, i, i);
+ ssmt_set_vid_for_idx(ssmt->inst_data_ssmt_base, i, i);
+ }
+ } else {
+ for (core = 0; core < GXP_NUM_CORES; core++)
+ gxp_ssmt_set_core_vid(ssmt, core,
+ SSMT_CLAMP_MODE_BYPASS);
}
}
diff --git a/gxp-ssmt.h b/gxp-ssmt.h
index 6cf8971..b37bb53 100644
--- a/gxp-ssmt.h
+++ b/gxp-ssmt.h
@@ -10,7 +10,12 @@
#include "gxp-internal.h"
+#define SSMT_CFG_OFFSET (0x0004)
+#define SSMT_MODE_CLAMPED (0x0u)
+#define SSMT_MODE_CLIENT (0x1u)
+
#define SSMT_CLAMP_MODE_BYPASS (1u << 31)
+#define MAX_NUM_CONTEXTS 8
struct gxp_ssmt {
struct gxp_dev *gxp;
@@ -33,9 +38,10 @@ int gxp_ssmt_init(struct gxp_dev *gxp, struct gxp_ssmt *ssmt);
*/
void gxp_ssmt_set_core_vid(struct gxp_ssmt *ssmt, uint core, uint vid);
-static inline void gxp_ssmt_set_core_bypass(struct gxp_ssmt *ssmt, uint core)
-{
- gxp_ssmt_set_core_vid(ssmt, core, SSMT_CLAMP_MODE_BYPASS);
-}
+/*
+ * Programs SSMT to always use SCIDs as VIDs.
+ * Supports both client-driven and clamp mode.
+ */
+void gxp_ssmt_set_bypass(struct gxp_ssmt *ssmt);
#endif /* __GXP_SSMT_H__ */
diff --git a/gxp-vd.c b/gxp-vd.c
index fa4ea9e..57011ba 100644
--- a/gxp-vd.c
+++ b/gxp-vd.c
@@ -894,11 +894,12 @@ int gxp_vd_run(struct gxp_virtual_device *vd)
{
struct gxp_dev *gxp = vd->gxp;
int ret;
+ enum gxp_virtual_device_state orig_state = vd->state;
lockdep_assert_held_write(&gxp->vd_semaphore);
- if (vd->state != GXP_VD_READY && vd->state != GXP_VD_OFF)
+ if (orig_state != GXP_VD_READY && orig_state != GXP_VD_OFF)
return -EINVAL;
- if (vd->state == GXP_VD_OFF) {
+ if (orig_state == GXP_VD_OFF) {
ret = gxp_vd_block_ready(vd);
/*
* The failure of `gxp_vd_block_ready` function means following two things:
@@ -933,7 +934,9 @@ int gxp_vd_run(struct gxp_virtual_device *vd)
err_vd_block_unready:
debug_dump_unlock(vd);
- gxp_vd_block_unready(vd);
+ /* Run this only when gxp_vd_block_ready was executed. */
+ if (orig_state == GXP_VD_OFF)
+ gxp_vd_block_unready(vd);
err_vd_unavailable:
vd->state = GXP_VD_UNAVAILABLE;
return ret;