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=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 300D0C3A59F for ; Thu, 29 Aug 2019 22:48:08 +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 F0AF221874 for ; Thu, 29 Aug 2019 22:48: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="jWmcexNs"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="nByf2uix" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0AF221874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:MIME-Version:References:Message-ID: In-Reply-To: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=KbC6TAaoiPnWArnuj9EqomvHLrvlZO6t5Tq2agA0EVk=; b=jWmcexNsFb3drI 0iLAH79Y9x85PvtxJrWH1A10AO5tnC04C0wFBQ32++tPnAOCmqGecX8JX+JLSYNbsyJcKW/Bl8/Yf GXDRj6FlqpBzgzU+eiK8k8mZK0l2RFPdTheGu3MOFPhhPQUEY+NXVxzakyHWXAbdiaAr/e34eOKjn jU3UKpoaOkOD3uql/B6RoEQkXhXOvqBItx9qXZsRDWgFhOugbWH7ZOe8zLTNb8W48HpNo1exzpBMe 1v4j3r3gYjTjfu1lZrG0lDyrljcdcXwqZwNgfVSZvyeWoSZiYvIpopxhB0MytL46dRmmIW7SCBVwe cHebawCtCm0k4hCZ40UQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i3TD0-0002V5-E0; Thu, 29 Aug 2019 22:48:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i3TBu-0001Sf-GH for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2019 22:46:56 +0000 Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A007921874; Thu, 29 Aug 2019 22:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567118814; bh=5i8UCHTKfxI1RiMfkzSc2sP1EbSS0hZk+I67qfUo5Vk=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=nByf2uix/jKaDvvUZ1qwUvvrxJTXcNbZh5hDsGTEjOY4Jt22C9npxp8mXinRLNkdh Ng+zNwUuJ/ZBTQDt7J+XMvSaC6k/RUWNR4LtRYT4no+c2PpjB1n5k0rxg9rEf88n1e eJGIHBop60nSe3P/MlgsYuNqtBD9h718EzAH7onw= Date: Thu, 29 Aug 2019 15:46:53 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Christoph Hellwig Subject: Re: [PATCH 06/11] swiotlb-xen: always use dma-direct helpers to alloc coherent pages In-Reply-To: <20190826121944.515-7-hch@lst.de> Message-ID: References: <20190826121944.515-1-hch@lst.de> <20190826121944.515-7-hch@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190829_154654_683162_56F4E64B X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Stefano Stabellini , Konrad Rzeszutek Wilk , x86@kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, linux-arm-kernel@lists.infradead.org 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 + Boris, Juergen On Mon, 26 Aug 2019, Christoph Hellwig wrote: > x86 currently calls alloc_pages, but using dma-direct works as well > there, with the added benefit of using the CMA pool if available. > The biggest advantage is of course to remove a pointless bit of > architecture specific code. > > Signed-off-by: Christoph Hellwig > --- > arch/x86/include/asm/xen/page-coherent.h | 16 ---------------- > drivers/xen/swiotlb-xen.c | 7 +++---- > include/xen/arm/page-coherent.h | 12 ------------ > 3 files changed, 3 insertions(+), 32 deletions(-) > > diff --git a/arch/x86/include/asm/xen/page-coherent.h b/arch/x86/include/asm/xen/page-coherent.h > index 116777e7f387..8ee33c5edded 100644 > --- a/arch/x86/include/asm/xen/page-coherent.h > +++ b/arch/x86/include/asm/xen/page-coherent.h > @@ -5,22 +5,6 @@ > #include > #include > > -static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, > - dma_addr_t *dma_handle, gfp_t flags, > - unsigned long attrs) > -{ > - void *vstart = (void*)__get_free_pages(flags, get_order(size)); > - *dma_handle = virt_to_phys(vstart); This is where we need Boris and Juergen's opinion. From an ARM POV it looks OK. > - return vstart; > -} > - > -static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, > - void *cpu_addr, dma_addr_t dma_handle, > - unsigned long attrs) > -{ > - free_pages((unsigned long) cpu_addr, get_order(size)); > -} > - > static inline void xen_dma_map_page(struct device *hwdev, struct page *page, > dma_addr_t dev_addr, unsigned long offset, size_t size, > enum dma_data_direction dir, unsigned long attrs) { } > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > index b8808677ae1d..f9dd4cb6e4b3 100644 > --- a/drivers/xen/swiotlb-xen.c > +++ b/drivers/xen/swiotlb-xen.c > @@ -299,8 +299,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, > * address. In fact on ARM virt_to_phys only works for kernel direct > * mapped RAM memory. Also see comment below. > */ > - ret = xen_alloc_coherent_pages(hwdev, size, dma_handle, flags, attrs); > - > + ret = dma_direct_alloc(hwdev, size, dma_handle, flags, attrs); > if (!ret) > return ret; > > @@ -319,7 +318,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, > else { > if (xen_create_contiguous_region(phys, order, > fls64(dma_mask), dma_handle) != 0) { > - xen_free_coherent_pages(hwdev, size, ret, (dma_addr_t)phys, attrs); > + dma_direct_free(hwdev, size, ret, (dma_addr_t)phys, attrs); > return NULL; > } > SetPageXenRemapped(virt_to_page(ret)); > @@ -351,7 +350,7 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, > TestClearPageXenRemapped(virt_to_page(vaddr))) > xen_destroy_contiguous_region(phys, order); > > - xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs); > + dma_direct_free(hwdev, size, vaddr, (dma_addr_t)phys, attrs); > } > > /* > diff --git a/include/xen/arm/page-coherent.h b/include/xen/arm/page-coherent.h > index a840d6949a87..0e244f4fec1a 100644 > --- a/include/xen/arm/page-coherent.h > +++ b/include/xen/arm/page-coherent.h > @@ -16,18 +16,6 @@ void __xen_dma_sync_single_for_cpu(struct device *hwdev, > void __xen_dma_sync_single_for_device(struct device *hwdev, > dma_addr_t handle, size_t size, enum dma_data_direction dir); > > -static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, > - dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs) > -{ > - return dma_direct_alloc(hwdev, size, dma_handle, flags, attrs); > -} > - > -static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, > - void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs) > -{ > - dma_direct_free(hwdev, size, cpu_addr, dma_handle, attrs); > -} > - > static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, > dma_addr_t handle, size_t size, enum dma_data_direction dir) > { > -- > 2.20.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel