From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,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 CCFECC433E2 for ; Tue, 8 Sep 2020 11:21:12 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DCF220936 for ; Tue, 8 Sep 2020 11:21:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DCF220936 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2FA6781B63; Tue, 8 Sep 2020 11:21:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hnh7G97Jj02N; Tue, 8 Sep 2020 11:21:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 4C3B2871B5; Tue, 8 Sep 2020 11:21:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2E83EC0859; Tue, 8 Sep 2020 11:21:09 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 123A1C0051 for ; Tue, 8 Sep 2020 11:21:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EB95E868CA for ; Tue, 8 Sep 2020 11:21:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AcqTorL3PPTv for ; Tue, 8 Sep 2020 11:21:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by whitealder.osuosl.org (Postfix) with ESMTPS id A64A78698B for ; Tue, 8 Sep 2020 11:21:04 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 655D5AF93; Tue, 8 Sep 2020 11:21:03 +0000 (UTC) Message-ID: Subject: Re: [PATCH v11 07/11] device-mapping: Introduce DMA range map, supplanting dma_pfn_offset From: Nicolas Saenz Julienne To: Christoph Hellwig Date: Tue, 08 Sep 2020 13:20:56 +0200 In-Reply-To: <20200908094345.GA20959@lst.de> References: <20200902223852.GA1786990@ubuntu-n2-xlarge-x86> <6922bc0b-1849-2f2f-ec2f-fe9f0124dcfc@gmail.com> <20200903005240.GA1118@Ryzen-9-3900X.localdomain> <34aa0d6094e7d6fb3492d2cda0fec8ecc04790ed.camel@suse.de> <20200908072935.GA15119@lst.de> <20200908073203.GA15176@lst.de> <20200908094345.GA20959@lst.de> User-Agent: Evolution 3.36.5 MIME-Version: 1.0 Cc: Rich Felker , "open list:SUPERH" , David Airlie , "open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS" , Hanjun Guo , "open list:REMOTE PROCESSOR REMOTEPROC SUBSYSTEM" , "open list:DRM DRIVERS FOR ALLWINNER A10" , Julien Grall , "H. Peter Anvin" , Will Deacon , Dan Williams , "open list:STAGING SUBSYSTEM" , Jean-Philippe Brucker , Florian Fainelli , Yoshinori Sato , Bartosz Golaszewski , Frank Rowand , "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" , Russell King , "open list:ACPI FOR ARM64 ACPI/arm64" , Chen-Yu Tsai , Ingo Molnar , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Alan Stern , Len Brown , Ohad Ben-Cohen , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Daniel Vetter , Mauro Carvalho Chehab , Maxime Ripard , Rob Herring , Borislav Petkov , Yong Deng , Santosh Shilimkar , Bjorn Helgaas , Nathan Chancellor , Andy Shevchenko , "moderated list:ARM PORT" , Felipe Balbi , Saravana Kannan , Greg Kroah-Hartman , "open list:USB SUBSYSTEM" , "Rafael J. Wysocki" , open list , Paul Kocialkowski , "open list:IOMMU DRIVERS" , Thomas Gleixner , Stefano Stabellini , Jim Quinlan , Sudeep Holla , "open list:ALLWINNER A10 CSI DRIVER" , Robin Murphy X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1538615944287656743==" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" --===============1538615944287656743== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-1OGRXui0587Xh/1Wx88W" --=-1OGRXui0587Xh/1Wx88W Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2020-09-08 at 11:43 +0200, Christoph Hellwig wrote: > And because I like replying to myself so much, here is a link to the > version with the arm cleanup patch applied. Unlike the previous two > attempts this has at least survived very basic sanity testing: >=20 > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-range= s.2 >=20 > Note that we'll still need to sort out the arm/keystone warnings from > the original patch. Do we have anyone on the CC list who knows that > platform a little better to figure out if the ifdef solution would work? Had to do the following to boot without errors: diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h index ef61a33c47bc..7dd88a0b6d0b 100644 --- a/include/linux/dma-direct.h +++ b/include/linux/dma-direct.h @@ -97,6 +97,9 @@ static inline bool dma_capable(struct device *dev, dma_ad= dr_t addr, size_t size, { dma_addr_t end =3D addr + size - 1; =20 + if (addr =3D=3D DMA_MAPPING_ERROR) + return false; + if (!dev->dma_mask) return false; =20 diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 90f1ecb6baaf..25809703a5bf 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -71,7 +71,12 @@ static gfp_t dma_direct_optimal_gfp_mask(struct device *= dev, u64 dma_mask, =20 static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t s= ize) { - return phys_to_dma_direct(dev, phys) + size - 1 <=3D + dma_addr_t dma_addr =3D phys_to_dma_direct(dev, phys); + + if (dma_addr =3D=3D DMA_MAPPING_ERROR) + return false; + + return dma_addr + size - 1 <=3D min_not_zero(dev->coherent_dma_mask, dev->bus_dma_l= imit); } Regards, Nicolas --=-1OGRXui0587Xh/1Wx88W 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/4FAl9XaRgACgkQlfZmHno8 x/5hmQf+KJxR0hNS10JTc726MNRsObKDOzjwqaR1tJerfDOL1gaY6j5AbZEYFEv8 KpIPxjeVvN6hP8IGpKk3kxohk3GEOWPUkvmEbX79/SpKW6CGVVYIqjbBM0bUGkId xxvo9IaqucXQMH5Okolzi0XwfNWpKsJMiVsJvXE4xchSsxd0MWG1qdM/VkToQl/n gSJV/O1hASL+CKekOPoU7+/qlRRnzJFpH8d/H7TnlT5nkaUyPcdMqUX4NFo/PtpQ w5j70lkemGFNmKHwUPeTZBL2C4BRohEe0MpZgTtDPIhNQ81WVQRoPuqaCqL3vsZg 45Ziy9UCeOvxaCasbOZA3ihex/Y4/Q== =yLRF -----END PGP SIGNATURE----- --=-1OGRXui0587Xh/1Wx88W-- --===============1538615944287656743== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu --===============1538615944287656743==--