linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 8/9] mmmc: core: Keep PM domain powered during ->probe() of SDIO func driver
Date: Fri, 13 Mar 2015 16:10:14 +0000	[thread overview]
Message-ID: <20150313161014.GR8656@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1426261429-31883-9-git-send-email-ulf.hansson@linaro.org>

On Fri, Mar 13, 2015 at 04:43:48PM +0100, Ulf Hansson wrote:
> To sucessfully probe some devices their corresponding PM domains may
> need to be powered.
> 
> Use the dev_pm_domain_get|put() APIs, to control the behavior of the PM
> domain.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/core/sdio_bus.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index 71357b8..0d89b4b 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -320,7 +320,14 @@ int sdio_add_func(struct sdio_func *func)
>  	if (ret)
>  		return ret;
>  
> +	ret = dev_pm_domain_get(func->dev.pm_domain);
> +	if (ret) {
> +		dev_pm_domain_detach(&func->dev, false);
> +		return ret;
> +	}
> +
>  	ret = device_add(&func->dev);
> +	dev_pm_domain_put(func->dev.pm_domain);

This is broken.  It assumes that the device will be probed in device_add().
That's not always the case.  Come on Ulf, I'm dismayed at you producing
bad and fragile patches like this.  You are the apparent maintainer for
several important subsystems, and you are putting yourself up for more,
yet you don't seem to know the basics about the kernel infrastructure.
That makes you dangerous.

Look, device_add() adds the device to the list of available devices,
publishes it in sysfs, triggers a uevent, and tries to find a driver to
bind it to.

If it doesn't find a driver already registered in the kernel, that could
be because the required driver is a module.  In that case, device_add()
will already have returned.

At some point later, the module will be loaded by user space, and that
will cause the list of devices to be scanned, looking for devices which
the newly registered driver can bind to.  With your code above, these
will _not_ result in the PM domain being "got" before probing.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2015-03-13 16:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 15:43 [PATCH 0/9] PM / Domains: Don't leave unused PM domains powered after ->probe() Ulf Hansson
2015-03-13 15:43 ` [PATCH 1/9] PM / Domains: Add dev_pm_domain_get|put() APIs Ulf Hansson
2015-03-14  1:31   ` Rafael J. Wysocki
2015-03-16  9:26     ` Ulf Hansson
2015-03-17  3:01       ` Rafael J. Wysocki
2015-03-17  9:27         ` Ulf Hansson
2015-03-17 14:45           ` Rafael J. Wysocki
2015-03-17 14:25             ` Russell King - ARM Linux
2015-03-18  1:16               ` Rafael J. Wysocki
2015-03-17 14:40             ` Ulf Hansson
2015-03-18  1:09               ` Rafael J. Wysocki
2015-03-18 13:41                 ` Ulf Hansson
2015-03-18 15:02                   ` [PATCH] driver core / PM: Add callbacks for PM domain initialization/cleanup Rafael J. Wysocki
2015-03-19  8:49                     ` Ulf Hansson
2015-03-19 11:45                       ` Rafael J. Wysocki
2015-03-19 13:16                         ` Ulf Hansson
2015-03-19 13:29                     ` Greg Kroah-Hartman
2015-03-19 14:21                       ` Rafael J. Wysocki
2015-03-19 14:12                         ` Greg Kroah-Hartman
2015-03-19 15:24                           ` Rafael J. Wysocki
2015-03-19 14:20                         ` Alan Stern
2015-03-19 14:45                           ` Ulf Hansson
2015-03-19 15:44                             ` Rafael J. Wysocki
2015-03-19 15:37                               ` Ulf Hansson
2015-03-19 16:04                                 ` Rafael J. Wysocki
2015-03-19 15:48                                   ` Ulf Hansson
2015-03-19 16:18                                     ` Rafael J. Wysocki
2015-03-19 16:58                                       ` [PATCH] driver core / PM: Add PM domain callbacks for device setup/cleanup Rafael J. Wysocki
2015-03-19 21:51                                         ` [PATCH v2] " Rafael J. Wysocki
2015-03-19 22:42                                           ` Dmitry Torokhov
2015-03-20  0:43                                             ` Rafael J. Wysocki
2015-03-20  0:43                                               ` Dmitry Torokhov
2015-03-20  7:45                                           ` Ulf Hansson
2015-03-20 11:37                                             ` Ulf Hansson
2015-03-20 12:31                                               ` Rafael J. Wysocki
2015-03-20 12:57                                           ` [PATCH v3] " Rafael J. Wysocki
2015-03-20 12:59                                             ` Rafael J. Wysocki
2015-03-20 13:44                                               ` Ulf Hansson
2015-03-21  0:09                                               ` Kevin Hilman
2015-03-21  1:00                                               ` Rafael J. Wysocki
2015-03-22 11:46                                                 ` Greg Kroah-Hartman
2015-03-19 14:46                           ` [PATCH] driver core / PM: Add callbacks for PM domain initialization/cleanup Geert Uytterhoeven
2015-03-18 15:09                   ` [PATCH 1/9] PM / Domains: Add dev_pm_domain_get|put() APIs Rafael J. Wysocki
2015-03-13 15:43 ` [PATCH 2/9] PM / Domains: Enable genpd to support ->get|put() callbacks Ulf Hansson
2015-03-16  2:11   ` Chao
2015-03-13 15:43 ` [PATCH 3/9] amba: Keep PM domain powered during ->probe() Ulf Hansson
2015-03-13 16:03   ` Russell King - ARM Linux
2015-03-16  8:37     ` Ulf Hansson
2015-03-13 15:43 ` [PATCH 4/9] drivercore / platform: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 5/9] i2c: core: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 6/9] spi: " Ulf Hansson
2015-03-13 15:43 ` [PATCH 7/9] mmc: core: Attach PM domain prior probing of SDIO func driver Ulf Hansson
2015-03-17  5:04   ` Aaron Lu
2015-03-13 15:43 ` [PATCH 8/9] mmmc: core: Keep PM domain powered during ->probe() " Ulf Hansson
2015-03-13 16:10   ` Russell King - ARM Linux [this message]
2015-03-16  8:24     ` Ulf Hansson
2015-03-13 15:43 ` [PATCH 9/9] Revert "PM / Domains: Power on the PM domain right after attach completes" Ulf Hansson
2015-03-16  9:07   ` Geert Uytterhoeven

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=20150313161014.GR8656@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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).