From: Bjorn Helgaas <bhelgaas@google.com>
To: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
Cc: axboe@kernel.dk, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, stephenmcameron@gmail.com,
thenzl@redhat.com, akpm@linux-foundation.org
Subject: Re: [PATCH] PCI: warn on driver probe return value greater than zero
Date: Wed, 6 Nov 2013 16:30:09 -0700 [thread overview]
Message-ID: <20131106233009.GA28117@google.com> (raw)
In-Reply-To: <20131101193455.18686.92302.stgit@beardog.cce.hp.com>
On Fri, Nov 01, 2013 at 02:34:55PM -0500, Stephen M. Cameron wrote:
> From: Stephen M. Cameron <scameron@beardog.cce.hp.com>
>
> Ages ago, drivers could return values greater than zero from
> their probe function and this would be regarded as success.
> Commit f3ec4f87d607f40497 "PCI: change device runtime PM
> settings for probe and remove" slightly altered this in 2010,
> and commit 967577b062417b4e4b8e27b "PCI/PM: Keep runtime PM
> enabled for unbound PCI devices" in late 2012 altered it more
> signficantly, setting pci_dev->driver to NULL if the driver's
> probe function returned a value greater than zero, which would
> for example prevent the driver's remove function from being
> called on rmmod.
>
> Neither of those changes would necessarily make the driver fail
> in an obvious way though, and so at least a couple drivers (cciss,
> hpsa) fell into this hole since they were returning 1, and this
> situation went unnoticed for quite some time.
>
> If a driver's probe function returns a value greater than zero,
> issue a warning, but otherwise treat this as success.
>
> Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Applied to my pci/misc branch for v3.13, thanks.
Bjorn
> ---
> drivers/pci/pci-driver.c | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 98f7b9b..7fbe343 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -264,11 +264,19 @@ static long local_pci_probe(void *_ddi)
> pm_runtime_get_sync(dev);
> pci_dev->driver = pci_drv;
> rc = pci_drv->probe(pci_dev, ddi->id);
> - if (rc) {
> + if (!rc)
> + return rc;
> + if (rc < 0) {
> pci_dev->driver = NULL;
> pm_runtime_put_sync(dev);
> + return rc;
> }
> - return rc;
> + /*
> + * Probe function should return < 0 for failure, 0 for success
> + * Treat values > 0 as success, but warn.
> + */
> + dev_warn(dev, "Driver probe function unexpectedly returned %d\n", rc);
> + return 0;
> }
>
> static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
>
prev parent reply other threads:[~2013-11-06 23:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 19:34 [PATCH] PCI: warn on driver probe return value greater than zero Stephen M. Cameron
2013-11-06 23:30 ` Bjorn Helgaas [this message]
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=20131106233009.GA28117@google.com \
--to=bhelgaas@google.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=scameron@beardog.cce.hp.com \
--cc=stephenmcameron@gmail.com \
--cc=thenzl@redhat.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 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).