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 729CC3033E8 for ; Thu, 19 Mar 2026 14:12:17 +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=1773929539; cv=none; b=KXFk1+BHzYNt1cAgyPBzAlaigtj0kRBRKNImFIQa9JW7Wkny72lxton3ij+X1VWSeKpbW+4NrtbOuieUitYsFALasKU1kAFpTiKz9ehTKRr7h4q7rIHJOffwDjyStzpnJH6L3pqVbD1cDg/DAVao72KdH/LOSJLSZDl+pGKhERA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773929539; c=relaxed/simple; bh=IfyjG0oQAceFxDXb4D6xoWuus9aQ/LmlQ+KniKVfTBk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=ebfpmZnIRwSHUqimGvw6sr7Bi15G9z8sqYUfRKiHkqrEmYj8LYVo5skFGt0M/b0H69zTNbPhVNyLKXSjcL83B3QtfZQUu7c5cadaWc71xxEuBxr3eA/wmYW/+ycgbbTCKcyOZZ+w1Z1SQLmh4ThbopoEH/9Ywde6sKPSN1rqTTQ= 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=JfUmwBZF; 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="JfUmwBZF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773929536; 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: in-reply-to:in-reply-to:references:references; bh=f9patlQbuB55/bJm1JsV9uGRmDphoePFBzZFkCXjCLA=; b=JfUmwBZF0g250tXYuPYWZOUxs9ZUe4gTpUaELAdoP93YWPphH1nA7jnkZsP+DMcfxQf0HR Oo8GPiP4v3HaVgh9FoT6Y0kE8wjjsDrYKs9bRpKgYRQ+MnF4rnOuwTuDQ1pVD8X73g0CCd Hn42u6ufpWM/dVIjRec37kKyL7ykDjU= 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-203-rWK4Yi85M2a3SwDFL_sLtg-1; Thu, 19 Mar 2026 10:12:14 -0400 X-MC-Unique: rWK4Yi85M2a3SwDFL_sLtg-1 X-Mimecast-MFC-AGG-ID: rWK4Yi85M2a3SwDFL_sLtg_1773929531 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 787B71800625; Thu, 19 Mar 2026 14:12:11 +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 07C2F180035F; Thu, 19 Mar 2026 14:12:06 +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 2/5] driver core: do not always lock parent in shutdown Date: Thu, 19 Mar 2026 10:11:39 -0400 Message-ID: <20260319141142.5781-3-djeffery@redhat.com> In-Reply-To: <20260319141142.5781-1-djeffery@redhat.com> References: <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: LFa5lgCpvKq6i-nbVcdyOV2EosOI0c54Y_h_y3CYPrE_1773929531 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Don't lock a parent device unless it is needed in device_shutdown. This is in preparation for making device shutdown asynchronous, when it will be needed to allow children of a common parent to shut down simultaneously. Signed-off-by: Stuart Hayes Signed-off-by: David Jeffery Tested-by: Laurence Oberman --- drivers/base/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 10586298e18b..2e9094f5c5aa 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4782,13 +4782,8 @@ int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid) return error; } -static void shutdown_one_device(struct device *dev) +static void __shutdown_one_device(struct device *dev) { - struct device *parent = dev->parent; - - /* hold lock to avoid race with probe/release */ - if (parent) - device_lock(parent); device_lock(dev); /* Don't allow any more runtime suspends */ @@ -4811,10 +4806,20 @@ static void shutdown_one_device(struct device *dev) } device_unlock(dev); - if (parent) - device_unlock(parent); +} - put_device(parent); +static void shutdown_one_device(struct device *dev) +{ + /* hold lock to avoid race with probe/release */ + if (dev->parent && dev->bus && dev->bus->need_parent_lock) { + device_lock(dev->parent); + __shutdown_one_device(dev); + device_unlock(dev->parent); + } else { + __shutdown_one_device(dev); + } + + put_device(dev->parent); put_device(dev); } -- 2.53.0