From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Szyprowski Subject: RE: [PATCH 3/8] ARM: dma-mapping: use asm-generic/dma-mapping-common.h Date: Mon, 27 Jun 2011 14:18:02 +0200 Message-ID: <000601cc34c4$430f91f0$c92eb5d0$%szyprowski@samsung.com> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-4-git-send-email-m.szyprowski@samsung.com> <201106241736.43576.arnd@arndb.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT Return-path: In-reply-to: <201106241736.43576.arnd@arndb.de> Content-language: pl Sender: owner-linux-mm@kvack.org To: 'Arnd Bergmann' Cc: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, 'Kyungmin Park' , 'Joerg Roedel' , 'Russell King - ARM Linux' List-Id: linux-arch.vger.kernel.org Hello, On Friday, June 24, 2011 5:37 PM Arnd Bergmann wrote: > On Monday 20 June 2011, Marek Szyprowski wrote: > > This patch modifies dma-mapping implementation on ARM architecture to > > use common dma_map_ops structure and asm-generic/dma-mapping-common.h > > helpers. > > > > Signed-off-by: Marek Szyprowski > > Signed-off-by: Kyungmin Park > > This is a good idea in general, but I have a few concerns about details: > > First of all, should we only allow using dma_map_ops on ARM, or do we > also want to support a case where these are all inlined as before? I really wonder if it is possible to have a clean implementation of dma_map_ops based and linear inlined dma-mapping framework together. Theoretically it should be possible, but it will end with a lot of #ifdef hackery which is really hard to follow and understand for anyone but the authors. > I suppose for the majority of the cases, the overhead of the indirect > function call is near-zero, compared to the overhead of the cache > management operation, so it would only make a difference for coherent > systems without an IOMMU. Do we care about micro-optimizing those? Even in coherent case, the overhead caused by additional function call should have really negligible impact on drivers performance. > > diff --git a/arch/arm/include/asm/dma-mapping.h > b/arch/arm/include/asm/dma-mapping.h > > index 799669d..f4e4968 100644 > > --- a/arch/arm/include/asm/dma-mapping.h > > +++ b/arch/arm/include/asm/dma-mapping.h > > @@ -10,6 +10,27 @@ > > #include > > #include > > > > +extern struct dma_map_ops dma_ops; > > + > > +static inline struct dma_map_ops *get_dma_ops(struct device *dev) > > +{ > > + if (dev->archdata.dma_ops) > > + return dev->archdata.dma_ops; > > + return &dma_ops; > > +} > > I would not name the global structure just 'dma_ops', the identifier could > too easily conflict with a local variable in some driver. How about > arm_dma_ops or linear_dma_ops instead? I'm fine with both of them. Even arm_linear_dma_ops make some sense. > > /* > > * The scatter list versions of the above methods. > > */ > > -extern int dma_map_sg(struct device *, struct scatterlist *, int, > > - enum dma_data_direction); > > -extern void dma_unmap_sg(struct device *, struct scatterlist *, int, > > +extern int arm_dma_map_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist > *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_cpu(struct device *, struct scatterlist *, > int, > > +extern void arm_dma_sync_sg_for_device(struct device *, struct > scatterlist *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, > int, > > - enum dma_data_direction); > > - > > You should not need to make these symbols visible in the header file any > more unless they are used outside of the main file later. They are used by the dma bounce code once converted to dma_map_ops framework. Best regards -- Marek Szyprowski Samsung Poland R&D Center -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout3.w1.samsung.com ([210.118.77.13]:64508 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756195Ab1F0MSJ (ORCPT ); Mon, 27 Jun 2011 08:18:09 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii Received: from eu_spt1 ([210.118.77.13]) by mailout3.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0LNG00GXC7I7D580@mailout3.w1.samsung.com> for linux-arch@vger.kernel.org; Mon, 27 Jun 2011 13:18:07 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LNG00J9V7I6IV@spt1.w1.samsung.com> for linux-arch@vger.kernel.org; Mon, 27 Jun 2011 13:18:06 +0100 (BST) Date: Mon, 27 Jun 2011 14:18:02 +0200 From: Marek Szyprowski Subject: RE: [PATCH 3/8] ARM: dma-mapping: use asm-generic/dma-mapping-common.h In-reply-to: <201106241736.43576.arnd@arndb.de> Message-ID: <000601cc34c4$430f91f0$c92eb5d0$%szyprowski@samsung.com> Content-language: pl References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-4-git-send-email-m.szyprowski@samsung.com> <201106241736.43576.arnd@arndb.de> Sender: linux-arch-owner@vger.kernel.org List-ID: To: 'Arnd Bergmann' Cc: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, 'Kyungmin Park' , 'Joerg Roedel' , 'Russell King - ARM Linux' Message-ID: <20110627121802.Fl-0uwcV9i6KSZDG5sKlTPsOubsOAqmgGKehbY_2QuE@z> Hello, On Friday, June 24, 2011 5:37 PM Arnd Bergmann wrote: > On Monday 20 June 2011, Marek Szyprowski wrote: > > This patch modifies dma-mapping implementation on ARM architecture to > > use common dma_map_ops structure and asm-generic/dma-mapping-common.h > > helpers. > > > > Signed-off-by: Marek Szyprowski > > Signed-off-by: Kyungmin Park > > This is a good idea in general, but I have a few concerns about details: > > First of all, should we only allow using dma_map_ops on ARM, or do we > also want to support a case where these are all inlined as before? I really wonder if it is possible to have a clean implementation of dma_map_ops based and linear inlined dma-mapping framework together. Theoretically it should be possible, but it will end with a lot of #ifdef hackery which is really hard to follow and understand for anyone but the authors. > I suppose for the majority of the cases, the overhead of the indirect > function call is near-zero, compared to the overhead of the cache > management operation, so it would only make a difference for coherent > systems without an IOMMU. Do we care about micro-optimizing those? Even in coherent case, the overhead caused by additional function call should have really negligible impact on drivers performance. > > diff --git a/arch/arm/include/asm/dma-mapping.h > b/arch/arm/include/asm/dma-mapping.h > > index 799669d..f4e4968 100644 > > --- a/arch/arm/include/asm/dma-mapping.h > > +++ b/arch/arm/include/asm/dma-mapping.h > > @@ -10,6 +10,27 @@ > > #include > > #include > > > > +extern struct dma_map_ops dma_ops; > > + > > +static inline struct dma_map_ops *get_dma_ops(struct device *dev) > > +{ > > + if (dev->archdata.dma_ops) > > + return dev->archdata.dma_ops; > > + return &dma_ops; > > +} > > I would not name the global structure just 'dma_ops', the identifier could > too easily conflict with a local variable in some driver. How about > arm_dma_ops or linear_dma_ops instead? I'm fine with both of them. Even arm_linear_dma_ops make some sense. > > /* > > * The scatter list versions of the above methods. > > */ > > -extern int dma_map_sg(struct device *, struct scatterlist *, int, > > - enum dma_data_direction); > > -extern void dma_unmap_sg(struct device *, struct scatterlist *, int, > > +extern int arm_dma_map_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist > *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_cpu(struct device *, struct scatterlist *, > int, > > +extern void arm_dma_sync_sg_for_device(struct device *, struct > scatterlist *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, > int, > > - enum dma_data_direction); > > - > > You should not need to make these symbols visible in the header file any > more unless they are used outside of the main file later. They are used by the dma bounce code once converted to dma_map_ops framework. Best regards -- Marek Szyprowski Samsung Poland R&D Center From mboxrd@z Thu Jan 1 00:00:00 1970 From: m.szyprowski@samsung.com (Marek Szyprowski) Date: Mon, 27 Jun 2011 14:18:02 +0200 Subject: [PATCH 3/8] ARM: dma-mapping: use asm-generic/dma-mapping-common.h In-Reply-To: <201106241736.43576.arnd@arndb.de> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-4-git-send-email-m.szyprowski@samsung.com> <201106241736.43576.arnd@arndb.de> Message-ID: <000601cc34c4$430f91f0$c92eb5d0$%szyprowski@samsung.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hello, On Friday, June 24, 2011 5:37 PM Arnd Bergmann wrote: > On Monday 20 June 2011, Marek Szyprowski wrote: > > This patch modifies dma-mapping implementation on ARM architecture to > > use common dma_map_ops structure and asm-generic/dma-mapping-common.h > > helpers. > > > > Signed-off-by: Marek Szyprowski > > Signed-off-by: Kyungmin Park > > This is a good idea in general, but I have a few concerns about details: > > First of all, should we only allow using dma_map_ops on ARM, or do we > also want to support a case where these are all inlined as before? I really wonder if it is possible to have a clean implementation of dma_map_ops based and linear inlined dma-mapping framework together. Theoretically it should be possible, but it will end with a lot of #ifdef hackery which is really hard to follow and understand for anyone but the authors. > I suppose for the majority of the cases, the overhead of the indirect > function call is near-zero, compared to the overhead of the cache > management operation, so it would only make a difference for coherent > systems without an IOMMU. Do we care about micro-optimizing those? Even in coherent case, the overhead caused by additional function call should have really negligible impact on drivers performance. > > diff --git a/arch/arm/include/asm/dma-mapping.h > b/arch/arm/include/asm/dma-mapping.h > > index 799669d..f4e4968 100644 > > --- a/arch/arm/include/asm/dma-mapping.h > > +++ b/arch/arm/include/asm/dma-mapping.h > > @@ -10,6 +10,27 @@ > > #include > > #include > > > > +extern struct dma_map_ops dma_ops; > > + > > +static inline struct dma_map_ops *get_dma_ops(struct device *dev) > > +{ > > + if (dev->archdata.dma_ops) > > + return dev->archdata.dma_ops; > > + return &dma_ops; > > +} > > I would not name the global structure just 'dma_ops', the identifier could > too easily conflict with a local variable in some driver. How about > arm_dma_ops or linear_dma_ops instead? I'm fine with both of them. Even arm_linear_dma_ops make some sense. > > /* > > * The scatter list versions of the above methods. > > */ > > -extern int dma_map_sg(struct device *, struct scatterlist *, int, > > - enum dma_data_direction); > > -extern void dma_unmap_sg(struct device *, struct scatterlist *, int, > > +extern int arm_dma_map_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_unmap_sg(struct device *, struct scatterlist *, int, > > + enum dma_data_direction, struct dma_attrs *attrs); > > +extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist > *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_cpu(struct device *, struct scatterlist *, > int, > > +extern void arm_dma_sync_sg_for_device(struct device *, struct > scatterlist *, int, > > enum dma_data_direction); > > -extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, > int, > > - enum dma_data_direction); > > - > > You should not need to make these symbols visible in the header file any > more unless they are used outside of the main file later. They are used by the dma bounce code once converted to dma_map_ops framework. Best regards -- Marek Szyprowski Samsung Poland R&D Center