From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 304C43064A0 for ; Thu, 19 Mar 2026 14:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929530; cv=none; b=sOINTSoNsshUXRKaewp3WddIl/mZc65ashwg7wMjcou8Cgzac8uc+5pr57b33sKv5rAf/+ViIasSexJVrir1Yjo9n1QCyZ35z4KMrjv+OA+Dt3nv9JgxxgoLYS5+krJx/D+NiZU8L6p13FqMHt30DNmC1dU9zP3m8u+JYVXaUPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929530; c=relaxed/simple; bh=TdmXuTASYkj9Rys1uAyBO/TVceQm1Pu2dfZbHNfEH0U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:content-type; b=QproN5a2aJPhYwc9pQN/U9dl3I+/+zCyxpWHAg/KeKqXZJdc/KDp23pNALkBoh5WLCvPRSG/sHJPjS58yNlQdMTR4XwDtrzg6ZmLvz/wSFRllj55+j5OhYP99XPNrYRNnnnD8jZYR57BLs7rB56OKK7yEZyZrL6cDcuCtoAI1wo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iHvPbIxh; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iHvPbIxh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773929527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V2JdnIhXXzN+GVqrnoeyXIDE2GukG4i3K5MsvMjYc+o=; b=iHvPbIxhbWFDAxG3l/G+lgSX8gJ/vIVQfsWRfdQo7GBIKiCik47+UGxCDUFyXXyp78L0bB TA0Oh6EDKJxJ+xJ0CM6l4BzY0WCSr4xF/N6gCUhRGhIi3yIqq46HTZO9esbo1Vz7NQz8Mz Wuv5Xai1gtJt2X1taENoPRENqY2EHRM= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-JKrbo_QWNIyWR-UJXpAQVw-1; Thu, 19 Mar 2026 10:12:03 -0400 X-MC-Unique: JKrbo_QWNIyWR-UJXpAQVw-1 X-Mimecast-MFC-AGG-ID: JKrbo_QWNIyWR-UJXpAQVw_1773929522 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BCF6918005BE; Thu, 19 Mar 2026 14:12:01 +0000 (UTC) Received: from fedora-work.redhat.com (unknown [10.22.66.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E7871800351; Thu, 19 Mar 2026 14:11:57 +0000 (UTC) From: David Jeffery To: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: Tarun Sahu , Pasha Tatashin , =?UTF-8?q?Micha=C5=82=20C=C5=82api=C5=84ski?= , Jordan Richards , Ewan Milne , John Meneghini , "Lombardi, Maurizio" , Stuart Hayes , Laurence Oberman , Bart Van Assche , Bjorn Helgaas , David Jeffery Subject: [PATCH v12 0/5] shut down devices asynchronously Date: Thu, 19 Mar 2026 10:11:37 -0400 Message-ID: <20260319141142.5781-1-djeffery@redhat.com> Precedence: bulk X-Mailing-List: driver-core@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-MFC-PROC-ID: UbJosGVHxWTPp1ODcRYdTjvT585ebAbA6dZE1nq3Dqs_1773929522 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true This patchset allows the kernel to shutdown devices asynchronously and unrelated async devices to be shut down in parallel to each other. Only devices which explicitly enable it are shut down asynchronously. The default is for a device to be shut down from the synchronous shutdown loop. This can dramatically reduce system shutdown/reboot time on systems that have multiple devices that take many seconds to shut down (like certain NVMe drives). On one system tested, the shutdown time went from 11 minutes without this patch to 55 seconds with the patch. And on another system from 80 seconds to 11. Changes from V11: * Swap the order of the first two patches * Rework conditional parent locking so that lock and unlock no longer use separate conditional checks * Remove an used variable * Comment and description text cleanups Changes from V10: Reworked to more closely match the design used for async suspend * No longer uses async subsystem cookies for synchronization * Minimized changes to struct device * Enable async shutdown for pci and scsi devices which support async suspend Changes from V9: Address resource and timing issues when spawning a unique async thread for every device during shutdown: * Make the asynchronous threads able to shut down multiple devices, instead of spawning a unique thread for every device. * Modify core kernel async code with a custom wake function so it doesn't wake up a thread waiting to synchronize on a cookie until the cookie has reached the desired value, instead of waking up every waiting thread to check the cookie every time an async thread ends. Changes from V8: Deal with shutdown hangs resulting when a parent/supplier device is later in the devices_kset list than its children/consumers: * Ignore sync_state_only devlinks for shutdown dependencies * Ignore shutdown_after for devices that don't want async shutdown * Add a sanity check to revert to sync shutdown for any device that would otherwise wait for a child/consumer shutdown that hasn't already been scheduled Changes from V7: Do not expose driver async_shutdown_enable in sysfs. Wrapped a long line. Changes from V6: Removed a sysfs attribute that allowed the async device shutdown to be "on" (with driver opt-out), "safe" (driver opt-in), or "off"... what was previously "safe" is now the only behavior, so drivers now only need to have the option to enable or disable async shutdown. Changes from V5: Separated into multiple patches to make review easier. Reworked some code to make it more readable Made devices wait for consumers to shut down, not just children (suggested by David Jeffery) Changes from V4: Change code to use cookies for synchronization rather than async domains Allow async shutdown to be disabled via sysfs, and allow driver opt-in or opt-out of async shutdown (when not disabled), with ability to control driver opt-in/opt-out via sysfs Changes from V3: Bug fix (used "parent" not "dev->parent" in device_shutdown) Changes from V2: Removed recursive functions to schedule children to be shutdown before parents, since existing device_shutdown loop will already do this Changes from V1: Rewritten using kernel async code (suggested by Lukas Wunner) Stuart Hayes (2): driver core: separate function to shutdown one device driver core: don't always lock parent in shutdown David Jeffery (5): driver core: async device shutdown infrastructure PCI: enable async shutdown support scsi: enable async shutdown support drivers/base/base.h | 2 + drivers/base/core.c | 176 +++++++++++++++++++++++++++++++------- drivers/pci/probe.c | 2 + drivers/scsi/hosts.c | 3 + drivers/scsi/scsi_scan.c | 1 + drivers/scsi/scsi_sysfs.c | 4 + include/linux/device.h | 13 +++ 7 files changed, 170 insertions(+), 31 deletions(-) -- 2.53.0