* [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available
@ 2015-04-23 18:47 Geert Uytterhoeven
2015-04-23 19:17 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2015-04-23 18:47 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman
Cc: devel, linux-kernel, 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().
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
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(+)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 53b748be27124793..600dbdcaa716cd76 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -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,
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available
2015-04-23 18:47 [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available Geert Uytterhoeven
@ 2015-04-23 19:17 ` Greg Kroah-Hartman
2015-04-24 7:15 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2015-04-23 19:17 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Thomas Petazzoni, Noralf Trønnes, devel, linux-kernel
On Thu, Apr 23, 2015 at 08:47:15PM +0200, Geert Uytterhoeven wrote:
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available
2015-04-23 19:17 ` Greg Kroah-Hartman
@ 2015-04-24 7:15 ` Geert Uytterhoeven
2015-04-24 7:17 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2015-04-24 7:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Thomas Petazzoni, Noralf Trønnes, driverdevel,
linux-kernel@vger.kernel.org
On Thu, Apr 23, 2015 at 9:17 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Thu, Apr 23, 2015 at 08:47:15PM +0200, Geert Uytterhoeven wrote:
>> 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.
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 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available
2015-04-24 7:15 ` Geert Uytterhoeven
@ 2015-04-24 7:17 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2015-04-24 7:17 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Thomas Petazzoni, Noralf Trønnes, driverdevel,
linux-kernel@vger.kernel.org
On Fri, Apr 24, 2015 at 09:15:00AM +0200, Geert Uytterhoeven wrote:
> On Thu, Apr 23, 2015 at 9:17 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Thu, Apr 23, 2015 at 08:47:15PM +0200, Geert Uytterhoeven wrote:
> >> 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.
>
> Alternatively, I can stick in one more #ifdef, to no longer rely on the compiler
> optimization?
That would be better.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-24 7:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-23 18:47 [PATCH v2] staging: fbtft: Disable DMA support if DMA is not available Geert Uytterhoeven
2015-04-23 19:17 ` Greg Kroah-Hartman
2015-04-24 7:15 ` Geert Uytterhoeven
2015-04-24 7:17 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox