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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED 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 36B1FC282D8 for ; Fri, 1 Feb 2019 15:28:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 077662086C for ; Fri, 1 Feb 2019 15:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728752AbfBAP22 (ORCPT ); Fri, 1 Feb 2019 10:28:28 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33400 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbfBAP21 (ORCPT ); Fri, 1 Feb 2019 10:28:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 202CB80D; Fri, 1 Feb 2019 07:28:27 -0800 (PST) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA5F03F71E; Fri, 1 Feb 2019 07:28:25 -0800 (PST) Subject: Re: [PATCH 04/19] dma-iommu: remove the flush_page callback To: Christoph Hellwig Cc: Joerg Roedel , Catalin Marinas , Will Deacon , Tom Lendacky , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20190114094159.27326-1-hch@lst.de> <20190114094159.27326-5-hch@lst.de> From: Robin Murphy Message-ID: <591d0c09-6361-fa28-06e5-faa98e60bcee@arm.com> Date: Fri, 1 Feb 2019 15:28:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190114094159.27326-5-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/01/2019 09:41, Christoph Hellwig wrote: > We now have a arch_dma_prep_coherent architecture hook that is used > for the generic DMA remap allocator, and we should use the same > interface for the dma-iommu code. Agreed - I'd definitely ack a version of this change which didn't depend on patch #3 ;) Robin. > Signed-off-by: Christoph Hellwig > --- > arch/arm64/mm/dma-mapping.c | 8 +------- > drivers/iommu/dma-iommu.c | 14 ++++---------- > include/linux/dma-iommu.h | 3 +-- > 3 files changed, 6 insertions(+), 19 deletions(-) > > diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c > index fb0908456a1f..75fe7273a1e4 100644 > --- a/arch/arm64/mm/dma-mapping.c > +++ b/arch/arm64/mm/dma-mapping.c > @@ -104,12 +104,6 @@ arch_initcall(arm64_dma_init); > #include > #include > > -/* Thankfully, all cache ops are by VA so we can ignore phys here */ > -static void flush_page(struct device *dev, const void *virt, phys_addr_t phys) > -{ > - __dma_flush_area(virt, PAGE_SIZE); > -} > - > static void *__iommu_alloc_attrs(struct device *dev, size_t size, > dma_addr_t *handle, gfp_t gfp, > unsigned long attrs) > @@ -186,7 +180,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, > struct page **pages; > > pages = iommu_dma_alloc(dev, iosize, gfp, attrs, ioprot, > - handle, flush_page); > + handle); > if (!pages) > return NULL; > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 4f5546a103d8..d6a437385b26 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -533,8 +534,6 @@ void iommu_dma_free(struct device *dev, struct page **pages, size_t size, > * @attrs: DMA attributes for this allocation > * @prot: IOMMU mapping flags > * @handle: Out argument for allocated DMA handle > - * @flush_page: Arch callback which must ensure PAGE_SIZE bytes from the > - * given VA/PA are visible to the given non-coherent device. > * > * If @size is less than PAGE_SIZE, then a full CPU page will be allocated, > * but an IOMMU which supports smaller pages might not map the whole thing. > @@ -543,8 +542,7 @@ void iommu_dma_free(struct device *dev, struct page **pages, size_t size, > * or NULL on failure. > */ > struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, > - unsigned long attrs, int prot, dma_addr_t *handle, > - void (*flush_page)(struct device *, const void *, phys_addr_t)) > + unsigned long attrs, int prot, dma_addr_t *handle) > { > struct iommu_domain *domain = iommu_get_dma_domain(dev); > struct iommu_dma_cookie *cookie = domain->iova_cookie; > @@ -580,12 +578,8 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, > for (i = 0; i < count; i++) { > phys_addr_t phys = page_to_phys(pages[i]); > > - if (!(prot & IOMMU_CACHE)) { > - void *vaddr = kmap_atomic(pages[i]); > - > - flush_page(dev, vaddr, phys); > - kunmap_atomic(vaddr); > - } > + if (!(prot & IOMMU_CACHE)) > + arch_dma_prep_coherent(pages[i], PAGE_SIZE); > > if (iommu_map(domain, iova + mapped, phys, PAGE_SIZE, prot)) > goto out_unmap; > diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h > index 65aa888c2768..59e606f78626 100644 > --- a/include/linux/dma-iommu.h > +++ b/include/linux/dma-iommu.h > @@ -43,8 +43,7 @@ int dma_info_to_prot(enum dma_data_direction dir, bool coherent, > * the arch code to take care of attributes and cache maintenance > */ > struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, > - unsigned long attrs, int prot, dma_addr_t *handle, > - void (*flush_page)(struct device *, const void *, phys_addr_t)); > + unsigned long attrs, int prot, dma_addr_t *handle); > void iommu_dma_free(struct device *dev, struct page **pages, size_t size, > dma_addr_t *handle); > >