Skip to content

Commit aa22f4d

Browse files
committed
Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux
Pull remoteproc updates from Bjorn Andersson: - Correct error path in rproc_alloc(), with regards to put_device() and freeing of the rproc index ida - The Mediatek SCP remoteproc driver is returned to only creating child devices from specific DeviceTree nodes - Update the OMAP remoteproc driver to match the cleanups in the OMAP iommu driver In addition to this, a number of conversions to devres and other small, mostly stylistic, code cleanups * tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: remoteproc: st: Use syscon_regmap_lookup_by_phandle_args remoteproc: keystone: Use syscon_regmap_lookup_by_phandle_args remoteproc: st: Simplify with dev_err_probe remoteproc: omap: Simplify returning syscon PTR_ERR remoteproc: keystone: Simplify returning syscon PTR_ERR remoteproc: k3-r5: Add devm action to release tsp remoteproc: k3-r5: Use devm_rproc_add() helper remoteproc: k3-r5: Use devm_ioremap_wc() helper remoteproc: k3-r5: Use devm_kcalloc() helper remoteproc: k3-r5: Add devm action to release reserved memory remoteproc: mtk_scp: Only populate devices for SCP cores remoteproc: omap: Handle ARM dma_iommu_mapping remoteproc: core: Fix ida_free call while not allocated
2 parents eda061c + 3a53ff9 commit aa22f4d

File tree

6 files changed

+97
-112
lines changed

6 files changed

+97
-112
lines changed

drivers/remoteproc/keystone_remoteproc.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,25 +335,16 @@ static int keystone_rproc_of_get_dev_syscon(struct platform_device *pdev,
335335
{
336336
struct device_node *np = pdev->dev.of_node;
337337
struct device *dev = &pdev->dev;
338-
int ret;
339338

340339
if (!of_property_read_bool(np, "ti,syscon-dev")) {
341340
dev_err(dev, "ti,syscon-dev property is absent\n");
342341
return -EINVAL;
343342
}
344343

345-
ksproc->dev_ctrl =
346-
syscon_regmap_lookup_by_phandle(np, "ti,syscon-dev");
347-
if (IS_ERR(ksproc->dev_ctrl)) {
348-
ret = PTR_ERR(ksproc->dev_ctrl);
349-
return ret;
350-
}
351-
352-
if (of_property_read_u32_index(np, "ti,syscon-dev", 1,
353-
&ksproc->boot_offset)) {
354-
dev_err(dev, "couldn't read the boot register offset\n");
355-
return -EINVAL;
356-
}
344+
ksproc->dev_ctrl = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-dev",
345+
1, &ksproc->boot_offset);
346+
if (IS_ERR(ksproc->dev_ctrl))
347+
return PTR_ERR(ksproc->dev_ctrl);
357348

358349
return 0;
359350
}

drivers/remoteproc/mtk_scp.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,11 @@ static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_clus
13261326
return ret;
13271327
}
13281328

1329+
static const struct of_device_id scp_core_match[] = {
1330+
{ .compatible = "mediatek,scp-core" },
1331+
{}
1332+
};
1333+
13291334
static int scp_probe(struct platform_device *pdev)
13301335
{
13311336
struct device *dev = &pdev->dev;
@@ -1357,13 +1362,15 @@ static int scp_probe(struct platform_device *pdev)
13571362
INIT_LIST_HEAD(&scp_cluster->mtk_scp_list);
13581363
mutex_init(&scp_cluster->cluster_lock);
13591364

1360-
ret = devm_of_platform_populate(dev);
1365+
ret = of_platform_populate(dev_of_node(dev), scp_core_match, NULL, dev);
13611366
if (ret)
13621367
return dev_err_probe(dev, ret, "Failed to populate platform devices\n");
13631368

13641369
ret = scp_cluster_init(pdev, scp_cluster);
1365-
if (ret)
1370+
if (ret) {
1371+
of_platform_depopulate(dev);
13661372
return ret;
1373+
}
13671374

13681375
return 0;
13691376
}
@@ -1379,6 +1386,7 @@ static void scp_remove(struct platform_device *pdev)
13791386
rproc_del(scp->rproc);
13801387
scp_free(scp);
13811388
}
1389+
of_platform_depopulate(&pdev->dev);
13821390
mutex_destroy(&scp_cluster->cluster_lock);
13831391
}
13841392

