Loading arch/arm64/configs/vendor/lito-perf_defconfig +1 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ CONFIG_VIDEO_ADV_DEBUG=y CONFIG_VIDEO_FIXED_MINOR_RANGES=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SPECTRA_CAMERA=y CONFIG_MSM_NPU=y CONFIG_V4L_TEST_DRIVERS=y CONFIG_VIDEO_VIM2M=m CONFIG_VIDEO_VICODEC=y Loading arch/arm64/configs/vendor/lito_defconfig +1 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,7 @@ CONFIG_VIDEO_ADV_DEBUG=y CONFIG_VIDEO_FIXED_MINOR_RANGES=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SPECTRA_CAMERA=y CONFIG_MSM_NPU=y CONFIG_V4L_TEST_DRIVERS=y CONFIG_VIDEO_VIM2M=y CONFIG_VIDEO_VICODEC=y Loading drivers/media/platform/msm/npu/npu_common.h +20 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <linux/types.h> #include <linux/uaccess.h> #include <linux/mailbox/qmp.h> #include <linux/msm-bus.h> #include "npu_mgr.h" Loading Loading @@ -201,6 +202,21 @@ struct npu_io_data { void __iomem *base; }; #define MAX_PATHS 2 #define DBL_BUF 2 #define MBYTE (1ULL << 20) struct npu_bwctrl { struct msm_bus_vectors vectors[MAX_PATHS * DBL_BUF]; struct msm_bus_paths bw_levels[DBL_BUF]; struct msm_bus_scale_pdata bw_data; uint32_t bus_client; int cur_ab; int cur_ib; int cur_idx; uint32_t num_paths; }; struct npu_device { struct mutex dev_lock; Loading Loading @@ -238,10 +254,13 @@ struct npu_device { struct thermal_cooling_device *tcdev; struct npu_pwrctrl pwrctrl; struct npu_thermalctrl thermalctrl; struct npu_bwctrl bwctrl; struct llcc_slice_desc *sys_cache; uint32_t execute_v2_flag; bool cxlimit_registered; uint32_t hw_version; }; struct npu_kevent { Loading Loading @@ -283,5 +302,6 @@ int enable_fw(struct npu_device *npu_dev); void disable_fw(struct npu_device *npu_dev); int load_fw(struct npu_device *npu_dev); int unload_fw(struct npu_device *npu_dev); int npu_set_bw(struct npu_device *npu_dev, int new_ib, int new_ab); #endif /* _NPU_COMMON_H */ drivers/media/platform/msm/npu/npu_debugfs.c +6 −0 Original line number Diff line number Diff line Loading @@ -436,6 +436,12 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } if (!debugfs_create_bool("auto_pil_disable", 0644, debugfs->root, &(host_ctx->auto_pil_disable))) { NPU_ERR("debugfs_creat_bool fail for auto pil\n"); goto err; } if (!debugfs_create_u32("fw_dbg_mode", 0644, debugfs->root, &(host_ctx->fw_dbg_mode))) { NPU_ERR("debugfs_create_u32 fail for fw_dbg_mode\n"); Loading drivers/media/platform/msm/npu/npu_dev.c +114 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ static long npu_ioctl(struct file *file, unsigned int cmd, static unsigned int npu_poll(struct file *filp, struct poll_table_struct *p); static int npu_parse_dt_clock(struct npu_device *npu_dev); static int npu_parse_dt_regulator(struct npu_device *npu_dev); static int npu_parse_dt_bw(struct npu_device *npu_dev); static int npu_of_parse_pwrlevels(struct npu_device *npu_dev, struct device_node *node); static int npu_pwrctrl_init(struct npu_device *npu_dev); Loading Loading @@ -1460,6 +1461,91 @@ static int npu_parse_dt_regulator(struct npu_device *npu_dev) return rc; } static int npu_parse_dt_bw(struct npu_device *npu_dev) { int ret, len; uint32_t ports[2]; struct platform_device *pdev = npu_dev->pdev; struct npu_bwctrl *bwctrl = &npu_dev->bwctrl; if (of_find_property(pdev->dev.of_node, "qcom,src-dst-ports", &len)) { len /= sizeof(ports[0]); if (len != 2) { NPU_ERR("Unexpected number of ports\n"); return -EINVAL; } ret = of_property_read_u32_array(pdev->dev.of_node, "qcom,src-dst-ports", ports, len); if (ret) { NPU_ERR("Failed to read bw property\n"); return ret; } } else { NPU_ERR("can't find bw property\n"); return -EINVAL; } bwctrl->bw_levels[0].vectors = &bwctrl->vectors[0]; bwctrl->bw_levels[1].vectors = &bwctrl->vectors[MAX_PATHS]; bwctrl->bw_data.usecase = bwctrl->bw_levels; bwctrl->bw_data.num_usecases = ARRAY_SIZE(bwctrl->bw_levels); bwctrl->bw_data.name = dev_name(&pdev->dev); bwctrl->bw_data.active_only = false; bwctrl->bw_levels[0].vectors[0].src = ports[0]; bwctrl->bw_levels[0].vectors[0].dst = ports[1]; bwctrl->bw_levels[1].vectors[0].src = ports[0]; bwctrl->bw_levels[1].vectors[0].dst = ports[1]; bwctrl->bw_levels[0].num_paths = 1; bwctrl->bw_levels[1].num_paths = 1; bwctrl->num_paths = 1; bwctrl->bus_client = msm_bus_scale_register_client(&bwctrl->bw_data); if (!bwctrl->bus_client) { NPU_ERR("Unable to register bus client\n"); return -ENODEV; } NPU_INFO("NPU BW client sets up successfully\n"); return 0; } int npu_set_bw(struct npu_device *npu_dev, int new_ib, int new_ab) { int i, ret; struct npu_bwctrl *bwctrl = &npu_dev->bwctrl; if (!bwctrl->bus_client) { NPU_DBG("bus client doesn't exist\n"); return 0; } if (bwctrl->cur_ib == new_ib && bwctrl->cur_ab == new_ab) return 0; i = (bwctrl->cur_idx + 1) % DBL_BUF; bwctrl->bw_levels[i].vectors[0].ib = new_ib * MBYTE; bwctrl->bw_levels[i].vectors[0].ab = new_ab / bwctrl->num_paths * MBYTE; bwctrl->bw_levels[i].vectors[1].ib = new_ib * MBYTE; bwctrl->bw_levels[i].vectors[1].ab = new_ab / bwctrl->num_paths * MBYTE; NPU_INFO("BW MBps: AB: %d IB: %d\n", new_ab, new_ib); ret = msm_bus_scale_client_update_request(bwctrl->bus_client, i); if (ret) { NPU_ERR("bandwidth request failed (%d)\n", ret); } else { bwctrl->cur_idx = i; bwctrl->cur_ib = new_ib; bwctrl->cur_ab = new_ab; } return ret; } static int npu_of_parse_pwrlevels(struct npu_device *npu_dev, struct device_node *node) { Loading Loading @@ -1670,6 +1756,25 @@ static void npu_mbox_deinit(struct npu_device *npu_dev) } } static int npu_hw_info_init(struct npu_device *npu_dev) { int rc = 0; npu_set_bw(npu_dev, 100, 100); rc = npu_enable_core_power(npu_dev); if (rc) { NPU_ERR("Failed to enable power\n"); return rc; } npu_dev->hw_version = REGR(npu_dev, NPU_HW_VERSION); NPU_DBG("NPU_HW_VERSION 0x%x\n", npu_dev->hw_version); npu_disable_core_power(npu_dev); npu_set_bw(npu_dev, 0, 0); return rc; } /* ------------------------------------------------------------------------- * Probe/Remove * ------------------------------------------------------------------------- Loading Loading @@ -1810,6 +1915,14 @@ static int npu_probe(struct platform_device *pdev) if (rc) goto error_get_dev_num; rc = npu_parse_dt_bw(npu_dev); if (rc) NPU_WARN("Parse bw info failed\n"); rc = npu_hw_info_init(npu_dev); if (rc) goto error_get_dev_num; rc = npu_pwrctrl_init(npu_dev); if (rc) goto error_get_dev_num; Loading Loading @@ -1926,6 +2039,7 @@ static int npu_remove(struct platform_device *pdev) unregister_chrdev_region(npu_dev->dev_num, 1); platform_set_drvdata(pdev, NULL); npu_mbox_deinit(npu_dev); msm_bus_scale_unregister_client(npu_dev->bwctrl.bus_client); g_npu_dev = NULL; Loading Loading
arch/arm64/configs/vendor/lito-perf_defconfig +1 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,7 @@ CONFIG_VIDEO_ADV_DEBUG=y CONFIG_VIDEO_FIXED_MINOR_RANGES=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SPECTRA_CAMERA=y CONFIG_MSM_NPU=y CONFIG_V4L_TEST_DRIVERS=y CONFIG_VIDEO_VIM2M=m CONFIG_VIDEO_VICODEC=y Loading
arch/arm64/configs/vendor/lito_defconfig +1 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,7 @@ CONFIG_VIDEO_ADV_DEBUG=y CONFIG_VIDEO_FIXED_MINOR_RANGES=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SPECTRA_CAMERA=y CONFIG_MSM_NPU=y CONFIG_V4L_TEST_DRIVERS=y CONFIG_VIDEO_VIM2M=y CONFIG_VIDEO_VICODEC=y Loading
drivers/media/platform/msm/npu/npu_common.h +20 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <linux/types.h> #include <linux/uaccess.h> #include <linux/mailbox/qmp.h> #include <linux/msm-bus.h> #include "npu_mgr.h" Loading Loading @@ -201,6 +202,21 @@ struct npu_io_data { void __iomem *base; }; #define MAX_PATHS 2 #define DBL_BUF 2 #define MBYTE (1ULL << 20) struct npu_bwctrl { struct msm_bus_vectors vectors[MAX_PATHS * DBL_BUF]; struct msm_bus_paths bw_levels[DBL_BUF]; struct msm_bus_scale_pdata bw_data; uint32_t bus_client; int cur_ab; int cur_ib; int cur_idx; uint32_t num_paths; }; struct npu_device { struct mutex dev_lock; Loading Loading @@ -238,10 +254,13 @@ struct npu_device { struct thermal_cooling_device *tcdev; struct npu_pwrctrl pwrctrl; struct npu_thermalctrl thermalctrl; struct npu_bwctrl bwctrl; struct llcc_slice_desc *sys_cache; uint32_t execute_v2_flag; bool cxlimit_registered; uint32_t hw_version; }; struct npu_kevent { Loading Loading @@ -283,5 +302,6 @@ int enable_fw(struct npu_device *npu_dev); void disable_fw(struct npu_device *npu_dev); int load_fw(struct npu_device *npu_dev); int unload_fw(struct npu_device *npu_dev); int npu_set_bw(struct npu_device *npu_dev, int new_ib, int new_ab); #endif /* _NPU_COMMON_H */
drivers/media/platform/msm/npu/npu_debugfs.c +6 −0 Original line number Diff line number Diff line Loading @@ -436,6 +436,12 @@ int npu_debugfs_init(struct npu_device *npu_dev) goto err; } if (!debugfs_create_bool("auto_pil_disable", 0644, debugfs->root, &(host_ctx->auto_pil_disable))) { NPU_ERR("debugfs_creat_bool fail for auto pil\n"); goto err; } if (!debugfs_create_u32("fw_dbg_mode", 0644, debugfs->root, &(host_ctx->fw_dbg_mode))) { NPU_ERR("debugfs_create_u32 fail for fw_dbg_mode\n"); Loading
drivers/media/platform/msm/npu/npu_dev.c +114 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ static long npu_ioctl(struct file *file, unsigned int cmd, static unsigned int npu_poll(struct file *filp, struct poll_table_struct *p); static int npu_parse_dt_clock(struct npu_device *npu_dev); static int npu_parse_dt_regulator(struct npu_device *npu_dev); static int npu_parse_dt_bw(struct npu_device *npu_dev); static int npu_of_parse_pwrlevels(struct npu_device *npu_dev, struct device_node *node); static int npu_pwrctrl_init(struct npu_device *npu_dev); Loading Loading @@ -1460,6 +1461,91 @@ static int npu_parse_dt_regulator(struct npu_device *npu_dev) return rc; } static int npu_parse_dt_bw(struct npu_device *npu_dev) { int ret, len; uint32_t ports[2]; struct platform_device *pdev = npu_dev->pdev; struct npu_bwctrl *bwctrl = &npu_dev->bwctrl; if (of_find_property(pdev->dev.of_node, "qcom,src-dst-ports", &len)) { len /= sizeof(ports[0]); if (len != 2) { NPU_ERR("Unexpected number of ports\n"); return -EINVAL; } ret = of_property_read_u32_array(pdev->dev.of_node, "qcom,src-dst-ports", ports, len); if (ret) { NPU_ERR("Failed to read bw property\n"); return ret; } } else { NPU_ERR("can't find bw property\n"); return -EINVAL; } bwctrl->bw_levels[0].vectors = &bwctrl->vectors[0]; bwctrl->bw_levels[1].vectors = &bwctrl->vectors[MAX_PATHS]; bwctrl->bw_data.usecase = bwctrl->bw_levels; bwctrl->bw_data.num_usecases = ARRAY_SIZE(bwctrl->bw_levels); bwctrl->bw_data.name = dev_name(&pdev->dev); bwctrl->bw_data.active_only = false; bwctrl->bw_levels[0].vectors[0].src = ports[0]; bwctrl->bw_levels[0].vectors[0].dst = ports[1]; bwctrl->bw_levels[1].vectors[0].src = ports[0]; bwctrl->bw_levels[1].vectors[0].dst = ports[1]; bwctrl->bw_levels[0].num_paths = 1; bwctrl->bw_levels[1].num_paths = 1; bwctrl->num_paths = 1; bwctrl->bus_client = msm_bus_scale_register_client(&bwctrl->bw_data); if (!bwctrl->bus_client) { NPU_ERR("Unable to register bus client\n"); return -ENODEV; } NPU_INFO("NPU BW client sets up successfully\n"); return 0; } int npu_set_bw(struct npu_device *npu_dev, int new_ib, int new_ab) { int i, ret; struct npu_bwctrl *bwctrl = &npu_dev->bwctrl; if (!bwctrl->bus_client) { NPU_DBG("bus client doesn't exist\n"); return 0; } if (bwctrl->cur_ib == new_ib && bwctrl->cur_ab == new_ab) return 0; i = (bwctrl->cur_idx + 1) % DBL_BUF; bwctrl->bw_levels[i].vectors[0].ib = new_ib * MBYTE; bwctrl->bw_levels[i].vectors[0].ab = new_ab / bwctrl->num_paths * MBYTE; bwctrl->bw_levels[i].vectors[1].ib = new_ib * MBYTE; bwctrl->bw_levels[i].vectors[1].ab = new_ab / bwctrl->num_paths * MBYTE; NPU_INFO("BW MBps: AB: %d IB: %d\n", new_ab, new_ib); ret = msm_bus_scale_client_update_request(bwctrl->bus_client, i); if (ret) { NPU_ERR("bandwidth request failed (%d)\n", ret); } else { bwctrl->cur_idx = i; bwctrl->cur_ib = new_ib; bwctrl->cur_ab = new_ab; } return ret; } static int npu_of_parse_pwrlevels(struct npu_device *npu_dev, struct device_node *node) { Loading Loading @@ -1670,6 +1756,25 @@ static void npu_mbox_deinit(struct npu_device *npu_dev) } } static int npu_hw_info_init(struct npu_device *npu_dev) { int rc = 0; npu_set_bw(npu_dev, 100, 100); rc = npu_enable_core_power(npu_dev); if (rc) { NPU_ERR("Failed to enable power\n"); return rc; } npu_dev->hw_version = REGR(npu_dev, NPU_HW_VERSION); NPU_DBG("NPU_HW_VERSION 0x%x\n", npu_dev->hw_version); npu_disable_core_power(npu_dev); npu_set_bw(npu_dev, 0, 0); return rc; } /* ------------------------------------------------------------------------- * Probe/Remove * ------------------------------------------------------------------------- Loading Loading @@ -1810,6 +1915,14 @@ static int npu_probe(struct platform_device *pdev) if (rc) goto error_get_dev_num; rc = npu_parse_dt_bw(npu_dev); if (rc) NPU_WARN("Parse bw info failed\n"); rc = npu_hw_info_init(npu_dev); if (rc) goto error_get_dev_num; rc = npu_pwrctrl_init(npu_dev); if (rc) goto error_get_dev_num; Loading Loading @@ -1926,6 +2039,7 @@ static int npu_remove(struct platform_device *pdev) unregister_chrdev_region(npu_dev->dev_num, 1); platform_set_drvdata(pdev, NULL); npu_mbox_deinit(npu_dev); msm_bus_scale_unregister_client(npu_dev->bwctrl.bus_client); g_npu_dev = NULL; Loading