Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E55DEC432C0 for ; Tue, 19 Nov 2019 10:19:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BDB3A22304 for ; Tue, 19 Nov 2019 10:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfKSKT7 (ORCPT ); Tue, 19 Nov 2019 05:19:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:50404 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725798AbfKSKT7 (ORCPT ); Tue, 19 Nov 2019 05:19:59 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 405A9B301; Tue, 19 Nov 2019 10:19:56 +0000 (UTC) Message-ID: Subject: Re: [PATCH 1/3] dma-direct: unify the dma_capable definitions From: Nicolas Saenz Julienne To: Marek Szyprowski , Christoph Hellwig , iommu@lists.linux-foundation.org, Russell King Cc: linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski , 'Linux Samsung SOC' Date: Tue, 19 Nov 2019 11:19:54 +0100 In-Reply-To: <1c227c91-512c-e871-0e03-a27b2c0435d7@samsung.com> References: <20191113073539.9660-1-hch@lst.de> <20191113073539.9660-2-hch@lst.de> <1c227c91-512c-e871-0e03-a27b2c0435d7@samsung.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-9aduMZ9FwgNk+BtbhcTa" User-Agent: Evolution 3.34.1 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org --=-9aduMZ9FwgNk+BtbhcTa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2019-11-19 at 10:27 +0100, Marek Szyprowski wrote: > Hi Christoph, >=20 > On 13.11.2019 08:35, Christoph Hellwig wrote: > > Currently each architectures that wants to override dma_to_phys and > > phys_to_dma also has to provide dma_capable. But there isn't really > > any good reason for that. powerpc and mips just have copies of the > > generic one minus the latests fix, and the arm one was the inspiration > > for said fix, but misses the bus_dma_mask handling. > > Make all architectures use the generic version instead. > >=20 > > Signed-off-by: Christoph Hellwig >=20 > This patch breaks DMAengine PL330 driver on Samsung Exynos SoCs: >=20 > [ 3.602338] dma-pl330 12690000.pdma: overflow 0x13810020+1 of DMA=20 > mask ffffffff bus mask 0 > [ 3.605113] ------------[ cut here ]------------ > [ 3.609719] WARNING: CPU: 2 PID: 1 at kernel/dma/direct.c:36=20 > report_addr+0xc0/0xfc > [ 3.617226] Modules linked in: > [ 3.620271] CPU: 2 PID: 1 Comm: init Not tainted=20 > 5.4.0-rc5-00056-gb037b220e71d #6911 > [ 3.627986] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) > [ 3.634094] [] (unwind_backtrace) from []=20 > (show_stack+0x10/0x14) > [ 3.641803] [] (show_stack) from []=20 > (dump_stack+0xa8/0xd4) > [ 3.649002] [] (dump_stack) from []=20 > (__warn+0xf4/0x10c) > [ 3.655940] [] (__warn) from []=20 > (warn_slowpath_fmt+0xb0/0xb8) > [ 3.663404] [] (warn_slowpath_fmt) from []=20 > (report_addr+0xc0/0xfc) > [ 3.671303] [] (report_addr) from []=20 > (dma_direct_map_resource+0x98/0xa0) > [ 3.679739] [] (dma_direct_map_resource) from []= =20 > (pl330_prep_slave_fifo+0xe4/0x128) > [ 3.689099] [] (pl330_prep_slave_fifo) from []=20 > (pl330_prep_slave_sg+0x54/0x1cc) > [ 3.698129] [] (pl330_prep_slave_sg) from []=20 > (s3c24xx_serial_start_tx_dma+0x118/0x1e8) > [ 3.707764] [] (s3c24xx_serial_start_tx_dma) from=20 > [] (uart_write+0xe4/0x1e0) > [ 3.716532] [] (uart_write) from []=20 > (n_tty_write+0x1c8/0x474) > [ 3.723992] [] (n_tty_write) from []=20 > (tty_write+0x154/0x314) > [ 3.731380] [] (tty_write) from []=20 > (__vfs_write+0x30/0x1d0) > [ 3.738662] [] (__vfs_write) from []=20 > (vfs_write+0xa4/0x180) > [ 3.745949] [] (vfs_write) from []=20 > (ksys_write+0x60/0xd8) > [ 3.753069] [] (ksys_write) from []=20 > (ret_fast_syscall+0x0/0x28) > [ 3.760705] Exception stack(0xee8dffa8 to 0xee8dfff0) > [ 3.765739] ffa0: 0000004a beca876c 00000002=20 > beca876c 0000004a 00000000 > [ 3.773900] ffc0: 0000004a beca876c b6f02cf0 00000004 beca876c=20 > 0000004a 00000000 b6f99010 > [ 3.782056] ffe0: 0000006c beca8628 b6e1d000 b6e7a634 > [ 3.787092] irq event stamp: 289740 > [ 3.790571] hardirqs last enabled at (289739): []=20 > _raw_spin_unlock_irqrestore+0x6c/0x74 > [ 3.799503] hardirqs last disabled at (289740): []=20 > _raw_spin_lock_irqsave+0x1c/0x58 > [ 3.808011] softirqs last enabled at (289576): []=20 > __do_softirq+0x4fc/0x5fc > [ 3.815830] softirqs last disabled at (289567): []=20 > irq_exit+0x16c/0x170 > [ 3.823286] ---[ end trace b1432c658797b861 ]--- > [ 3.827898] samsung-uart 13810000.serial: Unable to get desc for Tx > [ 3.834624] samsung-uart 13810000.serial: Unable to get desc for Tx > [ 3.840487] samsung-uart 13810000.serial: Unable to get desc for Tx >=20 > I'm checking now which part of it causes the issue. Hi Marek, is this a on a non LPAE ARM32 device? Regards, Nicolas > > --- > > arch/arm/include/asm/dma-direct.h | 19 ------------------- > > arch/mips/include/asm/dma-direct.h | 8 -------- > > arch/powerpc/include/asm/dma-direct.h | 9 --------- > > include/linux/dma-direct.h | 2 +- > > 4 files changed, 1 insertion(+), 37 deletions(-) > >=20 > > diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/d= ma- > > direct.h > > index b67e5fc1fe43..7c3001a6a775 100644 > > --- a/arch/arm/include/asm/dma-direct.h > > +++ b/arch/arm/include/asm/dma-direct.h > > @@ -14,23 +14,4 @@ static inline phys_addr_t __dma_to_phys(struct devic= e > > *dev, dma_addr_t dev_addr) > > return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset; > > } > > =20 > > -static inline bool dma_capable(struct device *dev, dma_addr_t addr, si= ze_t > > size) > > -{ > > - u64 limit, mask; > > - > > - if (!dev->dma_mask) > > - return 0; > > - > > - mask =3D *dev->dma_mask; > > - > > - limit =3D (mask + 1) & ~mask; > > - if (limit && size > limit) > > - return 0; > > - > > - if ((addr | (addr + size - 1)) & ~mask) > > - return 0; > > - > > - return 1; > > -} > > - > > #endif /* ASM_ARM_DMA_DIRECT_H */ > > diff --git a/arch/mips/include/asm/dma-direct.h b/arch/mips/include/asm= /dma- > > direct.h > > index b5c240806e1b..14e352651ce9 100644 > > --- a/arch/mips/include/asm/dma-direct.h > > +++ b/arch/mips/include/asm/dma-direct.h > > @@ -2,14 +2,6 @@ > > #ifndef _MIPS_DMA_DIRECT_H > > #define _MIPS_DMA_DIRECT_H 1 > > =20 > > -static inline bool dma_capable(struct device *dev, dma_addr_t addr, si= ze_t > > size) > > -{ > > - if (!dev->dma_mask) > > - return false; > > - > > - return addr + size - 1 <=3D *dev->dma_mask; > > -} > > - > > dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr); > > phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr); > > =20 > > diff --git a/arch/powerpc/include/asm/dma-direct.h > > b/arch/powerpc/include/asm/dma-direct.h > > index a2912b47102c..e29e8a236b8d 100644 > > --- a/arch/powerpc/include/asm/dma-direct.h > > +++ b/arch/powerpc/include/asm/dma-direct.h > > @@ -2,15 +2,6 @@ > > #ifndef ASM_POWERPC_DMA_DIRECT_H > > #define ASM_POWERPC_DMA_DIRECT_H 1 > > =20 > > -static inline bool dma_capable(struct device *dev, dma_addr_t addr, si= ze_t > > size) > > -{ > > - if (!dev->dma_mask) > > - return false; > > - > > - return addr + size - 1 <=3D > > - min_not_zero(*dev->dma_mask, dev->bus_dma_mask); > > -} > > - > > static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_= t > > paddr) > > { > > if (!dev) > > diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h > > index 6db863c3eb93..991f8aa2676e 100644 > > --- a/include/linux/dma-direct.h > > +++ b/include/linux/dma-direct.h > > @@ -24,6 +24,7 @@ static inline phys_addr_t __dma_to_phys(struct device > > *dev, dma_addr_t dev_addr) > > =20 > > return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT); > > } > > +#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */ > > =20 > > static inline bool dma_capable(struct device *dev, dma_addr_t addr, s= ize_t > > size) > > { > > @@ -38,7 +39,6 @@ static inline bool dma_capable(struct device *dev, > > dma_addr_t addr, size_t size) > > =20 > > return end <=3D min_not_zero(*dev->dma_mask, dev->bus_dma_mask); > > } > > -#endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */ > > =20 > > #ifdef CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED > > bool force_dma_unencrypted(struct device *dev); >=20 > Best regards --=-9aduMZ9FwgNk+BtbhcTa Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl3TwcoACgkQlfZmHno8 x/4hYggAgy09wSQ1ZdnrSCRXM/qq4EQzGTlWlNYjUCtT8eDcvo8fKm0pfdBpGStG QPbrAzJaKNlsIR6Tx/TEF/m1JX1I/QzNsng9h76ShOpn9CGshg57W91L82b57qT4 vJDniIW8Gv3SQ+jSSspU8N2UVYLYCqOqpxxjyy8zTRkU0CtyaJCyLXeSQTLjGyab fs/5NI6u7gE4bLChR9+lkqu7t3ga1Wsxuoq2Fx/J8tio0q82ZFowbsevVWAFzb0b Nfm1YGv7BYtSYOldIHrYPwiwJzcJ5zv5tAJh+GaszzXMTIGk9Tpv2VpjymlSbLja HCVKkk0xkKPJrTOWzYpiiX4w6WeybA== =xWer -----END PGP SIGNATURE----- --=-9aduMZ9FwgNk+BtbhcTa--