drivers/remoteproc/omap_remoteproc.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
#include <linux/platform_data/dmtimer-omap.h>
3939

40+
#ifdef CONFIG_ARM_DMA_USE_IOMMU
41+
#include <asm/dma-iommu.h>
42+
#endif
43+
4044
#include "omap_remoteproc.h"
4145
#include "remoteproc_internal.h"
4246

@@ -1133,7 +1137,6 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev,
11331137
struct device_node *np = pdev->dev.of_node;
11341138
struct omap_rproc *oproc = rproc->priv;
11351139
const struct omap_rproc_dev_data *data;
1136-
int ret;
11371140

11381141
data = of_device_get_match_data(&pdev->dev);
11391142
if (!data)
@@ -1149,10 +1152,8 @@ static int omap_rproc_get_boot_data(struct platform_device *pdev,
11491152

11501153
oproc->boot_data->syscon =
11511154
syscon_regmap_lookup_by_phandle(np, "ti,bootreg");
1152-
if (IS_ERR(oproc->boot_data->syscon)) {
1153-
ret = PTR_ERR(oproc->boot_data->syscon);
1154-
return ret;
1155-
}
1155+
if (IS_ERR(oproc->boot_data->syscon))
1156+
return PTR_ERR(oproc->boot_data->syscon);
11561157

11571158
if (of_property_read_u32_index(np, "ti,bootreg", 1,
11581159
&oproc->boot_data->boot_reg)) {
@@ -1323,6 +1324,19 @@ static int omap_rproc_probe(struct platform_device *pdev)
13231324
/* All existing OMAP IPU and DSP processors have an MMU */
13241325
rproc->has_iommu = true;
13251326

1327+
#ifdef CONFIG_ARM_DMA_USE_IOMMU
1328+
/*
1329+
* Throw away the ARM DMA mapping that we'll never use, so it doesn't
1330+
* interfere with the core rproc->domain and we get the right DMA ops.
1331+
*/
1332+
if (pdev->dev.archdata.mapping) {
1333+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(&pdev->dev);
1334+
1335+
arm_iommu_detach_device(&pdev->dev);
1336+
arm_iommu_release_mapping(mapping);
1337+
}
1338+
#endif
1339+
13261340
ret = omap_rproc_of_get_internal_memories(pdev, rproc);
13271341
if (ret)
13281342
return ret;

drivers/remoteproc/remoteproc_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,13 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
24862486
rproc->dev.driver_data = rproc;
24872487
idr_init(&rproc->notifyids);
24882488

2489+
/* Assign a unique device index and name */
2490+
rproc->index = ida_alloc(&rproc_dev_index, GFP_KERNEL);
2491+
if (rproc->index < 0) {
2492+
dev_err(dev, "ida_alloc failed: %d\n", rproc->index);
2493+
goto put_device;
2494+
}
2495+
24892496
rproc->name = kstrdup_const(name, GFP_KERNEL);
24902497
if (!rproc->name)
24912498
goto put_device;
@@ -2496,13 +2503,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
24962503
if (rproc_alloc_ops(rproc, ops))
24972504
goto put_device;
24982505

2499-
/* Assign a unique device index and name */
2500-
rproc->index = ida_alloc(&rproc_dev_index, GFP_KERNEL);
2501-
if (rproc->index < 0) {
2502-
dev_err(dev, "ida_alloc failed: %d\n", rproc->index);
2503-
goto put_device;
2504-
}
2505-
25062506
dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
25072507

25082508
atomic_set(&rproc->power, 0);

drivers/remoteproc/st_remoteproc.c

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -290,45 +290,35 @@ static int st_rproc_parse_dt(struct platform_device *pdev)
290290
if (ddata->config->sw_reset) {
291291
ddata->sw_reset = devm_reset_control_get_exclusive(dev,
292292
"sw_reset");
293-
if (IS_ERR(ddata->sw_reset)) {
294-
dev_err(dev, "Failed to get S/W Reset\n");
295-
return PTR_ERR(ddata->sw_reset);
296-
}
293+
if (IS_ERR(ddata->sw_reset))
294+
return dev_err_probe(dev, PTR_ERR(ddata->sw_reset),
295+
"Failed to get S/W Reset\n");
297296
}
298297

299298
if (ddata->config->pwr_reset) {
300299
ddata->pwr_reset = devm_reset_control_get_exclusive(dev,
301300
"pwr_reset");
302-
if (IS_ERR(ddata->pwr_reset)) {
303-
dev_err(dev, "Failed to get Power Reset\n");
304-
return PTR_ERR(ddata->pwr_reset);
305-
}
301+
if (IS_ERR(ddata->pwr_reset))
302+
return dev_err_probe(dev, PTR_ERR(ddata->pwr_reset),
303+
"Failed to get Power Reset\n");
306304
}
307305

308306
ddata->clk = devm_clk_get(dev, NULL);
309-
if (IS_ERR(ddata->clk)) {
310-
dev_err(dev, "Failed to get clock\n");
311-
return PTR_ERR(ddata->clk);
312-
}
307+
if (IS_ERR(ddata->clk))
308+
return dev_err_probe(dev, PTR_ERR(ddata->clk),
309+
"Failed to get clock\n");
313310

314311
err = of_property_read_u32(np, "clock-frequency", &ddata->clk_rate);
315312
if (err) {
316313
dev_err(dev, "failed to get clock frequency\n");
317314
return err;
318315
}
319316

320-
ddata->boot_base = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
321-
if (IS_ERR(ddata->boot_base)) {
322-
dev_err(dev, "Boot base not found\n");
323-
return PTR_ERR(ddata->boot_base);
324-
}
325-
326-
err = of_property_read_u32_index(np, "st,syscfg", 1,
327-
&ddata->boot_offset);
328-
if (err) {
329-
dev_err(dev, "Boot offset not found\n");
330-
return -EINVAL;
331-
}
317+
ddata->boot_base = syscon_regmap_lookup_by_phandle_args(np, "st,syscfg",
318+
1, &ddata->boot_offset);
319+
if (IS_ERR(ddata->boot_base))
320+
return dev_err_probe(dev, PTR_ERR(ddata->boot_base),
321+
"Boot base not found\n");
332322

333323
err = clk_prepare(ddata->clk);
334324
if (err)
@@ -395,32 +385,32 @@ static int st_rproc_probe(struct platform_device *pdev)
395385
*/
396386
chan = mbox_request_channel_byname(&ddata->mbox_client_vq0, "vq0_rx");
397387
if (IS_ERR(chan)) {
398-
dev_err(&rproc->dev, "failed to request mbox chan 0\n");
399-
ret = PTR_ERR(chan);
388+
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
389+
"failed to request mbox chan 0\n");
400390
goto free_clk;
401391
}
402392
ddata->mbox_chan[ST_RPROC_VQ0 * MBOX_MAX + MBOX_RX] = chan;
403393

404394
chan = mbox_request_channel_byname(&ddata->mbox_client_vq0, "vq0_tx");
405395
if (IS_ERR(chan)) {
406-
dev_err(&rproc->dev, "failed to request mbox chan 0\n");
407-
ret = PTR_ERR(chan);
396+
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
397+
"failed to request mbox chan 0\n");
408398
goto free_mbox;
409399
}
410400
ddata->mbox_chan[ST_RPROC_VQ0 * MBOX_MAX + MBOX_TX] = chan;
411401

412402
chan = mbox_request_channel_byname(&ddata->mbox_client_vq1, "vq1_rx");
413403
if (IS_ERR(chan)) {
414-
dev_err(&rproc->dev, "failed to request mbox chan 1\n");
415-
ret = PTR_ERR(chan);
404+
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
405+
"failed to request mbox chan 1\n");
416406
goto free_mbox;
417407
}
418408
ddata->mbox_chan[ST_RPROC_VQ1 * MBOX_MAX + MBOX_RX] = chan;
419409

420410
chan = mbox_request_channel_byname(&ddata->mbox_client_vq1, "vq1_tx");
421411
if (IS_ERR(chan)) {
422-
dev_err(&rproc->dev, "failed to request mbox chan 1\n");
423-
ret = PTR_ERR(chan);
412+
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
413+
"failed to request mbox chan 1\n");
424414
goto free_mbox;
425415
}
426416
ddata->mbox_chan[ST_RPROC_VQ1 * MBOX_MAX + MBOX_TX] = chan;

0 commit comments

Comments
 (0)