[parisc-linux-cvs] linux-2.6 varenet

Thibaut VARENE varenet at esiee.fr
Mon Aug 16 11:29:51 MDT 2004


On Mon, 16 Aug 2004 11:25:28 -0600 (MDT)
varenet at parisc-linux.org (Thibaut Varene) wrote:

> CVSROOT:	/var/cvs
> Module name:	linux-2.6
> Changes by:	varenet	04/08/16 11:25:28
> 
> Modified files:
> 	.              : Makefile 
> 	arch/parisc/kernel: pdc_cons.c 
> 	arch/parisc/lib: debuglocks.c 
> 	include/asm-parisc: pdc.h 
> 
> Log message:
> implementing memory barriers in debuglocks and pdc_printf patch from
> tausq.

here comes the patch



Thibaut VARENE
The PA/Linux ESIEE Team
http://www.pateam.org/
-------------- next part --------------
? debuglocks.diff
Index: Makefile
===================================================================
RCS file: /var/cvs/linux-2.6/Makefile,v
retrieving revision 1.236
diff -u -p -r1.236 Makefile
--- Makefile	15 Aug 2004 15:52:12 -0000	1.236
+++ Makefile	16 Aug 2004 17:18:40 -0000
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 8
-EXTRAVERSION = .1-pa2
+EXTRAVERSION = .1-pa3
 NAME=Zonked Quokka
 
 # *DOCUMENTATION*
Index: arch/parisc/kernel/pdc_cons.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/kernel/pdc_cons.c,v
retrieving revision 1.6
diff -u -p -r1.6 pdc_cons.c
--- arch/parisc/kernel/pdc_cons.c	19 Jan 2004 05:15:47 -0000	1.6
+++ arch/parisc/kernel/pdc_cons.c	16 Aug 2004 17:18:44 -0000
@@ -71,6 +71,19 @@ void pdc_outc(unsigned char c)
 	pdc_iodc_outc(c);
 }
 
