Skip to content

Commit 0262393

Browse files
committed
Merge tag 'icc-6.16-rc5' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/djakov/icc into char-misc-linus
Georgi writes: interconnect fixes for v6.16-rc This contains a few framework core fixes (related to the new dynamic node id feature), as well as some misc Qualcomm and Samsung driver fixes. - interconnect: qcom: sc7280: Add missing num_links to xm_pcie3_1 node - interconnect: exynos: handle node name allocation failure - interconnect: increase ICC_DYN_ID_START - interconnect: icc-clk: destroy nodes in case of memory allocation failures - interconnect: avoid memory allocation when 'icc_bw_lock' is held Signed-off-by: Georgi Djakov <[email protected]> * tag 'icc-6.16-rc5' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/djakov/icc: interconnect: avoid memory allocation when 'icc_bw_lock' is held interconnect: icc-clk: destroy nodes in case of memory allocation failures interconnect: increase ICC_DYN_ID_START interconnect: exynos: handle node name allocation failure interconnect: qcom: sc7280: Add missing num_links to xm_pcie3_1 node
2 parents 5f59638 + c5b6059 commit 0262393

7 files changed

Lines changed: 56 additions & 7 deletions

File tree

drivers/interconnect/core.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "internal.h"
2222

23-
#define ICC_DYN_ID_START 10000
23+
#define ICC_DYN_ID_START 100000
2424

2525
#define CREATE_TRACE_POINTS
2626
#include "trace.h"
@@ -819,6 +819,9 @@ static struct icc_node *icc_node_create_nolock(int id)
819819
{
820820
struct icc_node *node;
821821

822+
if (id >= ICC_DYN_ID_START)
823+
return ERR_PTR(-EINVAL);
824+
822825
/* check if node already exists */
823826
node = node_find(id);
824827
if (node)
@@ -906,10 +909,35 @@ void icc_node_destroy(int id)
906909
return;
907910

908911
kfree(node->links);
912+
if (node->id >= ICC_DYN_ID_START)
913+
kfree(node->name);
909914
kfree(node);
910915
}
911916
EXPORT_SYMBOL_GPL(icc_node_destroy);
912917

918+
/**
919+
* icc_node_set_name() - set node name
920+
* @node: node
921+
* @provider: node provider
922+
* @name: node name
923+
*
924+
* Return: 0 on success, or -ENOMEM on allocation failure
925+
*/
926+
int icc_node_set_name(struct icc_node *node, const struct icc_provider *provider, const char *name)
927+
{
928+
if (node->id >= ICC_DYN_ID_START) {
929+
node->name = kasprintf(GFP_KERNEL, "%s@%s", name,
930+
dev_name(provider->dev));
931+
if (!node->name)
932+
return -ENOMEM;
933+
} else {
934+
node->name = name;
935+
}
936+
937+
return 0;
938+
}
939+
EXPORT_SYMBOL_GPL(icc_node_set_name);
940+
913941
/**
914942
* icc_link_nodes() - create link between two nodes
915943
* @src_node: source node
@@ -1038,10 +1066,6 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider)
10381066
node->avg_bw = node->init_avg;
10391067
node->peak_bw = node->init_peak;
10401068

1041-
if (node->id >= ICC_DYN_ID_START)
1042-
node->name = devm_kasprintf(provider->dev, GFP_KERNEL, "%s@%s",
1043-
node->name, dev_name(provider->dev));
1044-
10451069
if (node->avg_bw || node->peak_bw) {
10461070
if (provider->pre_aggregate)
10471071
provider->pre_aggregate(node);

drivers/interconnect/icc-clk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
117117

118118
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_master", data[i].name);
119119
if (!node->name) {
120+
icc_node_destroy(node->id);
120121
ret = -ENOMEM;
121122
goto err;
122123
}
@@ -135,6 +136,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
135136

136137
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_slave", data[i].name);
137138
if (!node->name) {
139+
icc_node_destroy(node->id);
138140
ret = -ENOMEM;
139141
goto err;
140142
}

drivers/interconnect/qcom/icc-rpmh.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev)
293293
goto err_remove_nodes;
294294
}
295295

296-
node->name = qn->name;
296+
ret = icc_node_set_name(node, provider, qn->name);
297+
if (ret) {
298+
icc_node_destroy(node->id);
299+
goto err_remove_nodes;
300+
}
301+
297302
node->data = qn;
298303
icc_node_add(node, provider);
299304

drivers/interconnect/qcom/osm-l3.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
236236
goto err;
237237
}
238238

239-
node->name = qnodes[i]->name;
239+
ret = icc_node_set_name(node, provider, qnodes[i]->name);
240+
if (ret) {
241+
icc_node_destroy(node->id);
242+
goto err;
243+
}
244+
240245
/* Cast away const and add it back in qcom_osm_l3_set() */
241246
node->data = (void *)qnodes[i];
242247
icc_node_add(node, provider);

drivers/interconnect/qcom/sc7280.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ static struct qcom_icc_node xm_pcie3_1 = {
238238
.id = SC7280_MASTER_PCIE_1,
239239
.channels = 1,
240240
.buswidth = 8,
241+
.num_links = 1,
241242
.links = { SC7280_SLAVE_ANOC_PCIE_GEM_NOC },
242243
};
243244

drivers/interconnect/samsung/exynos.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static int exynos_generic_icc_probe(struct platform_device *pdev)
134134
priv->node = icc_node;
135135
icc_node->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn",
136136
bus_dev->of_node);
137+
if (!icc_node->name) {
138+
icc_node_destroy(pdev->id);
139+
return -ENOMEM;
140+
}
141+
137142
if (of_property_read_u32(bus_dev->of_node, "samsung,data-clock-ratio",
138143
&priv->bus_clk_ratio))
139144
priv->bus_clk_ratio = EXYNOS_ICC_DEFAULT_BUS_CLK_RATIO;

include/linux/interconnect-provider.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
119119
struct icc_node *icc_node_create_dyn(void);
120120
struct icc_node *icc_node_create(int id);
121121
void icc_node_destroy(int id);
122+
int icc_node_set_name(struct icc_node *node, const struct icc_provider *provider, const char *name);
122123
int icc_link_nodes(struct icc_node *src_node, struct icc_node **dst_node);
123124
int icc_link_create(struct icc_node *node, const int dst_id);
124125
void icc_node_add(struct icc_node *node, struct icc_provider *provider);
@@ -152,6 +153,12 @@ static inline void icc_node_destroy(int id)
152153
{
153154
}
154155

156+
static inline int icc_node_set_name(struct icc_node *node, const struct icc_provider *provider,
157+
const char *name)
158+
{
159+
return -EOPNOTSUPP;
160+
}
161+
155162
static inline int icc_link_nodes(struct icc_node *src_node, struct icc_node **dst_node)
156163
{
157164
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)