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 E8307C433F5 for ; Wed, 23 Feb 2022 00:28:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AC448D0002; Tue, 22 Feb 2022 19:28:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 734A68D0001; Tue, 22 Feb 2022 19:28:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D6298D0002; Tue, 22 Feb 2022 19:28:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 4F1108D0001 for ; Tue, 22 Feb 2022 19:28:39 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 1E955801C6 for ; Wed, 23 Feb 2022 00:28:39 +0000 (UTC) X-FDA: 79172158758.09.9F44506 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 776FE20004 for ; Wed, 23 Feb 2022 00:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645576116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WOLDx8q1ngYrAj19wfdGLpJNSm/WPzUt/IOVhlw/tjA=; b=eBrBmLz4Z5ivtoYzYhW6SwKcjrcScX7GVb80sT9AGsuBhlDaflYNqL0pkFfpvNyCcUjpYM Fl5H3XR+L5aP6UMcLgOR5tbqbQdgNy/EiXUh1xY2Wpu6QsGOnOOHxNn2Rafq8L2TxLQyKR BD4e543anVAJJO5PEWPgunsFmBiwFkc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-3C3JWSdoPTmefmpUs0S2UQ-1; Tue, 22 Feb 2022 19:28:31 -0500 X-MC-Unique: 3C3JWSdoPTmefmpUs0S2UQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2AE81006AA7; Wed, 23 Feb 2022 00:28:26 +0000 (UTC) Received: from localhost (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AAE174EC77; Wed, 23 Feb 2022 00:28:15 +0000 (UTC) Date: Wed, 23 Feb 2022 08:28:13 +0800 From: Baoquan He To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, cl@linux.com, 42.hyeyoo@gmail.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 1/2] dma-mapping: check dma_mask for streaming mapping allocs Message-ID: References: <20220219005221.634-1-bhe@redhat.com> <20220219005221.634-22-bhe@redhat.com> <20220219071730.GG26711@lst.de> <20220220084044.GC93179@MiWiFi-R3L-srv> <20220222084530.GA6210@lst.de> <20220222131120.GB10093@lst.de> <20220222155904.GA13323@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220222155904.GA13323@lst.de> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 776FE20004 X-Stat-Signature: nzbh1zz4cgm8ct1pwdg4c7zon9qn9aik Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eBrBmLz4; spf=none (imf03.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1645576118-159973 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 02/22/22 at 04:59pm, Christoph Hellwig wrote: > On Tue, Feb 22, 2022 at 09:41:43PM +0800, Baoquan He wrote: > > For newly added streaming mapping APIs, the internal core function > > __dma_alloc_pages() should check dev->dma_mask, but not > > ev->coherent_dma_mask which is for coherent mapping. > > No, this is wrong. dev->coherent_dma_mask is and should be used here. Could you tell more why this is wrong? According to Documentation/core-api/dma-api.rst and DMA code, __dma_alloc_pages() is the core function of dma_alloc_pages()/dma_alloc_noncoherent() which are obviously streaming mapping, why do we need to check dev->coherent_dma_mask here? Because dev->coherent_dma_mask is the subset of dev->dma_mask, it's safer to use dev->coherent_dma_mask in these places? This is confusing, I talked to Hyeonggon in private mail, he has the same feeling. > > > > > > > Meanwhile, just filter out gfp flags if they are any of > > __GFP_DMA, __GFP_DMA32 and __GFP_HIGHMEM, but not fail it. This change > > makes it consistent with coherent mapping allocs. > > This is wrong as well. We want to eventually fail dma_alloc_coherent > for these, too. It just needs more work. >