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 F0613C4332F for ; Mon, 7 Nov 2022 09:45:06 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FKjqtcpVcL6CruC2USgNpH0OT3QcA2TlMboK4yfISUk=; b=IOhvCD2ZLDhVBA HKAI/4FUCF8e3yb+n3NzdBRS0f+X0wFFAPwsRPLPGRhJS1kNQJxDOiLNmJEMYhvJ3QWAM6DwA7ine SQ+P004CL/QmF+aC4y8Y17MJpqv4OTk9qkyGfQZTwZWwwwr9crKTqHAk2THMfuP4lI+4vGA/kyMR8 1rbKkNRvNySv8dXDmArucgCUHwvcCX04Z8h+ZIdvVEHb/a6fJOJTGFNUYBS0DwtG9O0iiF1t15CJs rP5TqB5dZ7FczxMDku46UXMp7AyCmDQG3BXzO9wtIj+AhFr+u9qFclTEK6zt13GQ7T7Yt3G8gDlWD a/MWLRDhNbheFbqotr6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oryfk-00DRrf-F1; Mon, 07 Nov 2022 09:44:04 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oryfg-00DRqe-T7 for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 09:44:02 +0000 Received: by verein.lst.de (Postfix, from userid 2407) id E953767373; Mon, 7 Nov 2022 10:43:55 +0100 (CET) Date: Mon, 7 Nov 2022 10:43:55 +0100 From: Christoph Hellwig To: Catalin Marinas Cc: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , 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" , Robin Murphy , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 02/13] dma-mapping: Force bouncing if the kmalloc() size is not cacheline-aligned Message-ID: <20221107094355.GA6055@lst.de> References: <20221106220143.2129263-1-catalin.marinas@arm.com> <20221106220143.2129263-3-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221106220143.2129263-3-catalin.marinas@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221107_014401_107349_CDE5F75C X-CRM114-Status: GOOD ( 15.46 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org > +/* > + * Check whether the given size, assuming it is for a kmalloc()'ed object, is > + * safe for non-coherent DMA or needs bouncing. > + */ > +static inline bool dma_kmalloc_needs_bounce(struct device *dev, size_t size, > + enum dma_data_direction dir) > +{ > + /* > + * No need for bouncing if coherent DMA or the direction is > + * DMA_TO_DEVICE. > + */ > + if (!IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) || > + dir == DMA_TO_DEVICE || dev_is_dma_coherent(dev)) Minor nit, but for clarify I'd preper to split the generaly availabily checks from the direction one, i.e.: if (dev_is_dma_coherent(dev) || !IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC)) return false; if (dir == DMA_TO_DEVICE) return false; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel