Commit aa22f4da authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents eda061cc 3a53ff95
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -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;
}
+10 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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;
}
@@ -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);
}

+19 −5
Original line number Diff line number Diff line
@@ -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"

@@ -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)
@@ -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)) {
@@ -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;
+7 −7
Original line number Diff line number Diff line
@@ -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;
@@ -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);
+22 −32
Original line number Diff line number Diff line
@@ -290,26 +290,23 @@ 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) {
@@ -317,18 +314,11 @@ static int st_rproc_parse_dt(struct platform_device *pdev)
		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)
@@ -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;
Loading