Thread (1 message) 1 message, 1 author, 2012-12-10

Re: [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

From: Artem Bityutskiy <hidden>
Date: 2012-12-10 15:00:44

On Fri, 2012-12-07 at 08:22 +0100, Stefan Roese wrote:
+       /*
+        * Wait for some time as unlocking of all sectors takes quite long
+        */
+       timeo = jiffies + (2 * HZ);     /* 2s max (un)locking */
Please, use msecs_to_jiffies() instead.
+       for (;;) {
+               if (chip_ready(map, adr))
+                       break;
+
+               if (time_after(jiffies, timeo)) {
+                       printk(KERN_ERR "Waiting for chip to be ready timed out.\n");
+                       ret = -EIO;
+                       break;
+               }
+               mutex_unlock(&chip->mutex);
+               cfi_udelay(1);
+               mutex_lock(&chip->mutex);
+       } 
Would you please educate me a bit and explain what is protected by
'chip->mutex' and by 'get_chip()'.

Why you need to drop the mutex here?

Why is it not an ABBA deadlock to do this:

Task 1: In the loop above, has chip locked, doing
        mutex_lock(&chip->mutex);

Task 2: done mutex_lock(&chip->mutex), now doing
        ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);

-- 
Best Regards,
Artem Bityutskiy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help