Skip to contentSkip to conversation

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

PATCH Superseded Geert Uytterhoeven 2 participants 3 messages Apr 23, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/staging/fbtft/fbtft-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/fbtft/fbtft-core.c +4 -0
index 53b748be27124793..88bf4705ebadc590 100644
@@ -47,9 +47,13 @@ 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
+static const bool dma;
+#endif
 
 
 void fbtft_dbg_hex(const struct device *dev, int groupsize,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 18 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.

---
 drivers/staging/fbtft/fbtft-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/fbtft/fbtft-core.c +0 -0
index 53b748be27124793..88bf4705ebadc590 100644
@@ -47,9 +47,13 @@ static unsigned long debug;
 module_param(debug, ulong, 0);

drivers/staging/fbtft/fbtft-core.c static unsigned long debug; · line 57

Quoted 10 lines
drivers/staging/fbtft/fbtft-core.c +4 -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
+static const bool dma;
+#endif
 

I don't see how this change can fix the build error you show above. What am I missing?

thanks,

greg k-h

#2 lore raw
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 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.

---
 drivers/staging/fbtft/fbtft-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/fbtft/fbtft-core.c +0 -0
index 53b748be27124793..88bf4705ebadc590 100644
@@ -47,9 +47,13 @@ static unsigned long debug;
 module_param(debug, ulong, 0);
 MODULE_PARM_DESC(debug, "override device debug level");
 
Quoted 10 lines

drivers/staging/fbtft/fbtft-core.c static unsigned long debug; · line 56

Quoted 7 lines
drivers/staging/fbtft/fbtft-core.c +4 -0
+#ifdef CONFIG_HAS_DMA
 static bool dma = true;
 module_param(dma, bool, 0);
 MODULE_PARM_DESC(dma, "Use DMA buffer");
+#else
+static const bool dma;
+#endif

I don't see how this change can fix the build error you show above. What am I missing?

You're missing that gcc is optimized optimize away the branch that calls dmam_alloc_coherent():

                if (dma) {
                        dev->coherent_dma_mask = ~0;
                        txbuf = dmam_alloc_coherent(dev, txbuflen,
&par->txbuf.dma, GFP_DMA);
                } else {
                        ...
                }

HOWEVER, please drop this patch.

Originally I had "static const bool dma = false;", but checkpatch rightfully complained about the initialization of a static, so I dropped it. Guess what, gcc 4.1.2 no longer optimizes away the branch :-(

Will send v2 in a few minutes.

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