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 B706CC77B73 for ; Tue, 30 May 2023 13:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EF3F6B0072; Tue, 30 May 2023 09:02:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 476C7900003; Tue, 30 May 2023 09:02:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F0CC900002; Tue, 30 May 2023 09:02:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 205A56B0072 for ; Tue, 30 May 2023 09:02:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C00EA1A024A for ; Tue, 30 May 2023 13:02:37 +0000 (UTC) X-FDA: 80846935554.19.79B97E1 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id CB84E2020F for ; Tue, 30 May 2023 13:01:39 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685451703; 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=tS47haEmDCU3DO3j1ZKMYNv/RSNNWXK09RdUV5ZojI8=; b=4AfT/U2+zf4BLmqzETfnsw4lxYMmpC4thibWIFDPTJx9XlpmZaRAQc2Li9YvljvbY8Pq/u 0YESO0BqqSqeJvhi++hBizdSPcC43m3M8AyY+afpJrLb6ZHD7SRz1n94/H4KEZNlkU4vOf c1JY75nsUM2yRQJ/3pyCFyPOb+1dbbM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.hostedemail.com: domain of robin.murphy@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=robin.murphy@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685451703; a=rsa-sha256; cv=none; b=I9l3p5zF/kqkKaJ+oN5sjoaFVneElz6opY3fIp5EWkaWZH3K+6IzSK4PDbTR232Lyrf0Ul 33Q065JBC2B1jmSkoB0Nj9P9zoKBsN8eTH7ncaujciwHzbgCJW23Va0IwjPUCn7FPSNDZ3 PsTGQLvnXD/OApT4i6VE3+zocl5v0Fo= 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 96CC7AB6; Tue, 30 May 2023 06:02:23 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB7A43F67D; Tue, 30 May 2023 06:01:35 -0700 (PDT) Message-ID: Date: Tue, 30 May 2023 14:01:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v5 13/15] iommu/dma: Force bouncing if the size is not cacheline-aligned To: Catalin Marinas , Jisheng Zhang Cc: Linus Torvalds , Christoph Hellwig , 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" , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org References: <20230524171904.3967031-1-catalin.marinas@arm.com> <20230524171904.3967031-14-catalin.marinas@arm.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: udctay5dmwdngegi3hu4nxefqtgfuoxi X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CB84E2020F X-HE-Tag: 1685451699-832837 X-HE-Meta: U2FsdGVkX19tJGsyvKRgob+Kvj9RL/I7hdHDiJcZXTRFOnho7DEPnDcF6evlJqLdxmYuGp6P+hha7iujJWmZFo69Skye3+s7Eszv7JtECe0DIi6noNas+tHvxLdVvJ/EH3t/IsgAvwmWPDCGAnyE8nIhqgnABldq65uADGS+Bu0HqCLDo/DoeyblTFjgazp1/DrLRYRihdgUkc5xGc391C6jLnK9rnsLMmfANF2bT6+BGm/dizM7574SpBccf7IBKdhw1w67c827/LAim6oGEa6lcrapg1+Sj0lEYriJ5wk/qwMS1ZB1P/4zqWkgrm2KUwUff/2gKK0hLfoQlUhsZ2QPkv+vFWGxHyrHzhr4LH3BtV05p60SZfKDYAU3O32Ys7OM7Hpym0kszV54hLaAs71RdSFkEhGA8uM5m327eveF/SGpohXa/rQ/GTpBij/bt1i+IPtXIQLVSXOfzzbueyOP3WWn7B9tLMvMxDAyMsXUuRMI5dgbPP07zJvgvTF2sMBLl+PqKCtxjdZu+rUUnWOKprQ/wyGXTGnOu1PMIteQ3AzDX0x26KTt+Ctluwa3Etdz1EKHneruwrtJsAZaurEaHesn8m6OOxcO6WkEyVOJt7cOIGByx4/pPBPH99hNLp+kqcIXUiTLMucjpbBRJhUOj1SIvFENvgn1/1lmMbAs8ZJtc3sEtfR02deALvjse9VNKn2UlYehfy/ZJzCh4qRnWI1SDHXakok/5X6+qa3at7Fe0W2gMvwLFtV81Ya2JRRAAyXrTyV4aMt1nxKtO7U9uboTOekE2ygjjXFEfvK6XgDRW9GUMLdLdcV9+3fUOxRqLRzGTWjP35+kCZAQwsqMYyhcQT22CmVJM2X9S889pG53WkPfxkVMsvVjLCMVzFYdxoLE3Z/otxZ75QsyThQAwhhLFkf/bQ/iS7pWGUxMYcjNYewcAplItaOOCsDpSrKvFNI9kwbsilSmao6 dDJC9NFR OkfM6QsvndksoVprBME3S1Ly9h/Aju3m/jhxkwzhXACgC7unpdlfyarNYr49eWhaO+N0c2eaR7SUPGRYqyJZnX7vg6SrdFe8ix/MaT3JLs3iUuVU= 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 26/05/2023 8:22 pm, Catalin Marinas wrote: > On Sat, May 27, 2023 at 12:36:30AM +0800, Jisheng Zhang wrote: >> On Wed, May 24, 2023 at 06:19:02PM +0100, Catalin Marinas wrote: >>> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h >>> index 87aaf8b5cdb4..330a157c5501 100644 >>> --- a/include/linux/scatterlist.h >>> +++ b/include/linux/scatterlist.h >>> @@ -248,6 +248,29 @@ static inline void sg_unmark_end(struct scatterlist *sg) >>> sg->page_link &= ~SG_END; >>> } >>> >>> +#define SG_DMA_BUS_ADDRESS (1 << 0) >>> +#define SG_DMA_USE_SWIOTLB (1 << 1) >>> + >>> +#ifdef CONFIG_SWIOTLB >> >> s/CONFIG_SWIOTLB/CONFIG_NEED_SG_DMA_FLAGS ? >> Otherwise, there's compiler error if SWIOTLB=y but IOMMU=n > > Yes, I pushed a fixup to the kmalloc-minalign branch. I'd agree that CONFIG_NEED_SG_DMA_FLAGS is the better option. >>> +static inline bool sg_is_dma_use_swiotlb(struct scatterlist *sg) >>> +{ >>> + return sg->dma_flags & SG_DMA_USE_SWIOTLB; >>> +} >>> + >>> +static inline void sg_dma_mark_use_swiotlb(struct scatterlist *sg) >>> +{ >>> + sg->dma_flags |= SG_DMA_USE_SWIOTLB; >>> +} >>> +#else >>> +static inline bool sg_is_dma_use_swiotlb(struct scatterlist *sg) >>> +{ >>> + return false; >>> +} >>> +static inline void sg_dma_mark_use_swiotlb(struct scatterlist *sg) >>> +{ >>> +} >>> +#endif > > And I wonder whether we should keep these accessors in the scatterlist.h > file. They are only used by the dma-iommu.c code. Nah, logically they belong with the definition of the flag itself, which certainly should be here. Also once this does land, dma-direct and possibly others will be able to take advantage if it too (as a small win over repeating the is_swiotlb_buffer() check a lot). Thanks, Robin.