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 B510DC433FE for ; Mon, 7 Nov 2022 09:44:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C28B6B0071; Mon, 7 Nov 2022 04:44:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 372616B0072; Mon, 7 Nov 2022 04:44:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2611D8E0001; Mon, 7 Nov 2022 04:44:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 132316B0071 for ; Mon, 7 Nov 2022 04:44:02 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C21F6A06BC for ; Mon, 7 Nov 2022 09:44:01 +0000 (UTC) X-FDA: 80106159882.24.D9876E4 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf18.hostedemail.com (Postfix) with ESMTP id 039911C0007 for ; Mon, 7 Nov 2022 09:44:00 +0000 (UTC) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221106220143.2129263-3-catalin.marinas@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667814241; 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=NSEG1lmCw84GynXzZyv6E30iWjXmivGh2xG9ONiAR+4=; b=jEiAYRVQuTBW6FIOb7aPqUwl73kk/iBzc49ZJCMbSlf9eyVgNVf9ksZVb3T2wh39MY3lm9 EZc60DPtkPrDcDumGqZnlkvAXnms2GgDG4EfUp4YQVRfHu3WgH8CRpuCtr/RFcDOFmViIy vTt4fLsVT7UkgJp4IT+ZQdAO9RZDcXs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=none (imf18.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667814241; a=rsa-sha256; cv=none; b=8g2uBhowh6otwhKxmXypQd+bpE/uihLC7w2OAu1HZfJrdlOWR/Wke0dketik1MiEgO78kl Il/oSFrYynkRzdl5kRy1la8JILFUt008XJPdHk4slznXvHRxB+gcTuUAOsxKWI1gsmB6zP dZt48rpv98tc7I06Oa4UfpCuKYtwJJ0= X-Rspamd-Queue-Id: 039911C0007 Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=none (imf18.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: 8gguri7aq4idn4y8gebpcebfzyaeqw1b X-HE-Tag: 1667814240-172186 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: > +/* > + * 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;