From nobody Tue Feb 10 04:14:37 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569385047; cv=none; d=zoho.com; s=zohoarc; b=m8BPoGgefMJZ8Nk7EmkSuoC+XgRw0ELz/mOntCuIM/hDD71Sptu/fjy8Gaukl3VQoSXZvWhc78ApEFDftIIyKWn4JKI9aSCMlzq0LS5w30WcHzG9HgOVu6Yx1snvf7lqmFlVXNzx2gv3gWdVIE3Eof/WrY8IUKPtkpppFsvm4DM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569385047; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=T36tVt8GU3MsyefTeHKpFy3lWhxkmmIHjn5KP2Ja9+Q=; b=MrFr3r8aAojXGj6AF5ZKSB1dOIU4dHvZq1IMFgsco/zZuKu8wlDIO20ChFX/Klp5uXKWD7hPz53R/uXUDj8j9FY58OESBksecZZpYMH/deuHsWIMpKoLLGC2lqbNPFu64crKGe9VpFPQnutwy5J2D5IFI8QHAOhei3lMb2+bqy0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156938504757454.0140146363417; Tue, 24 Sep 2019 21:17:27 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCyj5-0000Wm-4A; Wed, 25 Sep 2019 04:16:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCpJY-0000Hj-Ee for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 18:13:28 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id f8c21a78-def6-11e9-8628-bc764e2007e4; Tue, 24 Sep 2019 18:13:13 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 71267ABBD; Tue, 24 Sep 2019 18:13:11 +0000 (UTC) X-Inumbo-ID: f8c21a78-def6-11e9-8628-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Nicolas Saenz Julienne 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 , "Rafael J. Wysocki" , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Sinan Kaya , Andy Gross , Lucas Stach , Russell King , Christian Gmeiner , Maxime Ripard , Chen-Yu Tsai , Oleksandr Andrushchenko , Thierry Reding , Stanimir Varbanov , Kyungmin Park , Kamil Debski , Jeongtae Park , Andrzej Hajda , Boris Ostrovsky , Juergen Gross , Stefano Stabellini Date: Tue, 24 Sep 2019 20:12:42 +0200 Message-Id: <20190924181244.7159-12-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924181244.7159-1-nsaenzjulienne@suse.de> References: <20190924181244.7159-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 25 Sep 2019 04:16:20 +0000 Subject: [Xen-devel] [PATCH 11/11] of: simplify of_dma_config()'s arguments X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org, f.fainelli@gmail.com, Daniel Vetter , David Airlie , Sean Paul , Rob Clark , Vinod Koul , mbrugger@suse.com, wahrenst@gmx.net, james.quinlan@broadcom.com, Dan Williams , Mauro Carvalho Chehab , robin.murphy@arm.com, Nicolas Saenz Julienne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- 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 =3D 0; =20 if (dev->of_node) { - ret =3D of_dma_configure(dev, dev->of_node, true); + ret =3D of_dma_configure(dev, true); } else if (has_acpi_companion(dev)) { attr =3D acpi_get_dma_attr(to_acpi_device_node(dev->fwnode)); ret =3D 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, =20 core->irq =3D bcma_of_get_irq(parent, core, 0); =20 - of_dma_configure(&core->dev, node, false); + of_dma_configure(&core->dev, false); } =20 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(struc= t device_node *np) goto out; } new_pdev->dev.of_node =3D 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/etnavi= v/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); =20 ret =3D platform_device_add(pdev); if (ret) { diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/ad= reno/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 d= evice_node *node) =20 gmu->dev =3D &pdev->dev; =20 - of_dma_configure(gmu->dev, node, true); + of_dma_configure(gmu->dev, true); =20 /* Fow now, don't do anything fancy until we get our feet under us */ gmu->idle_level =3D 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, struc= t device *master, * for us, and DRM doesn't do per-device allocation either, so * we would need to fix DRM first... */ - ret =3D of_dma_configure(drm->dev, dev->of_node, true); + ret =3D 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 =3D DMA_BIT_MASK(32); - ret =3D of_dma_configure(dev, NULL, true); + ret =3D 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, =20 static int host1x_dma_configure(struct device *dev) { - return of_dma_configure(dev, dev->of_node, true); + return of_dma_configure(dev, true); } =20 static const struct dev_pm_ops host1x_device_pm_ops =3D { diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/p= latform/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) =20 pdev->dev.of_node =3D np; =20 - ret =3D of_dma_configure(&pdev->dev, np, true); + ret =3D 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/platf= orm/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 dev= ice *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); =20 if (device_add(child) =3D=3D 0) { ret =3D 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 forc= e_dma) +int of_dma_configure(struct device *dev, bool force_dma) { struct device_node *dma_parent; int ret; =20 - dma_parent =3D __of_get_dma_parent(np); + dma_parent =3D __of_get_dma_parent(dev->of_node); ret =3D of_dma_configure_parent(dev, dma_parent, force_dma); of_node_put(dma_parent); =20 @@ -95,6 +94,31 @@ int of_dma_configure(struct device *dev, struct device_n= ode *np, bool force_dma) } EXPORT_SYMBOL_GPL(of_dma_configure); =20 +/** + * 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 =3D __of_get_dma_parent(np); + ret =3D 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); =20 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); } =20 -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) } =20 static inline int of_dma_configure(struct device *dev, - struct device_node *np, bool force_dma) { return 0; } =20 +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) --=20 2.23.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel