From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v2 RFC/RFT 1/5] ARM: dma-mapping: Add fallback normal page allocations Date: Wed, 24 Apr 2019 17:06:38 +0200 Message-ID: <20190424150638.GA22191@lst.de> References: <20190326230131.16275-1-nicoleotsuka@gmail.com> <20190326230131.16275-2-nicoleotsuka@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190326230131.16275-2-nicoleotsuka@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: Nicolin Chen Cc: hch@lst.de, robin.murphy@arm.com, vdumpa@nvidia.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, joro@8bytes.org, m.szyprowski@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, tony@atomide.com List-Id: iommu@lists.linux-foundation.org On Tue, Mar 26, 2019 at 04:01:27PM -0700, Nicolin Chen wrote: > page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); > + if (!page) > + page = alloc_pages(gfp, order); We have this fallback in most callers already. And with me adding it to the dma-iommu code in one series, and you to arm here I think we really need to take a step back and think of a better way to handle this, and the general mess that dma_alloc_from_contiguous. So what about: (1) change the dma_alloc_from_contiguous prototype to be: struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp); that is: calculate order and count internally, pass the full gfp_t and mask it internally, and drop the pointless from in the name. I'd also use the oppurtunity to forbid a NULL dev argument and opencode those uses. (2) handle the alloc_pages fallback internally. Note that we should use alloc_pages_node as we do in dma-direct. > + if (!dma_release_from_contiguous(dev, page, count)) > + __free_pages(page, get_order(size)); Same for dma_release_from_contiguous - drop the _from, pass the actual size, and handle the free_pages fallback. 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 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F3AC10F11 for ; Wed, 24 Apr 2019 15:06:58 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F23682084F for ; Wed, 24 Apr 2019 15:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F23682084F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A3D86FD5; Wed, 24 Apr 2019 15:06:57 +0000 (UTC) Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C526CFD2 for ; Wed, 24 Apr 2019 15:06:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from newverein.lst.de (verein.lst.de [213.95.11.211]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 60E1A74A for ; Wed, 24 Apr 2019 15:06:56 +0000 (UTC) Received: by newverein.lst.de (Postfix, from userid 2407) id EB16368AA6; Wed, 24 Apr 2019 17:06:38 +0200 (CEST) Date: Wed, 24 Apr 2019 17:06:38 +0200 From: Christoph Hellwig To: Nicolin Chen Subject: Re: [PATCH v2 RFC/RFT 1/5] ARM: dma-mapping: Add fallback normal page allocations Message-ID: <20190424150638.GA22191@lst.de> References: <20190326230131.16275-1-nicoleotsuka@gmail.com> <20190326230131.16275-2-nicoleotsuka@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190326230131.16275-2-nicoleotsuka@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: tony@atomide.com, catalin.marinas@arm.com, will.deacon@arm.com, linux@armlinux.org.uk, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, hch@lst.de, linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Sender: iommu-bounces@lists.linux-foundation.org Errors-To: iommu-bounces@lists.linux-foundation.org Message-ID: <20190424150638.co2Zxx1E1yPoejiRENyPjD7E-XEbAj8tfeARNGA4IJw@z> On Tue, Mar 26, 2019 at 04:01:27PM -0700, Nicolin Chen wrote: > page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); > + if (!page) > + page = alloc_pages(gfp, order); We have this fallback in most callers already. And with me adding it to the dma-iommu code in one series, and you to arm here I think we really need to take a step back and think of a better way to handle this, and the general mess that dma_alloc_from_contiguous. So what about: (1) change the dma_alloc_from_contiguous prototype to be: struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp); that is: calculate order and count internally, pass the full gfp_t and mask it internally, and drop the pointless from in the name. I'd also use the oppurtunity to forbid a NULL dev argument and opencode those uses. (2) handle the alloc_pages fallback internally. Note that we should use alloc_pages_node as we do in dma-direct. > + if (!dma_release_from_contiguous(dev, page, count)) > + __free_pages(page, get_order(size)); Same for dma_release_from_contiguous - drop the _from, pass the actual size, and handle the free_pages fallback. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E674AC282E1 for ; Wed, 24 Apr 2019 15:07:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B6C112089F for ; Wed, 24 Apr 2019 15:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="smDFG1Ni" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6C112089F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TAzZTDU4bx9Pao8foIgjFOI95Hb9lL4CiT/P1ZQlLkc=; b=smDFG1Ni4ljPB4 vps8k6UjZHVZHhQPkAyaRa5jrZ44RVSSydckyOfyDOz1EgqxUZLfbOZZd/sABd+EdelwPe0fHvrq7 ICkF4Cv14/XWg9FF3V4tXMGZ7k57FYP/yVEA7Zyqbo/WkyzORQ+0cs7Yvh0MQ9PAgMRb418hO8M4H OXoYItRJHBKTKs8s9WQl9wizkapLQbF9A6hwW/EY6DnyeC3VeQI4lzW1i1FUIR35PK72QPQyMwn/w o5OGWxOLMK/kO7b964C6SD1M1JsYb/3nyMfEzK+WgcotpFGoJsgF+l2Z9evvyh+z8XZ59w4SwVSLd CLK1Rf1Rc2wTtHMTR8bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJJU9-0000E5-RO; Wed, 24 Apr 2019 15:06:57 +0000 Received: from verein.lst.de ([213.95.11.211] helo=newverein.lst.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJJU7-0000Di-QE for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2019 15:06:57 +0000 Received: by newverein.lst.de (Postfix, from userid 2407) id EB16368AA6; Wed, 24 Apr 2019 17:06:38 +0200 (CEST) Date: Wed, 24 Apr 2019 17:06:38 +0200 From: Christoph Hellwig To: Nicolin Chen Subject: Re: [PATCH v2 RFC/RFT 1/5] ARM: dma-mapping: Add fallback normal page allocations Message-ID: <20190424150638.GA22191@lst.de> References: <20190326230131.16275-1-nicoleotsuka@gmail.com> <20190326230131.16275-2-nicoleotsuka@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190326230131.16275-2-nicoleotsuka@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190424_080656_004314_4B5278D6 X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tony@atomide.com, catalin.marinas@arm.com, joro@8bytes.org, will.deacon@arm.com, linux@armlinux.org.uk, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, hch@lst.de, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 26, 2019 at 04:01:27PM -0700, Nicolin Chen wrote: > page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); > + if (!page) > + page = alloc_pages(gfp, order); We have this fallback in most callers already. And with me adding it to the dma-iommu code in one series, and you to arm here I think we really need to take a step back and think of a better way to handle this, and the general mess that dma_alloc_from_contiguous. So what about: (1) change the dma_alloc_from_contiguous prototype to be: struct page *dma_alloc_contiguous(struct device *dev, size_t size, gfp_t gfp); that is: calculate order and count internally, pass the full gfp_t and mask it internally, and drop the pointless from in the name. I'd also use the oppurtunity to forbid a NULL dev argument and opencode those uses. (2) handle the alloc_pages fallback internally. Note that we should use alloc_pages_node as we do in dma-direct. > + if (!dma_release_from_contiguous(dev, page, count)) > + __free_pages(page, get_order(size)); Same for dma_release_from_contiguous - drop the _from, pass the actual size, and handle the free_pages fallback. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel