Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1695726rdh; Tue, 26 Sep 2023 00:03:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOJ/dikztBvd45TPzPCP2mz9fMHYLEqJVLyAWSyx74BuoG6JlDdEh8R5J9aHNp/u3RqKF2 X-Received: by 2002:a25:86d1:0:b0:d15:7402:f7cd with SMTP id y17-20020a2586d1000000b00d157402f7cdmr9037862ybm.27.1695711828093; Tue, 26 Sep 2023 00:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695711828; cv=none; d=google.com; s=arc-20160816; b=B05QANa7bV9cRXOPze41ysm5Wr5m09dGfCKHLlTOvYcZrGX1hU3oZcjXiOj/GPHXGs HZJaj7+8fcNw1JcITa6Y3a+YQPJ3/2pg9JupheqIXbtRYXIOOUfl0oLAwPIP5Dr7Fel/ oW3OkLYyhvZyv1dBDH7qbOcUWAr6ocqiWDCAQVEW4jHbSJoM2T4srscSk62hdZ4tLdwn JkSEc0dz74W/Zqd5KHgkenteRT43K96tSrnN8WpPcPcay+rxMCo8OTuHp4Iybk7z1gYI 48GgWXimRgcos4jquIktNk7RKgR/5A55kvEzLw4qyQWQ3RpAurLsolKL9GraOwQ9yAGH egXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IJTHNYks+rgL0elrz9cllGWQ+woT607xV4a3XMz6cy4=; fh=n5ub27sOw/O4u6BVw7wxluNhM9xF2UhURxD8v78graw=; b=lgP7TDT5aXQe+MiW5Vi5bXk7FU/aAS8tZ3RRwS+corDmP2+oDMEschBLUXjoQemaUq cpXyo/vnIOJFzCkcuWAXNusiFQTE2bQMMg4n2TOeI6/fs4PY1PVAiDXIm1//MNHuDjyp J6Nr7e4kEsileU0umNTLeHV9KQbOS92l1bGgkVOOZRRLbtSSekUz/eN4EPCqw5oc6Rr5 YzrEda27Yw68bWymbE7aKeC+cylxj8KUJfgFaczD6tjJDJQE+plG/x+OJ9sq6S2mYDI6 AYc9mFHhQ68ol7wKpqMUQPZKkqR2BcJpBz6VVNGsuqpIcuCcduN7Nrdy3gxeg+8okVXz 2Q3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x7-20020a634847000000b0056c297d163csi11767664pgk.530.2023.09.26.00.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 711BB8065817; Mon, 25 Sep 2023 23:51:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbjIZGvB (ORCPT + 99 others); Tue, 26 Sep 2023 02:51:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjIZGvA (ORCPT ); Tue, 26 Sep 2023 02:51:00 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E01FE6; Mon, 25 Sep 2023 23:50:54 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 2588267373; Tue, 26 Sep 2023 08:50:50 +0200 (CEST) Date: Tue, 26 Sep 2023 08:50:49 +0200 From: Christoph Hellwig To: Tomasz Figa Cc: Fang Hui , Christoph Hellwig , Robin Murphy , m.szyprowski@samsung.com, mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, anle.pan@nxp.com, xuegang.liu@nxp.com Subject: Re: [PATCH] MA-21654 Use dma_alloc_pages in vb2_dma_sg_alloc_compacted Message-ID: <20230926065049.GA5606@lst.de> References: <20230914145812.12851-1-hui.fang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 23:51:00 -0700 (PDT) On Wed, Sep 20, 2023 at 04:41:08PM +0900, Tomasz Figa wrote: > On Thu, Sep 14, 2023 at 4:41 PM Fang Hui wrote: > > > > On system with "CONFIG_ZONE_DMA32=y", if the allocated physical address is > > First of all, thanks a lot for the patch! Please check my review comments below. > > Is CONFIG_ZONE_DMA32 really the factor that triggers the problem? My > understanding was that the problem was that the hardware has 32-bit > DMA, but the system has physical memory at addresses beyond the first > 4G. You should NEVER disable CONFIG_ZONE_DMA32 for a system that has memory > 4GB. I've made this point repeatedly, but the ARM64 maintainers insist on making it configurable instead of selecting it like most other 64-bit architetures that aren't guaranteed to always use a IOMMU. We need to stop that. > Hmm, when I was proposing dma_alloc_pages(), I missed that it returns > a DMA handle. That on its own can be handled by saving the returned > handles somewhere in struct vb2_dma_sg_buf, but there is a bigger > problem - the function would actually create a mapping if the DMA > device requires some mapping management (e.g. is behind an IOMMU), > which is undesirable, because we create the mapping ourselves below > anyway... > > @Christoph Hellwig @Robin Murphy I need your thoughts on this as > well. Would it make sense to have a variant of dma_alloc_pages() that > only allocates the pages, but doesn't perform the mapping? (Or a flag > that tells the implementation to skip creating a mapping.) dma_map_pages needs to map the pages as part of finding out that the allocation actually works. So skipping it can't really be done. So why do you want to create your own mapping anyway?