diff --git a/msm/vidc/hfi_common.c b/msm/vidc/hfi_common.c index 83202257e9f6..84c12622e100 100644 --- a/msm/vidc/hfi_common.c +++ b/msm/vidc/hfi_common.c @@ -824,15 +824,12 @@ static int __vote_bandwidth(struct bus_info *bus, unsigned long bw_kbps, u32 sid) { int rc = 0; - uint64_t ab = 0; - /* Bus Driver expects values in Bps */ - ab = bw_kbps * 1000; - s_vpr_p(sid, "Voting bus %s to ab %llu bps\n", bus->name, ab); - rc = msm_bus_scale_update_bw(bus->client, ab, 0); + s_vpr_p(sid, "Voting bus %s to ab %llu kbps\n", bus->name, bw_kbps); + rc = icc_set_bw(bus->path, kbps_to_icc(bw_kbps), 0); if (rc) s_vpr_e(sid, "Failed voting bus %s to ab %llu, rc=%d\n", - bus->name, ab, rc); + bus->name, bw_kbps, rc); return rc; } @@ -863,7 +860,7 @@ static int __vote_buses(struct venus_hfi_device *device, enum vidc_bus_type type; venus_hfi_for_each_bus(device, bus) { - if (bus && bus->client) { + if (bus && bus->path) { type = get_type_frm_name(bus->name); if (type == DDR) { @@ -3308,8 +3305,8 @@ static void __deinit_bus(struct venus_hfi_device *device) device->bus_vote = DEFAULT_BUS_VOTE; venus_hfi_for_each_bus_reverse(device, bus) { - msm_bus_scale_unregister(bus->client); - bus->client = NULL; + icc_put(bus->path); + bus->path = NULL; } } @@ -3322,21 +3319,21 @@ static int __init_bus(struct venus_hfi_device *device) return -EINVAL; venus_hfi_for_each_bus(device, bus) { - if (!strcmp(bus->mode, "msm-vidc-llcc")) { + if (!strcmp(bus->name, "venus-llcc")) { if (msm_vidc_syscache_disable) { - d_vpr_h("Skipping LLC bus init %s: %s\n", - bus->name, bus->mode); + d_vpr_h("Skipping LLC bus init: %s\n", + bus->name); continue; } } - bus->client = msm_bus_scale_register(bus->master, bus->slave, - bus->name, false); - if (IS_ERR_OR_NULL(bus->client)) { - rc = PTR_ERR(bus->client) ? - PTR_ERR(bus->client) : -EBADHANDLE; + bus->path = of_icc_get(bus->dev, bus->name); + if (IS_ERR_OR_NULL(bus->path)) { + rc = PTR_ERR(bus->path) ? + PTR_ERR(bus->path) : -EBADHANDLE; + d_vpr_e("Failed to register bus %s: %d\n", bus->name, rc); - bus->client = NULL; + bus->path = NULL; goto err_add_dev; } } diff --git a/msm/vidc/msm_v4l2_vidc.c b/msm/vidc/msm_v4l2_vidc.c index 86c921a4eee7..1d5f2755a0e6 100644 --- a/msm/vidc/msm_v4l2_vidc.c +++ b/msm/vidc/msm_v4l2_vidc.c @@ -404,7 +404,6 @@ static struct attribute_group msm_vidc_core_attr_group = { static const struct of_device_id msm_vidc_dt_match[] = { {.compatible = "qcom,msm-vidc"}, {.compatible = "qcom,msm-vidc,context-bank"}, - {.compatible = "qcom,msm-vidc,bus"}, {.compatible = "qcom,msm-vidc,mem-cdsp"}, {} }; @@ -584,11 +583,6 @@ static int msm_vidc_probe_context_bank(struct platform_device *pdev) return read_context_bank_resources_from_dt(pdev); } -static int msm_vidc_probe_bus(struct platform_device *pdev) -{ - return read_bus_resources_from_dt(pdev); -} - static int msm_vidc_probe(struct platform_device *pdev) { /* @@ -598,9 +592,6 @@ static int msm_vidc_probe(struct platform_device *pdev) */ if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-vidc")) { return msm_vidc_probe_vidc_device(pdev); - } else if (of_device_is_compatible(pdev->dev.of_node, - "qcom,msm-vidc,bus")) { - return msm_vidc_probe_bus(pdev); } else if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-vidc,context-bank")) { return msm_vidc_probe_context_bank(pdev); diff --git a/msm/vidc/msm_vidc_bus.h b/msm/vidc/msm_vidc_bus.h index 07a5371df699..bde59a0c53d1 100644 --- a/msm/vidc/msm_vidc_bus.h +++ b/msm/vidc/msm_vidc_bus.h @@ -194,7 +194,7 @@ static struct lut { }, }; -static inline u32 get_type_frm_name(char *name) +static inline u32 get_type_frm_name(const char *name) { if (!strcmp(name, "venus-llcc")) return LLCC; diff --git a/msm/vidc/msm_vidc_debug.c b/msm/vidc/msm_vidc_debug.c index 2f6792f50675..00c1bccfb7c5 100644 --- a/msm/vidc/msm_vidc_debug.c +++ b/msm/vidc/msm_vidc_debug.c @@ -807,34 +807,6 @@ void trace_msm_v4l2_vidc_buffer_event_end(char *event_type, u32 device_addr, (void) offset; } -int -msm_bus_scale_update_bw(struct msm_bus_client_handle *cl, u64 ab, u64 ib) -{ - (void) cl; - (void) ab; - (void) ib; - - return 0; -} - -struct msm_bus_client_handle dummy_cl; -struct msm_bus_client_handle* -msm_bus_scale_register(uint32_t mas, uint32_t slv, char *name, - bool active_only) -{ - (void) mas; - (void) slv; - (void) name; - (void) active_only; - - return &dummy_cl; -} - -void msm_bus_scale_unregister(struct msm_bus_client_handle *cl) -{ - (void) cl; -} - void do_gettimeofday(struct timeval *__ddl_tv) { } diff --git a/msm/vidc/msm_vidc_debug.h b/msm/vidc/msm_vidc_debug.h index 3dbb4d25aadd..e8524f9789d8 100644 --- a/msm/vidc/msm_vidc_debug.h +++ b/msm/vidc/msm_vidc_debug.h @@ -50,25 +50,6 @@ void trace_msm_v4l2_vidc_buffer_event_end(char *event_type, u32 device_addr, // void disable_irq_nosync(unsigned int irq); // void enable_irq(unsigned int irq); -struct msm_bus_client_handle { - char *name; - int mas; - int slv; - int first_hop; - // struct device *mas_dev; - u64 cur_act_ib; - u64 cur_act_ab; - u64 cur_dual_ib; - u64 cur_dual_ab; - bool active_only; -}; - -int msm_bus_scale_update_bw(struct msm_bus_client_handle *cl, u64 ab, u64 ib); -int msm_bus_scale_update_bw(struct msm_bus_client_handle *cl, u64 ab, u64 ib); -struct msm_bus_client_handle* msm_bus_scale_register(uint32_t mas, uint32_t slv, - char *name, bool active_only); -void msm_bus_scale_unregister(struct msm_bus_client_handle *cl); - void do_gettimeofday(struct timeval *__ddl_tv); #ifndef CONFIG_VIDEOBUF2_CORE diff --git a/msm/vidc/msm_vidc_internal.h b/msm/vidc/msm_vidc_internal.h index 22102d76607e..ffb44f46431b 100644 --- a/msm/vidc/msm_vidc_internal.h +++ b/msm/vidc/msm_vidc_internal.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "msm_vidc.h" #include #include "vidc_hfi_api.h" diff --git a/msm/vidc/msm_vidc_res_parse.c b/msm/vidc/msm_vidc_res_parse.c index 6bc9aa61ce95..12808c8ef847 100644 --- a/msm/vidc/msm_vidc_res_parse.c +++ b/msm/vidc/msm_vidc_res_parse.c @@ -69,10 +69,9 @@ static inline void msm_vidc_free_qdss_addr_table( res->qdss_addr_set.addr_tbl = NULL; } -static inline void msm_vidc_free_bus_vectors( +static inline void msm_vidc_free_bus_table( struct msm_vidc_platform_resources *res) { - kfree(res->bus_set.bus_tbl); res->bus_set.bus_tbl = NULL; res->bus_set.count = 0; } @@ -114,7 +113,7 @@ void msm_vidc_free_platform_resources( msm_vidc_free_allowed_clocks_table(res); msm_vidc_free_reg_table(res); msm_vidc_free_qdss_addr_table(res); - msm_vidc_free_bus_vectors(res); + msm_vidc_free_bus_table(res); msm_vidc_free_buffer_usage_table(res); } @@ -360,76 +359,64 @@ static int msm_vidc_populate_mem_cdsp(struct device *dev, return 0; } -static int msm_vidc_populate_bus(struct device *dev, - struct msm_vidc_platform_resources *res) +static int msm_vidc_load_bus_table(struct msm_vidc_platform_resources *res) { struct bus_set *buses = &res->bus_set; - const char *temp_name = NULL; - struct bus_info *bus = NULL, *temp_table; - u32 range[2]; - int rc = 0; + int c = 0, num_buses = 0, rc = 0; + u32 *bus_ranges = NULL; + struct platform_device *pdev = res->pdev; - temp_table = krealloc(buses->bus_tbl, sizeof(*temp_table) * - (buses->count + 1), GFP_KERNEL); - if (!temp_table) { - d_vpr_e("%s: Failed to allocate memory", __func__); + num_buses = of_property_count_strings(pdev->dev.of_node, + "interconnect-names"); + if (num_buses <= 0) { + d_vpr_e("No buses found\n"); + return -EINVAL; + } + + buses->count = num_buses; + d_vpr_h("Found %d bus interconnects\n", num_buses); + + bus_ranges = kzalloc(2 * num_buses * sizeof(*bus_ranges), GFP_KERNEL); + if (!bus_ranges) { + d_vpr_e("No memory to read bus ranges\n"); + return -ENOMEM; + } + + rc = of_property_read_u32_array(pdev->dev.of_node, + "qcom,bus-range-kbps", bus_ranges, + num_buses); + if (rc) { + d_vpr_e( + "Failed to read bus ranges: defaulting to <0 INT_MAX>\n"); + for (c = 0; c < num_buses; c++) { + bus_ranges[c * 2] = 0; + bus_ranges[c * 2 + 1] = INT_MAX; + } + } + + buses->bus_tbl = devm_kzalloc(&pdev->dev, num_buses * + sizeof(*buses->bus_tbl), GFP_KERNEL); + if (!buses->bus_tbl) { + d_vpr_e("No memory for bus table\n"); rc = -ENOMEM; - goto err_bus; + goto exit; } - buses->bus_tbl = temp_table; - bus = &buses->bus_tbl[buses->count]; + for (c = 0; c < num_buses; c++) { + struct bus_info *bus = &res->bus_set.bus_tbl[c]; - memset(bus, 0x0, sizeof(struct bus_info)); + of_property_read_string_index(pdev->dev.of_node, + "interconnect-names", c, &bus->name); - rc = of_property_read_string(dev->of_node, "label", &temp_name); - if (rc) { - d_vpr_e("'label' not found in node\n"); - goto err_bus; - } - /* need a non-const version of name, hence copying it over */ - bus->name = devm_kstrdup(dev, temp_name, GFP_KERNEL); - if (!bus->name) { - rc = -ENOMEM; - goto err_bus; + bus->dev = &pdev->dev; + bus->range[0] = bus_ranges[c * 2]; + bus->range[1] = bus_ranges[c * 2 + 1]; + + d_vpr_h("Found bus %s\n", bus->name); } - rc = of_property_read_u32(dev->of_node, "qcom,bus-master", - &bus->master); - if (rc) { - d_vpr_e("'bus-master' not found in node\n"); - goto err_bus; - } - - rc = of_property_read_u32(dev->of_node, "qcom,bus-slave", &bus->slave); - if (rc) { - d_vpr_e("'bus-slave' not found in node\n"); - goto err_bus; - } - - rc = of_property_read_string(dev->of_node, "qcom,mode", - &bus->mode); - - if (!rc && !strcmp(bus->mode, "performance")) - bus->is_prfm_mode = true; - - rc = of_property_read_u32_array(dev->of_node, "qcom,bus-range-kbps", - range, ARRAY_SIZE(range)); - if (rc) { - rc = 0; - d_vpr_h("'bus-range' not found defaulting to <0 INT_MAX>\n"); - range[0] = 0; - range[1] = INT_MAX; - } - - bus->range[0] = range[0]; /* min */ - bus->range[1] = range[1]; /* max */ - - buses->count++; - bus->dev = dev; - d_vpr_h("Found bus %s [%d->%d] with mode %s\n", - bus->name, bus->master, bus->slave, bus->mode); -err_bus: +exit: + kfree(bus_ranges); return rc; } @@ -875,6 +862,12 @@ int read_platform_resources_from_dt( goto err_load_regulator_table; } + rc = msm_vidc_load_bus_table(res); + if (rc) { + d_vpr_e("Failed to load bus table: %d\n", rc); + goto err_load_bus_table; + } + rc = msm_vidc_load_clock_table(res); if (rc) { d_vpr_e("Failed to load clock table: %d\n", rc); @@ -908,6 +901,8 @@ err_load_reset_table: err_load_allowed_clocks_table: msm_vidc_free_clock_table(res); err_load_clock_table: + msm_vidc_free_bus_table(res); +err_load_bus_table: msm_vidc_free_regulator_table(res); err_load_regulator_table: msm_vidc_free_buffer_usage_table(res); @@ -1187,29 +1182,6 @@ int read_context_bank_resources_from_dt(struct platform_device *pdev) return rc; } -int read_bus_resources_from_dt(struct platform_device *pdev) -{ - struct msm_vidc_core *core; - - if (!pdev) { - d_vpr_e("Invalid platform device\n"); - return -EINVAL; - } else if (!pdev->dev.parent) { - d_vpr_e("Failed to find a parent for %s\n", - dev_name(&pdev->dev)); - return -ENODEV; - } - - core = dev_get_drvdata(pdev->dev.parent); - if (!core) { - d_vpr_e("Failed to find cookie in parent device %s", - dev_name(pdev->dev.parent)); - return -EINVAL; - } - - return msm_vidc_populate_bus(&pdev->dev, &core->resources); -} - int read_mem_cdsp_resources_from_dt(struct platform_device *pdev) { struct msm_vidc_core *core; diff --git a/msm/vidc/msm_vidc_resources.h b/msm/vidc/msm_vidc_resources.h index 3c1ecec57ea6..a64575d189e7 100644 --- a/msm/vidc/msm_vidc_resources.h +++ b/msm/vidc/msm_vidc_resources.h @@ -77,14 +77,10 @@ struct clock_set { }; struct bus_info { - char *name; - int master; - int slave; + const char *name; unsigned int range[2]; struct device *dev; - struct msm_bus_client_handle *client; - bool is_prfm_mode; - const char *mode; + struct icc_path *path; }; struct bus_set {