diff --git a/msm/eva/cvp.c b/msm/eva/cvp.c index cecdb7a766..aa210c52ea 100644 --- a/msm/eva/cvp.c +++ b/msm/eva/cvp.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -36,13 +37,11 @@ struct msm_cvp_drv *cvp_driver; static int cvp_open(struct inode *inode, struct file *filp) { - struct msm_cvp_core *core = container_of(inode->i_cdev, - struct msm_cvp_core, cdev); struct msm_cvp_inst *inst; - dprintk(CVP_SESS, "%s: core->id: %d\n", __func__, core->id); + dprintk(CVP_SESS, "%s\n", __func__); - inst = msm_cvp_open(core->id, MSM_CVP_USER, current); + inst = msm_cvp_open(MSM_CVP_USER, current); if (!inst) { dprintk(CVP_ERR, "Failed to create cvp instance\n"); return -ENOMEM; @@ -185,7 +184,7 @@ static ssize_t pwr_collapse_delay_store(struct device *dev, else if (!val) return -EINVAL; - core = get_cvp_core(MSM_CORE_CVP); + core = cvp_driver->cvp_core; if (!core) return -EINVAL; core->resources.msm_cvp_pwr_collapse_delay = val; @@ -198,7 +197,7 @@ static ssize_t pwr_collapse_delay_show(struct device *dev, { struct msm_cvp_core *core = NULL; - core = get_cvp_core(MSM_CORE_CVP); + core = cvp_driver->cvp_core; if (!core) return -EINVAL; @@ -266,7 +265,7 @@ static ssize_t boot_store(struct device *dev, if (val == 1 && booted == 0) { struct msm_cvp_inst *inst; - inst = msm_cvp_open(MSM_CORE_CVP, MSM_CVP_BOOT, current); + inst = msm_cvp_open(MSM_CVP_BOOT, current); if (!inst) { dprintk(CVP_ERR, "Failed to create cvp instance\n"); @@ -281,7 +280,7 @@ static ssize_t boot_store(struct device *dev, } else if (val == 2) { struct msm_cvp_inst *inst; - inst = msm_cvp_open(MSM_CORE_CVP, MSM_CVP_USER, current); + inst = msm_cvp_open(MSM_CVP_USER, current); if (!inst) { dprintk(CVP_ERR, "Failed to create eva instance\n"); @@ -347,8 +346,6 @@ static int msm_probe_cvp_device(struct platform_device *pdev) goto err_core_init; } - core->id = MSM_CORE_CVP; - rc = alloc_chrdev_region(&core->dev_num, 0, 1, DRIVER_NAME); if (rc < 0) { dprintk(CVP_ERR, "alloc_chrdev_region failed: %d\n", @@ -383,17 +380,6 @@ static int msm_probe_cvp_device(struct platform_device *pdev) goto error_cdev_add; } - /* finish setting up the 'core' */ - mutex_lock(&cvp_driver->lock); - if (cvp_driver->num_cores + 1 > MSM_CVP_CORES_MAX) { - mutex_unlock(&cvp_driver->lock); - dprintk(CVP_ERR, "Maximum cores already exist, core_no = %d\n", - cvp_driver->num_cores); - goto err_cores_exceeded; - } - cvp_driver->num_cores++; - mutex_unlock(&cvp_driver->lock); - rc = sysfs_create_group(&core->dev->kobj, &msm_cvp_core_attr_group); if (rc) { dprintk(CVP_ERR, @@ -404,11 +390,10 @@ static int msm_probe_cvp_device(struct platform_device *pdev) /* VM manager shall be started before HFI init */ vm_manager.vm_ops->vm_start(core); - core->device = cvp_hfi_initialize(core->hfi_type, core->id, + core->device = cvp_hfi_initialize(core->hfi_type, &core->resources, &cvp_handle_cmd_response); if (IS_ERR_OR_NULL(core->device)) { mutex_lock(&cvp_driver->lock); - cvp_driver->num_cores--; mutex_unlock(&cvp_driver->lock); rc = PTR_ERR(core->device) ?: -EBADHANDLE; @@ -422,7 +407,7 @@ static int msm_probe_cvp_device(struct platform_device *pdev) cvp_synx_ftbl_init(core); mutex_lock(&cvp_driver->lock); - list_add_tail(&core->list, &cvp_driver->cores); + cvp_driver->cvp_core = core; mutex_unlock(&cvp_driver->lock); cvp_driver->debugfs_root = msm_cvp_debugfs_init_drv(); @@ -567,7 +552,7 @@ static int msm_cvp_pm_suspend(struct device *dev) return -EINVAL; } - rc = msm_cvp_suspend(core->id); + rc = msm_cvp_suspend(); if (rc == -ENOTSUPP) rc = 0; else if (rc) @@ -610,7 +595,6 @@ static int __init msm_cvp_init(void) return -ENOMEM; } - INIT_LIST_HEAD(&cvp_driver->cores); mutex_init(&cvp_driver->lock); rc = platform_driver_register(&msm_cvp_driver); diff --git a/msm/eva/cvp_core_hfi.c b/msm/eva/cvp_core_hfi.c index 832fe0117b..3ebbf2f987 100644 --- a/msm/eva/cvp_core_hfi.c +++ b/msm/eva/cvp_core_hfi.c @@ -9,7 +9,7 @@ #include "cvp_core_hfi.h" struct cvp_hfi_device *cvp_hfi_initialize(enum msm_cvp_hfi_type hfi_type, - u32 device_id, struct msm_cvp_platform_resources *res, + struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback) { struct cvp_hfi_device *hdev = NULL; @@ -21,7 +21,7 @@ struct cvp_hfi_device *cvp_hfi_initialize(enum msm_cvp_hfi_type hfi_type, return NULL; } - rc = cvp_iris_hfi_initialize(hdev, device_id, res, callback); + rc = cvp_iris_hfi_initialize(hdev, res, callback); if (rc) { if (rc != -EPROBE_DEFER) diff --git a/msm/eva/cvp_core_hfi.h b/msm/eva/cvp_core_hfi.h index 9f41bb2632..d44cb54271 100644 --- a/msm/eva/cvp_core_hfi.h +++ b/msm/eva/cvp_core_hfi.h @@ -95,7 +95,7 @@ struct cvp_hfi_mem_map { (i * sizeof(struct cvp_hfi_queue_header))) #define QDSS_SIZE 4096 -#define SFR_SIZE 4096 +#define SFR_SIZE 1048576 #define QUEUE_SIZE (CVP_IFACEQ_TABLE_SIZE + \ (CVP_IFACEQ_QUEUE_SIZE * CVP_IFACEQ_NUMQ)) @@ -242,7 +242,6 @@ struct iris_hfi_device { struct list_head sess_head; u32 version; u32 intr_status; - u32 device_id; u32 clk_freq; u32 last_packet_type; u32 error; @@ -285,7 +284,7 @@ irqreturn_t iris_hfi_core_work_handler(int irq, void *data); irqreturn_t iris_hfi_isr_wd(int irq, void *dev); void cvp_iris_hfi_delete_device(void *device); -int cvp_iris_hfi_initialize(struct cvp_hfi_device *hdev, u32 device_id, +int cvp_iris_hfi_initialize(struct cvp_hfi_device *hdev, struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback); diff --git a/msm/eva/cvp_hfi.c b/msm/eva/cvp_hfi.c index a15f799a99..5a722683b1 100644 --- a/msm/eva/cvp_hfi.c +++ b/msm/eva/cvp_hfi.c @@ -177,7 +177,7 @@ int get_hfi_version(void) struct msm_cvp_core *core; struct iris_hfi_device *hfi; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; hfi = (struct iris_hfi_device *)core->device->hfi_device_data; return hfi->version; @@ -189,7 +189,7 @@ unsigned int get_msg_size(struct cvp_hfi_msg_session_hdr *hdr) struct iris_hfi_device *device; u32 minor_ver; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) device = core->device->hfi_device_data; else @@ -823,7 +823,7 @@ static int __set_registers(struct iris_hfi_device *device) return -EINVAL ; } - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; pdata = core->platform_data; reg_set = &device->res->reg_set; @@ -2936,7 +2936,6 @@ static void __process_fatal_error( { struct msm_cvp_cb_cmd_done cmd_done = {0}; - cmd_done.device_id = device->device_id; device->callback(HAL_SYS_ERROR, &cmd_done); } @@ -2965,7 +2964,7 @@ static void iris_hfi_pm_handler(struct work_struct *work) struct msm_cvp_core *core; struct iris_hfi_device *device; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) device = core->device->hfi_device_data; else @@ -3357,7 +3356,7 @@ static int __response_handler(struct iris_hfi_device *device) struct msm_cvp_cb_info info = { .response_type = HAL_SYS_WATCHDOG_TIMEOUT, .response.cmd = { - .device_id = device->device_id, + .device_id = 0, } }; @@ -3386,8 +3385,7 @@ static int __response_handler(struct iris_hfi_device *device) int rc = 0; print_msg_hdr(hdr); - rc = cvp_hfi_process_msg_packet(device->device_id, - raw_packet, info); + rc = cvp_hfi_process_msg_packet(0, raw_packet, info); if (rc) { dprintk(CVP_WARN, "Corrupt/unknown packet found, discarding\n"); @@ -3464,7 +3462,7 @@ irqreturn_t iris_hfi_core_work_handler(int irq, void *data) u32 intr_status; static bool warning_on = true; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) device = core->device->hfi_device_data; else @@ -3544,7 +3542,7 @@ static void iris_hfi_wd_work_handler(struct work_struct *work) struct iris_hfi_device *device; struct msm_cvp_cb_cmd_done response = {0}; enum hal_command_response cmd = HAL_SYS_WATCHDOG_TIMEOUT; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) device = core->device->hfi_device_data; else @@ -3552,7 +3550,7 @@ static void iris_hfi_wd_work_handler(struct work_struct *work) if (msm_cvp_hw_wd_recovery) { dprintk(CVP_ERR, "Cleaning up as HW WD recovery is enable %d\n", msm_cvp_hw_wd_recovery); - response.device_id = device->device_id; + response.device_id = 0; handle_sys_error(cmd, (void *) &response); enable_irq(device->cvp_hal_data->irq_wd); } @@ -4887,7 +4885,7 @@ static inline int __resume(struct iris_hfi_device *device) return -EINVAL; } - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; dprintk(CVP_PWR, "Resuming from power collapse\n"); rc = __iris_power_on(device); @@ -5104,7 +5102,7 @@ static void __noc_error_info_iris2(struct iris_hfi_device *device) bool log_required = false; int rc; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core->ssr_count && core->resources.max_ssr_allowed > 1) log_required = true; @@ -5286,8 +5284,7 @@ void __init_cvp_ops(struct iris_hfi_device *device) device->vpu_ops = &iris2_ops; } -static struct iris_hfi_device *__add_device(u32 device_id, - struct msm_cvp_platform_resources *res, +static struct iris_hfi_device *__add_device(struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback) { struct iris_hfi_device *hdevice = NULL; @@ -5298,8 +5295,6 @@ static struct iris_hfi_device *__add_device(u32 device_id, return NULL; } - dprintk(CVP_INFO, "%s: device_id: %d\n", __func__, device_id); - hdevice = kzalloc(sizeof(*hdevice), GFP_KERNEL); if (!hdevice) { dprintk(CVP_ERR, "failed to allocate new device\n"); @@ -5325,7 +5320,6 @@ static struct iris_hfi_device *__add_device(u32 device_id, goto err_cleanup; hdevice->res = res; - hdevice->device_id = device_id; hdevice->callback = callback; __init_cvp_ops(hdevice); @@ -5361,8 +5355,7 @@ exit: return NULL; } -static struct iris_hfi_device *__get_device(u32 device_id, - struct msm_cvp_platform_resources *res, +static struct iris_hfi_device *__get_device(struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback) { if (!res || !callback) { @@ -5370,7 +5363,7 @@ static struct iris_hfi_device *__get_device(u32 device_id, return NULL; } - return __add_device(device_id, res, callback); + return __add_device(res, callback); } void cvp_iris_hfi_delete_device(void *device) @@ -5381,7 +5374,7 @@ void cvp_iris_hfi_delete_device(void *device) if (!device) return; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) dev = core->device->hfi_device_data; @@ -5448,7 +5441,7 @@ static void iris_init_hfi_callbacks(struct cvp_hfi_device *hdev) hdev->debug_hook = iris_debug_hook; } -int cvp_iris_hfi_initialize(struct cvp_hfi_device *hdev, u32 device_id, +int cvp_iris_hfi_initialize(struct cvp_hfi_device *hdev, struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback) { @@ -5461,7 +5454,7 @@ int cvp_iris_hfi_initialize(struct cvp_hfi_device *hdev, u32 device_id, goto err_iris_hfi_init; } - hdev->hfi_device_data = __get_device(device_id, res, callback); + hdev->hfi_device_data = __get_device(res, callback); if (IS_ERR_OR_NULL(hdev->hfi_device_data)) { rc = PTR_ERR(hdev->hfi_device_data) ?: -EINVAL; diff --git a/msm/eva/cvp_hfi_api.h b/msm/eva/cvp_hfi_api.h index 5fd28f3600..f21daf5b9c 100644 --- a/msm/eva/cvp_hfi_api.h +++ b/msm/eva/cvp_hfi_api.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __CVP_HFI_API_H__ @@ -298,7 +299,7 @@ enum cvp_status hfi_process_session_init_done_prop_read( struct cvp_hal_session_init_done *session_init_done); struct cvp_hfi_device *cvp_hfi_initialize(enum msm_cvp_hfi_type hfi_type, - u32 device_id, struct msm_cvp_platform_resources *res, + struct msm_cvp_platform_resources *res, hfi_cmd_response_callback callback); void cvp_hfi_deinitialize(enum msm_cvp_hfi_type hfi_type, struct cvp_hfi_device *hdev); diff --git a/msm/eva/cvp_power.c b/msm/eva/cvp_power.c index 42b4ed39e9..e9e6ce2952 100644 --- a/msm/eva/cvp_power.c +++ b/msm/eva/cvp_power.c @@ -155,7 +155,7 @@ static int adjust_bw_freqs(void) int i, rc = 0, bus_count = 0; unsigned long ctrl_freq; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; hdev = core->device->hfi_device_data; clocks = &core->resources.clock_set; @@ -444,7 +444,7 @@ unsigned int msm_cvp_get_hw_aggregate_cycles(enum hfi_hw_thread hwblk) struct msm_cvp_inst *inst; unsigned long cycles_sum = 0; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, "%s: invalid core\n", __func__); diff --git a/msm/eva/cvp_smem.c b/msm/eva/cvp_smem.c index 673db56b3f..1dcf884ec6 100644 --- a/msm/eva/cvp_smem.c +++ b/msm/eva/cvp_smem.c @@ -579,7 +579,7 @@ int msm_cvp_map_ipcc_regs(u32 *iova) phys_addr_t paddr; u32 size; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) { hfi_ops = core->device; if (hfi_ops) @@ -616,7 +616,7 @@ int msm_cvp_unmap_ipcc_regs(u32 iova) struct iris_hfi_device *dev = NULL; u32 size; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) { hfi_ops = core->device; if (hfi_ops) diff --git a/msm/eva/hfi_response_handler.c b/msm/eva/hfi_response_handler.c index 0ded7e6026..0cb9559f63 100644 --- a/msm/eva/hfi_response_handler.c +++ b/msm/eva/hfi_response_handler.c @@ -523,7 +523,7 @@ static int hfi_process_session_dump_notify(u32 device_id, return -E2BIG; } session_id = get_msg_session_id(pkt); - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; inst = cvp_get_inst_from_id(core, session_id); if (!inst) { dprintk(CVP_ERR, "%s: invalid session\n", __func__); @@ -568,7 +568,7 @@ static int hfi_process_session_cvp_msg(u32 device_id, return -E2BIG; } session_id = get_msg_session_id(pkt); - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; inst = cvp_get_inst_from_id(core, session_id); if (!inst) { diff --git a/msm/eva/msm_cvp.c b/msm/eva/msm_cvp.c index 9635e61a5e..62cba335d7 100644 --- a/msm/eva/msm_cvp.c +++ b/msm/eva/msm_cvp.c @@ -1647,7 +1647,6 @@ int msm_cvp_session_init(struct msm_cvp_inst *inst) inst, hash32_ptr(inst->session)); /* set default frequency */ - inst->clk_data.core_id = 0; inst->clk_data.min_freq = 1000; inst->clk_data.ddr_bw = 1000; inst->clk_data.sys_cache_bw = 1000; diff --git a/msm/eva/msm_cvp_buf.c b/msm/eva/msm_cvp_buf.c index e6cf5a9243..9001440cd6 100644 --- a/msm/eva/msm_cvp_buf.c +++ b/msm/eva/msm_cvp_buf.c @@ -1702,7 +1702,7 @@ int msm_cvp_map_frame(struct msm_cvp_inst *inst, struct msm_cvp_inst *instance = (struct msm_cvp_inst *)0xdeadbeef; struct msm_cvp_core *core = NULL; - core = get_cvp_core(MSM_CORE_CVP); + core = cvp_driver->cvp_core; if (!core) return -EINVAL; @@ -1903,7 +1903,7 @@ void msm_cvp_print_inst_bufs(struct msm_cvp_inst *inst, bool log) struct inst_snapshot *snap = NULL; int i = 0, c = 0; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (log && core->log.snapshot_index < 16) { snap = &core->log.snapshot[core->log.snapshot_index]; snap->session = inst->session; diff --git a/msm/eva/msm_cvp_common.c b/msm/eva/msm_cvp_common.c index 8429137ac8..3b03d87a27 100644 --- a/msm/eva/msm_cvp_common.c +++ b/msm/eva/msm_cvp_common.c @@ -72,31 +72,6 @@ void print_hfi_queue_info(struct cvp_hfi_device *hdev) } } - - -struct msm_cvp_core *get_cvp_core(int core_id) -{ - struct msm_cvp_core *core; - int found = 0; - - if (core_id > MSM_CVP_CORES_MAX) { - dprintk(CVP_ERR, "Core id = %d is greater than max = %d\n", - core_id, MSM_CVP_CORES_MAX); - return NULL; - } - mutex_lock(&cvp_driver->lock); - list_for_each_entry(core, &cvp_driver->cores, list) { - if (core->id == core_id) { - found = 1; - break; - } - } - mutex_unlock(&cvp_driver->lock); - if (found) - return core; - return NULL; -} - static void handle_sys_init_done(enum hal_command_response cmd, void *data) { struct msm_cvp_cb_cmd_done *response = data; @@ -116,7 +91,7 @@ static void handle_sys_init_done(enum hal_command_response cmd, void *data) "Failed to get valid response for sys init\n"); return; } - core = get_cvp_core(response->device_id); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, "Wrong device_id received\n"); return; @@ -239,8 +214,7 @@ static void handle_session_set_buf_done(enum hal_command_response cmd, return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "set_buf_done has an inactive session\n"); return; @@ -275,8 +249,7 @@ static void handle_session_release_buf_done(enum hal_command_response cmd, return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s: Got a response for an inactive session\n", @@ -321,7 +294,7 @@ static void handle_sys_release_res_done( "Failed to get valid response for sys init\n"); return; } - core = get_cvp_core(response->device_id); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, "Wrong device_id received\n"); return; @@ -428,8 +401,7 @@ static void handle_session_init_done(enum hal_command_response cmd, void *data) return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s:Got a response for an inactive session\n", @@ -471,8 +443,7 @@ static void handle_session_dump_notify(enum hal_command_response cmd, return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s:Got a response for an inactive session\n", __func__); @@ -497,8 +468,7 @@ static void handle_release_res_done(enum hal_command_response cmd, void *data) return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s:Got a response for an inactive session\n", __func__); @@ -520,8 +490,7 @@ static void handle_session_ctrl(enum hal_command_response cmd, void *data) return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s:Got a response for an inactive session\n", __func__); @@ -551,8 +520,7 @@ static void handle_session_error(enum hal_command_response cmd, void *data) return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s: response for an inactive session\n", __func__); @@ -596,7 +564,7 @@ void handle_sys_error(enum hal_command_response cmd, void *data) return; } - core = get_cvp_core(response->device_id); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, "Got SYS_ERR but unable to identify core\n"); @@ -702,8 +670,7 @@ static void handle_session_close(enum hal_command_response cmd, void *data) return; } - inst = cvp_get_inst(get_cvp_core(response->device_id), - response->session_id); + inst = cvp_get_inst(cvp_driver->cvp_core, response->session_id); if (!inst) { dprintk(CVP_WARN, "%s: response for an inactive session\n", __func__); @@ -784,53 +751,6 @@ static inline enum msm_cvp_thermal_level msm_comm_cvp_thermal_level(int level) } } -static bool is_core_turbo(struct msm_cvp_core *core, unsigned long freq) -{ - int i = 0; - struct allowed_clock_rates_table *allowed_clks_tbl = NULL; - u32 max_freq = 0; - - allowed_clks_tbl = core->resources.allowed_clks_tbl; - for (i = 0; i < core->resources.allowed_clks_tbl_size; i++) { - if (max_freq < allowed_clks_tbl[i].clock_rate) - max_freq = allowed_clks_tbl[i].clock_rate; - } - return freq >= max_freq; -} - -static bool is_thermal_permissible(struct msm_cvp_core *core) -{ - enum msm_cvp_thermal_level tl; - unsigned long freq = 0; - bool is_turbo = false; - - if (!core->resources.thermal_mitigable) - return true; - - if (msm_cvp_thermal_mitigation_disabled) { - dprintk(CVP_CORE, - "Thermal mitigation not enabled. debugfs %d\n", - msm_cvp_thermal_mitigation_disabled); - return true; - } - - tl = msm_comm_cvp_thermal_level(cvp_driver->thermal_level); - freq = core->curr_freq; - - is_turbo = is_core_turbo(core, freq); - dprintk(CVP_CORE, - "Core freq %ld Thermal level %d Turbo mode %d\n", - freq, tl, is_turbo); - - if (is_turbo && tl >= CVP_THERMAL_LOW) { - dprintk(CVP_ERR, - "CVP session not allowed. Turbo mode %d Thermal level %d\n", - is_turbo, tl); - return false; - } - return true; -} - static int msm_comm_session_abort(struct msm_cvp_inst *inst) { int rc = 0, abort_completion = 0; @@ -875,22 +795,9 @@ exit: return rc; } -static void handle_thermal_event(struct msm_cvp_core *core) -{ - dprintk(CVP_WARN, "Deprecated thermal_event handler\n"); -} - void msm_cvp_comm_handle_thermal_event(void) { - struct msm_cvp_core *core; - - list_for_each_entry(core, &cvp_driver->cores, list) { - if (!is_thermal_permissible(core)) { - dprintk(CVP_WARN, - "Thermal level critical, stop all active sessions!\n"); - handle_thermal_event(core); - } - } + dprintk(CVP_WARN, "deprecated %s called\n", __func__); } int msm_cvp_comm_check_core_init(struct msm_cvp_core *core) @@ -900,8 +807,8 @@ int msm_cvp_comm_check_core_init(struct msm_cvp_core *core) mutex_lock(&core->lock); if (core->state >= CVP_CORE_INIT_DONE) { - dprintk(CVP_INFO, "CVP core: %d is already in state: %d\n", - core->id, core->state); + dprintk(CVP_INFO, "CVP core: is already in state: %d\n", + core->state); goto exit; } dprintk(CVP_CORE, "Waiting for SYS_INIT_DONE\n"); @@ -952,8 +859,8 @@ static int msm_comm_init_core(struct msm_cvp_inst *inst) hdev = core->device; mutex_lock(&core->lock); if (core->state >= CVP_CORE_INIT) { - dprintk(CVP_CORE, "CVP core: %d is already in state: %d\n", - core->id, core->state); + dprintk(CVP_CORE, "CVP core: is already in state: %d\n", + core->state); goto core_already_inited; } if (!core->capabilities) { @@ -974,8 +881,7 @@ static int msm_comm_init_core(struct msm_cvp_inst *inst) dprintk(CVP_CORE, "%s: core %pK\n", __func__, core); rc = call_hfi_op(hdev, core_init, hdev->hfi_device_data); if (rc) { - dprintk(CVP_ERR, "Failed to init core, id = %d\n", - core->id); + dprintk(CVP_ERR, "Failed to init core\n"); goto fail_core_init; } core->state = CVP_CORE_INIT; @@ -1095,17 +1001,16 @@ exit: return rc; } -int msm_cvp_comm_suspend(int core_id) +int msm_cvp_comm_suspend(void) { struct cvp_hfi_device *hdev; struct msm_cvp_core *core; int rc = 0; - core = get_cvp_core(core_id); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, - "%s: Failed to find core for core_id = %d\n", - __func__, core_id); + "%s: Failed to find cvp core\n", __func__); return -EINVAL; } @@ -1153,7 +1058,7 @@ int msm_cvp_comm_try_state(struct msm_cvp_inst *inst, int state) int flipped_state; struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!inst) { dprintk(CVP_ERR, "%s: invalid params %pK", __func__, inst); @@ -1362,7 +1267,6 @@ void msm_cvp_comm_generate_sys_error(struct msm_cvp_inst *inst) } dprintk(CVP_WARN, "%s: inst %pK\n", __func__, inst); core = inst->core; - response.device_id = (u32) core->id; handle_sys_error(cmd, (void *) &response); } @@ -1480,7 +1384,7 @@ bool is_cvp_inst_valid(struct msm_cvp_inst *inst) struct msm_cvp_core *core; struct msm_cvp_inst *sess; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core) return false; diff --git a/msm/eva/msm_cvp_common.h b/msm/eva/msm_cvp_common.h index b9dc2e06f2..f434e91304 100644 --- a/msm/eva/msm_cvp_common.h +++ b/msm/eva/msm_cvp_common.h @@ -16,10 +16,9 @@ struct msm_cvp_inst *cvp_get_inst_validate(struct msm_cvp_core *core, bool is_cvp_inst_valid(struct msm_cvp_inst *inst); void cvp_change_inst_state(struct msm_cvp_inst *inst, enum instance_state state); -struct msm_cvp_core *get_cvp_core(int core_id); int msm_cvp_comm_try_state(struct msm_cvp_inst *inst, int state); int msm_cvp_deinit_core(struct msm_cvp_inst *inst); -int msm_cvp_comm_suspend(int core_id); +int msm_cvp_comm_suspend(void); void msm_cvp_comm_session_clean(struct msm_cvp_inst *inst); int msm_cvp_comm_kill_session(struct msm_cvp_inst *inst); void msm_cvp_comm_generate_sys_error(struct msm_cvp_inst *inst); diff --git a/msm/eva/msm_cvp_core.c b/msm/eva/msm_cvp_core.c index e9825c4bed..2fe425e9b5 100644 --- a/msm/eva/msm_cvp_core.c +++ b/msm/eva/msm_cvp_core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -138,7 +139,7 @@ static void __deinit_session_queue(struct msm_cvp_inst *inst) wake_up_all(&inst->session_queue.wq); } -void *msm_cvp_open(int core_id, int session_type, struct task_struct *task) +void *msm_cvp_open(int session_type, struct task_struct *task) { struct msm_cvp_inst *inst = NULL; struct msm_cvp_core *core = NULL; @@ -146,16 +147,9 @@ void *msm_cvp_open(int core_id, int session_type, struct task_struct *task) int i = 0; u32 instance_count; - if (core_id >= MSM_CVP_CORES_MAX || - session_type >= MSM_CVP_MAX_DEVICES) { - dprintk(CVP_ERR, "Invalid input, core_id = %d, session = %d\n", - core_id, session_type); - goto err_invalid_core; - } - core = get_cvp_core(core_id); + core = cvp_driver->cvp_core; if (!core) { - dprintk(CVP_ERR, - "Failed to find core for core_id = %d\n", core_id); + dprintk(CVP_ERR, "%s CVP core not initialized\n", __func__); goto err_invalid_core; } @@ -210,7 +204,6 @@ void *msm_cvp_open(int core_id, int session_type, struct task_struct *task) inst->clk_data.ddr_bw = 0; inst->clk_data.sys_cache_bw = 0; inst->clk_data.bitrate = 0; - inst->clk_data.core_id = 0; for (i = SESSION_MSG_INDEX(SESSION_MSG_START); i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) { @@ -473,8 +466,8 @@ int msm_cvp_close(void *instance) } EXPORT_SYMBOL(msm_cvp_close); -int msm_cvp_suspend(int core_id) +int msm_cvp_suspend(void) { - return msm_cvp_comm_suspend(core_id); + return msm_cvp_comm_suspend(); } EXPORT_SYMBOL(msm_cvp_suspend); diff --git a/msm/eva/msm_cvp_core.h b/msm/eva/msm_cvp_core.h index 15c12fd8c0..dd0f706dc0 100644 --- a/msm/eva/msm_cvp_core.h +++ b/msm/eva/msm_cvp_core.h @@ -20,11 +20,6 @@ #define DDR_TYPE_LPDDR4Y 0x8 #define DDR_TYPE_LPDDR5 0x9 -enum core_id { - MSM_CORE_CVP = 0, - MSM_CVP_CORES_MAX, -}; - enum session_type { MSM_CVP_USER = 1, MSM_CVP_KERNEL, @@ -34,9 +29,9 @@ enum session_type { MSM_CVP_MAX_DEVICES = MSM_CVP_UNKNOWN, }; -void *msm_cvp_open(int core_id, int session_type, struct task_struct *task); +void *msm_cvp_open(int session_type, struct task_struct *task); int msm_cvp_close(void *instance); -int msm_cvp_suspend(int core_id); +int msm_cvp_suspend(void); int msm_cvp_poll(void *instance, struct file *filp, struct poll_table_struct *pt); int msm_cvp_private(void *cvp_inst, unsigned int cmd, diff --git a/msm/eva/msm_cvp_debug.c b/msm/eva/msm_cvp_debug.c index 160491c3ea..381ed94987 100644 --- a/msm/eva/msm_cvp_debug.c +++ b/msm/eva/msm_cvp_debug.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -90,7 +91,7 @@ static ssize_t core_info_read(struct file *file, char __user *buf, hdev = core->device; cur += write_str(cur, end - cur, "===============================\n"); - cur += write_str(cur, end - cur, "CORE %d: %pK\n", core->id, core); + cur += write_str(cur, end - cur, "CORE %d: %pK\n", 0, core); cur += write_str(cur, end - cur, "===============================\n"); cur += write_str(cur, end - cur, "Core state: %d\n", core->state); rc = call_hfi_op(hdev, get_fw_info, hdev->hfi_device_data, &fw_info); @@ -181,7 +182,7 @@ static int cvp_power_get(void *data, u64 *val) struct msm_cvp_core *core; struct iris_hfi_device *hfi_device; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core) return 0; hfi_ops = core->device; @@ -206,7 +207,7 @@ static int cvp_power_set(void *data, u64 val) struct iris_hfi_device *hfi_device; int rc = 0; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core) return -EINVAL; @@ -288,7 +289,7 @@ static int _clk_rate_set(void *data, u64 val) struct allowed_clock_rates_table *tbl = NULL; unsigned int tbl_size, i; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; dev = core->device; tbl = core->resources.allowed_clks_tbl; tbl_size = core->resources.allowed_clks_tbl_size; @@ -324,7 +325,7 @@ static int _clk_rate_get(void *data, u64 *val) struct msm_cvp_core *core; struct iris_hfi_device *hdev; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; hdev = core->device->hfi_device_data; if (msm_cvp_clock_voting) *val = msm_cvp_clock_voting; @@ -357,7 +358,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(dsp_debug_fops, _dsp_dbg_get, _dsp_dbg_set, "%llu\n"); static int _max_ssr_set(void *data, u64 val) { struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) { if (val < 1) { dprintk(CVP_WARN, @@ -373,7 +374,7 @@ static int _max_ssr_set(void *data, u64 val) static int _max_ssr_get(void *data, u64 *val) { struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) *val = core->resources.max_ssr_allowed; @@ -385,7 +386,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(max_ssr_fops, _max_ssr_get, _max_ssr_set, "%llu\n"); static int _ssr_stall_set(void *data, u64 val) { struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) core->resources.fatal_ssr = (val >= 1) ? true : false; @@ -395,7 +396,7 @@ static int _ssr_stall_set(void *data, u64 val) static int _ssr_stall_get(void *data, u64 *val) { struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) *val = core->resources.fatal_ssr ? 1 : 0; @@ -416,7 +417,7 @@ struct dentry *msm_cvp_debugfs_init_core(struct msm_cvp_core *core, goto failed_create_dir; } - snprintf(debugfs_name, MAX_DEBUGFS_NAME, "core%d", core->id); + snprintf(debugfs_name, MAX_DEBUGFS_NAME, "core%d", 0); dir = debugfs_create_dir(debugfs_name, parent); if (IS_ERR_OR_NULL(dir)) { dir = NULL; diff --git a/msm/eva/msm_cvp_dsp.c b/msm/eva/msm_cvp_dsp.c index 289867ff51..78ee7f944f 100644 --- a/msm/eva/msm_cvp_dsp.c +++ b/msm/eva/msm_cvp_dsp.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -494,7 +495,7 @@ static bool dsp_session_exist(void) struct msm_cvp_core *core; struct msm_cvp_inst *inst = NULL; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) { mutex_lock(&core->lock); list_for_each_entry(inst, &core->instances, list) { @@ -896,7 +897,7 @@ static int __reinit_dsp(void) struct msm_cvp_core *core; struct iris_hfi_device *device; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core && core->device) device = core->device->hfi_device_data; else @@ -1365,7 +1366,7 @@ void cvp_dsp_send_hfi_queue(void) uint32_t size; int rc; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core && core->device) device = core->device->hfi_device_data; else @@ -1469,7 +1470,7 @@ static void *get_inst_from_dsp(uint32_t session_cpu_high, uint32_t session_cpu_l return inst; } - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (core) { mutex_lock(&core->lock); list_for_each_entry(sess_inst, &core->instances, list) { @@ -1565,7 +1566,7 @@ static void __dsp_cvp_sess_create(struct cvp_dsp_cmd_msg *cmd) goto fail_lookup; } - inst = msm_cvp_open(MSM_CORE_CVP, MSM_CVP_DSP, task); + inst = msm_cvp_open(MSM_CVP_DSP, task); if (!inst) { dprintk(CVP_ERR, "%s Failed create instance\n", __func__); goto fail_msm_cvp_open; @@ -2099,7 +2100,7 @@ static int cvp_dsp_thread(void *data) struct cvp_hfi_device *hdev; struct msm_cvp_core *core; - core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list); + core = cvp_driver->cvp_core; if (!core) { dprintk(CVP_ERR, "%s: Failed to find core\n", __func__); rc = -EINVAL; diff --git a/msm/eva/msm_cvp_internal.h b/msm/eva/msm_cvp_internal.h index 203b7afb1a..e81a0b3d5a 100644 --- a/msm/eva/msm_cvp_internal.h +++ b/msm/eva/msm_cvp_internal.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _MSM_CVP_INTERNAL_H_ @@ -135,8 +136,7 @@ struct cvp_kmem_cache { struct msm_cvp_drv { struct mutex lock; - struct list_head cores; - int num_cores; + struct msm_cvp_core *cvp_core; struct dentry *debugfs_root; int thermal_level; u32 sku_version; @@ -170,7 +170,6 @@ struct cvp_clock_data { u32 ddr_bw; u32 sys_cache_bw; u32 operating_rate; - u32 core_id; bool low_latency_mode; bool turbo_mode; }; @@ -331,10 +330,8 @@ struct cvp_debug_log { }; struct msm_cvp_core { - struct list_head list; struct mutex lock; struct mutex clk_lock; - int id; dev_t dev_num; struct cdev cdev; struct class *class;