Merge "msm: vidc: Migrate to icc API to set bus bandwidth"
This commit is contained in:
commit
2b03e2e748
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/videobuf2-core.h>
|
||||
#include <media/videobuf2-v4l2.h>
|
||||
#include <linux/interconnect.h>
|
||||
#include "msm_vidc.h"
|
||||
#include <media/msm_media_info.h>
|
||||
#include "vidc_hfi_api.h"
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user