From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: robh+dt@kernel.org, devicetree@vger.kernel.org,
frowand.list@gmail.com, linux-arm-kernel@lists.infradead.org,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org,
etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
xen-devel@lists.xenproject.org, linux-tegra@vger.kernel.org,
linux-media@vger.kernel.org, linux-pci@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Rafał Miłecki" <zajec5@gmail.com>,
"Sinan Kaya" <okaya@kernel.org>, "Andy Gross" <agross@kernel.org>,
"Lucas Stach" <l.stach@pengutronix.de>,
"Russell King" <linux+etnaviv@armlinux.org.uk>,
"Christian Gmeiner" <christian.gmeiner@gmail.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Chen-Yu Tsai" <wens@csie.org>,
"Oleksandr Andrushchenko" <oleksandr_andrushchenko@epam.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Stanimir Varbanov" <stanimir.varbanov@linaro.org>,
"Kyungmin Park" <kyungmin.park@samsung.com>,
"Kamil Debski" <kamil@wypas.org>,
"Jeongtae Park" <jtp.park@samsung.com>,
"Andrzej Hajda" <a.hajda@samsung.com>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Juergen Gross" <jgross@suse.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Cc: mbrugger@suse.com, robin.murphy@arm.com, f.fainelli@gmail.com,
james.quinlan@broadcom.com, wahrenst@gmx.net,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Vinod Koul <vkoul@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
freedreno@lists.freedesktop.org
Subject: [PATCH 11/11] of: simplify of_dma_config()'s arguments
Date: Tue, 24 Sep 2019 20:12:42 +0200 [thread overview]
Message-ID: <20190924181244.7159-12-nsaenzjulienne@suse.de> (raw)
In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de>
The widespread use case for of_dma_config() highlights a redundant
argument. Most callers provide both 'dev' and 'dev->of_node'. The rest
of users use it to copy some device's DMA configuration into a device
not represented in DT.
In order to simplify the common use case, and make code a little more
explicit, create of_dma_config_copy() which will take another device's
DT node as an argument and simplify of_dma_config() by removing one of
it's redundant arguments.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
drivers/base/platform.c | 2 +-
drivers/bcma/main.c | 2 +-
drivers/dma/qcom/hidma_mgmt.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +-
drivers/gpu/drm/sun4i/sun4i_backend.c | 2 +-
drivers/gpu/drm/xen/xen_drm_front.c | 2 +-
drivers/gpu/host1x/bus.c | 2 +-
drivers/media/platform/qcom/venus/firmware.c | 2 +-
drivers/media/platform/s5p-mfc/s5p_mfc.c | 2 +-
drivers/of/device.c | 30 ++++++++++++++++++--
drivers/xen/gntdev.c | 2 +-
include/linux/of_device.h | 12 ++++++--
13 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b6c6c7d97d5b..4e252028aee9 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1221,7 +1221,7 @@ int platform_dma_configure(struct device *dev)
int ret = 0;
if (dev->of_node) {
- ret = of_dma_configure(dev, dev->of_node, true);
+ ret = of_dma_configure(dev, true);
} else if (has_acpi_companion(dev)) {
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
ret = acpi_dma_configure(dev, attr);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 6535614a7dc1..4c7e8b35525c 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -207,7 +207,7 @@ static void bcma_of_fill_device(struct device *parent,
core->irq = bcma_of_get_irq(parent, core, 0);
- of_dma_configure(&core->dev, node, false);
+ of_dma_configure(&core->dev, false);
}
unsigned int bcma_core_irq(struct bcma_device *core, int num)
diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c
index 806ca02c52d7..4ea901537902 100644
--- a/drivers/dma/qcom/hidma_mgmt.c
+++ b/drivers/dma/qcom/hidma_mgmt.c
@@ -388,7 +388,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
goto out;
}
new_pdev->dev.of_node = child;
- of_dma_configure(&new_pdev->dev, child, true);
+ of_dma_configure(&new_pdev->dev, true);
/*
* It is assumed that calling of_msi_configure is safe on
* platforms with or without MSI support.
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 1f9c01be40d7..1375f41593ef 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -706,7 +706,7 @@ static int __init etnaviv_init(void)
* device as the GPU we found. This assumes that all Vivante
* GPUs in the system share the same DMA constraints.
*/
- of_dma_configure(&pdev->dev, np, true);
+ of_dma_configure_copy(&pdev->dev, np, true);
ret = platform_device_add(pdev);
if (ret) {
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 85f14feafdec..825fcdc72bd9 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -1268,7 +1268,7 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
gmu->dev = &pdev->dev;
- of_dma_configure(gmu->dev, node, true);
+ of_dma_configure(gmu->dev, true);
/* Fow now, don't do anything fancy until we get our feet under us */
gmu->idle_level = GMU_IDLE_STATE_ACTIVE;
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 4e29f4fe4a05..97dd5d31e38d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -802,7 +802,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
* for us, and DRM doesn't do per-device allocation either, so
* we would need to fix DRM first...
*/
- ret = of_dma_configure(drm->dev, dev->of_node, true);
+ ret = of_dma_configure_copy(drm->dev, dev->of_node, true);
if (ret)
return ret;
} else {
diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c
index ba1828acd8c9..fa0bfd6517fa 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -726,7 +726,7 @@ static int xen_drv_probe(struct xenbus_device *xb_dev,
* node to set default DMA ops.
*/
dev->coherent_dma_mask = DMA_BIT_MASK(32);
- ret = of_dma_configure(dev, NULL, true);
+ ret = of_dma_configure(dev, true);
if (ret < 0) {
DRM_ERROR("Cannot setup DMA ops, ret %d", ret);
return ret;
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 2fdc04383a60..4eb531906e4a 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -337,7 +337,7 @@ static int host1x_device_uevent(struct device *dev,
static int host1x_dma_configure(struct device *dev)
{
- return of_dma_configure(dev, dev->of_node, true);
+ return of_dma_configure(dev, true);
}
static const struct dev_pm_ops host1x_device_pm_ops = {
diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
index d3d1748a7ef6..82f433218d99 100644
--- a/drivers/media/platform/qcom/venus/firmware.c
+++ b/drivers/media/platform/qcom/venus/firmware.c
@@ -238,7 +238,7 @@ int venus_firmware_init(struct venus_core *core)
pdev->dev.of_node = np;
- ret = of_dma_configure(&pdev->dev, np, true);
+ ret = of_dma_configure(&pdev->dev, true);
if (ret) {
dev_err(core->dev, "dma configure fail\n");
goto err_unregister;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index b776f83e395e..ad33e7a655aa 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1095,7 +1095,7 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev,
* to be treated as valid DMA masters we need a bit of a hack to force
* them to inherit the MFC node's DMA configuration.
*/
- of_dma_configure(child, dev->of_node, true);
+ of_dma_configure_copy(child, dev->of_node, true);
if (device_add(child) == 0) {
ret = of_reserved_mem_device_init_by_idx(child, dev->of_node,
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 1d0b1127d05e..66726a2499d3 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -75,19 +75,18 @@ int of_device_add(struct platform_device *ofdev)
/**
* of_dma_configure - Setup DMA configuration
* @dev: Device to apply DMA configuration
- * @np: Pointer to OF node having DMA configuration
* @force_dma: Whether device is to be set up by of_dma_configure() even if
* DMA capability is not explicitly described by firmware.
*
* Try to get devices's DMA configuration from DT and update it
* accordingly.
*/
-int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
+int of_dma_configure(struct device *dev, bool force_dma)
{
struct device_node *dma_parent;
int ret;
- dma_parent = __of_get_dma_parent(np);
+ dma_parent = __of_get_dma_parent(dev->of_node);
ret = of_dma_configure_parent(dev, dma_parent, force_dma);
of_node_put(dma_parent);
@@ -95,6 +94,31 @@ int of_dma_configure(struct device *dev, struct device_node *np, bool force_dma)
}
EXPORT_SYMBOL_GPL(of_dma_configure);
+/**
+ * of_dma_configure_copy - Setup DMA configuration based on another device's DT
+ * node
+ * @dev: Device to apply DMA configuration
+ * @np: Device node to copy the configuration from
+ * @force_dma: Whether device is to be set up by of_dma_configure() even if
+ * DMA capability is not explicitly described by firmware.
+ *
+ * Try to get devices's DMA configuration from DT and update it
+ * accordingly.
+ */
+int of_dma_configure_copy(struct device *dev, struct device_node *np,
+ bool force_dma)
+{
+ struct device_node *dma_parent;
+ int ret;
+
+ dma_parent = __of_get_dma_parent(np);
+ ret = of_dma_configure_parent(dev, dma_parent, force_dma);
+ of_node_put(dma_parent);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(of_dma_configure_copy);
+
/**
* of_dma_configure_parent - Setup DMA configuration based on a parent bus'
* DT node
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a446a7221e13..115e39f9f67a 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -632,7 +632,7 @@ static int gntdev_open(struct inode *inode, struct file *flip)
* Fix this by calling of_dma_configure() with a NULL node to set
* default DMA ops.
*/
- of_dma_configure(priv->dma_dev, NULL, true);
+ of_dma_configure(priv->dma_dev, true);
#endif
pr_debug("priv %p\n", priv);
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 8f319b8c9deb..b05a86fd35a4 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -55,7 +55,9 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
return of_node_get(cpu_dev->of_node);
}
-int of_dma_configure(struct device *dev, struct devce_node *np, bool force_dma);
+int of_dma_configure(struct device *dev, bool force_dma);
+int of_dma_configure_copy(struct device *dev, struct device_node *np,
+ bool force_dma);
int of_dma_configure_parent(struct device *dev, struct device_node *parent,
bool force_dma);
#else /* CONFIG_OF */
@@ -107,12 +109,18 @@ static inline struct device_node *of_cpu_device_node_get(int cpu)
}
static inline int of_dma_configure(struct device *dev,
- struct device_node *np,
bool force_dma)
{
return 0;
}
+static inline int of_dma_configure_copy(struct device *dev,
+ struct device_node *np,
+ bool force_dma)
+{
+ return 0;
+}
+
static inline int of_dma_configure_parent(struct device *dev,
struct device_node *parent,
bool force_dma)
--
2.23.0
next prev parent reply other threads:[~2019-09-24 18:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 18:12 [PATCH 00/11] of: Fix DMA configuration for non-DT masters Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 01/11] of: address: clean-up unused variable in of_dma_get_range() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 02/11] of: base: introduce __of_n_*_cells_parent() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 03/11] of: address: use parent DT node in bus->count_cells() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 04/11] of: address: introduce of_translate_dma_address_parent() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 05/11] of: expose __of_get_dma_parent() to OF subsystem Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 06/11] of: address: use parent OF node in of_dma_get_range() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 07/11] dts: arm64: layerscape: add dma-ranges property to qoric-mc node Nicolas Saenz Julienne
2019-10-14 8:28 ` Shawn Guo
2019-10-14 10:00 ` Nicolas Saenz Julienne
2019-10-14 11:09 ` Shawn Guo
2019-09-24 18:12 ` [PATCH 08/11] dts: arm64: layerscape: add dma-ranges property to pcie nodes Nicolas Saenz Julienne
2019-10-14 8:29 ` Shawn Guo
2019-09-24 18:12 ` [PATCH 09/11] of: device: remove comment in of_dma_configure() Nicolas Saenz Julienne
2019-09-24 18:12 ` [PATCH 10/11] of: device: introduce of_dma_configure_parent() Nicolas Saenz Julienne
2019-09-24 18:12 ` Nicolas Saenz Julienne [this message]
2019-09-24 21:59 ` [PATCH 00/11] of: Fix DMA configuration for non-DT masters Rob Herring
2019-09-25 14:52 ` Nicolas Saenz Julienne
2019-09-25 15:09 ` Robin Murphy
2019-09-25 15:30 ` Nicolas Saenz Julienne
2019-09-25 16:16 ` Rob Herring
2019-09-25 16:52 ` Robin Murphy
2019-09-25 21:33 ` Rob Herring
2019-09-26 10:44 ` Nicolas Saenz Julienne
2019-09-26 11:20 ` Robin Murphy
2019-10-02 18:28 ` Florian Fainelli
2019-09-25 16:07 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190924181244.7159-12-nsaenzjulienne@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=a.hajda@samsung.com \
--cc=agross@kernel.org \
--cc=airlied@linux.ie \
--cc=boris.ostrovsky@oracle.com \
--cc=christian.gmeiner@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=etnaviv@lists.freedesktop.org \
--cc=f.fainelli@gmail.com \
--cc=freedreno@lists.freedesktop.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.quinlan@broadcom.com \
--cc=jgross@suse.com \
--cc=jtp.park@samsung.com \
--cc=kamil@wypas.org \
--cc=kyungmin.park@samsung.com \
--cc=l.stach@pengutronix.de \
--cc=linux+etnaviv@armlinux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mbrugger@suse.com \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=okaya@kernel.org \
--cc=oleksandr_andrushchenko@epam.com \
--cc=rafael@kernel.org \
--cc=robdclark@gmail.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sean@poorly.run \
--cc=sstabellini@kernel.org \
--cc=stanimir.varbanov@linaro.org \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
--cc=wahrenst@gmx.net \
--cc=wens@csie.org \
--cc=xen-devel@lists.xenproject.org \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).