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 07CD9C77B7A for ; Fri, 26 May 2023 19:22:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37CA6900004; Fri, 26 May 2023 15:22:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30581900002; Fri, 26 May 2023 15:22:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A5DC900004; Fri, 26 May 2023 15:22:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 07BE6900002 for ; Fri, 26 May 2023 15:22:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C4395120FEE for ; Fri, 26 May 2023 19:22:23 +0000 (UTC) X-FDA: 80833377366.10.4C6EF18 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 004DB1C0007 for ; Fri, 26 May 2023 19:22:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685128942; 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: in-reply-to:in-reply-to:references:references; bh=Gda0mVKi4+xa+XGnZGma0L/7snp9jS5zQw6qrTRvCbg=; b=cHVmfNy1MD3zPZkWGnCEf+oNXhaIyEEdCnOi6uzin5lwWTKkhz8QsbKBTnaBqxqWfAnbtw 8GYo5ZWyDKCgvIKyFtMsMp+v6vOOLD6Hk3vr2DdWlPQAPrCQN9+Lz7fUbT4nnLdfLUnYbB 5Y5oN4V9JwVWSu5KRNWIlA03wFpv/VE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685128942; a=rsa-sha256; cv=none; b=Mz+o81CcqxSO1H0JnnAtS57cMwt9icke35GXVV2w48HpkE1jSIegcxIwMJpyos5z9CHYnh mJ+STISX/sOc8wYYYQhOLNz2GoRmDNj8fgAgi88cexfK+jtS8vHi/TjHyqpgvoVOMyxNNW aAr2PhK6a7b+UfUVvw/+gKsUjeQU/cY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC35F652AE; Fri, 26 May 2023 19:22:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FB83C433EF; Fri, 26 May 2023 19:22:16 +0000 (UTC) Date: Fri, 26 May 2023 20:22:14 +0100 From: Catalin Marinas To: Jisheng Zhang Cc: Linus Torvalds , Christoph Hellwig , Robin Murphy , 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 Subject: Re: [PATCH v5 13/15] iommu/dma: Force bouncing if the size is not cacheline-aligned Message-ID: References: <20230524171904.3967031-1-catalin.marinas@arm.com> <20230524171904.3967031-14-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 004DB1C0007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: nksxykii8xx3d4d6s9cswp4bypjxdzzp X-HE-Tag: 1685128941-65656 X-HE-Meta: U2FsdGVkX1/dNqZBxt9DyEjxdoj54d7yWoOEK9rbyU+OwlRlkJ0VTZWo33NmOzEFNd163UdcoiDvZVfWg4kM+Taopv4M8/hxCC2KQUvzpPQYzyELDJRzXsPlPc2+MPA2V4tOmnF8izoQUzx7Ef3DAFMWnE10umrWxHBO4zqCbtnF9XSxgGShNDrg+TlZkYnT1Ppzj4YcyOvIcjTf0a/IVwTRkQtZrIZShPD89J77C5O9qSpDFB+b+eimGi8pxidK7h1GVObSqhadJGDvpDN1aVe/bjAHFWXRrk72jlFxR4Klki8LAXrycs3Fj6tllK+EwvwywGHCA6JxrCawxV8vMYqRQt6QVhDQgWB3zdXDe+u0WVSXJ4HQn88mRFkYYJxoOsBUN8bRYByzCRKx+vmhKBH05x4QpnU5iSDcPraLUM2PV1bqWwwCeK160/e9fNae+PSnVz8KaKFDpctzdVZEjn6ewV4pYLPH0aiPvNN+ORpZm9x/MPdbz5rXkZmkyekNiQGK4oUNngxyKFBQFdm1cpyaOcq4Aq8QGnj3YlSGYYKkT0YuQw9CN4P8qdSt/td6NhT9JKttWQ2/GfCTI4Stef7EGrUWGVGop8pO8o5beRwkZTZM3/18KRHapKB5kV6piskoPIX83HEWi8ea4DZiU6zAjJIlfCwHYhE19vOUyPmtbDwmZ5AfxZpWZjUCBirVtnfCtAGsL+7qoGQW6p0L8omodC6FOMieryosz4h+ib2DNhseXKewe6OO38brBw4LtHrQuQyOF69x6Vr49EtUHdRTHLI3J8ejh8CWpy1e5BPJMR7lVPpxzFxdMpg8gKv00ru6De0me+yCpRofZS9/STu1dflWHfJ8VTVjpfDiYaUUaIcks3tm/T/+58ubfY+OX0AETmNlaA9mS42CmXRuqOUr0yKOG3rOm1ht8uqGhQwP55R/1xlkcCcDScOMOV6bRqGxp317MO0+Y0pY1zB EK0g3Rbz uZG7J17CsbPGfnGW0oI4LHkckTm8Lbd96CSajv2/WmftyBTCDrpYcbXfvYSbeZSske5FBJ6Sq3YgVgwX8VNxf3pHcKvvQVXe1fDh2oBywGbLc+gfRqFX2hxCyeL1W6iHvc4yZGsYHnyms0FEeOUg/I8V0xRtLwmLEDymkHKVf2k0Zaw19zSBQWYs+5CWBEIbERs3j/NlRRk0Yol8fVZ7Rp6cGn0jPoQsoD847NGFvmZM8KEYnkwgpT/gIVIVl6TkF6R3UxLEXvxt4aGn+zuglLJmYvUNqHwlW+IDJIgvWwdxmpPGfQH7SrRGl/57rJZKrK8yg2u23uMPA3oF+Y55mQL2Im915c6/f7T4o/YOKO/aqbMzkoRHhxmKgfsSzh9bXV4F0/uANa10eUDUAL2V8RdCukBpO5Ev7nZ2V 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 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. > > +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. -- Catalin