From 261488ef83e707e0822bf84b4ebed768bb0fa445 Mon Sep 17 00:00:00 2001 From: Mainak Sen Date: Thu, 20 Mar 2025 13:54:06 +0000 Subject: [PATCH] gpu: host1x-emu: Add host1x_syncpt_get_shim_info Implement host1x_syncpt_get_shim_info function for host1x-emu driver and add it to the dynamic dispatch mechanism in host1x-fence. This function provides clients with the physical address of syncpoint aperture, stride and number of syncpoints, which is needed by various client drivers like ISP, VI, PVA, GPU etc Jira HOSTX-5971 Change-Id: I50e60222a035228c981dfa993cb0088e1d15dad2 Signed-off-by: Mainak Sen Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3323327 GVS: buildbot_gerritrpt Reviewed-by: Raghavendra Vishnu Kumar Reviewed-by: Amitabh Dutta --- drivers/gpu/host1x-emu/dev.c | 1 + .../gpu/host1x-emu/include/linux/host1x-emu.h | 5 ++++ drivers/gpu/host1x-emu/syncpt.c | 24 +++++++++++++++++++ drivers/gpu/host1x-fence/dispatch.c | 17 ++++++++++++- .../include/linux/host1x-dispatch.h | 3 ++- .../include/linux/host1x-dispatch_api.h | 5 ++++ .../include/linux/host1x-dispatch_type.h | 2 ++ 7 files changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x-emu/dev.c b/drivers/gpu/host1x-emu/dev.c index 275a0394..491ea87e 100644 --- a/drivers/gpu/host1x-emu/dev.c +++ b/drivers/gpu/host1x-emu/dev.c @@ -61,6 +61,7 @@ struct host1x_interface_ops host1x_emu_api = { .host1x_syncpt_id = HOST1X_EMU_EXPORT_SYMBOL_NAME(host1x_syncpt_id), .host1x_syncpt_wait_ts = HOST1X_EMU_EXPORT_SYMBOL_NAME(host1x_syncpt_wait_ts), .host1x_syncpt_wait = HOST1X_EMU_EXPORT_SYMBOL_NAME(host1x_syncpt_wait), + .host1x_syncpt_get_shim_info = HOST1X_EMU_EXPORT_SYMBOL_NAME(host1x_syncpt_get_shim_info), //nvhost.h Interface .host1x_writel = HOST1X_EMU_EXPORT_SYMBOL_NAME(host1x_writel), diff --git a/drivers/gpu/host1x-emu/include/linux/host1x-emu.h b/drivers/gpu/host1x-emu/include/linux/host1x-emu.h index a169d41c..47fac5dc 100644 --- a/drivers/gpu/host1x-emu/include/linux/host1x-emu.h +++ b/drivers/gpu/host1x-emu/include/linux/host1x-emu.h @@ -82,4 +82,9 @@ HOST1X_EMU_EXPORT_DECL(int, host1x_fence_get_node(struct dma_fence *fence)); HOST1X_EMU_EXPORT_DECL(void, host1x_fence_cancel(struct dma_fence *fence)); +HOST1X_EMU_EXPORT_DECL(int, host1x_syncpt_get_shim_info(struct host1x *host, + phys_addr_t *base, + u32 *stride, + u32 *num_syncpts)); + #endif diff --git a/drivers/gpu/host1x-emu/syncpt.c b/drivers/gpu/host1x-emu/syncpt.c index b7b4c483..76882e38 100644 --- a/drivers/gpu/host1x-emu/syncpt.c +++ b/drivers/gpu/host1x-emu/syncpt.c @@ -485,6 +485,30 @@ HOST1X_EMU_EXPORT_DECL(int, host1x_syncpt_wait_ts(struct host1x_syncpt *sp, } HOST1X_EMU_EXPORT_SYMBOL(host1x_syncpt_wait_ts); +/** + * @brief Get the physical address of the syncpoint aperture, stride and number of syncpoints + * + * @param host: host1x instance + * @param base: physical address of syncpoint aperture + * @param stride: stride between syncpoints + * @param num_syncpts: number of syncpoints + * + * @return 0 if successful + */ +HOST1X_EMU_EXPORT_DECL(int, host1x_syncpt_get_shim_info(struct host1x *host, + phys_addr_t *base, u32 *stride, u32 *num_syncpts)) +{ + if (!host || !base || !stride || !num_syncpts) + return -EINVAL; + + *base = host->syncpt_phy_apt; + *stride = host->syncpt_page_size; + *num_syncpts = host->syncpt_count; + + return 0; +} +HOST1X_EMU_EXPORT_SYMBOL(host1x_syncpt_get_shim_info); + /** * @brief Wait for a syncpoint to reach a given threshold value * diff --git a/drivers/gpu/host1x-fence/dispatch.c b/drivers/gpu/host1x-fence/dispatch.c index a19d223d..7df46800 100644 --- a/drivers/gpu/host1x-fence/dispatch.c +++ b/drivers/gpu/host1x-fence/dispatch.c @@ -29,6 +29,7 @@ static bool host1x_wrapper_init_default_interface(void) host1x_api_table.host1x_syncpt_id = host1x_syncpt_id; host1x_api_table.host1x_syncpt_wait_ts = host1x_syncpt_wait_ts; host1x_api_table.host1x_syncpt_wait = host1x_syncpt_wait; + host1x_api_table.host1x_syncpt_get_shim_info = host1x_syncpt_get_shim_info; // Interface for nvhost.h host1x_api_table.host1x_writel = host1x_writel; host1x_api_table.nvhost_get_default_device = nvhost_get_default_device; @@ -191,10 +192,24 @@ EXPORT_SYMBOL(wrap_host1x_syncpt_wait_ts); int wrap_host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, u32 *value) { - return host1x_api_table.host1x_syncpt_wait(sp, thresh, timeout, value); + if (host1x_api_table.host1x_syncpt_wait != NULL) + return host1x_api_table.host1x_syncpt_wait(sp, thresh, timeout, value); + return -ENOSYS; } EXPORT_SYMBOL(wrap_host1x_syncpt_wait); +/** + * Wrapper function for host1x_syncpt_get_shim_info + */ +int wrap_host1x_syncpt_get_shim_info(struct host1x *host, + phys_addr_t *base, u32 *stride, u32 *num_syncpts) +{ + + return host1x_api_table.host1x_syncpt_get_shim_info(host, base, stride, num_syncpts); + return -ENOSYS; +} +EXPORT_SYMBOL(wrap_host1x_syncpt_get_shim_info); + // nvhost.c void wrap_host1x_writel(struct platform_device *pdev, u32 r, u32 v) { diff --git a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch.h b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch.h index 64991724..df3a2c50 100644 --- a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch.h +++ b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch.h @@ -26,7 +26,8 @@ #define host1x_syncpt_id wrap_host1x_syncpt_id #define host1x_syncpt_wait_ts wrap_host1x_syncpt_wait_ts #define host1x_syncpt_wait wrap_host1x_syncpt_wait -#define host1x_fence_get_node wrap_host1x_fence_get_node +#define host1x_fence_get_node wrap_host1x_fence_get_node +#define host1x_syncpt_get_shim_info wrap_host1x_syncpt_get_shim_info //nvhost.h #define host1x_writel wrap_host1x_writel diff --git a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_api.h b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_api.h index c55f3955..f6c69d94 100644 --- a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_api.h +++ b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_api.h @@ -78,6 +78,11 @@ int wrap_host1x_syncpt_wait_ts(struct host1x_syncpt *sp, int wrap_host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, u32 *value); +int wrap_host1x_syncpt_get_shim_info(struct host1x *host, + phys_addr_t *base, + u32 *stride, + u32 *num_syncpts); + int wrap_host1x_fence_get_node(struct dma_fence *fence); //nvhost.h diff --git a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_type.h b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_type.h index a0bad12e..62b829f7 100644 --- a/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_type.h +++ b/drivers/gpu/host1x-fence/include/linux/host1x-dispatch_type.h @@ -37,6 +37,8 @@ void (*host1x_syncpt_put)(struct host1x_syncpt *sp); u32 (*host1x_syncpt_id)(struct host1x_syncpt *sp); int (*host1x_syncpt_wait_ts)(struct host1x_syncpt *sp, u32 thresh, long timeout, u32 *value, ktime_t *ts); int (*host1x_syncpt_wait)(struct host1x_syncpt *sp, u32 thresh, long timeout,u32 *value); +int (*host1x_syncpt_get_shim_info)(struct host1x *host, phys_addr_t *base, + u32 *stride, u32 *num_syncpts); //nvhost.h Interface void (*host1x_writel)(struct platform_device *pdev, u32 r, u32 v);