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

Artem Bityutskiy
2012-12-10T14:59:45Z

[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]