From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Tue, 07 Jun 2016 10:43:08 +0200 Subject: [PATCH] arm64: Implement arch_setup_pdev_archdata hook In-Reply-To: References: Message-ID: <3369300.0KEI34cGsj@wuerfel> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tuesday, June 7, 2016 4:29:21 PM CEST Baolin Wang wrote: > Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if > it did not call 'arch_setup_dma_ops' at device creation time by issuing > platform_device_alloc() function, that will cause failure when setting > the dma mask for device. > > Hence We need to hook the archdata to setup proper dma_ops for these devices. > > Signed-off-by: Baolin Wang > --- > arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c > index c566ec8..04e057b 100644 > --- a/arch/arm64/mm/dma-mapping.c > +++ b/arch/arm64/mm/dma-mapping.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > > @@ -961,3 +962,23 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, > dev->archdata.dma_coherent = coherent; > __iommu_setup_dma_ops(dev, dma_base, size, iommu); > } > + > +void arch_setup_pdev_archdata(struct platform_device *pdev) > +{ > + if (!pdev->dev.archdata.dma_ops) > + pdev->dev.archdata.dma_ops = &swiotlb_dma_ops; You need to check the DT here to see if these are the right ops, or if you have to go through an IOMMU. Also, you have to set up the other fields that are controlled by arch_setup_dma_ops: whether it's coherent and what the offset is. > + /* > + * Set default coherent_dma_mask to 32 bit. Drivers are expected to > + * setup the correct supported mask. > + */ > + if (!pdev->dev.coherent_dma_mask) > + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); > + > + /* > + * Set it to coherent_dma_mask by default if the architecture > + * code has not set it. > + */ > + if (!pdev->dev.dma_mask) > + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; > +} We still have an open bug about the dma_set_mask() function on ARM64: we have to check the dma-ranges property to ensure that no device can set a mask wider than what its parent bus can support. What is your plan for this in case of these devices? Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751728AbcFIMmh (ORCPT ); Thu, 9 Jun 2016 08:42:37 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:55905 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbcFIMme (ORCPT ); Thu, 9 Jun 2016 08:42:34 -0400 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Baolin Wang , catalin.marinas@arm.com, will.deacon@arm.com, jszhang@marvell.com, balbi@kernel.org, jroedel@suse.de, linux-kernel@vger.kernel.org, broonie@kernel.org, Suravee.Suthikulpanit@amd.com, akpm@linux-foundation.org, robin.murphy@arm.com Subject: Re: [PATCH] arm64: Implement arch_setup_pdev_archdata hook Date: Tue, 07 Jun 2016 10:43:08 +0200 Message-ID: <3369300.0KEI34cGsj@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:UBBbzriUU4CuVm78zZ+Kklz7HMUZ/pnyDCs4EPKcX0/Q67EuFrV Qv1v8PyLieVEJ8ffb/oNzoY7Q7P10MP9lVByF4U4aVv2/mn6Qnb+tah4NvF75R8JEJKzyjU 1QCa7PFwtLpDPpiOY1rhKcwJ9CxTInF3+YwQv2BRH2Cg4+e85crbRlEQdl7vRtKLkiWhG7I ZDnQn180xfGIDGJQX3M6g== X-UI-Out-Filterresults: notjunk:1;V01:K0:4UGPhggmie4=:ejYCeSZGpbA8kXNd3o5/mY 19sK6iTchehdOC5MPIR5ZcryjRIvp8Ap2rFs4OzbLbxObT8eDNkNJpp2wd+1hZ6UHpxO3foMl b/qIYktBL8JkoY2CxkiCtgHlx82cdjlG/LdB3zf/rtBlBhqnoCY+OPctK+UUgj8WcffE72IT1 xNwn3v3er4qmaGF08RW0dgcKwQWquPXRviwihxaaYTqdLi1EAR5Omg3WFD5tt3tKdnRpybM/K PI4Bsvc5r1Csx0iGvIRHpfnd01tse6yC5uT5+n+7U4YXTZe59ylSfj4wl56danW+f4mQ+a7hS tSzKh2k4WaV15fjVm1ATFUSY3M9JWlz4PHtQiyzxSu1lxsH1UAR7vnCikNcBt+OfrCFAdBk2H cf1FWEnPm+nUm6ivPbf48u5qrdcGjLgIyh705psgZf++ZknEV55AnSo2ZjD7rUuEDk+Gj5CCT P2okbvdvAamGqYrT0biRZ4rFl9V4+sR99c5XZL+8mF8FaTr5p+mOe7puAAeR+/rXCb8GIwSDw 64E6c7Ji7goDiY0oNzfJ6SYXEZFe0Ec9TmhELJ4jo+y52m3UR0F1ZiJ5TNd0wypRfhGSgOqWk WLhf2Vmr7+jyLIQDB+8nqYBuZyx5QDvItopKQRg56AhJhwB3gnuQarsQyBr1g1Z8VisAILJHl Zi2Svjz87/U+F28VLf8jJWWSWz7sPVgmSwbzxfdJ1WN8KVHF6lSgHfZ64TZXw7UfbWxG+wcxf yg21rHKzsb3UVYy/ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, June 7, 2016 4:29:21 PM CEST Baolin Wang wrote: > Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if > it did not call 'arch_setup_dma_ops' at device creation time by issuing > platform_device_alloc() function, that will cause failure when setting > the dma mask for device. > > Hence We need to hook the archdata to setup proper dma_ops for these devices. > > Signed-off-by: Baolin Wang > --- > arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c > index c566ec8..04e057b 100644 > --- a/arch/arm64/mm/dma-mapping.c > +++ b/arch/arm64/mm/dma-mapping.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > > @@ -961,3 +962,23 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, > dev->archdata.dma_coherent = coherent; > __iommu_setup_dma_ops(dev, dma_base, size, iommu); > } > + > +void arch_setup_pdev_archdata(struct platform_device *pdev) > +{ > + if (!pdev->dev.archdata.dma_ops) > + pdev->dev.archdata.dma_ops = &swiotlb_dma_ops; You need to check the DT here to see if these are the right ops, or if you have to go through an IOMMU. Also, you have to set up the other fields that are controlled by arch_setup_dma_ops: whether it's coherent and what the offset is. > + /* > + * Set default coherent_dma_mask to 32 bit. Drivers are expected to > + * setup the correct supported mask. > + */ > + if (!pdev->dev.coherent_dma_mask) > + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); > + > + /* > + * Set it to coherent_dma_mask by default if the architecture > + * code has not set it. > + */ > + if (!pdev->dev.dma_mask) > + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; > +} We still have an open bug about the dma_set_mask() function on ARM64: we have to check the dma-ranges property to ensure that no device can set a mask wider than what its parent bus can support. What is your plan for this in case of these devices? Arnd