+void pdc_printf(const char *fmt, ...)
+{
+	va_list args;
+	char buf[1024];
+	int i, len;
+
+	va_start(args, fmt);
+	len = vscnprintf(buf, sizeof(buf), fmt, args);
+	va_end(args);
+
+	for (i = 0; i < len; i++)
+		pdc_iodc_outc(buf[i]);
+}
 
 int pdc_console_poll_key(struct console *co)
 {
Index: arch/parisc/lib/debuglocks.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/lib/debuglocks.c,v
retrieving revision 1.7
diff -u -p -r1.7 debuglocks.c
--- arch/parisc/lib/debuglocks.c	14 Jul 2004 18:20:34 -0000	1.7
+++ arch/parisc/lib/debuglocks.c	16 Aug 2004 17:18:44 -0000
@@ -18,6 +18,11 @@
  *    You should have received a copy of the GNU General Public License
  *    along with this program; if not, write to the Free Software
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *    We use pdc_printf() throughout the file for all output messages, to avoid
+ *    loosing messages because of disabled interrupts. Since we're using these
+ *    messages for debugging purposes, it makes sense not to send them to the
+ *    linux console.
  */
 
 
@@ -27,12 +32,14 @@
 #include <linux/spinlock.h>
 #include <asm/system.h>
 #include <asm/hardirq.h>	/* in_interrupt() */
+#include <asm/pdc.h>
 
 #undef INIT_STUCK
 #define INIT_STUCK 1L << 30
 
 #ifdef CONFIG_DEBUG_SPINLOCK
 
+
 void _dbg_spin_lock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	volatile unsigned int *a;
@@ -59,12 +66,14 @@ try_again:
 	 * <tausq> __ldcw() returns 1 if we get the lock; otherwise we
 	 * 	spin until the value of the lock changes, or we time out.
 	 */
+	mb();
 	a = __ldcw_align(lock);
 	while (stuck && (__ldcw(a) == 0))
 		while ((*a == 0) && --stuck);
+	mb();
 
 	if (unlikely(stuck <= 0)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_lock(%s/%p) stuck in %s at %p(%d)"
 			" owned by %s:%d in %s at %p(%d)\n",
 			base_file, line_no, lock->module, lock,
@@ -84,7 +93,7 @@ try_again:
 	lock->bline = line_no;
 
 	if (unlikely(printed)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_lock grabbed in %s at %p(%d) %ld ticks\n",
 			base_file, line_no, current->comm, inline_pc,
 			cpu, jiffies - started);
@@ -94,21 +103,28 @@ try_again:
 void _dbg_spin_unlock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	CHECK_LOCK(lock);
-	volatile unsigned int *a = __ldcw_align(lock);
+	volatile unsigned int *a;
+	mb();
+	a = __ldcw_align(lock);
 	if (unlikely((*a != 0) && lock->babble)) {
 		lock->babble--;
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: spin_unlock(%s:%p) not locked\n",
 			base_file, line_no, lock->module, lock);
 	}
 	*a = 1;	
+	mb();
 }
 
 int _dbg_spin_trylock(spinlock_t * lock, const char *base_file, int line_no)
 {
 	int ret;
-	volatile unsigned int *a = __ldcw_align(lock);
-	if ((ret = (__ldcw(a) != 0))) {
+	volatile unsigned int *a;
+	mb();
+	a = __ldcw_align(lock);
+	ret = (__ldcw(a) != 0);
+	mb();
+	if (ret) {
 		lock->oncpu = smp_processor_id();
 		lock->previous = __builtin_return_address(0);
 		lock->task = current;
@@ -150,7 +166,7 @@ void _dbg_write_lock(rwlock_t *rw, const
 	int cpu = smp_processor_id();
 	
 	if(unlikely(in_interrupt())) {	/* acquiring write lock in interrupt context, bad idea */
-		printk(KERN_WARNING "write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+		pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
 		BUG();
 	}
 
@@ -167,7 +183,7 @@ retry:
 		
 		stuck--;
 		if ((unlikely(stuck <= 0)) && (rw->counter < 0)) {
-			printk(KERN_WARNING
+			pdc_printf(
 				"%s:%d: write_lock stuck on writer"
 				" in %s at %p(%d) %ld ticks\n",
 				bfile, bline, current->comm, inline_pc,
@@ -176,7 +192,7 @@ retry:
 			printed = 1;
 		}
 		else if (unlikely(stuck <= 0)) {
-			printk(KERN_WARNING
+			pdc_printf(
 				"%s:%d: write_lock stuck on reader"
 				" in %s at %p(%d) %ld ticks\n",
 				bfile, bline, current->comm, inline_pc,
@@ -194,7 +210,7 @@ retry:
 	rw->counter = -1; /* remember we are locked */
 
 	if (unlikely(printed)) {
-		printk(KERN_WARNING
+		pdc_printf(
 			"%s:%d: write_lock grabbed in %s at %p(%d) %ld ticks\n",
 			bfile, bline, current->comm, inline_pc,
 			cpu, jiffies - started);
@@ -215,7 +231,7 @@ void _dbg_read_lock(rwlock_t * rw, const
 
 	rw->counter++;
 #if 0
-	printk(KERN_WARNING
+	pdc_printf(
 		"%s:%d: read_lock grabbed in %s at %p(%d) %ld ticks\n",
 		bfile, bline, current->comm, inline_pc,
 		cpu, jiffies - started);
Index: include/asm-parisc/pdc.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/pdc.h,v
retrieving revision 1.8
diff -u -p -r1.8 pdc.h
--- include/asm-parisc/pdc.h	10 Jul 2004 07:51:15 -0000	1.8
+++ include/asm-parisc/pdc.h	16 Aug 2004 17:18:52 -0000
@@ -754,6 +754,7 @@ void pdc_io_reset_devices(void);
 int pdc_iodc_getc(void);
 void pdc_iodc_putc(unsigned char c);
 void pdc_iodc_outc(unsigned char c);
+void pdc_printf(const char *fmt, ...);
 
 void pdc_emergency_unlock(void);
 int pdc_sti_call(unsigned long func, unsigned long flags,


More information about the parisc-linux-cvs mailing list