Skip to contentSkip to conversation

staging: fbtft: Disable DMA support if DMA is not available

PATCH Superseded Geert Uytterhoeven 2 participants 4 messages Apr 23, 2015 – Apr 24, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: fbtft: Disable DMA support if DMA is not available

If NO_DMA=y:

drivers/built-in.o: In function `fbtft_framebuffer_alloc':
(.text+0xb53cae): undefined reference to `dmam_alloc_coherent'

As DMA support is already optional, make it depend on HAS_DMA.

If !HAS_DMA, "dma" will always be false, and the compiler will optimize away the call to dmam_alloc_coherent().

---
v2:
- Explain better how it works,
- Keep the "= false" to avoid breakage (seen not only with gcc 4.1.2,

    but also with 4.6.3 and 4.9.0).
---
 drivers/staging/fbtft/fbtft-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/staging/fbtft/fbtft-core.c +5 -0
index 53b748be27124793..600dbdcaa716cd76 100644
@@ -47,9 +47,14 @@ static unsigned long debug;
 module_param(debug, ulong, 0);
 MODULE_PARM_DESC(debug, "override device debug level");
 
+#ifdef CONFIG_HAS_DMA
 static bool dma = true;
 module_param(dma, bool, 0);
 MODULE_PARM_DESC(dma, "Use DMA buffer");
+#else
+/* Do not remove the "= false", gcc needs it to optimize away the DMA calls */
+static const bool dma = false;
+#endif
 
 
 void fbtft_dbg_hex(const struct device *dev, int groupsize,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 9 lines · Geert Uytterhoeven

If NO_DMA=y:

drivers/built-in.o: In function `fbtft_framebuffer_alloc':
(.text+0xb53cae): undefined reference to `dmam_alloc_coherent'

As DMA support is already optional, make it depend on HAS_DMA.

If !HAS_DMA, "dma" will always be false, and the compiler will optimize away the call to dmam_alloc_coherent().

Oh that's "sneaky" and not good, let's just make this driver be dependant on DMA and be done with it. I don't like to rely on the optimizer to get things to work properly.

thanks,

greg k-h

#2 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Geert Uytterhoeven

If NO_DMA=y:

drivers/built-in.o: In function `fbtft_framebuffer_alloc':
(.text+0xb53cae): undefined reference to `dmam_alloc_coherent'

Quoted 8 lines
Quoted 4 lines

As DMA support is already optional, make it depend on HAS_DMA.

If !HAS_DMA, "dma" will always be false, and the compiler will optimize away the call to dmam_alloc_coherent().

Oh that's "sneaky" and not good, let's just make this driver be dependant on DMA and be done with it. I don't like to rely on the optimizer to get things to work properly.

Alternatively, I can stick in one more #ifdef, to no longer rely on the compiler optimization?
AFAICS, the driver itself considers DMA optional, and will work without.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw
Quoted 13 lines · Geert Uytterhoeven
Quoted 11 lines · Greg Kroah-Hartman
Quoted 9 lines · Geert Uytterhoeven

If NO_DMA=y:

drivers/built-in.o: In function `fbtft_framebuffer_alloc':
(.text+0xb53cae): undefined reference to `dmam_alloc_coherent'

As DMA support is already optional, make it depend on HAS_DMA.

If !HAS_DMA, "dma" will always be false, and the compiler will optimize away the call to dmam_alloc_coherent().

Quoted 6 lines
Quoted 3 lines

Oh that's "sneaky" and not good, let's just make this driver be dependant on DMA and be done with it. I don't like to rely on the optimizer to get things to work properly.

Alternatively, I can stick in one more #ifdef, to no longer rely on the compiler optimization?

That would be better.

thanks,

greg k-h