Skip to content

Commit

Permalink
Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Jan 26, 2025
2 parents eda061c + 3a53ff9 commit aa22f4d
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 112 deletions.
17 changes: 4 additions & 13 deletions drivers/remoteproc/keystone_remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,25 +335,16 @@ static int keystone_rproc_of_get_dev_syscon(struct platform_device *pdev,
{
struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
int ret;

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

ksproc->dev_ctrl =
syscon_regmap_lookup_by_phandle(np, "ti,syscon-dev");
if (IS_ERR(ksproc->dev_ctrl)) {
ret = PTR_ERR(ksproc->dev_ctrl);
return ret;
}

if (of_property_read_u32_index(np, "ti,syscon-dev", 1,
&ksproc->boot_offset)) {
dev_err(dev, "couldn't read the boot register offset\n");
return -EINVAL;
}
ksproc->dev_ctrl = syscon_regmap_lookup_by_phandle_args(np, "ti,syscon-dev",
1, &ksproc->boot_offset);
if (IS_ERR(ksproc->dev_ctrl))
return PTR_ERR(ksproc->dev_ctrl);

return 0;
}
Expand Down
12 changes: 10 additions & 2 deletions drivers/remoteproc/mtk_scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,11 @@ static int scp_cluster_init(struct platform_device *pdev, struct mtk_scp_of_clus
return ret;
}

static const struct of_device_id scp_core_match[] = {
{ .compatible = "mediatek,scp-core" },
{}
};

static int scp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Expand Down Expand Up @@ -1357,13 +1362,15 @@ static int scp_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&scp_cluster->mtk_scp_list);
mutex_init(&scp_cluster->cluster_lock);

ret = devm_of_platform_populate(dev);
ret = of_platform_populate(dev_of_node(dev), scp_core_match, NULL, dev);
if (ret)
return dev_err_probe(dev, ret, "Failed to populate platform devices\n");

ret = scp_cluster_init(pdev, scp_cluster);
if (ret)
if (ret) {
of_platform_depopulate(dev);
return ret;
}

return 0;
}
Expand All @@ -1379,6 +1386,7 @@ static void scp_remove(struct platform_device *pdev)
rproc_del(scp->rproc);
scp_free(scp);
}
of_platform_depopulate(&pdev->dev);
mutex_destroy(&scp_cluster->cluster_lock);
}

Expand Down
24 changes: 19 additions & 5 deletions drivers/remoteproc/omap_remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

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

#ifdef CONFIG_ARM_DMA_USE_IOMMU
#include <asm/dma-iommu.h>
#endif

#include "omap_remoteproc.h"
#include "remoteproc_internal.h"

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

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

oproc->boot_data->syscon =
syscon_regmap_lookup_by_phandle(np, "ti,bootreg");
if (IS_ERR(oproc->boot_data->syscon)) {
ret = PTR_ERR(oproc->boot_data->syscon);
return ret;
}
if (IS_ERR(oproc->boot_data->syscon))
return PTR_ERR(oproc->boot_data->syscon);

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

#ifdef CONFIG_ARM_DMA_USE_IOMMU
/*
* Throw away the ARM DMA mapping that we'll never use, so it doesn't
* interfere with the core rproc->domain and we get the right DMA ops.
*/
if (pdev->dev.archdata.mapping) {
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(&pdev->dev);

arm_iommu_detach_device(&pdev->dev);
arm_iommu_release_mapping(mapping);
}
#endif

ret = omap_rproc_of_get_internal_memories(pdev, rproc);
if (ret)
return ret;
Expand Down
14 changes: 7 additions & 7 deletions drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,13 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
rproc->dev.driver_data = rproc;
idr_init(&rproc->notifyids);

/* Assign a unique device index and name */
rproc->index = ida_alloc(&rproc_dev_index, GFP_KERNEL);
if (rproc->index < 0) {
dev_err(dev, "ida_alloc failed: %d\n", rproc->index);
goto put_device;
}

