linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Daniel Vetter <daniel@ffwll.ch>, Lukas Wunner <lukas@wunner.de>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Lucas Stach <l.stach@pengutronix.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: [PATCH 2/6] driver core: Reorder actions in __device_links_no_driver()
Date: Thu, 24 Jan 2019 12:16:43 +0100	[thread overview]
Message-ID: <1613403.ZNkCsVQxPT@aspire.rjw.lan> (raw)
In-Reply-To: <2493187.oiOpCWJBV7@aspire.rjw.lan>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

All links to suppliers have to be either "available" or in the
"supplier unbind in progress" state after __device_links_no_driver()
and the kref_put() may not actually delete them, so change the state
of each link in __device_links_no_driver() before attempting to drop
it.

While at it, update the kernedoc comment of __device_links_no_driver()
to reflect what happens more accurately.

Fixes: ead18c23c263 ("driver core: Introduce device links reference counting")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/core.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Index: linux-pm/drivers/base/core.c
===================================================================
--- linux-pm.orig/drivers/base/core.c
+++ linux-pm/drivers/base/core.c
@@ -500,11 +500,11 @@ void device_links_driver_bound(struct de
  * __device_links_no_driver - Update links of a device without a driver.
  * @dev: Device without a drvier.
  *
- * Delete all non-persistent links from this device to any suppliers.
+ * Drop references to non-persistent links from this device to any suppliers.
  *
- * Persistent links stay around, but their status is changed to "available",
- * unless they already are in the "supplier unbind in progress" state in which
- * case they need not be updated.
+ * Links with DL_FLAG_AUTOREMOVE_CONSUMER unset stay around, but their status is
+ * changed to "available", unless they already are in the "supplier unbind in
+ * progress" state in which case they need not be updated.
  *
  * Links with the DL_FLAG_STATELESS flag set are ignored.
  */
@@ -516,10 +516,11 @@ static void __device_links_no_driver(str
 		if (link->flags & DL_FLAG_STATELESS)
 			continue;
 
+		if (link->status != DL_STATE_SUPPLIER_UNBIND)
+			WRITE_ONCE(link->status, DL_STATE_AVAILABLE);
+
 		if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER)
 			kref_put(&link->kref, __device_link_del);
-		else if (link->status != DL_STATE_SUPPLIER_UNBIND)
-			WRITE_ONCE(link->status, DL_STATE_AVAILABLE);
 	}
 
 	dev->links.status = DL_DEV_NO_DRIVER;


  parent reply	other threads:[~2019-01-24 11:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24 11:13 [PATCH 0/6] driver core: Fix some issues related to device links Rafael J. Wysocki
2019-01-24 11:15 ` [PATCH 1/6] driver core: Fix DL_FLAG_AUTOREMOVE_SUPPLIER device link flag handling Rafael J. Wysocki
2019-01-24 11:16 ` Rafael J. Wysocki [this message]
2019-01-24 11:18 ` [PATCH 3/6] driver core: Avoid careless re-use of existing device links Rafael J. Wysocki
2019-01-24 11:19 ` [PATCH 4/6] driver core: Do not resume suppliers under device_links_write_lock() Rafael J. Wysocki
2019-01-24 11:21 ` [PATCH 5/6] driver core: Fix handling of runtime PM flags in device_link_add() Rafael J. Wysocki
2019-01-25 11:18   ` [PATCH v2 " Rafael J. Wysocki
2019-01-24 11:23 ` [PATCH 6/6] driver core: Fix adding device links to probing suppliers Rafael J. Wysocki
2019-01-24 14:58 ` [PATCH 0/6] driver core: Fix some issues related to device links Russell King - ARM Linux admin
2019-01-24 23:08   ` Rafael J. Wysocki
2019-01-31 10:09 ` Rafael J. Wysocki
2019-01-31 13:22   ` Greg Kroah-Hartman
2019-01-31 13:24     ` Greg Kroah-Hartman
2019-01-31 16:02       ` Rafael J. Wysocki
2019-01-31 18:24         ` Greg Kroah-Hartman
2019-01-31 18:36           ` Rafael J. Wysocki
2019-01-31 23:50           ` Rafael J. Wysocki
2019-02-01  0:12             ` Greg Kroah-Hartman
2019-02-01  0:20               ` Rafael J. Wysocki
2019-01-31 16:03       ` Ulf Hansson

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=1613403.ZNkCsVQxPT@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=a.hajda@samsung.com \
    --cc=daniel@ffwll.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=l.stach@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lukas@wunner.de \
    --cc=thierry.reding@gmail.com \
    --cc=ulf.hansson@linaro.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).