2011-05-04 08:14:34

by Michael Cree

[permalink] [raw]
Subject: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

The radeon drm code now relies on DMA_ERROR_CODE. This defines
it in alpha dma-mapping header to at least enable me to compile
radeon drm/kms into kernel.

Signed-off-by: Michael Cree <[email protected]>
---
arch/alpha/include/asm/dma-mapping.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
index 4567aca..644d9c3 100644
--- a/arch/alpha/include/asm/dma-mapping.h
+++ b/arch/alpha/include/asm/dma-mapping.h
@@ -3,6 +3,8 @@

#include <linux/dma-attrs.h>

+#define DMA_ERROR_CODE 0
+
extern struct dma_map_ops *dma_ops;

static inline struct dma_map_ops *get_dma_ops(struct device *dev)
--
1.7.4.3


2011-05-04 21:59:52

by Matt Turner

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Wed, May 4, 2011 at 4:13 AM, Michael Cree <[email protected]> wrote:
> The radeon drm code now relies on DMA_ERROR_CODE. ?This defines
> it in alpha dma-mapping header to at least enable me to compile
> radeon drm/kms into kernel.
>
> Signed-off-by: Michael Cree <[email protected]>
> ---
> ?arch/alpha/include/asm/dma-mapping.h | ? ?2 ++
> ?1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/arch/alpha/include/asm/dma-mapping.h b/arch/alpha/include/asm/dma-mapping.h
> index 4567aca..644d9c3 100644
> --- a/arch/alpha/include/asm/dma-mapping.h
> +++ b/arch/alpha/include/asm/dma-mapping.h
> @@ -3,6 +3,8 @@
>
> ?#include <linux/dma-attrs.h>
>
> +#define DMA_ERROR_CODE 0
> +
> ?extern struct dma_map_ops *dma_ops;
>
> ?static inline struct dma_map_ops *get_dma_ops(struct device *dev)
> --
> 1.7.4.3
>
>

Other architectures define this differently.

arch/ia64/include/asm/dma-mapping.h:#define DMA_ERROR_CODE 0
arch/microblaze/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
(~(dma_addr_t)0x0)
arch/powerpc/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
(~(dma_addr_t)0x0)
arch/sparc/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
(~(dma_addr_t)0x0)
arch/x86/include/asm/dma-mapping.h:#define DMA_ERROR_CODE 0

Any idea what the reason is?

Matt

2011-05-06 12:30:37

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Wed, 4 May 2011 20:13:37 +1200
Michael Cree <[email protected]> wrote:

> The radeon drm code now relies on DMA_ERROR_CODE. This defines
> it in alpha dma-mapping header to at least enable me to compile
> radeon drm/kms into kernel.
>
> Signed-off-by: Michael Cree <[email protected]>
> ---
> arch/alpha/include/asm/dma-mapping.h | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)

This isn't correct. The drivers should not use DMA_ERROR_CODE directly
(some architecture specific drivers use it though). Fix rademon
drm/kms instead.

2011-05-06 12:44:04

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Wed, 4 May 2011 17:59:29 -0400
Matt Turner <[email protected]> wrote:

> Other architectures define this differently.
>
> arch/ia64/include/asm/dma-mapping.h:#define DMA_ERROR_CODE 0
> arch/microblaze/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
> (~(dma_addr_t)0x0)
> arch/powerpc/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
> (~(dma_addr_t)0x0)
> arch/sparc/include/asm/dma-mapping.h:#define DMA_ERROR_CODE
> (~(dma_addr_t)0x0)
> arch/x86/include/asm/dma-mapping.h:#define DMA_ERROR_CODE 0
>
> Any idea what the reason is?

Because an invalid DMA address is architecture specific. To be exact,
an invalid DMA address is DMA operation specific.

As I wrote in another mail, this patch is wrong.

Architectures don't need to define DMA_ERROR_CODE.

Some architectures need multiple dma_mapping_error functions. You
could use DMA_ERROR_CODE in order to avoid duplicated code like
this. That is, you define only for dma_map_ops that needs the own
mapping_error function.

static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
struct dma_map_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

return (dma_addr == DMA_ERROR_CODE);
}

2011-05-06 13:50:22

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Fri, May 06, 2011 at 09:30:03PM +0900, FUJITA Tomonori wrote:
> On Wed, 4 May 2011 20:13:37 +1200
> Michael Cree <[email protected]> wrote:
>
> > The radeon drm code now relies on DMA_ERROR_CODE. This defines
> > it in alpha dma-mapping header to at least enable me to compile
> > radeon drm/kms into kernel.
> >
> > Signed-off-by: Michael Cree <[email protected]>
> > ---
> > arch/alpha/include/asm/dma-mapping.h | 2 ++
> > 1 files changed, 2 insertions(+), 0 deletions(-)
>
> This isn't correct. The drivers should not use DMA_ERROR_CODE directly
> (some architecture specific drivers use it though). Fix rademon
> drm/kms instead.

