All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Tony Lindgren <tony@atomide.com>,
	linux-omap@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: arm-soc + rmk's tree boot failure on OMAP4430SDP
Date: Mon, 19 Mar 2012 11:33:21 +0200	[thread overview]
Message-ID: <1332149601.2144.15.camel@deskari> (raw)
In-Reply-To: <20120317211505.GA4720@n2100.arm.linux.org.uk>

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

On Sat, 2012-03-17 at 21:15 +0000, Russell King - ARM Linux wrote:

> And the reason is that a platform _driver_ (omapdss_dss) is being
> registered while a platform device (omapdss) is being probed.
> 
> This is a very bad idea.  There is absolutely no reason to register
> drivers from within a probe function - to put it another way, this
> code is absolutely insane.
> 
> Why?  Because you're destroying the whole idea that drivers only ever
> get registered once.  If you happen to have two omapdss devices (okay
> that probably won't happen yet) then you'll register those device
> structures twice which will cause all hell to break lose.
> 
> Moreover - and this is why it's failing - when devices are probed, their
> mutex is held.  But not just _their_ mutex, but also their direct parent's
> mutex as well.
> 
> So, when the omapdss_dss driver is registered while the omapdss device is
> being probed, and there's already an omapdss_dss platform device present,
> the driver model tries to bind the omapdss_dss platform device with the
> newly registered omapdss_dss platform driver.
> 
> That binding wants to take the mutex on the omapdss device, but wait,
> that's already held by the thread registering the omapdss_dss platform
> driver.  Hence, deadlock.
> 
> This mess has been created by all those
> 	"DSS2: xxx: create platform_driver, move init, exit to driver"
> 
> commits, and they're all _wrong_ for the above reason.

Yep, it's totally broken. It's been working by luck, and nobody has paid
attention to it. I noticed this while I was working with device tree
adaptation, and the patches here fix the issue:

http://marc.info/?l=linux-omap&m=133112435224731&w=2

I wasn't planning to merge them yet, as it's quite late in the release
cycle, but it seems I have to. I think I'll drop some of the unrelated
patches (taal and tfp410 related) from that series, as they are just
cleanup-churn.

> However, I doubt simply moving the driver registration calls out of the
> probe function will be enough - "OMAP: DSS2: Fix init and unit sequence"
> hints that there's a dependence in the driver initialization order.
> That's another finger pointing at the approach being wrong, because
> there is _no_ guarantee as to the order in which drivers or devices are
> probed by the driver model.

True. I think the best would be to have a dynamic approach, where the
subdrivers would register themselves somewhere, and it the order
wouldn't matter. That would even allow compiling the subdrivers as
separate modules.

But that's a bigger work item, so what I did in the series above is that
I changed platform_driver_register()s to platform_driver_probe()s. All
the DSS subdevices are present at boot time and are non-hotpluggable, so
I think that should work fine.

However, there's one problem with this approach that is present in the
code: we don't know if platform_driver_probe() returns an error because
there are no devices for the driver (e.g. no HDMI on OMAP3), or because
the probe of the driver failed. In the former case we don't need to care
about the error, but in the latter case we should do something.

I'll try to find a quick solution for this also.

 Tomi


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

  reply	other threads:[~2012-03-19  9:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 23:11 arm-soc + rmk's tree boot failure on OMAP4430SDP Russell King - ARM Linux
2012-03-17  0:47 ` Tony Lindgren
2012-03-17 21:15   ` Russell King - ARM Linux
2012-03-19  9:33     ` Tomi Valkeinen [this message]
2012-03-19 12:30       ` Russell King - ARM Linux
2012-03-19 12:41         ` Tomi Valkeinen
2012-03-19 12:59           ` Russell King - ARM Linux
2012-03-19 13:02           ` Tomi Valkeinen
2012-03-19 13:59             ` Tomi Valkeinen
2012-03-19 19:21               ` Tony Lindgren
2012-03-22  1:15               ` Russ Dill

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=1332149601.2144.15.camel@deskari \
    --to=tomi.valkeinen@ti.com \
    --cc=arnd@arndb.de \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tony@atomide.com \
    /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.