summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurora pro automerger <aurora-pro-automerger@google.com>2022-05-23 12:51:51 +0000
committerJohn Scheible <johnscheible@google.com>2022-05-23 19:40:12 +0000
commitf74aa638e06c1edcb7c8c295c03d2f7b9b6f604d (patch)
tree581ae85ae9b6f7c153ba4e4d884da2b71b26a65c
parent35e3403a4d6660b3db2e434d5fa93e23961222ec (diff)
downloadgs201-f74aa638e06c1edcb7c8c295c03d2f7b9b6f604d.tar.gz
[Copybara Auto Merge] Merge branch 'gs201-release' into 'android13-gs-pixel-5.10'.
release info:233216473 dsp prod 5/23 RC03 gxp: remove unrequired CORE_SCRATCHPAD_BASE offset Bug: 233381187 gxp: Refactor FW boot mode into its own functions Bug: 233381187 gxp: Switch the boot mode storage from CSRs into the scratchpad space Bug: 233381187 gxp: Fix locking in gxp_telemetry_disable() Bug: 232876605 GitOrigin-RevId: da625dba4f2565974652c7b1fdfb6db90870230e Change-Id: Iaab2bef0c866741ce0d1390ad39ddd87e932dd73
-rw-r--r--amalthea/csrs.h1
-rw-r--r--gxp-firmware.c34
-rw-r--r--gxp-firmware.h14
-rw-r--r--gxp-telemetry.c6
-rw-r--r--gxp-vd.c16
5 files changed, 55 insertions, 16 deletions
diff --git a/amalthea/csrs.h b/amalthea/csrs.h
index 1338121..a8b8d07 100644
--- a/amalthea/csrs.h
+++ b/amalthea/csrs.h
@@ -51,7 +51,6 @@ enum gxp_csrs {
enum gxp_core_csrs {
GXP_REG_INST_BPM = 0x0000,
- GXP_REG_BOOT_MODE = 0x2080,
GXP_REG_PROFILING_CONDITION = 0x4000,
GXP_REG_PROCESSOR_ID = 0x4004,
GXP_REG_ALT_RESET_VECTOR = 0x4008,
diff --git a/gxp-firmware.c b/gxp-firmware.c
index ba3a784..15497cf 100644
--- a/gxp-firmware.c
+++ b/gxp-firmware.c
@@ -283,8 +283,7 @@ static int gxp_firmware_load(struct gxp_dev *gxp, uint core)
memset(gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF, 0,
AURORA_SCRATCHPAD_LEN);
- core_scratchpad_base = gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF +
- CORE_SCRATCHPAD_BASE(core);
+ core_scratchpad_base = gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF;
offset = SCRATCHPAD_MSG_OFFSET(MSG_CORE_ALIVE);
writel(0, core_scratchpad_base + offset);
offset = SCRATCHPAD_MSG_OFFSET(MSG_TOP_ACCESS_OK);
@@ -649,8 +648,7 @@ int gxp_firmware_run(struct gxp_dev *gxp, struct gxp_virtual_device *vd,
}
/* Mark this as a cold boot */
- gxp_write_32_core(gxp, core, GXP_REG_BOOT_MODE,
- GXP_BOOT_MODE_REQUEST_COLD_BOOT);
+ gxp_firmware_set_boot_mode(gxp, core, GXP_BOOT_MODE_REQUEST_COLD_BOOT);
#ifdef CONFIG_GXP_GEM5
/*
@@ -743,3 +741,31 @@ void gxp_firmware_stop(struct gxp_dev *gxp, struct gxp_virtual_device *vd,
gxp_pm_core_off(gxp, core);
gxp_firmware_unload(gxp, core);
}
+
+void gxp_firmware_set_boot_mode(struct gxp_dev *gxp, uint core, u32 mode)
+{
+ void __iomem *boot_mode_addr;
+
+ /* Callers shouldn't call the function under this condition. */
+ if (!gxp->fwbufs[core].vaddr)
+ return;
+
+ boot_mode_addr = gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF +
+ SCRATCHPAD_MSG_OFFSET(MSG_BOOT_MODE);
+
+ writel(mode, boot_mode_addr);
+}
+
+u32 gxp_firmware_get_boot_mode(struct gxp_dev *gxp, uint core)
+{
+ void __iomem *boot_mode_addr;
+
+ /* Callers shouldn't call the function under this condition. */
+ if (!gxp->fwbufs[core].vaddr)
+ return 0;
+
+ boot_mode_addr = gxp->fwbufs[core].vaddr + AURORA_SCRATCHPAD_OFF +
+ SCRATCHPAD_MSG_OFFSET(MSG_BOOT_MODE);
+
+ return readl(boot_mode_addr);
+}
diff --git a/gxp-firmware.h b/gxp-firmware.h
index f945d3e..4834e87 100644
--- a/gxp-firmware.h
+++ b/gxp-firmware.h
@@ -25,12 +25,12 @@
#define Q7_ALIVE_MAGIC 0x55555555
-#define CORE_SCRATCHPAD_BASE(_core_) (_core_ << 16)
#define SCRATCHPAD_MSG_OFFSET(_msg_) (_msg_ << 2)
enum aurora_msg {
MSG_CORE_ALIVE,
MSG_TOP_ACCESS_OK,
+ MSG_BOOT_MODE,
MSG_SCRATCHPAD_MAX,
};
@@ -81,4 +81,16 @@ void gxp_firmware_stop(struct gxp_dev *gxp, struct gxp_virtual_device *vd,
int gxp_firmware_setup_hw_after_block_off(struct gxp_dev *gxp, uint core,
bool verbose);
+/*
+ * Sets the specified core's boot mode or suspend request value.
+ * This function should be called only after the firmware has been run.
+ */
+void gxp_firmware_set_boot_mode(struct gxp_dev *gxp, uint core, u32 mode);
+
+/*
+ * Returns the specified core's boot mode or boot status.
+ * This function should be called only after the firmware has been run.
+ */
+u32 gxp_firmware_get_boot_mode(struct gxp_dev *gxp, uint core);
+
#endif /* __GXP_FIRMWARE_H__ */
diff --git a/gxp-telemetry.c b/gxp-telemetry.c
index be56c84..19351fd 100644
--- a/gxp-telemetry.c
+++ b/gxp-telemetry.c
@@ -460,6 +460,7 @@ out:
* @core: The core in @gxp to notify of the telemetry state change
* @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING`
*
+ * Caller must hold `telemetry_mgr->lock`.
* Caller must hold @gxp's virtual device lock
*
* Return:
@@ -516,6 +517,7 @@ static int notify_core_and_wait_for_disable(struct gxp_dev *gxp, uint core,
* @type: Either `GXP_TELEMETRY_TYPE_LOGGING` or `GXP_TELEMETRY_TYPE_TRACING`
*
* Caller must hold `telemetry_mgr->lock`.
+ * Caller must hold `gxp->vd_semaphore` for reading.
*
* Return:
* * 0 - Success
@@ -553,7 +555,6 @@ static int telemetry_disable_locked(struct gxp_dev *gxp, u8 type)
null_daddrs, 0);
/* Notify any running cores that firmware-data was updated */
- down_read(&gxp->vd_semaphore);
for (core = 0; core < GXP_NUM_CORES; core++) {
if (gxp_is_fw_running(gxp, core)) {
ret = notify_core_and_wait_for_disable(gxp, core, type);
@@ -564,7 +565,6 @@ static int telemetry_disable_locked(struct gxp_dev *gxp, u8 type)
__func__, core, type, ret);
}
}
- up_read(&gxp->vd_semaphore);
return 0;
}
@@ -574,9 +574,11 @@ int gxp_telemetry_disable(struct gxp_dev *gxp, u8 type)
int ret;
mutex_lock(&gxp->telemetry_mgr->lock);
+ down_read(&gxp->vd_semaphore);
ret = telemetry_disable_locked(gxp, type);
+ up_read(&gxp->vd_semaphore);
mutex_unlock(&gxp->telemetry_mgr->lock);
return ret;
diff --git a/gxp-vd.c b/gxp-vd.c
index 021d35a..ef83615 100644
--- a/gxp-vd.c
+++ b/gxp-vd.c
@@ -354,8 +354,8 @@ void gxp_vd_suspend(struct gxp_virtual_device *vd)
continue;
}
/* Mark the boot mode as a suspend event */
- gxp_write_32_core(gxp, core, GXP_REG_BOOT_MODE,
- GXP_BOOT_MODE_REQUEST_SUSPEND);
+ gxp_firmware_set_boot_mode(gxp, core,
+ GXP_BOOT_MODE_REQUEST_SUSPEND);
/*
* Request a suspend event by sending a mailbox
* notification.
@@ -371,8 +371,8 @@ void gxp_vd_suspend(struct gxp_virtual_device *vd)
if (!(failed_cores & BIT(core))) {
if (!gxp_lpm_wait_state_eq(gxp, core,
LPM_PG_STATE)) {
- boot_state = gxp_read_32_core(
- gxp, core, GXP_REG_BOOT_MODE);
+ boot_state = gxp_firmware_get_boot_mode(
+ gxp, core);
if (boot_state !=
GXP_BOOT_MODE_STATUS_SUSPEND_COMPLETED) {
dev_err(gxp->dev,
@@ -452,8 +452,8 @@ int gxp_vd_resume(struct gxp_virtual_device *vd)
}
}
/* Mark this as a resume power-up event. */
- gxp_write_32_core(gxp, core, GXP_REG_BOOT_MODE,
- GXP_BOOT_MODE_REQUEST_RESUME);
+ gxp_firmware_set_boot_mode(gxp, core,
+ GXP_BOOT_MODE_REQUEST_RESUME);
/*
* Power on the core by explicitly switching its PSM to
* PS0 (LPM_ACTIVE_STATE).
@@ -470,8 +470,8 @@ int gxp_vd_resume(struct gxp_virtual_device *vd)
/* in microseconds */
timeout = 1000000;
while (--timeout) {
- boot_state = gxp_read_32_core(
- gxp, core, GXP_REG_BOOT_MODE);
+ boot_state = gxp_firmware_get_boot_mode(
+ gxp, core);
if (boot_state ==
GXP_BOOT_MODE_STATUS_RESUME_COMPLETED)
break;