rproc->name = kstrdup_const(name, GFP_KERNEL);
if (!rproc->name)
goto put_device;
Expand All @@ -2496,13 +2503,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
if (rproc_alloc_ops(rproc, ops))
goto put_device;

/* Assign a unique device index and name */
rproc->index = ida_alloc(&rproc_dev_index, GFP_KERNEL);
if (rproc->index < 0) {
dev_err(dev, "ida_alloc failed: %d\n", rproc->index);
goto put_device;
}

dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);

atomic_set(&rproc->power, 0);
Expand Down
54 changes: 22 additions & 32 deletions drivers/remoteproc/st_remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,45 +290,35 @@ static int st_rproc_parse_dt(struct platform_device *pdev)
if (ddata->config->sw_reset) {
ddata->sw_reset = devm_reset_control_get_exclusive(dev,
"sw_reset");
if (IS_ERR(ddata->sw_reset)) {
dev_err(dev, "Failed to get S/W Reset\n");
return PTR_ERR(ddata->sw_reset);
}
if (IS_ERR(ddata->sw_reset))
return dev_err_probe(dev, PTR_ERR(ddata->sw_reset),
"Failed to get S/W Reset\n");
}

if (ddata->config->pwr_reset) {
ddata->pwr_reset = devm_reset_control_get_exclusive(dev,
"pwr_reset");
if (IS_ERR(ddata->pwr_reset)) {
dev_err(dev, "Failed to get Power Reset\n");
return PTR_ERR(ddata->pwr_reset);
}
if (IS_ERR(ddata->pwr_reset))
return dev_err_probe(dev, PTR_ERR(ddata->pwr_reset),
"Failed to get Power Reset\n");
}

ddata->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddata->clk)) {
dev_err(dev, "Failed to get clock\n");
return PTR_ERR(ddata->clk);
}
if (IS_ERR(ddata->clk))
return dev_err_probe(dev, PTR_ERR(ddata->clk),
"Failed to get clock\n");

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

ddata->boot_base = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
if (IS_ERR(ddata->boot_base)) {
dev_err(dev, "Boot base not found\n");
return PTR_ERR(ddata->boot_base);
}

err = of_property_read_u32_index(np, "st,syscfg", 1,
&ddata->boot_offset);
if (err) {
dev_err(dev, "Boot offset not found\n");
return -EINVAL;
}
ddata->boot_base = syscon_regmap_lookup_by_phandle_args(np, "st,syscfg",
1, &ddata->boot_offset);
if (IS_ERR(ddata->boot_base))
return dev_err_probe(dev, PTR_ERR(ddata->boot_base),
"Boot base not found\n");

err = clk_prepare(ddata->clk);
if (err)
Expand Down Expand Up @@ -395,32 +385,32 @@ static int st_rproc_probe(struct platform_device *pdev)
*/
chan = mbox_request_channel_byname(&ddata->mbox_client_vq0, "vq0_rx");
if (IS_ERR(chan)) {
dev_err(&rproc->dev, "failed to request mbox chan 0\n");
ret = PTR_ERR(chan);
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
"failed to request mbox chan 0\n");
goto free_clk;
}
ddata->mbox_chan[ST_RPROC_VQ0 * MBOX_MAX + MBOX_RX] = chan;

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

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

chan = mbox_request_channel_byname(&ddata->mbox_client_vq1, "vq1_tx");
if (IS_ERR(chan)) {
dev_err(&rproc->dev, "failed to request mbox chan 1\n");
ret = PTR_ERR(chan);
ret = dev_err_probe(&rproc->dev, PTR_ERR(chan),
"failed to request mbox chan 1\n");
goto free_mbox;
}
ddata->mbox_chan[ST_RPROC_VQ1 * MBOX_MAX + MBOX_TX] = chan;
Expand Down
Loading

0 comments on commit aa22f4d

Please sign in to comment.