Skip to contentSkip to conversation

dmaengine: shdma: fix a build failure on platforms with no DMA support

PATCH Superseded Guennadi Liakhovetski 4 participants 7 messages May 31, 2013 – Jun 27, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

---

v2: in "next" shdma_chan_filter() is defined in shdma-base.c, which is built if CONFIG_SH_DMAE_BASE is defined. This version uses the correct symbol.

This is for "next." Compile-tested only. I'll test it on hardware next week, but I don't think it shall break anything.

 include/linux/sh_dma.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sh_dma.h +4 -0
index b64d6be..1fd8a20 100644
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE	0x00000002
 #define CHCR_IE	0x00000004
 
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL
+#endif
 
 #endif
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

Quoted 27 lines · Guennadi Liakhovetski

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

---

v2: in "next" shdma_chan_filter() is defined in shdma-base.c, which is built if CONFIG_SH_DMAE_BASE is defined. This version uses the correct symbol.

This is for "next." Compile-tested only. I'll test it on hardware next week, but I don't think it shall break anything.

 include/linux/sh_dma.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sh_dma.h +0 -0
index b64d6be..1fd8a20 100644

include/linux/sh_dma.h struct sh_dmae_pdata { · line 105

Quoted 7 lines
include/linux/sh_dma.h +3 -0
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE	0x00000002
 #define CHCR_IE	0x00000004
 
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL

OK I did not see a reply to my previous comment
Would this not be better as a
#else
static inline bool shdma_chan_filter(struct dma_chan *chan, void *arg) { return false; } #endif

Otherwise runtime will call a NULL pointer

Quoted 3 lines
include/linux/sh_dma.h +1 -0
+#endif
 
 #endif
Signature · 2 lines
------------------
Dan Murphy
#2 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

Quoted 41 lines · Dan Murphy
Quoted 27 lines · Guennadi Liakhovetski

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

---

v2: in "next" shdma_chan_filter() is defined in shdma-base.c, which is built if CONFIG_SH_DMAE_BASE is defined. This version uses the correct symbol.

This is for "next." Compile-tested only. I'll test it on hardware next week, but I don't think it shall break anything.

 include/linux/sh_dma.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sh_dma.h +0 -0
index b64d6be..1fd8a20 100644

include/linux/sh_dma.h struct sh_dmae_pdata { · line 105

Quoted 7 lines
include/linux/sh_dma.h +3 -0
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE	0x00000002
 #define CHCR_IE	0x00000004
 
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL

OK I did not see a reply to my previous comment
Would this not be better as a
#else
static inline bool shdma_chan_filter(struct dma_chan *chan, void *arg) { return false; } #endif

Quoted 1 line

Otherwise runtime will call a NULL pointer

Have you looked at the code?:

		if (fn && !fn(chan, fn_param)) {

Have you considered, when this channel allocation at all has a chance to get as far as to checking the filter? Have you thought about the meaning of "inline" when uing a function to assign it to a pointer? Are you sure "will" is the right word here?

Thanks
Guennadi

Quoted 9 lines
Quoted 3 lines
include/linux/sh_dma.h +1 -0
+#endif
 
 #endif
Signature · 2 lines
------------------
Dan Murphy

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

#3 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

Quoted 44 lines · Guennadi Liakhovetski
Quoted 41 lines · Dan Murphy
Quoted 27 lines · Guennadi Liakhovetski

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

---

v2: in "next" shdma_chan_filter() is defined in shdma-base.c, which is built if CONFIG_SH_DMAE_BASE is defined. This version uses the correct symbol.

This is for "next." Compile-tested only. I'll test it on hardware next week, but I don't think it shall break anything.

 include/linux/sh_dma.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sh_dma.h +0 -0
index b64d6be..1fd8a20 100644

include/linux/sh_dma.h struct sh_dmae_pdata { · line 105

Quoted 7 lines
include/linux/sh_dma.h +3 -0
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE	0x00000002
 #define CHCR_IE	0x00000004
 
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL

OK I did not see a reply to my previous comment
Would this not be better as a
#else
static inline bool shdma_chan_filter(struct dma_chan *chan, void *arg) { return false; } #endif

Quoted 1 line

Otherwise runtime will call a NULL pointer

Quoted 8 lines

Have you looked at the code?:

		if (fn && !fn(chan, fn_param)) {

Have you considered, when this channel allocation at all has a chance to get as far as to checking the filter? Have you thought about the meaning of "inline" when uing a function to assign it to a pointer? Are you sure "will" is the right word here?

My consideration was that since this is an exported symbol that a driver could call this API explicitly without checking for the function pointer first, there is a potential of calling a NULL pointer.

Dan

Quoted 15 lines

Thanks
Guennadi

Quoted 8 lines
Quoted 3 lines
include/linux/sh_dma.h +1 -0
+#endif
 
 #endif
Signature · 2 lines
------------------
Dan Murphy

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

Signature · 2 lines
------------------
Dan Murphy
#4 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

Quoted 3 lines · On Friday 31 May 2013 10:00:29 Dan Murphy wrote:

My consideration was that since this is an exported symbol that a driver could call this API explicitly without checking for
the function pointer first, there is a potential of calling a NULL pointer.

Drivers never call a filter function directly, so that is not an issue. Even if a driver would try it, that would not actually compile.

Arnd

#5 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

In reply to Guennadi Liakhovetski
Quoted 10 lines · On Friday 31 May 2013 05:01:31 Guennadi Liakhovetski wrote:

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

Sorry, I saw your patch too late and already spent some time doing a different one.

include/linux/sh_dma.h struct sh_dmae_pdata { · line 106

Quoted 13 lines
include/linux/sh_dma.h +4 -0
index b64d6be..1fd8a20 100644
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE        0x00000002
 #define CHCR_IE        0x00000004
 
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL
+#endif

I still think that this is not the right solution, or at least not
complete: No slave driver should care about which dma-engine it is connected to. You have already done most of the necessary conversion, so it would be straightforward to also pass the filter function pointer to the sdhi driver along with the data that gets passed into it.

Arnd

#6 lore raw

PATCH v2 1/1 dmaengine: shdma: fix a build failure on platforms with no DMA support

Quoted 22 lines · Arnd Bergmann
Quoted 10 lines · On Friday 31 May 2013 05:01:31 Guennadi Liakhovetski wrote:

On platforms with no support for the shdma dmaengine driver build is currently failing with

drivers/built-in.o: In function `sh_mobile_sdhi_probe':
drivers/mmc/host/sh_mobile_sdhi.c:170: undefined reference to`shdma_chan_filter'

Fix the breakage by defining shdma_chan_filter to NULL in such configurations.

Sorry, I saw your patch too late and already spent some time doing a different one.

Quoted 8 lines
include/linux/sh_dma.h +0 -0
index b64d6be..1fd8a20 100644
@@ -99,6 +99,10 @@ struct sh_dmae_pdata {
 #define CHCR_TE        0x00000002
 #define CHCR_IE        0x00000004
 
Quoted 12 lines

include/linux/sh_dma.h struct sh_dmae_pdata { · line 106

Quoted 5 lines
include/linux/sh_dma.h +4 -0
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL
+#endif

I still think that this is not the right solution, or at least not
complete: No slave driver should care about which dma-engine it is connected to. You have already done most of the necessary conversion, so it would be straightforward to also pass the filter function pointer to the sdhi driver along with the data that gets passed into it.

Hi Arnd, Hi Guennadi,

It seems to me that the solution above, though not particularly generic, is sufficient as according to Guennadi SHDMA users cannot use other DMA drivers[1]. The change above also has the merit of being rather small.

[1] https://patchwork.kernel.org/patch/2644101/

With that reasoning I would like to provide: