Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] 4xx: PCIe indirect DCR spinlock fix.

Since we have mfdcri() and mtdcri() as macros, we can't use constructions,
such as "mtdcri(base, reg, mfdcri(base, reg) | val)". In this case the
mfdcri() stuff is not evaluated first. It's evaluated inside the mtdcri()
macro and we have the dcr_ind_lock spinlock acquired twice.

To avoid this error, I've added __mfdcri()/__mtdcri() inline functions that
take the lock after register name fix-up.

Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>

authored by

Valentine Barshak and committed by
Josh Boyer
e8318d98 853265e5

+29 -18
+29 -18
include/asm-powerpc/dcr-native.h
··· 59 59 /* R/W of indirect DCRs make use of standard naming conventions for DCRs */ 60 60 extern spinlock_t dcr_ind_lock; 61 61 62 - #define mfdcri(base, reg) \ 63 - ({ \ 64 - unsigned long flags; \ 65 - unsigned int val; \ 66 - spin_lock_irqsave(&dcr_ind_lock, flags); \ 67 - mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg); \ 68 - val = mfdcr(DCRN_ ## base ## _CONFIG_DATA); \ 69 - spin_unlock_irqrestore(&dcr_ind_lock, flags); \ 70 - val; \ 71 - }) 62 + static inline unsigned __mfdcri(int base_addr, int base_data, int reg) 63 + { 64 + unsigned long flags; 65 + unsigned int val; 72 66 73 - #define mtdcri(base, reg, data) \ 74 - do { \ 75 - unsigned long flags; \ 76 - spin_lock_irqsave(&dcr_ind_lock, flags); \ 77 - mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg); \ 78 - mtdcr(DCRN_ ## base ## _CONFIG_DATA, data); \ 79 - spin_unlock_irqrestore(&dcr_ind_lock, flags); \ 80 - } while (0) 67 + spin_lock_irqsave(&dcr_ind_lock, flags); 68 + __mtdcr(base_addr, reg); 69 + val = __mfdcr(base_data); 70 + spin_unlock_irqrestore(&dcr_ind_lock, flags); 71 + return val; 72 + } 73 + 74 + static inline void __mtdcri(int base_addr, int base_data, int reg, 75 + unsigned val) 76 + { 77 + unsigned long flags; 78 + 79 + spin_lock_irqsave(&dcr_ind_lock, flags); 80 + __mtdcr(base_addr, reg); 81 + __mtdcr(base_data, val); 82 + spin_unlock_irqrestore(&dcr_ind_lock, flags); 83 + } 84 + 85 + #define mfdcri(base, reg) __mfdcri(DCRN_ ## base ## _CONFIG_ADDR, \ 86 + DCRN_ ## base ## _CONFIG_DATA, \ 87 + reg) 88 + 89 + #define mtdcri(base, reg, data) __mtdcri(DCRN_ ## base ## _CONFIG_ADDR, \ 90 + DCRN_ ## base ## _CONFIG_DATA, \ 91 + reg, data) 81 92 82 93 #endif /* __ASSEMBLY__ */ 83 94 #endif /* __KERNEL__ */