summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Peng <robinpeng@google.com>2022-05-30 18:32:56 +0800
committerRobin Peng <robinpeng@google.com>2022-05-30 18:32:56 +0800
commit78604a94057626ed2d19da08ef15765beb8d4686 (patch)
tree07970abc5a3c639a8afb4eaf5fa0dbf65b1bf6f4
parent35e3403a4d6660b3db2e434d5fa93e23961222ec (diff)
parentb16f2fa6d4a747b68c8eab8fefb4dd94537d5426 (diff)
downloadgs201-78604a94057626ed2d19da08ef15765beb8d4686.tar.gz
Merge android13-gs-pixel-5.10-tm-d1 into android13-gs-pixel-5.10-tm-qpr1
Bug: 233569354 Signed-off-by: Robin Peng <robinpeng@google.com> Change-Id: Id0524ac1ee83e75bf5d3c6c951415cb01ad77fa2
-rw-r--r--amalthea/csrs.h1
-rw-r--r--gxp-client.h4
-rw-r--r--gxp-firmware.c34
-rw-r--r--gxp-firmware.h14
-rw-r--r--gxp-platform.c7
-rw-r--r--gxp-telemetry.c6
-rw-r--r--gxp-vd.c16
-rw-r--r--gxp-wakelock.c8
8 files changed, 68 insertions, 22 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-client.h b/gxp-client.h
index c3dacf3..fee0b9b 100644
--- a/gxp-client.h
+++ b/gxp-client.h
@@ -8,6 +8,7 @@
#define __GXP_CLIENT_H__
#include <linux/rwsem.h>
+#include <linux/sched.h>
#include <linux/types.h>
#include "gxp-internal.h"
@@ -40,6 +41,9 @@ struct gxp_client {
struct gxp_eventfd *mb_eventfds[GXP_NUM_CORES];
+ /* client process thread group ID is really the main process ID. */
+ pid_t tgid;
+ /* client process ID is really the thread ID, may be transient. */
pid_t pid;
};
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-platform.c b/gxp-platform.c
index 36ae93d..46fb5bb 100644
--- a/gxp-platform.c
+++ b/gxp-platform.c
@@ -22,6 +22,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/sched.h>
#include <linux/uaccess.h>
#include <linux/uidgid.h>
#if (IS_ENABLED(CONFIG_GXP_TEST) || IS_ENABLED(CONFIG_ANDROID)) && !IS_ENABLED(CONFIG_GXP_GEM5)
@@ -159,6 +160,7 @@ static int gxp_open(struct inode *inode, struct file *file)
if (IS_ERR(client))
return PTR_ERR(client);
+ client->tgid = current->tgid;
client->pid = current->pid;
file->private_data = client;
@@ -1277,9 +1279,10 @@ static int gxp_acquire_wake_lock_compat(
client->has_block_wakelock = true;
/*
- * Update client's PID in case the process that opened /dev/gxp
- * is not the one that called this IOCTL.
+ * Update client's TGID/PID in case the process that opened
+ * /dev/gxp is not the one that called this IOCTL.
*/
+ client->tgid = current->tgid;
client->pid = current->pid;
}
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;
diff --git a/gxp-wakelock.c b/gxp-wakelock.c
index 7f0d392..9110a3d 100644
--- a/gxp-wakelock.c
+++ b/gxp-wakelock.c
@@ -118,16 +118,16 @@ int gxp_wakelock_suspend(struct gxp_dev *gxp)
if (!down_read_trylock(&client->semaphore)) {
dev_warn_ratelimited(
gxp->dev,
- "Unable to acquire client lock (pid=%d)\n",
- client->pid);
+ "Unable to acquire client lock (tgid=%d pid=%d)\n",
+ client->tgid, client->pid);
continue;
}
if (client->has_block_wakelock)
dev_warn_ratelimited(
gxp->dev,
- "Cannot suspend with client holding wakelock (pid=%d)\n",
- client->pid);
+ "Cannot suspend with client holding wakelock (tgid=%d pid=%d)\n",
+ client->tgid, client->pid);
up_read(&client->semaphore);
}