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 14093C433EF for ; Sat, 19 Feb 2022 11:18:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E4076B0074; Sat, 19 Feb 2022 06:18:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 993FC6B0075; Sat, 19 Feb 2022 06:18:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 835FC6B0078; Sat, 19 Feb 2022 06:18:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id 740496B0074 for ; Sat, 19 Feb 2022 06:18:33 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2B4F418163929 for ; Sat, 19 Feb 2022 11:18:33 +0000 (UTC) X-FDA: 79159281306.24.B8688EC Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf12.hostedemail.com (Postfix) with ESMTP id C94B540009 for ; Sat, 19 Feb 2022 11:18:32 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id y11so4456241pfi.11 for ; Sat, 19 Feb 2022 03:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T9wL2HNOoTgBZyR7LnzekNWG1kIrAc5CB3FyMF90in4=; b=AKr/HZtB3nquxX/MtfbxTPxV12bTXOYvn238/PxnW0MXFPvwUMuvQm4pSP2ByR4afp 7CRauKL6AyW537CotJWum8uw+2DBwxh4qfpI3VJiasOdQ5vQkfjRksY1TdFYiT2Y8GIK rFRwatWTqK3t/5sVFaAFX5oQNyf0CNvBXAsN9kSosKZaUkl0a5nNH8t2UvnT84Y8xQGm v6eaNilBb2nDcNkPir3151J48dq4KTWHlCWpy2pWtzQU2A8HR+ALSLt5NbaD7Ol2vhBp UWTjX1b64stJNYWfl3sYgLdfsymPU3IIPFIkdfDtdPyi4+6CT10rN0Ov+HrZ1Bsg5w9U om4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=T9wL2HNOoTgBZyR7LnzekNWG1kIrAc5CB3FyMF90in4=; b=xeoWShQIk/yrMoZBpJhVDjsbJquhc396AKF51snk8S4IdTGOhGMs6yFICFxUtD2Tae +y9RtAs/2n3tnxwczEm7lHFmFJ6UPe0rWqLXMQVpvoy9ojorfFBrkl7veodJAIxYqv2p nh5si1T6vLOJpKkkvY4wgAW4QZ3XGRMGFQy/xW+825mF2E8B2O1Cj2LVQ31nqe3Lrn+7 toKdr0tHRjMwpMN8YmpsZ/oPqcnIjvwV2+BGKGSzPhwzW0rwiii8SR+Gb1nmFX8UZmp1 sei49Mkp9YITLLR5sdOjty3lwFZtpS6I+EV2qu84FOtZWk6AVNIdCu3nFpCNedcHZK9z SqiQ== X-Gm-Message-State: AOAM533eG41uPJtYGCHoAorojOgvGEy5Imt77ku9IWezpdftsLV9tIY+ yxRb0zT8paAP0tl9TAeUpRQ= X-Google-Smtp-Source: ABdhPJzJHg6MUMNmql+V4RRtwfXePN6ptFHUaPpMP1plEFbEbnlYUEQw7bbCjNbrsib/NZlMXZNZZA== X-Received: by 2002:a05:6a00:1995:b0:4e1:a7dd:96d6 with SMTP id d21-20020a056a00199500b004e1a7dd96d6mr11666406pfl.16.1645269511646; Sat, 19 Feb 2022 03:18:31 -0800 (PST) Received: from ip-172-31-19-208.ap-northeast-1.compute.internal (ec2-18-181-137-102.ap-northeast-1.compute.amazonaws.com. [18.181.137.102]) by smtp.gmail.com with ESMTPSA id y191sm6523542pfb.78.2022.02.19.03.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 03:18:31 -0800 (PST) Date: Sat, 19 Feb 2022 11:18:24 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Hellwig Cc: Baoquan He , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, David.Laight@aculab.com, david@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, steffen.klassert@secunet.com, netdev@vger.kernel.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, linux-s390@vger.kernel.org, michael@walle.cc, linux-i2c@vger.kernel.org, wsa@kernel.org Subject: Re: [PATCH 22/22] mtd: rawnand: Use dma_alloc_noncoherent() for dma buffer Message-ID: References: <20220219005221.634-1-bhe@redhat.com> <20220219005221.634-23-bhe@redhat.com> <20220219071900.GH26711@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220219071900.GH26711@lst.de> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C94B540009 X-Stat-Signature: nayzumgzmcyanmywppa1c4oe5fwri8x1 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="AKr/HZtB"; spf=pass (imf12.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1645269512-340269 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, Feb 19, 2022 at 08:19:00AM +0100, Christoph Hellwig wrote: > On Sat, Feb 19, 2022 at 08:52:21AM +0800, Baoquan He wrote: > > Use dma_alloc_noncoherent() instead of directly allocating buffer > > from kmalloc with GFP_DMA. DMA API will try to allocate buffer > > depending on devices addressing limitation. > > I think it would be better to still allocate the buffer at allocation > time and then just transfer ownership using dma_sync_single* in the I/O > path to avoid the GFP_ATOMIC allocation. This driver allocates the buffer at initialization step and maps the buffer for DMA_TO_DEVICE and DMA_FROM_DEVICE when processing IO. But after making this driver to use dma_alloc_noncoherent(), remapping dma_alloc_noncoherent()-ed buffer is strange So I just made it to allocate the buffer in IO path. At this point I thought we need an API that allocates based on address bit mask (like dma_alloc_noncoherent()), which does not maps buffer into dma address. __get_free_pages/kmalloc(GFP_DMA) has been so confusing.. Hmm.. for this specific case, What about allocating two buffers for DMA_TO_DEVICE and DMA_FROM_DEVICE at initialization time? Thanks, Hyeonggon