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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77D9DC77B73 for ; Tue, 30 May 2023 13:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n9HfqaMDUn+/3nS3qiTQaKi+4cdz1SayLpkJxsLc630=; b=y1+KiRdNWE04M2 2nCfy6K8e/i/01y41h9wQ0hU2HTwxL8RkBCofez8P8hBEBt7APV4izPmVC68PBodAGinvlukNj5NB 8xsRZckS5ZB20BshweWHZyDLb5vGE8vhGy7XthIkwqw/MdVEqNt63rl5hyHP4MrVLsBvFuHb/cu7o Lm+Zv0Meek4yBhjp7EdZnrDFiIHN7KwwvDKCME4NJFJgpIImUPcPye+EB2SYC1dah9T5kGKtZP3vN zAf0sg77yYlbKaLHgZ1FPBkfejdyfouidYrxJKSW7kgbFVmb5p31iyP5/+dapmAWZsiuuSYRYPYX+ lmzmH3AyQliCqcUgYHmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3yyr-00Dy7r-2n; Tue, 30 May 2023 13:01:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3yyp-00Dy7D-20 for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 13:01:40 +0000 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_060139_708375_B9F5BAF4 X-CRM114-Status: GOOD ( 16.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel