unresolved symbol dma_spin_lock with CONFIG_DEBUG_SPINLOCK enabled

Jan Veldeman jan.veldeman at gmail.com
Wed May 31 19:19:59 EST 2006


Hi,

when compiling for a platform without CONFIG_GENERIC_ISA_DMA set and with
CONFIG_DEBUG_SPINLOCK enabled, the linker complains about an unresolved symbol
to dma_spin_lock (which is declared in kernel/dma.c but doesn't get compiled).
Without CONFIG_DEBUG_SPINLOCK, these statements are removed by the compiler,
so that dma_spin_lock isn't referenced.

I see 3 possible solutions for this problem:

1. compile in kernel/dma.c when CONFIG_DEBUG_SPINLOCK is enabled

diff --git a/kernel/Makefile b/kernel/Makefile
index 58908f9..6cab2a3 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_FUTEX) += futex.o
 ifeq ($(CONFIG_COMPAT),y)
 obj-$(CONFIG_FUTEX) += futex_compat.o
 endif
+obj-$(CONFIG_DEBUG_SPINLOCK) += dma.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o spinlock.o
 obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o


as it's a debug build, the extra space shouldn't mind.
It will also solve similar problems for other architectures (if they exist, I
didn't check this)

2. stub the claim/release_dma_lock in include/asm-powerpc/dma.h

diff --git a/include/asm-powerpc/dma.h b/include/asm-powerpc/dma.h
index 4bb57fe..de5efc7 100644
--- a/include/asm-powerpc/dma.h
+++ b/include/asm-powerpc/dma.h
@@ -182,6 +182,8 @@ extern long ppc_cs4232_dma, ppc_cs4232_d

 #define DMA_AUTOINIT           0x10

+#ifdef CONFIG_GENERIC_ISA_DMA
+
 extern spinlock_t dma_spin_lock;

 static __inline__ unsigned long claim_dma_lock(void)
@@ -196,6 +198,22 @@ static __inline__ void release_dma_lock(
        spin_unlock_irqrestore(&dma_spin_lock, flags);
 }

+#else /* CONFIG_GENERIC_ISA_DMA */
+
+/* dma_spin_lock isn't declared because kernel/dma.c doesn't get compiled,
+ * so stub these functions */
+
+static __inline__ unsigned long claim_dma_lock(void)
+{
+       return 0;
+}
+
+static __inline__ void release_dma_lock(unsigned long flags)
+{
+}
+
+#endif /* CONFIG_GENERIC_ISA_DMA */
+
 /* enable/disable a specific DMA channel */
 static __inline__ void enable_dma(unsigned int dmanr)
 {

but this just doesn't feel right

3. fix the driver using claim_dma_lock on platforms without
    CONFIG_GENERIC_ISA_DMA

This just looks like a lot of work and would make it harder for drivers.

Any suggestions/remarks?

Best regards,
Jan



More information about the Linuxppc-dev mailing list