From mboxrd@z Thu Jan 1 00:00:00 1970 From: KyongHo Cho Subject: Re: [Linaro-mm-sig] [PATCH 8/8] ARM: dma-mapping: use alloc, mmap, free from dma_ops Date: Wed, 22 Jun 2011 15:53:55 +0900 Message-ID: References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mail-yx0-f174.google.com ([209.85.213.174]:38560 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784Ab1FVGx4 convert rfc822-to-8bit (ORCPT ); Wed, 22 Jun 2011 02:53:56 -0400 Received: by yxi11 with SMTP id 11so210430yxi.19 for ; Tue, 21 Jun 2011 23:53:55 -0700 (PDT) In-Reply-To: <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Marek Szyprowski Cc: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, Kyungmin Park , Russell King - ARM Linux , Joerg Roedel , Arnd Bergmann Hi. On Mon, Jun 20, 2011 at 4:50 PM, Marek Szyprowski wrote: > -extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t = *, gfp_t); > +extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr= _t *handle, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gfp_t gfp, struc= t dma_attrs *attrs); > + > +#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) > + > +static inline void *dma_alloc_attrs(struct device *dev, size_t size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0dma_addr_t *dma_handle, gfp_t flag, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0struct dma_attrs *attrs) > +{ > + =A0 =A0 =A0 struct dma_map_ops *ops =3D get_dma_ops(dev); > + =A0 =A0 =A0 void *cpu_addr; > + =A0 =A0 =A0 BUG_ON(!ops); > + > + =A0 =A0 =A0 cpu_addr =3D ops->alloc(dev, size, dma_handle, flag, at= trs); > + =A0 =A0 =A0 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_ad= dr); > + =A0 =A0 =A0 return cpu_addr; > +} > Apart from the necessity of alloc_attr, I hope the callback implementations to check if a function pointer is N= ULL. Suppose that a system want to use default ARM implementation of dma_all= oc_*() while it uses its own implementations of dma_map_*(). With your suggestion, we have only one option: void *my_alloc(...) { return dma_alloc_coherent(NULL, ...); } struct dma_map_ops ops =3D { =2Ealloc_coherent =3D &my_alloc, =2E.. }; I think the following method is simpler: struct dma_map_ops ops =3D { =2Ealloc_coherent =3D NULL, =2E.. }; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by kanga.kvack.org (Postfix) with ESMTP id BA56990015D for ; Wed, 22 Jun 2011 02:54:02 -0400 (EDT) Received: by yxn22 with SMTP id 22so266720yxn.14 for ; Tue, 21 Jun 2011 23:53:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> Date: Wed, 22 Jun 2011 15:53:55 +0900 Message-ID: Subject: Re: [Linaro-mm-sig] [PATCH 8/8] ARM: dma-mapping: use alloc, mmap, free from dma_ops From: KyongHo Cho Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Marek Szyprowski Cc: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, Kyungmin Park , Russell King - ARM Linux , Joerg Roedel , Arnd Bergmann Hi. On Mon, Jun 20, 2011 at 4:50 PM, Marek Szyprowski wrote: > -extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, g= fp_t); > +extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *= handle, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gfp_t gfp, struct dm= a_attrs *attrs); > + > +#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) > + > +static inline void *dma_alloc_attrs(struct device *dev, size_t size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0dma_addr_t *dma_handle, gfp_t flag, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0struct dma_attrs *attrs) > +{ > + =A0 =A0 =A0 struct dma_map_ops *ops =3D get_dma_ops(dev); > + =A0 =A0 =A0 void *cpu_addr; > + =A0 =A0 =A0 BUG_ON(!ops); > + > + =A0 =A0 =A0 cpu_addr =3D ops->alloc(dev, size, dma_handle, flag, attrs)= ; > + =A0 =A0 =A0 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); > + =A0 =A0 =A0 return cpu_addr; > +} > Apart from the necessity of alloc_attr, I hope the callback implementations to check if a function pointer is NULL. Suppose that a system want to use default ARM implementation of dma_alloc_*= () while it uses its own implementations of dma_map_*(). With your suggestion, we have only one option: void *my_alloc(...) { return dma_alloc_coherent(NULL, ...); } struct dma_map_ops ops =3D { .alloc_coherent =3D &my_alloc, ... }; I think the following method is simpler: struct dma_map_ops ops =3D { .alloc_coherent =3D NULL, ... }; -- 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 From: pullip.cho@samsung.com (KyongHo Cho) Date: Wed, 22 Jun 2011 15:53:55 +0900 Subject: [Linaro-mm-sig] [PATCH 8/8] ARM: dma-mapping: use alloc, mmap, free from dma_ops In-Reply-To: <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <1308556213-24970-9-git-send-email-m.szyprowski@samsung.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi. On Mon, Jun 20, 2011 at 4:50 PM, Marek Szyprowski wrote: > -extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t); > +extern void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, > + ? ? ? ? ? ? ? ? ? ? ? ? ?gfp_t gfp, struct dma_attrs *attrs); > + > +#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) > + > +static inline void *dma_alloc_attrs(struct device *dev, size_t size, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dma_addr_t *dma_handle, gfp_t flag, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct dma_attrs *attrs) > +{ > + ? ? ? struct dma_map_ops *ops = get_dma_ops(dev); > + ? ? ? void *cpu_addr; > + ? ? ? BUG_ON(!ops); > + > + ? ? ? cpu_addr = ops->alloc(dev, size, dma_handle, flag, attrs); > + ? ? ? debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); > + ? ? ? return cpu_addr; > +} > Apart from the necessity of alloc_attr, I hope the callback implementations to check if a function pointer is NULL. Suppose that a system want to use default ARM implementation of dma_alloc_*() while it uses its own implementations of dma_map_*(). With your suggestion, we have only one option: void *my_alloc(...) { return dma_alloc_coherent(NULL, ...); } struct dma_map_ops ops = { .alloc_coherent = &my_alloc, ... }; I think the following method is simpler: struct dma_map_ops ops = { .alloc_coherent = NULL, ... };