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 60455C4332F for ; Mon, 7 Nov 2022 09:46:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC2066B0071; Mon, 7 Nov 2022 04:46:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C71F66B0072; Mon, 7 Nov 2022 04:46:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B60416B0073; Mon, 7 Nov 2022 04:46:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A70A56B0071 for ; Mon, 7 Nov 2022 04:46:08 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7C3E71A0EB2 for ; Mon, 7 Nov 2022 09:46:08 +0000 (UTC) X-FDA: 80106165216.18.1D6DC30 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf25.hostedemail.com (Postfix) with ESMTP id EA67BA0007 for ; Mon, 7 Nov 2022 09:46:07 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id D0F8B67373; Mon, 7 Nov 2022 10:46:03 +0100 (CET) Date: Mon, 7 Nov 2022 10:46:03 +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 03/13] iommu/dma: Force bouncing of the size is not cacheline-aligned Message-ID: <20221107094603.GB6055@lst.de> References: <20221106220143.2129263-1-catalin.marinas@arm.com> <20221106220143.2129263-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221106220143.2129263-4-catalin.marinas@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667814368; a=rsa-sha256; cv=none; b=CANoTRtV7u+gfI63UAEBOu0M2yItTcT8hD1UftQ/Sfz/ET3DGyBWQtioyQE7khFFJdOeOi FJ4mMAdPB+wIsMH0cNffkg3nC5s0cF6AoCLr3wudBZhfjCyn0cl+TzCK4Yz58L4y9Lrlqb KNW/Nmu5S6ri68ThfkKpN5zP1OxgsMk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=none (imf25.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667814368; 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=D6vCOyisklg45FdZLux9LME3QuaNGcre6gWaFKWQOSs=; b=yq8RvU9VIMmuCS4RvJpRHndrN8t3DxX0P+tKmQW0rWLG0rL/KV7Be0wI9D1gn4U/TqlQc+ JbjQWhKm9NAntUew5VcZ6np18CJnYrwCVBykvHUZPteh7fEfUM8t5RwR1TXFnv+aPNoSvv N9ZhYPIq7MCSJPuxHehn0XFBfa0oLUI= X-Stat-Signature: xfnm5dyqmmbqwtzr63spfm3fhxwz6rt3 X-Rspamd-Queue-Id: EA67BA0007 Authentication-Results: imf25.hostedemail.com; dkim=none; spf=none (imf25.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1667814367-238179 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: > +static inline bool dma_sg_kmalloc_needs_bounce(struct device *dev, > + struct scatterlist *sg, int nents, > + enum dma_data_direction dir) > +{ > + struct scatterlist *s; > + int i; > + > + if (!IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) || > + dir == DMA_TO_DEVICE || dev_is_dma_coherent(dev)) > + return false; This part should be shared with dma-direct in a well documented helper. > + for_each_sg(sg, s, nents, i) { > + if (dma_kmalloc_needs_bounce(dev, s->length, dir)) > + return true; > + } And for this loop iteration I'd much prefer it to be out of line, and also not available in a global helper. But maybe someone can come up with a nice tweak to the dma-iommu code to not require the extra sglist walk anyway.