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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B2BC7EE2E for ; Fri, 9 Jun 2023 11:52:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC58C8E0002; Fri, 9 Jun 2023 07:52:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C75C78E0001; Fri, 9 Jun 2023 07:52:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B657B8E0002; Fri, 9 Jun 2023 07:52:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A755F8E0001 for ; Fri, 9 Jun 2023 07:52:38 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6F4BE1C7620 for ; Fri, 9 Jun 2023 11:52:38 +0000 (UTC) X-FDA: 80883047196.15.8B66776 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 4B41B4000F for ; Fri, 9 Jun 2023 11:52:36 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686311556; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2A/SeqNLQDsT38GF9tGXSpZc7sxT0nYpGdhB5wImqBY=; b=4tpX5RfjIFCWaEqYz21CD/YEWWR5ydlJACa31W5bKabouzqaV+GwcIPQD3mrg8Y0aNZDNi OA7ow53B+NuMzArbeON0Nco8yGuYm3/nsYUIstDISkjCawNAKx1hwWSFht9EvvVRl8kkET p2swNRVti2f1DIOxO5yHDa4Y1WRdR5Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686311556; a=rsa-sha256; cv=none; b=G3w7VuY5v0naeZ+LVcwm7M656Vxi0T3PRAPfSHj5i/D73LKUEWrmQKBH/hl92VLB2SheKf QvLvJX8udxCOdm5BJFxFZndc6hx0dXP9xFOPO5Z20Szd0QepnjaHt4Gx48fgetais+BQCE FoyEgRtMR5j1OiCl1RwmIaaj2iuorH8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 673C6AB6; Fri, 9 Jun 2023 04:53:20 -0700 (PDT) Received: from [10.57.85.120] (unknown [10.57.85.120]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB14A3F587; Fri, 9 Jun 2023 04:52:31 -0700 (PDT) Message-ID: <5438a21b-fcd8-0175-1fdd-ce6afbf84d86@arm.com> Date: Fri, 9 Jun 2023 12:52:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v6 15/17] iommu/dma: Force bouncing if the size is not cacheline-aligned To: Catalin Marinas , Linus Torvalds , Christoph Hellwig Cc: Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org References: <20230531154836.1366225-1-catalin.marinas@arm.com> <20230531154836.1366225-16-catalin.marinas@arm.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: <20230531154836.1366225-16-catalin.marinas@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4B41B4000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: d46tig6a5bckstgcu9pnqgahpgdicm3n X-HE-Tag: 1686311556-247880 X-HE-Meta: U2FsdGVkX1+cbs+H1OFBpXKoGTiaVBDqiVNYRWS+77RAKJCqzOZ9pWQh0JckQ6YAGhqRHWGnW0jpE1MAEkQuOJ4pe2QHY4n5ZDTR8JWiHSP6wcIQ8kUvyAb+3SnV87m3PehineaZzND0AumYn+WTqwZOY2X4W8sT9E4VHTebhniQ48dfHHBykpsN83wVfQD/SX5R85dGLR8Jayqbus/XC0flJjxSdftA0YFGoHpdYpxbR7OosNRiGRm1At7FH5Ku8lyAVqpcZ77vM8zcAbo7/M2SXi3xs/oIjsUr/ExaHxaf/AcXS1PA0J5NIAHWeoSQ6Wv+Z09qQeUT7CXwKimlk+v+R8OeLqLJVEWLFX4rIRciG0XEJg//TkJKj93ru0rxY+d6NjYzyKPggIImI6SkTpjFg/NQfPIJVTjhZZOu8ksMyTc2U/qQ7mVfpqPfUEtX/8K798VkRokvY1AAqgKeOoLe1244xzKYbVG4ovXPm37swLblzDBvycEr6TiMN6wCaeOViPN9ZAoRkIMuh23JvOn2wyc1TEWAJsJwSfqhAxdCjlKXMNnd/AjIfBqw5pWi/eEaauf5kndlf/BusGiLBTdjM29ocsHm5Ial6fQ739+JQ6ssFbpEnEOIQoq7ZDfPe4g9B5jVqmEHvbCtM/iFg/PxDfygJLU2OJ+LzTHQ0HjWMW2C8UIjjt2gtMnoB+lfxpXZbLqpNrwTGlOvOQH37xdtjXwePVSyRbmesenBzH/Qnv2K1p9YjMB4TGOES333LDhzXjx9NNF7bgb3rQvJIVsZbh62q5pFrTkW5T2ZzbdSQ54zuqX/TegTpyO9zGQIPgq1f6ddifvlcSA+nDXvn1igStxI8LajEPLohKlEcmz9M23i/4rGOIiAhkLNtzLRexWY6FBDUbsW3uCagOOqnVSl5snJmeT13fNoWbvQV0XeYpaO33cjnp6rfDLPC2tkY1XhZUlw3of0vv+T4Ir hPpwFEfg 8W3u+L6MlW4YcsLDdCE4QfUHiKwZfcF5rEt8bAmP5leWvAmi+C2Q8+EcQXiWN4jY2cZO2LFas+F5+/UncZHDML2Ru912qNpBgtdqP5Wm2xajo3Kg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2023-05-31 16:48, Catalin Marinas wrote: [...] > diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h > index 2f06178996ba..69d87e312263 100644 > --- a/include/linux/scatterlist.h > +++ b/include/linux/scatterlist.h > @@ -251,11 +251,13 @@ static inline void sg_unmark_end(struct scatterlist *sg) > /* > * One 64-bit architectures there is a 4-byte padding in struct scatterlist > * (assuming also CONFIG_NEED_SG_DMA_LENGTH is set). Use this padding for DMA > - * flags bits to indicate when a specific dma address is a bus address. > + * flags bits to indicate when a specific dma address is a bus address or the > + * buffer may have been bounced via SWIOTLB. > */ > #ifdef CONFIG_NEED_SG_DMA_FLAGS > > -#define SG_DMA_BUS_ADDRESS (1 << 0) > +#define SG_DMA_BUS_ADDRESS (1 << 0) > +#define SG_DMA_SWIOTLB (1 << 1) > > /** > * sg_dma_is_bus_address - Return whether a given segment was marked > @@ -298,6 +300,34 @@ static inline void sg_dma_unmark_bus_address(struct scatterlist *sg) > sg->dma_flags &= ~SG_DMA_BUS_ADDRESS; > } > > +/** > + * sg_dma_use_swiotlb - Return whether the scatterlist was marked for SWIOTLB > + * bouncing > + * @sg: SG entry > + * > + * Description: > + * Returns true if the scatterlist was marked for SWIOTLB bouncing. Not all > + * elements may have been bounced, so the caller would have to check > + * individual SG entries with is_swiotlb_buffer(). > + */ > +static inline bool sg_dma_use_swiotlb(struct scatterlist *sg) Nit: since you tweaked the flag name again, we could happily go back to the pattern with s/use/is/ for this one now too. > +{ > + return sg->dma_flags & SG_DMA_SWIOTLB; > +} > + > +/** > + * sg_dma_use_swiotlb - Mark the scatterlist for SWIOTLB bouncing Oops - s/use/mark/ Feel free to fix those up when applying if there's no other reason for a v7. Thanks, Robin. > + * @sg: SG entry > + * > + * Description: > + * Marks a a scatterlist for SWIOTLB bounce. Not all SG entries may be > + * bounced. > + */ > +static inline void sg_dma_mark_swiotlb(struct scatterlist *sg) > +{ > + sg->dma_flags |= SG_DMA_SWIOTLB; > +} > + > #else > > static inline bool sg_dma_is_bus_address(struct scatterlist *sg) > @@ -310,6 +340,13 @@ static inline void sg_dma_mark_bus_address(struct scatterlist *sg) > static inline void sg_dma_unmark_bus_address(struct scatterlist *sg) > { > } > +static inline bool sg_dma_use_swiotlb(struct scatterlist *sg) > +{ > + return false; > +} > +static inline void sg_dma_mark_swiotlb(struct scatterlist *sg) > +{ > +} > > #endif /* CONFIG_NEED_SG_DMA_FLAGS */ >