From 917cacdabbd90bf94ebcdca5f6bf51d3b316f3a7 Mon Sep 17 00:00:00 2001 From: Aurora zuma automerger Date: Thu, 13 Oct 2022 14:16:25 +0800 Subject: gxp: [Copybara Auto Merge] Merge branch 'zuma' into 'android13-gs-pixel-5.15' gxp: disable core interrupts before core releasing Bug: 252915360 GitOrigin-RevId: 1bc5cfb8686f36a2f5d4bbd125daa9dce8824833 Change-Id: I0bcb7a8c0d517b2e5979a4661253dc8cc1496084 --- callisto/csrs.h | 4 ++++ gxp-firmware.c | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/callisto/csrs.h b/callisto/csrs.h index fba6428..14659a8 100644 --- a/callisto/csrs.h +++ b/callisto/csrs.h @@ -82,6 +82,10 @@ enum gxp_csrs { #define GXP_CORE_REG_ALT_RESET_VECTOR(core) GXP_CORE_REG(core, 0x4008) #define GXP_CORE_REG_COMMON_INT_MASK_0(core) \ GXP_CORE_MCU_REG(core, 0x4010, 0x4020) +#define GXP_CORE_REG_COMMON_INT_MASK_1(core) \ + GXP_CORE_MCU_REG(core, 0x4014, 0x4024) +#define GXP_CORE_REG_DEDICATED_INT_MASK(core) \ + GXP_CORE_MCU_REG(core, 0x401c, 0x4028) #define GXP_CORE_REG_ETM_PWRCTL(core) GXP_CORE_REG(core, 0xB020) #define SYNC_BARRIER_SHADOW_OFFSET 0x800 diff --git a/gxp-firmware.c b/gxp-firmware.c index 70a650e..2ceac9e 100644 --- a/gxp-firmware.c +++ b/gxp-firmware.c @@ -702,6 +702,24 @@ err_authenticate_firmware: return ret; } +/* TODO(b/253464747): Refactor these interrupts handlers and gxp-doorbell.c. */ +static void enable_core_interrupts(struct gxp_dev *gxp, uint core) +{ + /* + * GXP_CORE_REG_COMMON_INT_MASK_0 is handled in doorbell module, so we + * don't need to enable it here. + */ + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_1(core), 0xffffffff); + gxp_write_32(gxp, GXP_CORE_REG_DEDICATED_INT_MASK(core), 0xffffffff); +} + +static void disable_core_interrupts(struct gxp_dev *gxp, uint core) +{ + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_0(core), 0); + gxp_write_32(gxp, GXP_CORE_REG_COMMON_INT_MASK_1(core), 0); + gxp_write_32(gxp, GXP_CORE_REG_DEDICATED_INT_MASK(core), 0); +} + static int gxp_firmware_setup(struct gxp_dev *gxp, uint core) { int ret = 0; @@ -727,8 +745,10 @@ static int gxp_firmware_setup(struct gxp_dev *gxp, uint core) if (ret) { dev_err(gxp->dev, "Failed to power up core %u\n", core); gxp_firmware_unload(gxp, core); + return ret; } + enable_core_interrupts(gxp, core); return ret; } @@ -822,8 +842,14 @@ static void gxp_firmware_stop_core(struct gxp_dev *gxp, dev_notice(gxp->dev, "Mailbox %u released\n", core); } - if (vd->state == GXP_VD_RUNNING) + if (vd->state == GXP_VD_RUNNING) { + /* + * Disable interrupts to prevent cores from being woken up + * unexpectedly. + */ + disable_core_interrupts(gxp, core); gxp_pm_core_off(gxp, core); + } gxp_firmware_unload(gxp, core); } -- cgit v1.2.3