All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Stefan Roese <sr@denx.de>
Cc: Holger Brunck <holger.brunck@keymile.com>,
	devicetree-discuss@ozlabs.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking
Date: Mon, 10 Dec 2012 17:00:44 +0200	[thread overview]
Message-ID: <1355151644.2657.41.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1354864954-30290-1-git-send-email-sr@denx.de>

[-- 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 --]

WARNING: multiple messages have this Message-ID (diff)
From: Artem Bityutskiy <dedekind1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
Cc: Holger Brunck
	<holger.brunck-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking
Date: Mon, 10 Dec 2012 17:00:44 +0200	[thread overview]
Message-ID: <1355151644.2657.41.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1354864954-30290-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>


[-- Attachment #1.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 #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2012-12-10 14:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  7:22 [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking Stefan Roese
2012-12-07  7:22 ` Stefan Roese
2012-12-07 10:41 ` Holger Brunck
2012-12-07 10:41   ` Holger Brunck
2012-12-10 15:00 ` Artem Bityutskiy [this message]
2012-12-10 15:00   ` Artem Bityutskiy
2012-12-10 18:40   ` Stefan Roese
2012-12-10 18:40     ` Stefan Roese
2012-12-12 15:25     ` Artem Bityutskiy
2012-12-12 15:25       ` Artem Bityutskiy
2012-12-12 15:44       ` Stefan Roese
2012-12-12 15:44         ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355151644.2657.41.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=devicetree-discuss@ozlabs.org \
    --cc=holger.brunck@keymile.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=sr@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.