diff options
author | Aurora zuma automerger <aurora-zuma-automerger@google.com> | 2022-10-06 07:35:11 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-07 00:24:08 -0700 |
commit | 666cd991fed1752172b37fc2fc6d7bf6839f43da (patch) | |
tree | ad1b849150ebbad13b6ac02f7e09db3ffe07e066 | |
parent | 1504743bcf468241a23885317acb402834841e7d (diff) | |
download | zuma-666cd991fed1752172b37fc2fc6d7bf6839f43da.tar.gz |
[Copybara Auto Merge] Merge branch 'zuma' into 'android13-gs-pixel-5.15'
gcip: constantize gcip_kci_args
GCIP_HEADERS_REV_ID: 795c621da040223ce1f19ca18ccdc1f1e91ffec9
gcip: constantize gcip_kci_args
GCIP_MAIN_REV_ID: 30a61c95e411fef4c7bc386d3f6c4ae35513a518
gxp: re-purpose GXP_LEGACY_MAILBOX
Bug: 245455607
gxp: use const args for mailbox init
gxp: refine MCU LPM programming sequence
Bug: 250579098
gxp: Initialize MCU telemetry before UCI and KCI
Bug: 237099103
Bug: 251372941
gxp: bump uapi version to 1.5
gxp: remove unnecessary coherent buf cast
GitOrigin-RevId: cdab6410631fff33c49d653a5dcdc5fcd53c1648
Change-Id: I4b6a3c1e78fd06f5cf60de2efa1bef2cd9a94ddc
-rw-r--r-- | gcip-kernel-driver/drivers/gcip/gcip-kci.c | 2 | ||||
-rw-r--r-- | gcip-kernel-driver/include/gcip/gcip-kci.h | 2 | ||||
-rw-r--r-- | gxp-common-platform.c | 12 | ||||
-rw-r--r-- | gxp-config.h | 4 | ||||
-rw-r--r-- | gxp-debugfs.c | 10 | ||||
-rw-r--r-- | gxp-mailbox-driver.c | 5 | ||||
-rw-r--r-- | gxp-mailbox-driver.h | 6 | ||||
-rw-r--r-- | gxp-mailbox.c | 32 | ||||
-rw-r--r-- | gxp-mailbox.h | 26 | ||||
-rw-r--r-- | gxp-mcu-firmware.c | 13 | ||||
-rw-r--r-- | gxp-mcu.c | 21 | ||||
-rw-r--r-- | gxp.h | 2 |
12 files changed, 76 insertions, 59 deletions
diff --git a/gcip-kernel-driver/drivers/gcip/gcip-kci.c b/gcip-kernel-driver/drivers/gcip/gcip-kci.c index 34b5d51..e11d2a1 100644 --- a/gcip-kernel-driver/drivers/gcip/gcip-kci.c +++ b/gcip-kernel-driver/drivers/gcip/gcip-kci.c @@ -449,7 +449,7 @@ static inline void gcip_kci_set_data(struct gcip_kci *kci, void *data) kci->data = data; } -int gcip_kci_init(struct gcip_kci *kci, struct gcip_kci_args *args) +int gcip_kci_init(struct gcip_kci *kci, const struct gcip_kci_args *args) { int ret; struct gcip_mailbox_args mailbox_args; diff --git a/gcip-kernel-driver/include/gcip/gcip-kci.h b/gcip-kernel-driver/include/gcip/gcip-kci.h index c4b78be..74e44ae 100644 --- a/gcip-kernel-driver/include/gcip/gcip-kci.h +++ b/gcip-kernel-driver/include/gcip/gcip-kci.h @@ -281,7 +281,7 @@ struct gcip_kci_args { }; /* Initializes a KCI object. */ -int gcip_kci_init(struct gcip_kci *kci, struct gcip_kci_args *args); +int gcip_kci_init(struct gcip_kci *kci, const struct gcip_kci_args *args); /* Cancels KCI and reverse KCI workers and workers that may send KCIs. */ void gcip_kci_cancel_work_queues(struct gcip_kci *kci); diff --git a/gxp-common-platform.c b/gxp-common-platform.c index 8452a6b..e7d5a27 100644 --- a/gxp-common-platform.c +++ b/gxp-common-platform.c @@ -51,10 +51,10 @@ #include "gxp-wakelock.h" #include "gxp.h" -#ifndef GXP_LEGACY_MAILBOX -#include "gxp-dci.h" -#else +#if GXP_USE_LEGACY_MAILBOX #include "gxp-mailbox-impl.h" +#else +#include "gxp-dci.h" #endif /* Caller needs to hold client->semaphore */ @@ -1760,10 +1760,10 @@ static int gxp_common_platform_probe(struct platform_device *pdev, struct gxp_de } if (gxp_is_direct_mode(gxp)) { -#ifndef GXP_LEGACY_MAILBOX - gxp_dci_init(gxp->mailbox_mgr); -#else +#if GXP_USE_LEGACY_MAILBOX gxp_mailbox_init(gxp->mailbox_mgr); +#else + gxp_dci_init(gxp->mailbox_mgr); #endif } diff --git a/gxp-config.h b/gxp-config.h index ded8ca5..2f50bd8 100644 --- a/gxp-config.h +++ b/gxp-config.h @@ -30,6 +30,10 @@ #define SYNC_BARRIER_COUNT 16 +#ifndef GXP_USE_LEGACY_MAILBOX +#define GXP_USE_LEGACY_MAILBOX 0 +#endif + /* LPM address space starts at lpm_version register */ #define GXP_LPM_BASE GXP_REG_LPM_VERSION #define GXP_LPM_PSM_0_BASE GXP_REG_LPM_PSM_0 diff --git a/gxp-debugfs.c b/gxp-debugfs.c index ef4ad24..09d8d36 100644 --- a/gxp-debugfs.c +++ b/gxp-debugfs.c @@ -310,13 +310,12 @@ static int gxp_log_buff_set(void *data, u64 val) mutex_lock(&gxp->core_telemetry_mgr->lock); if (!gxp->core_telemetry_mgr->logging_buff_data) { - dev_err(gxp->dev, "%s: Logging buffer has not been created\n", - __func__); + dev_err(gxp->dev, "Logging buffer has not been created"); mutex_unlock(&gxp->core_telemetry_mgr->lock); return -ENODEV; } - buffers = (struct gxp_coherent_buf *)gxp->core_telemetry_mgr->logging_buff_data->buffers; + buffers = gxp->core_telemetry_mgr->logging_buff_data->buffers; for (i = 0; i < GXP_NUM_CORES; i++) { ptr = buffers[i].vaddr; *ptr = val; @@ -335,13 +334,12 @@ static int gxp_log_buff_get(void *data, u64 *val) mutex_lock(&gxp->core_telemetry_mgr->lock); if (!gxp->core_telemetry_mgr->logging_buff_data) { - dev_err(gxp->dev, "%s: Logging buffer has not been created\n", - __func__); + dev_err(gxp->dev, "Logging buffer has not been created"); mutex_unlock(&gxp->core_telemetry_mgr->lock); return -ENODEV; } - buffers = (struct gxp_coherent_buf *)gxp->core_telemetry_mgr->logging_buff_data->buffers; + buffers = gxp->core_telemetry_mgr->logging_buff_data->buffers; *val = *(u64 *)(buffers[0].vaddr); diff --git a/gxp-mailbox-driver.c b/gxp-mailbox-driver.c index 8cc707c..23788f7 100644 --- a/gxp-mailbox-driver.c +++ b/gxp-mailbox-driver.c @@ -12,6 +12,7 @@ #include <linux/of_irq.h> #include <linux/spinlock.h> +#include "gxp-config.h" /* GXP_USE_LEGACY_MAILBOX */ #include "gxp-mailbox-driver.h" #include "gxp-mailbox-regs.h" #include "gxp-mailbox.h" @@ -413,7 +414,7 @@ int gxp_mailbox_inc_resp_queue_head_locked(struct gxp_mailbox *mailbox, u32 inc, return gxp_mailbox_inc_resp_queue_head_nolock(mailbox, inc, wrap_bit); } -#ifndef GXP_LEGACY_MAILBOX +#if !GXP_USE_LEGACY_MAILBOX u32 gxp_mailbox_gcip_ops_get_cmd_queue_head(struct gcip_mailbox *mailbox) { struct gxp_mailbox *gxp_mbx = mailbox->data; @@ -560,4 +561,4 @@ void gxp_mailbox_gcip_ops_after_fetch_resps(struct gcip_mailbox *mailbox, if (num_resps == size) gxp_mailbox_generate_device_interrupt(gxp_mbx, BIT(0)); } -#endif /* !GXP_LEGACY_MAILBOX */ +#endif /* !GXP_USE_LEGACY_MAILBOX */ diff --git a/gxp-mailbox-driver.h b/gxp-mailbox-driver.h index 1a67841..30292d2 100644 --- a/gxp-mailbox-driver.h +++ b/gxp-mailbox-driver.h @@ -10,7 +10,7 @@ #include "gxp-config.h" #include "gxp-mailbox.h" -#ifndef GXP_LEGACY_MAILBOX +#if !GXP_USE_LEGACY_MAILBOX #include <gcip/gcip-mailbox.h> #endif @@ -133,7 +133,7 @@ int gxp_mailbox_inc_resp_queue_head_nolock(struct gxp_mailbox *mailbox, u32 inc, int gxp_mailbox_inc_resp_queue_head_locked(struct gxp_mailbox *mailbox, u32 inc, u32 wrap_bit); -#ifndef GXP_LEGACY_MAILBOX +#if !GXP_USE_LEGACY_MAILBOX /* * Following functions are used when setting the operators of `struct gcip_mailbox_ops`. * To use these functions, @mailbox->data should be set as an instance of `struct gxp_mailbox`. @@ -168,6 +168,6 @@ int gxp_mailbox_gcip_ops_after_enqueue_cmd(struct gcip_mailbox *mailbox, void *cmd); void gxp_mailbox_gcip_ops_after_fetch_resps(struct gcip_mailbox *mailbox, u32 num_resps); -#endif /* !GXP_LEGACY_MAILBOX */ +#endif /* !GXP_USE_LEGACY_MAILBOX */ #endif /* __GXP_MAILBOX_DRIVER_H__ */ diff --git a/gxp-mailbox.c b/gxp-mailbox.c index 50751dc..fc6a206 100644 --- a/gxp-mailbox.c +++ b/gxp-mailbox.c @@ -14,6 +14,7 @@ #include <linux/slab.h> #include <uapi/linux/sched/types.h> +#include "gxp-config.h" /* GXP_USE_LEGACY_MAILBOX */ #include "gxp-dma.h" #include "gxp-internal.h" #include "gxp-mailbox.h" @@ -21,7 +22,7 @@ #include "gxp-pm.h" #include "gxp.h" -#ifdef GXP_LEGACY_MAILBOX +#if GXP_USE_LEGACY_MAILBOX #include "gxp-mailbox-impl.h" #else #include "gxp-kci.h" @@ -48,7 +49,7 @@ static void gxp_mailbox_consume_responses_work(struct kthread_work *work) if (mailbox->ops->consume_responses_work) mailbox->ops->consume_responses_work(mailbox); -#ifdef GXP_LEGACY_MAILBOX +#if GXP_USE_LEGACY_MAILBOX gxp_mailbox_consume_responses(mailbox); #else switch (mailbox->type) { @@ -191,10 +192,10 @@ static void release_mailbox(struct gxp_mailbox *mailbox, kfree(mailbox); } -#ifndef GXP_LEGACY_MAILBOX +#if !GXP_USE_LEGACY_MAILBOX static int init_gcip_mailbox(struct gxp_mailbox *mailbox) { - struct gcip_mailbox_args args = { + const struct gcip_mailbox_args args = { .dev = mailbox->gxp->dev, .queue_wrap_bit = mailbox->queue_wrap_bit, .cmd_queue = mailbox->cmd_queue_buf.vaddr, @@ -238,7 +239,7 @@ static void release_gcip_mailbox(struct gxp_mailbox *mailbox) static int init_gcip_kci(struct gxp_mailbox *mailbox) { - struct gcip_kci_args args = { + const struct gcip_kci_args args = { .dev = mailbox->gxp->dev, .cmd_queue = mailbox->cmd_queue_buf.vaddr, .resp_queue = mailbox->resp_queue_buf.vaddr, @@ -278,7 +279,7 @@ static void release_gcip_kci(struct gxp_mailbox *mailbox) kfree(gcip_kci); mailbox->mbx_impl.gcip_kci = NULL; } -#endif /* !GXP_LEGACY_MAILBOX */ +#endif /* !GXP_USE_LEGACY_MAILBOX */ /* * Initializes @mailbox->mbx_impl to start waiting and consuming responses. @@ -286,14 +287,14 @@ static void release_gcip_kci(struct gxp_mailbox *mailbox) * - GENERAL: will initialize @mailbox->mbx_impl.gcip_mbx * - KCI: will initialize @mailbox->mbx_impl.kci_mbx * - * Note: if `GXP_LEGACY_MAILBOX` is defined, it will initialize @mailbox itself as its queueing - * logic is implemented in the `gxp-mailbox-impl.c`. + * Note: On `GXP_USE_LEGACY_MAILBOX`, it will initialize @mailbox itself as its + * queuing logic is implemented in `gxp-mailbox-impl.c`. */ static int init_mailbox_impl(struct gxp_mailbox *mailbox) { int ret; -#ifdef GXP_LEGACY_MAILBOX +#if GXP_USE_LEGACY_MAILBOX if (mailbox->type != GXP_MBOX_TYPE_GENERAL) return -EOPNOTSUPP; @@ -315,7 +316,7 @@ static int init_mailbox_impl(struct gxp_mailbox *mailbox) default: return -EOPNOTSUPP; } -#endif +#endif /* GXP_USE_LEGACY_MAILBOX */ if (mailbox->ops->init_consume_responses_work) { ret = mailbox->ops->init_consume_responses_work(mailbox); @@ -375,20 +376,21 @@ struct gxp_mailbox *gxp_mailbox_alloc(struct gxp_mailbox_manager *mgr, } /* - * Releases the @mailbox->mbx_impl to flush all pending responses in the wait list. - * This will releases GCIP mailbox modules according to the type of @mailbox. + * Releases the @mailbox->mbx_impl to flush all pending responses in the wait + * list. + * This releases GCIP mailbox modules according to the type of @mailbox. * - GENERAL: will release @mailbox->mbx_impl.gcip_mbx * - KCI: will release @mailbox->mbx_impl.kci_mbx * - * Note: if `GXP_LEGACY_MAILBOX` is defined, it will release @mailbox itself as its queueing - * logic is implemented in the `gxp-mailbox-impl.c`. + * Note: On `GXP_USE_LEGACY_MAILBOX`, it will release @mailbox itself as its + * queuing logic is implemented in `gxp-mailbox-impl.c`. */ static void release_mailbox_impl(struct gxp_mailbox *mailbox) { if (mailbox->ops->release_consume_responses_work) mailbox->ops->release_consume_responses_work(mailbox); -#ifdef GXP_LEGACY_MAILBOX +#if GXP_USE_LEGACY_MAILBOX gxp_mailbox_release_consume_responses(mailbox); #else switch (mailbox->type) { diff --git a/gxp-mailbox.h b/gxp-mailbox.h index 2989ea5..286524e 100644 --- a/gxp-mailbox.h +++ b/gxp-mailbox.h @@ -9,16 +9,17 @@ #include <linux/kthread.h> -#ifndef GXP_LEGACY_MAILBOX -#include <gcip/gcip-kci.h> -#include <gcip/gcip-mailbox.h> -#endif - #include "gxp-client.h" +#include "gxp-config.h" /* GXP_USE_LEGACY_MAILBOX */ #include "gxp-dma.h" #include "gxp-internal.h" #include "gxp-mailbox-manager.h" +#if !GXP_USE_LEGACY_MAILBOX +#include <gcip/gcip-kci.h> +#include <gcip/gcip-mailbox.h> +#endif + /* * Offset from the host mailbox interface to the device interface that needs to * be mapped. @@ -61,17 +62,16 @@ enum gxp_mailbox_command_code { enum gxp_mailbox_type { /* * Mailbox will utilize `gcip-mailbox.h` internally. - * (Note: if `GXP_LEGACY_MAILBOX` is defined, it utilizes `gxp-mailbox-impl.h` instead.) - * Can be used in most cases. Mostly, will be used for handling user commands. + * (Note: On `GXP_USE_LEGACY_MAILBOX`, it utilizes `gxp-mailbox-impl.h` + * instead.) + * Mostly will be used for handling user commands. */ GXP_MBOX_TYPE_GENERAL = 0, -#ifndef GXP_LEGACY_MAILBOX /* * Mailbox will utilize `gcip-kci.h` internally. * Will be used for handling kernel commands. */ GXP_MBOX_TYPE_KCI = 1, -#endif }; enum gxp_response_status { @@ -159,7 +159,7 @@ struct gxp_mailbox_ops { * Context: in_interrupt(). */ void (*consume_responses_work)(struct gxp_mailbox *mailbox); -#ifndef GXP_LEGACY_MAILBOX +#if !GXP_USE_LEGACY_MAILBOX /* * Operators which has dependency on the GCIP according to the type of mailbox. * - GXP_MBOX_TYPE_GENERAL: @gcip_ops.mbx must be defined. @@ -227,13 +227,13 @@ struct gxp_mailbox { struct gxp_mailbox_ops *ops; void *data; /* private data */ -#ifdef GXP_LEGACY_MAILBOX +#if GXP_USE_LEGACY_MAILBOX u64 cur_seq; /* add to this list if a command needs to wait for a response */ struct list_head wait_list; /* queue for waiting for the wait_list to be consumed */ wait_queue_head_t wait_list_waitq; -#else /* !GXP_LEGACY_MAILBOX */ +#else /* !GXP_USE_LEGACY_MAILBOX */ /* * Implementation of the mailbox according to the type. * - GXP_MBOX_TYPE_GENERAL: @gcip_mbx will be allocated. @@ -243,7 +243,7 @@ struct gxp_mailbox { struct gcip_mailbox *gcip_mbx; struct gcip_kci *gcip_kci; } mbx_impl; -#endif /* GXP_LEGACY_MAILBOX */ +#endif /* GXP_USE_LEGACY_MAILBOX */ }; /* Mailbox APIs */ diff --git a/gxp-mcu-firmware.c b/gxp-mcu-firmware.c index d010bb4..f1f2d91 100644 --- a/gxp-mcu-firmware.c +++ b/gxp-mcu-firmware.c @@ -178,10 +178,21 @@ static void gxp_mcu_firmware_stop_locked(struct gxp_mcu_firmware *mcu_fw) int ret; lockdep_assert_held(&mcu_fw->lock); + + gxp_lpm_enable_state(gxp, GXP_MCU_CORE_ID, LPM_PG_STATE); + + /* Clear doorbell to refuse non-expected interrupts */ + gxp_doorbell_clear(gxp, CORE_WAKEUP_DOORBELL(GXP_MCU_CORE_ID)); + ret = gxp_kci_shutdown(&mcu->kci); if (ret) dev_warn(gxp->dev, "KCI shutdown failed: %d", ret); - gxp_lpm_down(gxp, GXP_MCU_CORE_ID); + + if (!gxp_lpm_wait_state_eq(gxp, GXP_MCU_CORE_ID, LPM_PG_STATE)) + dev_warn(gxp->dev, + "MCU PSM transition to PS3 fails, current state: %u\n", + gxp_lpm_get_state(gxp, GXP_MCU_CORE_ID)); + gxp_mcu_firmware_unload_locked(mcu_fw); } @@ -163,24 +163,25 @@ int gxp_mcu_init(struct gxp_dev *gxp, struct gxp_mcu *mcu) ret = gxp_mcu_map_resources(gxp, mcu); if (ret) goto err_free_shared_buffer; - ret = gxp_uci_init(mcu); - if (ret) - goto err_mcu_unmap_resources; - ret = gxp_kci_init(mcu); - if (ret) - goto err_uci_exit; /* - * MCU telemetry must be initialized after KCI since the telemetry IRQ - * is tied to KCI mailbox->interrupt_handlers. + * MCU telemetry must be initialized before UCI and KCI to match the + * .log_buffer address in the firmware linker.ld. */ ret = gxp_mcu_telemetry_init(mcu); if (ret) + goto err_mcu_unmap_resources; + ret = gxp_uci_init(mcu); + if (ret) + goto err_telemetry_exit; + ret = gxp_kci_init(mcu); + if (ret) goto err_uci_exit; - return 0; err_uci_exit: gxp_uci_exit(&mcu->uci); +err_telemetry_exit: + gxp_mcu_telemetry_exit(mcu); err_mcu_unmap_resources: gxp_mcu_unmap_resources(mcu); err_free_shared_buffer: @@ -194,9 +195,9 @@ err_fw_exit: void gxp_mcu_exit(struct gxp_mcu *mcu) { - gxp_mcu_telemetry_exit(mcu); gxp_kci_exit(&mcu->kci); gxp_uci_exit(&mcu->uci); + gxp_mcu_telemetry_exit(mcu); gxp_mcu_unmap_resources(mcu); gxp_free_shared_buffer(mcu); gxp_mcu_mem_pools_exit(mcu); @@ -13,7 +13,7 @@ /* Interface Version */ #define GXP_INTERFACE_VERSION_MAJOR 1 -#define GXP_INTERFACE_VERSION_MINOR 4 +#define GXP_INTERFACE_VERSION_MINOR 5 #define GXP_INTERFACE_VERSION_BUILD 0 /* |