This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / parisc / lib / debuglocks.c
index 5ac3eb0..5166a93 100644 (file)
  *    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
- *    losing 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.
  */
 
 
 #include <linux/spinlock.h>
 #include <linux/hardirq.h>     /* in_interrupt() */
 #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;
@@ -67,14 +59,12 @@ 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)) {
-               pdc_printf(
+               printk(KERN_WARNING
                        "%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,
@@ -94,7 +84,7 @@ try_again:
        lock->bline = line_no;
 
        if (unlikely(printed)) {
-               pdc_printf(
+               printk(KERN_WARNING
                        "%s:%d: spin_lock grabbed in %s at %p(%d) %ld ticks\n",
                        base_file, line_no, current->comm, inline_pc,
                        cpu, jiffies - started);
@@ -104,28 +94,21 @@ try_again:
 void _dbg_spin_unlock(spinlock_t * lock, const char *base_file, int line_no)
 {
        CHECK_LOCK(lock);
-       volatile unsigned int *a;
-       mb();
-       a = __ldcw_align(lock);
+       volatile unsigned int *a = __ldcw_align(lock);
        if (unlikely((*a != 0) && lock->babble)) {
                lock->babble--;
-               pdc_printf(
+               printk(KERN_WARNING
                        "%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;
-       mb();
-       a = __ldcw_align(lock);
-       ret = (__ldcw(a) != 0);
-       mb();
-       if (ret) {
+       volatile unsigned int *a = __ldcw_align(lock);
+       if ((ret = (__ldcw(a) != 0))) {
                lock->oncpu = smp_processor_id();
                lock->previous = __builtin_return_address(0);
                lock->task = current;
@@ -167,7 +150,7 @@ void _dbg_write_lock(rwlock_t *rw, const char *bfile, int bline)
        int cpu = smp_processor_id();
        
        if(unlikely(in_interrupt())) {  /* acquiring write lock in interrupt context, bad idea */
-               pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+               printk(KERN_WARNING "write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
                BUG();
        }
 
@@ -184,7 +167,7 @@ retry:
                
                stuck--;
                if ((unlikely(stuck <= 0)) && (rw->counter < 0)) {
-                       pdc_printf(
+                       printk(KERN_WARNING
                                "%s:%d: write_lock stuck on writer"
                                " in %s at %p(%d) %ld ticks\n",
                                bfile, bline, current->comm, inline_pc,
@@ -193,7 +176,7 @@ retry:
                        printed = 1;
                }
                else if (unlikely(stuck <= 0)) {
-                       pdc_printf(
+                       printk(KERN_WARNING
                                "%s:%d: write_lock stuck on reader"
                                " in %s at %p(%d) %ld ticks\n",
                                bfile, bline, current->comm, inline_pc,
@@ -211,47 +194,13 @@ retry:
        rw->counter = -1; /* remember we are locked */
 
        if (unlikely(printed)) {
-               pdc_printf(
+               printk(KERN_WARNING
                        "%s:%d: write_lock grabbed in %s at %p(%d) %ld ticks\n",
                        bfile, bline, current->comm, inline_pc,
                        cpu, jiffies - started);
        }
 }
 
-int _dbg_write_trylock(rwlock_t *rw, const char *bfile, int bline)
-{
-#if 0
-       void *inline_pc = __builtin_return_address(0);
-       int cpu = smp_processor_id();
-#endif
-       
-       if(unlikely(in_interrupt())) {  /* acquiring write lock in interrupt context, bad idea */
-               pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
-               BUG();
-       }
-
-       /* Note: if interrupts are disabled (which is most likely), the printk
-       will never show on the console. We might need a polling method to flush
-       the dmesg buffer anyhow. */
-       
-       _raw_spin_lock(&rw->lock);
-
-       if(rw->counter != 0) {
-               /* this basically never happens */
-               _raw_spin_unlock(&rw->lock);
-               
-               
-               return 0;
-       }
-
-       /* got it.  now leave without unlocking */
-       rw->counter = -1; /* remember we are locked */
-#if 0
-       pdc_printf("%s:%d: try write_lock grabbed in %s at %p(%d)\n",
-                  bfile, bline, current->comm, inline_pc, cpu);
-#endif
-}
-
 void _dbg_read_lock(rwlock_t * rw, const char *bfile, int bline)
 {
 #if 0
@@ -266,7 +215,7 @@ void _dbg_read_lock(rwlock_t * rw, const char *bfile, int bline)
 
        rw->counter++;
 #if 0
-       pdc_printf(
+       printk(KERN_WARNING
                "%s:%d: read_lock grabbed in %s at %p(%d) %ld ticks\n",
                bfile, bline, current->comm, inline_pc,
                cpu, jiffies - started);