{"id":2230375,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230375/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260429175016.7915-2-djeffery@redhat.com/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/1.1/projects/28/?format=json","name":"Linux PCI development","link_name":"linux-pci","list_id":"linux-pci.vger.kernel.org","list_email":"linux-pci@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260429175016.7915-2-djeffery@redhat.com>","date":"2026-04-29T17:50:12","name":"[1/5] driver core: separate function to shutdown one device","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"bb0f21284663b9d835b7143908502187083890e1","submitter":{"id":24471,"url":"http://patchwork.ozlabs.org/api/1.1/people/24471/?format=json","name":"David Jeffery","email":"djeffery@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260429175016.7915-2-djeffery@redhat.com/mbox/","series":[{"id":502117,"url":"http://patchwork.ozlabs.org/api/1.1/series/502117/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=502117","date":"2026-04-29T17:50:11","name":"shut down devices asynchronously","version":15,"mbox":"http://patchwork.ozlabs.org/series/502117/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230375/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230375/checks/","tags":{},"headers":{"Return-Path":"\n <linux-pci+bounces-53405-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=JAzmF7pk;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53405-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=\"JAzmF7pk\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=170.10.133.124","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=redhat.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5PyP2zFQz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 03:52:13 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 82197304A84F\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 17:51:04 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E2F0D38B133;\n\tWed, 29 Apr 2026 17:51:01 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 674B738B12F\n\tfor <linux-pci@vger.kernel.org>; Wed, 29 Apr 2026 17:51:00 +0000 (UTC)","from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-344-dKMwVYqFMc6TdsCEsQTSYg-1; Wed,\n 29 Apr 2026 13:50:56 -0400","from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 3009518005AA;\n\tWed, 29 Apr 2026 17:50:53 +0000 (UTC)","from fedora-work.redhat.com (unknown [10.22.80.165])\n\tby mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 25DDE300019F;\n\tWed, 29 Apr 2026 17:50:47 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777485061; cv=none;\n b=EBQY8Rk1krKNoG5tmbo9Xh9+Xoy4s1rxxfncdH11XM6rrWGYtmzmDjKCqJlMUunelcy9OS0v6gbKAfKIbAzbTMcg8b+mOxsIKCf7HEmWryFeAionRLX96HQ7AsA3WxwPmrkmNUO0P9fQg9QpACfhVow55nboPAbVxhsCtzATiQY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777485061; c=relaxed/simple;\n\tbh=STIwt9gAk1FaUXXBbUvSbB4skwLNDKuHH/bTEx0BxrY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=rjqcgAAV20+WZPHW60XdPKM3fTsE0iOZRgOIp95Zs51+tGqkC/Vlhjox6wnpocgLqF8l6QLkiayLvu9JUsId64pETz1ur7JW61s3YW3uv7K2q/hfxgWJLbcOzABOvR+cQ+gAaA+RJQdnU7fC5AOw5fTcR8YUn6ZtkI6cIf43Oj0=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=redhat.com;\n spf=pass smtp.mailfrom=redhat.com;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.b=JAzmF7pk; arc=none smtp.client-ip=170.10.133.124","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1777485059;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=/C64blJM3Kjz6Rlhck7tMz+JFCKWeVjDfMx7FPCDn24=;\n\tb=JAzmF7pkQ7DBReY8pDvybrHl75h/guTVZaduWYRH+I7A89LPFxy4SsR/MXult/bEm21Guh\n\tfQ/HNBSul1ioCGBx8nYWYAeT8SMyHMP5yauOtE3mNFNg/2WmZ3oJFefzckwa9TZOLXz5Dm\n\tqAw7wex5J6/VUymwza9Y0iKckJq2IbU=","X-MC-Unique":"dKMwVYqFMc6TdsCEsQTSYg-1","X-Mimecast-MFC-AGG-ID":"dKMwVYqFMc6TdsCEsQTSYg_1777485053","From":"David Jeffery <djeffery@redhat.com>","To":"linux-kernel@vger.kernel.org,\n\tdriver-core@lists.linux.dev,\n\tlinux-pci@vger.kernel.org,\n\tlinux-scsi@vger.kernel.org,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\t\"Rafael J. Wysocki\" <rafael@kernel.org>,\n\tDanilo Krummrich <dakr@kernel.org>","Cc":"Tarun Sahu <tarunsahu@google.com>, Pasha Tatashin <tatashin@google.com>,\n\t=?utf-8?b?TWljaGHFgiBDxYJhcGnFhHNraQ==?= <mclapinski@google.com>,\n Jordan Richards <jordanrichards@google.com>, Ewan Milne <emilne@redhat.com>,\n John Meneghini <jmeneghi@redhat.com>, \"Lombardi,\n Maurizio\" <mlombard@redhat.com>, Stuart Hayes <stuart.w.hayes@gmail.com>,\n Laurence Oberman <loberman@redhat.com>, Bart Van Assche <bvanassche@acm.org>,\n Bjorn Helgaas <helgaas@kernel.org>,\n \"Martin K . Petersen\" <martin.petersen@oracle.com>,\n John Garry <john.g.garry@oracle.com>, kexec@lists.infradead.org,\n David Jeffery <djeffery@redhat.com>,\n Pasha Tatashin <pasha.tatashin@soleen.com>","Subject":"[PATCH 1/5] driver core: separate function to shutdown one device","Date":"Wed, 29 Apr 2026 13:50:12 -0400","Message-ID":"<20260429175016.7915-2-djeffery@redhat.com>","In-Reply-To":"<20260429175016.7915-1-djeffery@redhat.com>","References":"<20260429175016.7915-1-djeffery@redhat.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.4"},"content":"Make a separate function for the part of device_shutdown() that does the\nshutown for a single device.  This is in preparation for making device\nshutdown asynchronous.\n\nSigned-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>\nSigned-off-by: David Jeffery <djeffery@redhat.com>\nTested-by: Laurence Oberman <loberman@redhat.com>\nReviewed-by: Martin K. Petersen <martin.petersen@oracle.com>\nReviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>\n---\n drivers/base/core.c | 71 +++++++++++++++++++++++++--------------------\n 1 file changed, 39 insertions(+), 32 deletions(-)","diff":"diff --git a/drivers/base/core.c b/drivers/base/core.c\nindex bd2ddf2aab50..90ef21c1e713 100644\n--- a/drivers/base/core.c\n+++ b/drivers/base/core.c\n@@ -4799,12 +4799,48 @@ int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid)\n \treturn error;\n }\n \n+static void shutdown_one_device(struct device *dev)\n+{\n+\tstruct device *parent = dev->parent;\n+\n+\t/* hold lock to avoid race with probe/release */\n+\tif (parent)\n+\t\tdevice_lock(parent);\n+\tdevice_lock(dev);\n+\n+\t/* Don't allow any more runtime suspends */\n+\tpm_runtime_get_noresume(dev);\n+\tpm_runtime_barrier(dev);\n+\n+\tif (dev->class && dev->class->shutdown_pre) {\n+\t\tif (initcall_debug)\n+\t\t\tdev_info(dev, \"shutdown_pre\\n\");\n+\t\tdev->class->shutdown_pre(dev);\n+\t}\n+\tif (dev->bus && dev->bus->shutdown) {\n+\t\tif (initcall_debug)\n+\t\t\tdev_info(dev, \"shutdown\\n\");\n+\t\tdev->bus->shutdown(dev);\n+\t} else if (dev->driver && dev->driver->shutdown) {\n+\t\tif (initcall_debug)\n+\t\t\tdev_info(dev, \"shutdown\\n\");\n+\t\tdev->driver->shutdown(dev);\n+\t}\n+\n+\tdevice_unlock(dev);\n+\tif (parent)\n+\t\tdevice_unlock(parent);\n+\n+\tput_device(parent);\n+\tput_device(dev);\n+}\n+\n /**\n  * device_shutdown - call ->shutdown() on each device to shutdown.\n  */\n void device_shutdown(void)\n {\n-\tstruct device *dev, *parent;\n+\tstruct device *dev;\n \n \twait_for_device_probe();\n \tdevice_block_probing();\n@@ -4826,7 +4862,7 @@ void device_shutdown(void)\n \t\t * prevent it from being freed because parent's\n \t\t * lock is to be held\n \t\t */\n-\t\tparent = get_device(dev->parent);\n+\t\tget_device(dev->parent);\n \t\tget_device(dev);\n \t\t/*\n \t\t * Make sure the device is off the kset list, in the\n@@ -4835,36 +4871,7 @@ void device_shutdown(void)\n \t\tlist_del_init(&dev->kobj.entry);\n \t\tspin_unlock(&devices_kset->list_lock);\n \n-\t\t/* hold lock to avoid race with probe/release */\n-\t\tif (parent)\n-\t\t\tdevice_lock(parent);\n-\t\tdevice_lock(dev);\n-\n-\t\t/* Don't allow any more runtime suspends */\n-\t\tpm_runtime_get_noresume(dev);\n-\t\tpm_runtime_barrier(dev);\n-\n-\t\tif (dev->class && dev->class->shutdown_pre) {\n-\t\t\tif (initcall_debug)\n-\t\t\t\tdev_info(dev, \"shutdown_pre\\n\");\n-\t\t\tdev->class->shutdown_pre(dev);\n-\t\t}\n-\t\tif (dev->bus && dev->bus->shutdown) {\n-\t\t\tif (initcall_debug)\n-\t\t\t\tdev_info(dev, \"shutdown\\n\");\n-\t\t\tdev->bus->shutdown(dev);\n-\t\t} else if (dev->driver && dev->driver->shutdown) {\n-\t\t\tif (initcall_debug)\n-\t\t\t\tdev_info(dev, \"shutdown\\n\");\n-\t\t\tdev->driver->shutdown(dev);\n-\t\t}\n-\n-\t\tdevice_unlock(dev);\n-\t\tif (parent)\n-\t\t\tdevice_unlock(parent);\n-\n-\t\tput_device(dev);\n-\t\tput_device(parent);\n+\t\tshutdown_one_device(dev);\n \n \t\tspin_lock(&devices_kset->list_lock);\n \t}\n","prefixes":["1/5"]}