From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754154AbcFGJQD (ORCPT ); Tue, 7 Jun 2016 05:16:03 -0400 Received: from foss.arm.com ([217.140.101.70]:42327 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbcFGJQA (ORCPT ); Tue, 7 Jun 2016 05:16:00 -0400 Subject: Re: [PATCH] arm64: Implement arch_setup_pdev_archdata hook To: Baolin Wang , catalin.marinas@arm.com, will.deacon@arm.com References: Cc: jroedel@suse.de, akpm@linux-foundation.org, jszhang@marvell.com, Suravee.Suthikulpanit@amd.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, broonie@kernel.org, balbi@kernel.org From: Robin Murphy Message-ID: <575690CB.5080501@arm.com> Date: Tue, 7 Jun 2016 10:15:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/06/16 09:29, 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. Yes, that's rather the whole point. DMA-capable devices are real hardware, therefore don't spring out of thin air without being described in DT or ACPI. Please elaborate on the situation that you're attempting to address here (please don't let it be the ongoing Designware USB catastrophe ;)) Robin. > 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; > + > + /* > + * 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; > +} >