What would be a proper value for non-existent bus addresses? As in the value
had not been set? 0?

2011-05-07 00:06:36

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Fri, 6 May 2011 09:49:25 -0400
Konrad Rzeszutek Wilk <[email protected]> wrote:

> On Fri, May 06, 2011 at 09:30:03PM +0900, FUJITA Tomonori wrote:
> > On Wed, 4 May 2011 20:13:37 +1200
> > Michael Cree <[email protected]> wrote:
> >
> > > The radeon drm code now relies on DMA_ERROR_CODE. This defines
> > > it in alpha dma-mapping header to at least enable me to compile
> > > radeon drm/kms into kernel.
> > >
> > > Signed-off-by: Michael Cree <[email protected]>
> > > ---
> > > arch/alpha/include/asm/dma-mapping.h | 2 ++
> > > 1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > This isn't correct. The drivers should not use DMA_ERROR_CODE directly
> > (some architecture specific drivers use it though). Fix rademon
> > drm/kms instead.
>
> What would be a proper value for non-existent bus addresses? As in the value
> had not been set? 0?

Zero is a valid DMA address for some devices.

2011-05-07 03:08:47

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Sat, May 07, 2011 at 09:05:50AM +0900, FUJITA Tomonori wrote:
> On Fri, 6 May 2011 09:49:25 -0400
> Konrad Rzeszutek Wilk <[email protected]> wrote:
>
> > On Fri, May 06, 2011 at 09:30:03PM +0900, FUJITA Tomonori wrote:
> > > On Wed, 4 May 2011 20:13:37 +1200
> > > Michael Cree <[email protected]> wrote:
> > >
> > > > The radeon drm code now relies on DMA_ERROR_CODE. This defines
> > > > it in alpha dma-mapping header to at least enable me to compile
> > > > radeon drm/kms into kernel.
> > > >
> > > > Signed-off-by: Michael Cree <[email protected]>
> > > > ---
> > > > arch/alpha/include/asm/dma-mapping.h | 2 ++
> > > > 1 files changed, 2 insertions(+), 0 deletions(-)
> > >
> > > This isn't correct. The drivers should not use DMA_ERROR_CODE directly
> > > (some architecture specific drivers use it though). Fix rademon
> > > drm/kms instead.
> >
> > What would be a proper value for non-existent bus addresses? As in the value
> > had not been set? 0?
>
> Zero is a valid DMA address for some devices.

Ok, so what is an invalid DMA address?

2011-05-07 23:22:22

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH] alpha: Add DMA_ERROR_CODE defn to avert compiler error in drm

On Fri, 6 May 2011 23:08:03 -0400
Konrad Rzeszutek Wilk <[email protected]> wrote:

> On Sat, May 07, 2011 at 09:05:50AM +0900, FUJITA Tomonori wrote:
> > On Fri, 6 May 2011 09:49:25 -0400
> > Konrad Rzeszutek Wilk <[email protected]> wrote:
> >
> > > On Fri, May 06, 2011 at 09:30:03PM +0900, FUJITA Tomonori wrote:
> > > > On Wed, 4 May 2011 20:13:37 +1200
> > > > Michael Cree <[email protected]> wrote:
> > > >
> > > > > The radeon drm code now relies on DMA_ERROR_CODE. This defines
> > > > > it in alpha dma-mapping header to at least enable me to compile
> > > > > radeon drm/kms into kernel.
> > > > >
> > > > > Signed-off-by: Michael Cree <[email protected]>
> > > > > ---
> > > > > arch/alpha/include/asm/dma-mapping.h | 2 ++
> > > > > 1 files changed, 2 insertions(+), 0 deletions(-)
> > > >
> > > > This isn't correct. The drivers should not use DMA_ERROR_CODE directly
> > > > (some architecture specific drivers use it though). Fix rademon
> > > > drm/kms instead.
> > >
> > > What would be a proper value for non-existent bus addresses? As in the value
> > > had not been set? 0?
> >
> > Zero is a valid DMA address for some devices.
>
> Ok, so what is an invalid DMA address?

You are looking for a DMA address that is invalid for any device?

If so, there is no such thing because as I wrote, it depends on how a
device does DMA.