Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752110AbaJYS6t (ORCPT ); Sat, 25 Oct 2014 14:58:49 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:37318 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbaJYS6s (ORCPT ); Sat, 25 Oct 2014 14:58:48 -0400 X-IronPort-AV: E=Sophos;i="5.04,786,1406592000"; d="scan'208";a="186159032" Date: Sat, 25 Oct 2014 14:29:07 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Stefano Stabellini CC: Catalin Marinas , Will Deacon , "xen-devel@lists.xensource.com" , "konrad.wilk@oracle.com" , "Ian.Campbell@citrix.com" , "david.vrabel@citrix.com" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux@arm.linux.org.uk" Subject: Re: [PATCH v4 3/7] [RFC] arm/arm64: introduce is_dma_coherent In-Reply-To: Message-ID: References: <1412941908-5850-3-git-send-email-stefano.stabellini@eu.citrix.com> <20141010120702.GI7755@arm.com> <20141013125725.GA19156@arm.com> <20141024104746.GC1955@localhost> <20141024154353.GE20534@e104818-lin.cambridge.arm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Oct 2014, Stefano Stabellini wrote: > On Fri, 24 Oct 2014, Stefano Stabellini wrote: > > On Fri, 24 Oct 2014, Catalin Marinas wrote: > > > > However given the timing constraints I hope you would be OK with the > > > > suboptimal solution for now and create a common is_dma_coherent function > > > > in 3.19? > > > > > > If you want to push something for 3.18, you could have a temporary > > > solution but I would prefer a bool or something in the dev_archdata > > > structure. Another untested patch: > > > > > > diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h > > > index cf98b362094b..243ef256b8c9 100644 > > > --- a/arch/arm64/include/asm/device.h > > > +++ b/arch/arm64/include/asm/device.h > > > @@ -21,6 +21,7 @@ struct dev_archdata { > > > #ifdef CONFIG_IOMMU_API > > > void *iommu; /* private IOMMU data */ > > > #endif > > > + bool dma_coherent; > > > }; > > > > > > struct pdev_archdata { > > > diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h > > > index adeae3f6f0fc..b6bc4c268878 100644 > > > --- a/arch/arm64/include/asm/dma-mapping.h > > > +++ b/arch/arm64/include/asm/dma-mapping.h > > > @@ -54,11 +54,17 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) > > > > > > static inline int set_arch_dma_coherent_ops(struct device *dev) > > > { > > > + dev->dev_archdata.dma_coherent = true; > > > set_dma_ops(dev, &coherent_swiotlb_dma_ops); > > > return 0; > > > } > > > #define set_arch_dma_coherent_ops set_arch_dma_coherent_ops > > > > > > +static inline int is_device_dma_coherent(struct device *dev) > > > +{ > > > + return dev->dev_archdata.dma_coherent; > > > +} > > > + > > > #include > > > > > > static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) > > > > > > > > > This way you don't have to test for swiotlb vs iommu ops (we don't have > > > the latter yet on arm64 but they are coming). Your suggestions and looking more at the code gave me another idea, that I think is clean and at the same time suitable for 3.18. What do you think of the following? It is simple, self-contained and doesn't need a new flag in struct device. diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c index 6153d61..2b259f1 100644 --- a/arch/arm/xen/mm32.c +++ b/arch/arm/xen/mm32.c @@ -2,10 +2,16 @@ #include #include #include +#include #include +static inline bool is_dma_coherent(struct device *dev) +{ + return of_dma_is_coherent(dev->of_node); +} + /* functions called by SWIOTLB */ static void dma_cache_maint(dma_addr_t handle, unsigned long offset, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/