linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected
Date: Wed, 13 Nov 2013 00:44:18 -0800	[thread overview]
Message-ID: <20131113084418.GA16999@norris.computersforpeace.net> (raw)
In-Reply-To: <5282F164.3040509@atmel.com>

Hi Josh,

On Wed, Nov 13, 2013 at 11:26:28AM +0800, Josh Wu wrote:
> On 11/13/2013 8:10 AM, Brian Norris wrote:
> >On Fri, Nov 08, 2013 at 11:46:30AM +0800, Josh Wu wrote:
> >>On 11/8/2013 2:09 AM, Brian Norris wrote:
> >>>   if (nand_nfc.is_initialized) {
> >>>     ...
> >>Yes, exactly.
> >>And the NAND probe will also load the NFC device before it reach
> >>above check code.
> >No, it loads the *driver*, not the *device*. I'm not familiar with the
> >driver core guarantees, but I don't think you can guarantee that just
> >because a driver was registered before another that the corresponding
> >devices will be probed in that order. Or are you relying on the
> >dependencies captured by device tree? (I don't think even the
> >parent/child dependency between NAND/NFC gives you enough.)
> 
> I put  more code here to make it clearer:
> 
> arch/arm/boot/dts/sama5d3.dtsi:
> nand0: nand at 60000000 {
>             compatible = "atmel,at91rm9200-nand";
>             ...
>             ranges;
>             ...
>             nfc at 70000000 {
>                 compatible = "atmel,sama5d3-nfc";
>                 ...
>             };
>         };

Ah, so you're focusing purely on the device tree support? It seems this
driver also supports traditional platform devices, but nobody uses NFC
without DT? That explains some things.

> drivers/mtd/nand/atmel_nand.c
> int atmel_of_init_port() {
>    ...
>    /* load the nfc driver if there is */
>   of_platform_populate(np, NULL, NULL, host->dev);   # <--- Manually
> populate the sub node (NFC node) to load NFC driver
>   ...
> }

Right, that makes sense. So the ordering of the driver registration
stuff is kind of a distraction in this case, then. It's this portion of
the NAND probe that triggers bus_probe_device() to initialize the NFC
device before continuing on.

[snip rest of explanation; thanks!]

So I don't think you have a problem for device tree platforms. But if
someone were to try to instantiate these devices via
platform_device_register(), they will have a problem.

Please, do follow up with the cleanup to the driver registration that
you mentioned.

Brian

  reply	other threads:[~2013-11-13  8:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05  9:59 [PATCH] mtd: atmel_nand: fix bug driver will in a dead lock if no nand detected Josh Wu
2013-11-07  8:39 ` Brian Norris
2013-11-07 10:26   ` Josh Wu
2013-11-07 10:55     ` Nicolas Ferre
2013-11-07 18:09     ` Brian Norris
2013-11-08  3:46       ` Josh Wu
2013-11-13  0:10         ` Brian Norris
2013-11-13  3:26           ` Josh Wu
2013-11-13  8:44             ` Brian Norris [this message]
2013-11-13 10:33               ` Nicolas Ferre
2013-11-07 18:43 ` Brian Norris

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=20131113084418.GA16999@norris.computersforpeace.net \
    --to=computersforpeace@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).