From patchwork Tue Jul 3 06:50:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 938416 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KZdq694Hz9s29 for ; Tue, 3 Jul 2018 16:55:59 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J6Fzle3x"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41KZdq4bX5zF1Pm for ; Tue, 3 Jul 2018 16:55:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J6Fzle3x"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J6Fzle3x"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41KZXm6G5MzF1NW for ; Tue, 3 Jul 2018 16:51:36 +1000 (AEST) Received: by mail-pf0-x242.google.com with SMTP id b17-v6so531980pfi.0 for ; Mon, 02 Jul 2018 23:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ekKHE1upI1u6JQRCI10SmXBvRXgm/pCCr/snxtYlQNI=; b=J6Fzle3xuXyBrIfVUrAKawmeVV6kFzHf3JZVhUDigezTcrC9fNJ5fdbeVU3Drd0kKV X6G5GsecuddQm1du9kG7HkYKiGIKEjPtc7/IhravSKUIqWPlyTgwuSEyIsAteZ3f0kTF DsewFtxM2fuS0UqKGEBy9SNSBr9p5JMTO0G8y3n+C2H2AYJmWne+MOYP5JvoYNf6ee+I /C8B/xhiGbjUPu5Q26gmSUkVnTTEYQ2NoL31172BC2b1jqN/+BLScnoaPK6zdjpAR3iI +lZKe44PrLi+LRGiC/gB3Kc0JM7ODliHZFLZf3qUelGzuxPkzu3TMriTuIClaOnl6gp7 PT0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ekKHE1upI1u6JQRCI10SmXBvRXgm/pCCr/snxtYlQNI=; b=GE9q1+rh7mBX6znIg8m1gOhRwDKqicAQLF5lFitFDrui1INlOjGPTNX/Kp9ZH2Omee VBZTAkN8r+FeLF88KEkYcxxQ6x5GmeNGy5il41PNnJ1Go0zeu5eRAxtcFFxCaaiFYvU5 3s1Ex4QFJwQXqnG4RZ4tmiVh/xMxGaVDTaRdVNaEgusGT2JY5EL5ddr18ymCBzZsU8N/ R0CWz2AhS/5xQrvvIgqrqB/6ID+Jd1IEDtyo9S/YP5L/oWDbcmO1/4HNCLoa3H4ALW2J lpqC+FGnwhi1XTgsI8tXLW7kdrM1rTxCRGqrV/7NUu9/+H9xyb3mAyf0uqE+7HbKKG16 CQYA== X-Gm-Message-State: APt69E3SeypwT4R95CFvPHW3AC2IUel/yujPFBtiTapJZ1GLY777lUU7 AZUFGCmlSRJofUBq7oowaQ== X-Google-Smtp-Source: AAOMgpcXhK2+wv6kn1QNTEtwzk89l3S+HwU2Q0sPNI/o4r91egKKDeLLprRI33urfADgU5fGOwDxUg== X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr28007532pfx.246.1530600694598; Mon, 02 Jul 2018 23:51:34 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e189-v6sm981122pfe.52.2018.07.02.23.51.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 23:51:34 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Subject: [PATCHv3 1/4] drivers/base: fold the routine of device's shutdown into a func Date: Tue, 3 Jul 2018 14:50:39 +0800 Message-Id: <1530600642-25090-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> References: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Greg Kroah-Hartman , "Rafael J . Wysocki" , linuxppc-dev@lists.ozlabs.org, Pingfan Liu , Christoph Hellwig , Bjorn Helgaas , linux-pci@vger.kernel.org, Dave Young Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Pack the code into a function to ease the using and reading. Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Grygorii Strashko Cc: Christoph Hellwig Cc: Bjorn Helgaas Cc: Dave Young Cc: linux-pci@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Pingfan Liu --- drivers/base/core.c | 100 +++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index df3e1a4..a48868f 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2802,12 +2802,62 @@ int device_move(struct device *dev, struct device *new_parent, } EXPORT_SYMBOL_GPL(device_move); +static void __device_shutdown(struct device *dev) +{ + struct device *parent; + /* + * hold reference count of device's parent to + * prevent it from being freed because parent's + * lock is to be held + */ + parent = get_device(dev->parent); + get_device(dev); + /* + * Make sure the device is off the kset list, in the + * event that dev->*->shutdown() doesn't remove it. + */ + list_del_init(&dev->kobj.entry); + spin_unlock(&devices_kset->list_lock); + + /* hold lock to avoid race with probe/release */ + if (parent) + device_lock(parent); + device_lock(dev); + + /* Don't allow any more runtime suspends */ + pm_runtime_get_noresume(dev); + pm_runtime_barrier(dev); + + if (dev->class && dev->class->shutdown_pre) { + if (initcall_debug) + dev_info(dev, "shutdown_pre\n"); + dev->class->shutdown_pre(dev); + } + if (dev->bus && dev->bus->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->bus->shutdown(dev); + } else if (dev->driver && dev->driver->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->driver->shutdown(dev); + } + + device_unlock(dev); + if (parent) + device_unlock(parent); + + put_device(dev); + put_device(parent); + spin_lock(&devices_kset->list_lock); +} + /** * device_shutdown - call ->shutdown() on each device to shutdown. */ void device_shutdown(void) { - struct device *dev, *parent; + struct device *dev; spin_lock(&devices_kset->list_lock); /* @@ -2818,53 +2868,7 @@ void device_shutdown(void) while (!list_empty(&devices_kset->list)) { dev = list_entry(devices_kset->list.prev, struct device, kobj.entry); - - /* - * hold reference count of device's parent to - * prevent it from being freed because parent's - * lock is to be held - */ - parent = get_device(dev->parent); - get_device(dev); - /* - * Make sure the device is off the kset list, in the - * event that dev->*->shutdown() doesn't remove it. - */ - list_del_init(&dev->kobj.entry); - spin_unlock(&devices_kset->list_lock); - - /* hold lock to avoid race with probe/release */ - if (parent) - device_lock(parent); - device_lock(dev); - - /* Don't allow any more runtime suspends */ - pm_runtime_get_noresume(dev); - pm_runtime_barrier(dev); - - if (dev->class && dev->class->shutdown_pre) { - if (initcall_debug) - dev_info(dev, "shutdown_pre\n"); - dev->class->shutdown_pre(dev); - } - if (dev->bus && dev->bus->shutdown) { - if (initcall_debug) - dev_info(dev, "shutdown\n"); - dev->bus->shutdown(dev); - } else if (dev->driver && dev->driver->shutdown) { - if (initcall_debug) - dev_info(dev, "shutdown\n"); - dev->driver->shutdown(dev); - } - - device_unlock(dev); - if (parent) - device_unlock(parent); - - put_device(dev); - put_device(parent); - - spin_lock(&devices_kset->list_lock); + __device_shutdown(dev); } spin_unlock(&devices_kset->list_lock); } From patchwork Tue Jul 3 06:50:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 938417 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KZhx1mSDz9s29 for ; Tue, 3 Jul 2018 16:58:41 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BifqwtDC"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41KZhx0BhbzF1Qp for ; Tue, 3 Jul 2018 16:58:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BifqwtDC"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BifqwtDC"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41KZXr5YlpzF1MY for ; Tue, 3 Jul 2018 16:51:40 +1000 (AEST) Received: by mail-pf0-x242.google.com with SMTP id e10-v6so530794pfn.1 for ; Mon, 02 Jul 2018 23:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9ejno87GyeulgdnAebRnV2Zex8zHD6PleTSMZDbb+jI=; b=BifqwtDCFSHMcPabs1Bh9/CyM2p1LbQR/l+26FowG946FQ+3chTBAR5QgHF67sQjgc 1WZTS37cRoMRoPoSGawITY5DNYJDJ4uEBp+rxK6IK4p7TaNc1hbP6FG0Bzppi4lOwMHr P5mQEbxxsavU7YncBC7U4Pe5qxmrmISwKjCOfY8++nj0DuK+R+r9eYqvhQy7VPynw1vF ycJZQ78QNnShCkCmIZgycwgUqfQFq9fj/pW6NQVFysY/BlcVyf576ulqC5SdTYNZ9tWH qptVS4XFpygMMj/H6+zAO3f7+AIMz8ce1VIhkgzj+iGw0jNqMHLoVKKqxCSOh6n2mnU0 kvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9ejno87GyeulgdnAebRnV2Zex8zHD6PleTSMZDbb+jI=; b=JyKSN6ZK7XAB11V/BV5bMna7LvBZP3EuXmojBgAA8NdNVYXgPvT0zcvRxrABo3dUUi ksvo4CApkKOdN+0CsJ4LzGaylJBewkjMfPyoU19xJ9mxA2NaTSwiYCXLDFyg+6au+Ct3 EYvOS9oNndkGsjJOyfT15gZ9ydVnGh28XhkqUIZAPlikrmji26dCrtNRS65fLwXj2Jz6 Bu0/lmvkFwe7Z418irWBGmfKARmgUs8W+5YscxJlxE4EUVRR3DiWqzv3ODm9CK5g32si zSktSms44vFbYG5Z2YXoM2/SaqZEiEOWr6Bn0JO5mi37wRIHLYxILmYJo42HFs1lQnlV vJNA== X-Gm-Message-State: APt69E2jyGlNHFCNsJayvcJq/B8v6kJoH+gyOD91W6ScNgK4HfjlZkOU Y/iGMgCjR2UjI2vlh5NabQ== X-Google-Smtp-Source: AAOMgpdyHfY7IfXmh16bgzGm3fOZd/ietu45vS2ArjouRdpg9HU8P7QmfJSO18YfkBqdZYbJATKfYA== X-Received: by 2002:a65:6243:: with SMTP id q3-v6mr21853883pgv.273.1530600699193; Mon, 02 Jul 2018 23:51:39 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e189-v6sm981122pfe.52.2018.07.02.23.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 23:51:38 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Subject: [PATCHv3 2/4] drivers/base: utilize device tree info to shutdown devices Date: Tue, 3 Jul 2018 14:50:40 +0800 Message-Id: <1530600642-25090-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> References: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Greg Kroah-Hartman , "Rafael J . Wysocki" , linuxppc-dev@lists.ozlabs.org, Pingfan Liu , Christoph Hellwig , Bjorn Helgaas , linux-pci@vger.kernel.org, Dave Young Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" commit 52cdbdd49853 ("driver core: correct device's shutdown order") places an assumption of supplier<-consumer order on the process of probe. But it turns out to break down the parent <- child order in some scene. E.g in pci, a bridge is enabled by pci core, and behind it, the devices have been probed. Then comes the bridge's module, which enables extra feature(such as hotplug) on this bridge. This will break the parent<-children order and cause failure when "kexec -e" in some scenario. The detailed description of the scenario: An IBM Power9 machine on which, two drivers portdrv_pci and shpchp(a mod) match the PCI_CLASS_BRIDGE_PCI, but neither of them success to probe due to some issue. For this case, the bridge is moved after its children in devices_kset. Then, when "kexec -e", a ata-disk behind the bridge can not write back buffer in flight due to the former shutdown of the bridge which clears the BusMaster bit. It is a little hard to impose both "parent<-child" and "supplier<-consumer" order on devices_kset. Take the following scene: step0: before a consumer's probing, (note child_a is supplier of consumer_a) [ consumer-X, child_a, ...., child_z] [... consumer_a, ..., consumer_z, ...] supplier-X ^^^^^^^^^^ affected range ^^^^^^^^^^ step1: when probing, moving consumer-X after supplier-X [ child_a, ...., child_z] [.... consumer_a, ..., consumer_z, ...] supplier-X, consumer-X step2: the children of consumer-X should be re-ordered to maintain the seq [... consumer_a, ..., consumer_z, ....] supplier-X [consumer-X, child_a, ...., child_z] step3: the consumer_a should be re-ordered to maintain the seq [... consumer_z, ...] supplier-X [ consumer-X, child_a, consumer_a ..., child_z] It requires two nested recursion to drain out all out-of-order item in "affected range". To avoid such complicated code, this patch suggests to utilize the info in device tree, instead of using the order of devices_kset during shutdown. It iterates the device tree, and firstly shutdown a device's children and consumers. After this patch, the buggy commit is hollow and left to clean. Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Grygorii Strashko Cc: Christoph Hellwig Cc: Bjorn Helgaas Cc: Dave Young Cc: linux-pci@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Pingfan Liu --- drivers/base/core.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- include/linux/device.h | 1 + 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index a48868f..684b994 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1446,6 +1446,7 @@ void device_initialize(struct device *dev) INIT_LIST_HEAD(&dev->links.consumers); INIT_LIST_HEAD(&dev->links.suppliers); dev->links.status = DL_DEV_NO_DRIVER; + dev->shutdown = false; } EXPORT_SYMBOL_GPL(device_initialize); @@ -2811,7 +2812,6 @@ static void __device_shutdown(struct device *dev) * lock is to be held */ parent = get_device(dev->parent); - get_device(dev); /* * Make sure the device is off the kset list, in the * event that dev->*->shutdown() doesn't remove it. @@ -2842,23 +2842,60 @@ static void __device_shutdown(struct device *dev) dev_info(dev, "shutdown\n"); dev->driver->shutdown(dev); } - + dev->shutdown = true; device_unlock(dev); if (parent) device_unlock(parent); - put_device(dev); put_device(parent); spin_lock(&devices_kset->list_lock); } +/* shutdown dev's children and consumer firstly, then itself */ +static int device_for_each_child_shutdown(struct device *dev) +{ + struct klist_iter i; + struct device *child; + struct device_link *link; + + /* already shutdown, then skip this sub tree */ + if (dev->shutdown) + return 0; + + if (!dev->p) + goto check_consumers; + + /* there is breakage of lock in __device_shutdown(), and the redundant + * ref++ on srcu protected consumer is harmless since shutdown is not + * hot path. + */ + get_device(dev); + + klist_iter_init(&dev->p->klist_children, &i); + while ((child = next_device(&i))) + device_for_each_child_shutdown(child); + klist_iter_exit(&i); + +check_consumers: + list_for_each_entry_rcu(link, &dev->links.consumers, s_node) { + if (!link->consumer->shutdown) + device_for_each_child_shutdown(link->consumer); + } + + __device_shutdown(dev); + put_device(dev); + return 0; +} + /** * device_shutdown - call ->shutdown() on each device to shutdown. */ void device_shutdown(void) { struct device *dev; + int idx; + idx = device_links_read_lock(); spin_lock(&devices_kset->list_lock); /* * Walk the devices list backward, shutting down each in turn. @@ -2866,11 +2903,12 @@ void device_shutdown(void) * devices offline, even as the system is shutting down. */ while (!list_empty(&devices_kset->list)) { - dev = list_entry(devices_kset->list.prev, struct device, + dev = list_entry(devices_kset->list.next, struct device, kobj.entry); - __device_shutdown(dev); + device_for_each_child_shutdown(dev); } spin_unlock(&devices_kset->list_lock); + device_links_read_unlock(idx); } /* diff --git a/include/linux/device.h b/include/linux/device.h index 055a69d..8a0f784 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1003,6 +1003,7 @@ struct device { bool offline:1; bool of_node_reused:1; bool dma_32bit_limit:1; + bool shutdown:1; /* one direction: false->true */ }; static inline struct device *kobj_to_dev(struct kobject *kobj) From patchwork Tue Jul 3 06:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 938422 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KZlz1fg9z9s29 for ; Tue, 3 Jul 2018 17:01:19 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gwN5kjXE"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41KZlz07bjzF1LS for ; Tue, 3 Jul 2018 17:01:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gwN5kjXE"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::243; helo=mail-pg0-x243.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gwN5kjXE"; dkim-atps=neutral Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41KZXx5k3xzF1NW for ; Tue, 3 Jul 2018 16:51:45 +1000 (AEST) Received: by mail-pg0-x243.google.com with SMTP id y5-v6so511235pgv.1 for ; Mon, 02 Jul 2018 23:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J0qcgsC/nOB72p/BlSDBRNrZW7QvDpARz7p33AuGiHQ=; b=gwN5kjXEb7A1aCEEgS/9KWn/ZpZNC/JdunGRP1vnX0chizwjYLi6/Bx7RJ4PA4sLzV 32gNLbeOofU/h54TDqpImxQVTrwQGq80nUdyOL+AOFw7uQgA79ofrQZBlTsZ4AnqX5MC E2T8Bv1PzejxT/JfBiFfL2rLYG6TIp71D2TIxql9prUfFJdkjBt1TlhfhuKMkEt5f/pu cDbKvh48xI9ParIixijmTCRkjZ4UzjvS/CwTj2R0x9o7xwzSGHHcIGagj31gi0Eq8btf WxoRDKVAKox74/zZlwxkiMAjFSgzKXUTPCIcijPnrlOg2Bed3Xw07eAD2hDrKk1l3Cg1 fVtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J0qcgsC/nOB72p/BlSDBRNrZW7QvDpARz7p33AuGiHQ=; b=KVWM2wZvkVeqy+4O78GPdZ9te6MzlyOD2BRgqUp0DwPdxb1FJILX8Nm4autJDsB2Qq 9D70h6RoayxMA7k8NeCsZIkjZkhqbIY29Y6GJYI+xvNbOytIp5Z+FvNI23g8StKglrLf fAPym06Rt6XRxOjCPKhLl9WXfpaHE7O0NsX4tNXnRvia8+crUCsbzdLrJQ5YEcy6x3Wi 2VKPutX1QAZ7Nw911L78ce3xOLW73uD40Cm8iT6Nq30Ck2B8xWuRip8G7H2MLsMGYjYH Z76kQh1WCJbVflWFSH6ZfTpKN5xde/akaPXXf0x+34VpKNshMCZU3cXM87sx1Id1PAy3 QoPw== X-Gm-Message-State: APt69E0iQ/GsPYPRLIpk4WeNMhLkMXfw+0SqOX3kbDkZd9KCoCrLaGfZ Wo3FFmQ7+LBQCii5sPH4Dg== X-Google-Smtp-Source: AAOMgpc8we1A7tpNoH7LXfsSvOG5VjIN+I6r6hsXSi64Ui8JTgJYGfi58fw6A8n+svczuGgzGsKB7Q== X-Received: by 2002:a63:2581:: with SMTP id l123-v6mr24239534pgl.226.1530600703667; Mon, 02 Jul 2018 23:51:43 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e189-v6sm981122pfe.52.2018.07.02.23.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 23:51:43 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Subject: [PATCHv3 3/4] drivers/base: clean up the usage of devices_kset_move_last() Date: Tue, 3 Jul 2018 14:50:41 +0800 Message-Id: <1530600642-25090-4-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> References: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Greg Kroah-Hartman , "Rafael J . Wysocki" , linuxppc-dev@lists.ozlabs.org, Pingfan Liu , Christoph Hellwig , Bjorn Helgaas , linux-pci@vger.kernel.org, Dave Young Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Clean up the referring to the code in commit 52cdbdd49853 ("driver core: correct device's shutdown order"). So later we can revert it safely. Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Grygorii Strashko Cc: Christoph Hellwig Cc: Bjorn Helgaas Cc: Dave Young Cc: linux-pci@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Pingfan Liu --- drivers/base/core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 684b994..db3deb8 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -127,13 +127,6 @@ static int device_reorder_to_tail(struct device *dev, void *not_used) { struct device_link *link; - /* - * Devices that have not been registered yet will be put to the ends - * of the lists during the registration, so skip them here. - */ - if (device_is_registered(dev)) - devices_kset_move_last(dev); - if (device_pm_initialized(dev)) device_pm_move_last(dev); From patchwork Tue Jul 3 06:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 938423 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KZpd3btHz9s29 for ; Tue, 3 Jul 2018 17:03:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E8r1qZAL"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41KZpd22KzzF1PD for ; Tue, 3 Jul 2018 17:03:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E8r1qZAL"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::244; helo=mail-pg0-x244.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E8r1qZAL"; dkim-atps=neutral Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41KZY21k6vzF1NW for ; Tue, 3 Jul 2018 16:51:50 +1000 (AEST) Received: by mail-pg0-x244.google.com with SMTP id l65-v6so503242pgl.8 for ; Mon, 02 Jul 2018 23:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TXQBgUrpFuHfd5+LvClU01eky3CM9TxFnoMItwpkzv0=; b=E8r1qZALHqIGg1WF8yStaNZz81lteokOux2GU2D3LlhOz1ksJbJNYA4UPZ6m/JG4N/ qG2FJTHUxoCrkzFxwO0AjO9VRGTjvUynfpmx3F2IE18TrrZIPLXJNL18/kM2r9sbQTPI hz7s3+qkcd9Cj3D3trayVvY4FpwxcP0J8bhJprCwbc4w2+bu0DUPzdR0fm/DCvWo0qwl 1vKl+MzdkSls7DVRwz9yi1uZ6fCkNO34WVcNVtfF3hlqV1WqdT832QJ1FTShEq/iMjpp 5GNa5ve12EstO5uO40CulO+yr4OB6cxvb4GLWeJD2Dx1PO7UG6ecvVclrY3g9XmAb1PR VwLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TXQBgUrpFuHfd5+LvClU01eky3CM9TxFnoMItwpkzv0=; b=C6WZz8l3Ek7dfWbTG+39ycNUk8+UcMFuhGMZPOkBwJ+mpV5z+dCHhg8MJuFdaB87LG K0If6rflV6p6hLqNeqey8/ix5JD9x4wWuvuliT23KTvHPyAcIK0+fPLt+yuJWjlFCUKl AzgRSo4SLGicTMmCH7IX0Wq82cTLXiFilT29zluNUu2g4Hc1fbLX/xvslj4d//FQWaQA mQ6Y44W3SgOT8pfG9lGsxxlxHVL7t3Ucw4kdxGFaWLWGNifD5l2eaBsP0zuHsT6AVrhQ Gdxn8QTdmoIUxmK/QYv7vs45UdD2AbhKYxdU2fcnYMX7sY70K6MDNIUkgclarL6aK6lk nT6g== X-Gm-Message-State: APt69E3zHU6FXBGmw6NVvflP+UHl/7NtLUN28B2rHVd6VTTFelH8A9og IxFnKTa+r77w+cdfoYdLBw== X-Google-Smtp-Source: ADUXVKIsyrhMEDGcj3FLR5qX06Is3G/1e7BmbsyqvF94o3T4VEPJGjCgrNPry/qjR7D83IJJgQ41NQ== X-Received: by 2002:a65:5683:: with SMTP id v3-v6mr23783860pgs.176.1530600708137; Mon, 02 Jul 2018 23:51:48 -0700 (PDT) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id e189-v6sm981122pfe.52.2018.07.02.23.51.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 23:51:47 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Subject: [PATCHv3 4/4] Revert "driver core: correct device's shutdown order" Date: Tue, 3 Jul 2018 14:50:42 +0800 Message-Id: <1530600642-25090-5-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> References: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Greg Kroah-Hartman , "Rafael J . Wysocki" , linuxppc-dev@lists.ozlabs.org, Pingfan Liu , Christoph Hellwig , Bjorn Helgaas , linux-pci@vger.kernel.org, Dave Young Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This reverts commit 52cdbdd49853dfa856082edb0f4c4c0249d9df07. Since the device_shutdown() does not rely on the order in devices_kset any more, reverting that commit safely. Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Grygorii Strashko Cc: Christoph Hellwig Cc: Bjorn Helgaas Cc: Dave Young Cc: linux-pci@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Pingfan Liu --- drivers/base/base.h | 1 - drivers/base/core.c | 49 ------------------------------------------------- drivers/base/dd.c | 8 -------- 3 files changed, 58 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index a75c302..5bc9064 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -135,7 +135,6 @@ extern void device_unblock_probing(void); /* /sys/devices directory */ extern struct kset *devices_kset; -extern void devices_kset_move_last(struct device *dev); #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) extern void module_add_driver(struct module *mod, struct device_driver *drv); diff --git a/drivers/base/core.c b/drivers/base/core.c index db3deb8..570aeee 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1259,52 +1259,6 @@ static DEVICE_ATTR_RO(dev); struct kset *devices_kset; /** - * devices_kset_move_before - Move device in the devices_kset's list. - * @deva: Device to move. - * @devb: Device @deva should come before. - */ -static void devices_kset_move_before(struct device *deva, struct device *devb) -{ - if (!devices_kset) - return; - pr_debug("devices_kset: Moving %s before %s\n", - dev_name(deva), dev_name(devb)); - spin_lock(&devices_kset->list_lock); - list_move_tail(&deva->kobj.entry, &devb->kobj.entry); - spin_unlock(&devices_kset->list_lock); -} - -/** - * devices_kset_move_after - Move device in the devices_kset's list. - * @deva: Device to move - * @devb: Device @deva should come after. - */ -static void devices_kset_move_after(struct device *deva, struct device *devb) -{ - if (!devices_kset) - return; - pr_debug("devices_kset: Moving %s after %s\n", - dev_name(deva), dev_name(devb)); - spin_lock(&devices_kset->list_lock); - list_move(&deva->kobj.entry, &devb->kobj.entry); - spin_unlock(&devices_kset->list_lock); -} - -/** - * devices_kset_move_last - move the device to the end of devices_kset's list. - * @dev: device to move - */ -void devices_kset_move_last(struct device *dev) -{ - if (!devices_kset) - return; - pr_debug("devices_kset: Moving %s to end of list\n", dev_name(dev)); - spin_lock(&devices_kset->list_lock); - list_move_tail(&dev->kobj.entry, &devices_kset->list); - spin_unlock(&devices_kset->list_lock); -} - -/** * device_create_file - create sysfs attribute file for device. * @dev: device. * @attr: device attribute descriptor. @@ -2776,15 +2730,12 @@ int device_move(struct device *dev, struct device *new_parent, break; case DPM_ORDER_DEV_AFTER_PARENT: device_pm_move_after(dev, new_parent); - devices_kset_move_after(dev, new_parent); break; case DPM_ORDER_PARENT_BEFORE_DEV: device_pm_move_before(new_parent, dev); - devices_kset_move_before(new_parent, dev); break; case DPM_ORDER_DEV_LAST: device_pm_move_last(dev); - devices_kset_move_last(dev); break; } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 1435d72..6ebcd65 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -434,14 +434,6 @@ static int really_probe(struct device *dev, struct device_driver *drv) goto probe_failed; } - /* - * Ensure devices are listed in devices_kset in correct order - * It's important to move Dev to the end of devices_kset before - * calling .probe, because it could be recursive and parent Dev - * should always go first - */ - devices_kset_move_last(dev); - if (dev->bus->probe) { ret = dev->bus->probe(dev); if (ret)