From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445AbdK0JEW (ORCPT ); Mon, 27 Nov 2017 04:04:22 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:46604 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbdK0JEU (ORCPT ); Mon, 27 Nov 2017 04:04:20 -0500 X-Google-Smtp-Source: AGs4zMaoc561gemNBYFrQzO2dJTaAD+2efkaM5wtFrcPbiLpZXI7yJ6fQ2rkxdwUZwtZ41KaklrkbA== Date: Mon, 27 Nov 2017 17:04:11 +0800 From: Peng Fan To: Marek Szyprowski Cc: Peng Fan , hch@lst.de, robin.murphy@arm.com, gregkh@linuxfoundation.org, robh+dt@kernel.org, frowand.list@gmail.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time Message-ID: <20171127090409.posgikgumpoq4wdm@linux-u7w5.ap.freescale.net> References: <20171126131346.12532-1-peng.fan@nxp.com> <20171126131346.12532-2-peng.fan@nxp.com> <875c3a8c-a857-823e-0243-487d1dd9bee7@samsung.com> <20171127083713.clh6oz5sgere4usq@linux-u7w5.ap.freescale.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marek, On Mon, Nov 27, 2017 at 09:44:20AM +0100, Marek Szyprowski wrote: >Hi Peng, > >On 2017-11-27 09:37, Peng Fan wrote: >> Hi Marek, >> >> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote: >> > Hi >> > >> > On 2017-11-26 14:13, Peng Fan wrote: >> > > Invoke of_reserved_mem_device_init at dma_configure, then >> > > there is no need to call of_reserved_mem_device_init in device >> > > specific probe function. >> > > >> > > Signed-off-by: Peng Fan >> > This has been already tried long time ago, without success: >> > http://patches.linaro.org/patch/33558/ >> Thanks for the info. I should first search mail list before >> sending out patches. > >It doesn't mean that I'm against such idea. I just pointed that I've >already tried. That time, however there was no dma_configure() function >yet, which seems to be better place for of_rmem_device_init(). > >I would however always call of_dma_configure(), even when reserved mem >node is there. IIRC on ARM64 that function configures dma_ops, without >which no dma is possible at all. So, you prefer this? if (dma_dev->of_node) { + of_reserved_mem_device_init(dev); ret = of_dma_configure(dev, dma_dev->of_node); However in of_reserved_mem_device, there is also an call to of_dma_configure. " /* ensure that dma_ops is set for virtual devices * using reserved memory */ ret = of_dma_configure(dev, np); " If always call of_dma_configure, of_dma_configure maybe called twice. I just checked more. of_reserved_mem_device_init only handle the first memory-region. To nodes which have multiple memory-region, seems 2nd and etc could not be handled, such as drivers/media/platform/s5p-mfc/s5p_mfc.c. Thanks, Peng. > >> >> Thanks, >> Peng. >> >> > > --- >> > > drivers/base/dma-mapping.c | 6 +++++- >> > > 1 file changed, 5 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c >> > > index e584eddef0a7..55dca06a7b55 100644 >> > > --- a/drivers/base/dma-mapping.c >> > > +++ b/drivers/base/dma-mapping.c >> > > @@ -12,6 +12,7 @@ >> > > #include >> > > #include >> > > #include >> > > +#include >> > > #include >> > > #include >> > > @@ -351,7 +352,9 @@ int dma_configure(struct device *dev) >> > > } >> > > if (dma_dev->of_node) { >> > > - ret = of_dma_configure(dev, dma_dev->of_node); >> > > + ret = of_reserved_mem_device_init(dev); >> > > + if (ret) >> > > + ret = of_dma_configure(dev, dma_dev->of_node); >> > > } else if (has_acpi_companion(dma_dev)) { >> > > attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode)); >> > > if (attr != DEV_DMA_NOT_SUPPORTED) >> > > @@ -367,5 +370,6 @@ int dma_configure(struct device *dev) >> > > void dma_deconfigure(struct device *dev) >> > > { >> > > of_dma_deconfigure(dev); >> > > + of_reserved_mem_device_release(dev); >> > > acpi_dma_deconfigure(dev); >> > > } > >Best regards >-- >Marek Szyprowski, PhD >Samsung R&D Institute Poland > -- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Subject: Re: [RFC 2/2] drivers: dma-mapping: parse per device reserved mem at probe time Date: Mon, 27 Nov 2017 17:04:11 +0800 Message-ID: <20171127090409.posgikgumpoq4wdm@linux-u7w5.ap.freescale.net> References: <20171126131346.12532-1-peng.fan@nxp.com> <20171126131346.12532-2-peng.fan@nxp.com> <875c3a8c-a857-823e-0243-487d1dd9bee7@samsung.com> <20171127083713.clh6oz5sgere4usq@linux-u7w5.ap.freescale.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Marek Szyprowski Cc: Peng Fan , hch-jcswGhMUV9g@public.gmane.org, robin.murphy-5wv7dgnIgG8@public.gmane.org, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org Hi Marek, On Mon, Nov 27, 2017 at 09:44:20AM +0100, Marek Szyprowski wrote: >Hi Peng, > >On 2017-11-27 09:37, Peng Fan wrote: >> Hi Marek, >> >> On Mon, Nov 27, 2017 at 09:31:00AM +0100, Marek Szyprowski wrote: >> > Hi >> > >> > On 2017-11-26 14:13, Peng Fan wrote: >> > > Invoke of_reserved_mem_device_init at dma_configure, then >> > > there is no need to call of_reserved_mem_device_init in device >> > > specific probe function. >> > > >> > > Signed-off-by: Peng Fan >> > This has been already tried long time ago, without success: >> > http://patches.linaro.org/patch/33558/ >> Thanks for the info. I should first search mail list before >> sending out patches. > >It doesn't mean that I'm against such idea. I just pointed that I've >already tried. That time, however there was no dma_configure() function >yet, which seems to be better place for of_rmem_device_init(). > >I would however always call of_dma_configure(), even when reserved mem >node is there. IIRC on ARM64 that function configures dma_ops, without >which no dma is possible at all. So, you prefer this? if (dma_dev->of_node) { + of_reserved_mem_device_init(dev); ret = of_dma_configure(dev, dma_dev->of_node); However in of_reserved_mem_device, there is also an call to of_dma_configure. " /* ensure that dma_ops is set for virtual devices * using reserved memory */ ret = of_dma_configure(dev, np); " If always call of_dma_configure, of_dma_configure maybe called twice. I just checked more. of_reserved_mem_device_init only handle the first memory-region. To nodes which have multiple memory-region, seems 2nd and etc could not be handled, such as drivers/media/platform/s5p-mfc/s5p_mfc.c. Thanks, Peng. > >> >> Thanks, >> Peng. >> >> > > --- >> > > drivers/base/dma-mapping.c | 6 +++++- >> > > 1 file changed, 5 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c >> > > index e584eddef0a7..55dca06a7b55 100644 >> > > --- a/drivers/base/dma-mapping.c >> > > +++ b/drivers/base/dma-mapping.c >> > > @@ -12,6 +12,7 @@ >> > > #include >> > > #include >> > > #include >> > > +#include >> > > #include >> > > #include >> > > @@ -351,7 +352,9 @@ int dma_configure(struct device *dev) >> > > } >> > > if (dma_dev->of_node) { >> > > - ret = of_dma_configure(dev, dma_dev->of_node); >> > > + ret = of_reserved_mem_device_init(dev); >> > > + if (ret) >> > > + ret = of_dma_configure(dev, dma_dev->of_node); >> > > } else if (has_acpi_companion(dma_dev)) { >> > > attr = acpi_get_dma_attr(to_acpi_device_node(dma_dev->fwnode)); >> > > if (attr != DEV_DMA_NOT_SUPPORTED) >> > > @@ -367,5 +370,6 @@ int dma_configure(struct device *dev) >> > > void dma_deconfigure(struct device *dev) >> > > { >> > > of_dma_deconfigure(dev); >> > > + of_reserved_mem_device_release(dev); >> > > acpi_dma_deconfigure(dev); >> > > } > >Best regards >-- >Marek Szyprowski, PhD >Samsung R&D Institute Poland > -- -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html