diff options
author | Aurora pro automerger <aurora-pro-automerger@google.com> | 2023-02-02 11:46:21 +0000 |
---|---|---|
committer | davidchiang <davidchiang@google.com> | 2023-02-02 12:17:17 +0000 |
commit | 51c89d9e9a7664ff4068fa1405fca5a5fe60aac0 (patch) | |
tree | 8fa3c34a8dee0d30896f6efc3effa8f86d313e42 /gxp-debugfs.c | |
parent | 8a4b0d93e1f8b9ae23fb476eef4d43f18bc3cc1d (diff) | |
download | gs201-51c89d9e9a7664ff4068fa1405fca5a5fe60aac0.tar.gz |
gxp: [Copybara Auto Merge] Merge branch 'gs201-u' into 'android13-gs-pixel-5.10-udc'android-u-preview-2_r0.4android-u-preview-2_r0.3android-gs-pantah-5.10-u-preview-2android-gs-bluejay-5.10-u-preview-2
gcip: use v*alloc without node
GCIP_MAIN_REV_ID: e48d8c14dff78d70064f93e5faee61c17b0479c2
gxp: create debug dir root earlier on probe
gxp: fix code style/formatting issues
gxp: Implement debug dump handling for mcu mode
Bug: 265092842
gcip: fix code style/formatting issues
GCIP_HEADERS_REV_ID: 8f57799df52bf60cb1805ab5e9ee48034bb139c8
gcip: expose config size calculation to header
Bug: 265605775
gcip: sync RKCI codes with fw
gcip: update comments of gcip_dma_fence_init
Bug: 264220687
gcip: add to_gcip_fence to gcip-dma-fence
Bug: 264220687 (repeat)
gcip: fix GCIP_DMA_FENCE_LIST_UNLOCK
Bug: 258876786
gcip: correct path of gcip-dma-fence.h
Bug: 258876786 (repeat)
gcip: add gcip-dma-fence.h
Bug: 258876786 (repeat)
gcip: introduce firmware crash type
Bug: 237739631
GCIP_HEADERS_REV_ID: 0a85dc4b06195de6efa46e2ca314548f07f30097
gxp: move core config region to second half of buf
gxp: boot status and doorbell for suspend/resume
Bug: 265742153
gxp: set VD and core config region
Bug: 265742153 (repeat)
gxp: use core cfg region for firmware handshake
Bug: 265742153 (repeat)
gxp: boot with virt_core on per-VD config method
Bug: 265742153 (repeat)
gxp: only map fwdata region in legacy protocol
Bug: 265742153 (repeat)
gxp: populate system config on fw data create
Bug: 265742153 (repeat)
gxp: flush SGT after map iova sgt
Bug: 265564221
gxp: remove gxp_vd_phys_core_list
gxp: signal eventfd when client is invalidated
Bug: 264830822
gxp: introduce GXP_(UN)REGISTER_INVALIDATED_EVENTFD ioctl
Bug: 264830822 (repeat)
gxp: add create/destroy app legacy functions
Bug: 265742153 (repeat)
gxp: pass vd to fw_data_create_app
Bug: 265742153 (repeat)
gxp: add structures for new app config
Bug: 265742153 (repeat)
gxp: add sys_cfg mapping support
Bug: 265605775 (repeat)
gxp: all chips/modes have shared region
Bug: 265605775 (repeat)
gxp: map config regions per image config
Bug: 265605775 (repeat)
gxp: set shared_buf vaddr
Bug: 265605775 (repeat)
gxp: map image config NS mappings
Bug: 265564221 (repeat)
gxp: use per VD scratchpad region
Bug: 261797596
gxp: conditionally map FW image region
Bug: 265105395
gxp: add lock_class_key to struct client
gxp: add image config parser to VD
Bug: 265105395 (repeat)
gxp: record image config on firmware requested
Bug: 265105395 (repeat)
gxp: add missing up_read in gxp_debugfs_mailbox
gxp: implement vd invalidation
Bug: 264831024
gxp: pass timeout_ms to gxp_pm_is_blk_down
gxp: set is_firmware_requested on SysFS FW load
gxp: set SSMT to bypass in MCU mode
Bug: 264950137
Revert "gxp: fetch segment boundaries from ELF header"
gxp: add gcip_dma_fence_manager to gxp_dev
Bug: 258876786 (repeat)
gxp: add gxp-dma-fence support
Bug: 258876786 (repeat)
gxp: introduce GXP_NAME macro
gxp: return vdid on VD allocation ioctl
Bug: 264827584
gxp: add VDID support
Bug: 264827584 (repeat)
gxp: remove a cleanup TODO from vd.h
gxp: add refcount to virtual device
Bug: 264739996
gxp: add sync fence interfaces
Bug: 258876786 (repeat)
gxp: detach vd->domain when the state is invalid
Bug: 263830035
gxp: call vd_block_unready when failed to run core fw
Bug: 263830035 (repeat)
gxp: apply clang-format to gxp-vd.c
Bug: 263830035 (repeat)
gxp: allow debugfs mailbox only with valid vd
Bug: 264629015
gxp: add debugfs_client to client_list
Bug: 264629015 (repeat)
gxp: hold vd_semaphore only when direct mode
Bug: 263830035 (repeat)
gxp: fix vd_semaphore locking
Bug: 263215610
gxp: revert VD state on after_vd_block_ready fail
Bug: 263215610 (repeat)
gcip: conditionally zero the non-contiguous region
gcip: expose config size calculation to header
Bug: 265605775 (repeat)
gcip: Use strscpy instead of memcpy
gcip: enhance image config NS mapping decoding
Bug: 265565307
gcip: don't fail dma_fence_init on long name
Bug: 264220687 (repeat)
gcip: implement gcip_dma_fence_show
Bug: 264220687 (repeat)
gcip: implement DMA fence status and signal
Bug: 264220687 (repeat)
gcip: add gcip-dma-fence.c
Bug: 258876786 (repeat)
GCIP_MAIN_REV_ID: 0a2e7b7e345705db78c8108890781cbe5c8c4eb7
GitOrigin-RevId: 277fffe779cbaf54c2d811928835e9a5ec67e832
Change-Id: Ied761f3000df6a44856db9438d21afd9b3ccb9aa
Diffstat (limited to 'gxp-debugfs.c')
-rw-r--r-- | gxp-debugfs.c | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/gxp-debugfs.c b/gxp-debugfs.c index ae31914..47a45a1 100644 --- a/gxp-debugfs.c +++ b/gxp-debugfs.c @@ -44,6 +44,7 @@ static int gxp_debugfs_mailbox(void *data, u64 val) u16 status; struct gxp_dev *gxp = (struct gxp_dev *)data; struct gxp_mailbox *mbx; + struct gxp_client *client; struct gxp_power_states power_states = { .power = GXP_POWER_STATE_NOM, .memory = MEMORY_POWER_STATE_UNDEFINED, @@ -52,6 +53,7 @@ static int gxp_debugfs_mailbox(void *data, u64 val) int ret; mutex_lock(&gxp->debugfs_client_lock); + client = gxp->debugfs_client; #if GXP_HAS_MCU if (gxp_is_direct_mode(gxp)) { @@ -74,17 +76,29 @@ static int gxp_debugfs_mailbox(void *data, u64 val) goto out; } + /* Create a dummy client to access @client->gxp from the `execute_cmd` callback. */ + if (!client) + client = gxp_client_create(gxp); mbx = gxp->mailbox_mgr->mailboxes[core]; cmd_code = GXP_MBOX_CODE_DISPATCH; #if GXP_HAS_MCU } else { - if (!gxp->debugfs_client) { + if (!client) { dev_err(gxp->dev, "You should load firmwares via gxp/firmware_run first\n"); ret = -EIO; goto out; } + down_read(&gxp->debugfs_client->semaphore); + if (!gxp_client_has_available_vd(gxp->debugfs_client, + "GXP_MAILBOX_COMMAND")) { + ret = -ENODEV; + up_read(&gxp->debugfs_client->semaphore); + goto out; + } + up_read(&gxp->debugfs_client->semaphore); + mbx = to_mcu_dev(gxp)->mcu.uci.mbx; if (!mbx) { dev_err(gxp->dev, "UCI is not initialized.\n"); @@ -96,12 +110,9 @@ static int gxp_debugfs_mailbox(void *data, u64 val) } #endif - down_read(&gxp->vd_semaphore); - /* In direct mode, gxp->debugfs_client and core will be ignored. */ - retval = gxp->mailbox_mgr->execute_cmd(gxp->debugfs_client, mbx, core, - cmd_code, 0, 0, 0, 0, 1, - power_states, NULL, &status); - up_read(&gxp->vd_semaphore); + retval = gxp->mailbox_mgr->execute_cmd(client, mbx, core, cmd_code, 0, + 0, 0, 0, 1, power_states, NULL, + &status); dev_info( gxp->dev, @@ -109,6 +120,8 @@ static int gxp_debugfs_mailbox(void *data, u64 val) core, status, retval); ret = 0; out: + if (client && client != gxp->debugfs_client) + gxp_client_destroy(client); mutex_unlock(&gxp->debugfs_client_lock); return ret; } @@ -168,9 +181,14 @@ static int gxp_firmware_run_set(void *data, u64 val) } gxp->debugfs_client = client; + mutex_lock(&gxp->client_list_lock); + list_add(&client->list_entry, &gxp->client_list); + mutex_unlock(&gxp->client_list_lock); + down_write(&client->semaphore); - ret = gxp_client_allocate_virtual_device(client, GXP_NUM_CORES, 0); + ret = gxp_client_allocate_virtual_device(client, GXP_NUM_CORES, + 0); if (ret) { dev_err(gxp->dev, "Failed to allocate VD\n"); goto err_destroy_client; @@ -201,8 +219,7 @@ static int gxp_firmware_run_set(void *data, u64 val) * Cleaning up the client will stop the VD it owns and release * the BLOCK wakelock it is holding. */ - gxp_client_destroy(gxp->debugfs_client); - gxp->debugfs_client = NULL; + goto out_destroy_client; } out: @@ -214,8 +231,13 @@ err_release_block_wakelock: gxp_client_release_block_wakelock(client); err_destroy_client: up_write(&client->semaphore); +out_destroy_client: + mutex_lock(&gxp->client_list_lock); + list_del(&gxp->debugfs_client->list_entry); + mutex_unlock(&gxp->client_list_lock); + /* Destroying a client cleans up any VDss or wakelocks it held. */ - gxp_client_destroy(client); + gxp_client_destroy(gxp->debugfs_client); gxp->debugfs_client = NULL; mutex_unlock(&gxp->debugfs_client_lock); return ret; @@ -488,10 +510,19 @@ static int gxp_cmu_mux2_get(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(gxp_cmu_mux2_fops, gxp_cmu_mux2_get, gxp_cmu_mux2_set, "%llu\n"); +void gxp_create_debugdir(struct gxp_dev *gxp) +{ + gxp->d_entry = debugfs_create_dir(GXP_NAME, NULL); + if (IS_ERR_OR_NULL(gxp->d_entry)) { + dev_warn(gxp->dev, "Create debugfs dir failed: %d", + PTR_ERR_OR_ZERO(gxp->d_entry)); + gxp->d_entry = NULL; + } +} + void gxp_create_debugfs(struct gxp_dev *gxp) { - gxp->d_entry = debugfs_create_dir("gxp", NULL); - if (IS_ERR_OR_NULL(gxp->d_entry)) + if (!gxp->d_entry) return; mutex_init(&gxp->debugfs_client_lock); @@ -518,9 +549,9 @@ void gxp_create_debugfs(struct gxp_dev *gxp) &gxp_cmu_mux2_fops); } -void gxp_remove_debugfs(struct gxp_dev *gxp) +void gxp_remove_debugdir(struct gxp_dev *gxp) { - if (IS_GXP_TEST && !gxp->d_entry) + if (!gxp->d_entry) return; debugfs_remove_recursive(gxp->d_entry); |