Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2957896ybl; Thu, 29 Aug 2019 15:48:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoCZTVcrMrb71jAwu1rXPZxykGREgLn/CKZEz+QvJyrPBnT80eOPXas+AF+YrH2wbkaqum X-Received: by 2002:a17:90a:858a:: with SMTP id m10mr12497975pjn.129.1567118894947; Thu, 29 Aug 2019 15:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567118894; cv=none; d=google.com; s=arc-20160816; b=PkoMw1cFhr7AaQ6VUzieWZPE2kwOm33G1nlgZX2oQVIi75TEjSqzBPPK0dm7QDZrB6 ZYF5yDiGOvudkjozLo+TEFJGz6o1rnvnSOG3yfqmnXewA5lXax5G8PEkFlPLPmbSmEJT J5P3lIHnXZngwT8KFZAqxZrVi0MyBZbrrbHz0fp9QRfCywD1Apr9AmBPvDv1w6Bx4OPp 1Tvx/4y1FxyFNkS1oroPB2118dcwOyft0UqRdIk8MCel+ue5uLm2tj0Ezk4V6DMZpxbp ZldHtp8tRYaOSMGf4steRvRYeFt5gXYieT/jxyaAzfmkXHBPvVOxFM/UBuQtBFX7jmKc HN/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=h4tC8iIwWPwXMsKON4nhC03HTv+nC9pjqMMpOFMJCT8=; b=ob9FYMYM8MS7ThheaCoDeuHLTKMC/vvRi9wkm2o6dlaf4euv2slEvTP5bFVkHp4v5k b388mXwbp0Gb7Kokq+x/fARVfVQSPxHfH8vTpkIyKLvjj4A2a6Sot6ei5Il+6BdWWgyW fXWAYODKMZoqtH11vAiZnOHDvNn4mFnNTOtTUhB4VhdyukYx0KBN6mxZbBjAlEwc+MZt oMKBl9L3BqjzZW4mHLK3jmapVZyR/8pFBDziQRmhcRIN5TmLnkKu8aJN8CBZBAAvs6tB bNUgNgmFgr3MSQQaKoGhpYH+iiEMFEN4wc2vsr7KZVqxR7YuaoJEvq71tNzPHCmVsBJ6 4Jvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nByf2uix; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si4275647pfp.253.2019.08.29.15.47.59; Thu, 29 Aug 2019 15:48:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nByf2uix; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728512AbfH2Wqz (ORCPT + 99 others); Thu, 29 Aug 2019 18:46:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:59966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbfH2Wqz (ORCPT ); Thu, 29 Aug 2019 18:46:55 -0400 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 cc: Stefano Stabellini , Konrad Rzeszutek Wilk , x86@kernel.org, linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com 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 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 >