From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796110197; b=cw8EW+DROjVo/078t9wU7Aa8SH0WW4LmGpP5cevGEBUyVpiWfKlL2Zpdpzlh1v4GigWd bMaeTCjcfc615mQBw5kKSIZk6w4gzxnawncRRmBvNzXwKo7m5wbanSAhAVOjJf4EYtHTN JonKq28TwAAdtgSlR44GrP4vGCu1pSx000ByVnczujsjtuTiR8pTJTZSfLTww2ZVxw5us lNjMXJ3sbkIDZ3KQ+RsejRIaS1hIaI2MsySHQ0KcDtRuyBFMNXH3hjiqFCqpGtwSAhqeR JWZ/hF1hWIChZpC3c8n3VfTYTjP2+Npp/xKWa22KDmGEDdiflTLbOc/t+Wt4T63yCgg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110197; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=2kckUWA1mwNK0q6ktC+1BzSfly+AgF5c2jnOKJ1DRds=; b=qfdGSr2sOAKXEptA1brpVrOoqMrvIaZaMWOBhDNqsDnfvBd8Bwwkgk4VXMuyp9Uj8yAi 0o8Wh48IN09SbqIfZ8+XyckYjK19bkR/6k5Ps/WiaGz0+Z8vulor0yHEnMj8Y+CRZRJn7 fVaLb6VhKeMFgfIoKS/5u1juN2adLLmwhkQWug6ySNu2yINV6P71XPV0LzpyWdAlZnMFY RAdHQyIpnGiuGhoQxPI8cc4QMf0jjR/Q1lqs39+rr9djTPgZcGCWu3OqYnPcYILELcAMW qnNGmxU4nzPvhxlypNGcjYY+CKMiJDuRzyLyDUF+A9oCzJEXr4+cjpteEsGG+pg8vNw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i7jm8H6f; arc=none smtp.remote-ip=209.85.215.169 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97A3E606A32A for ; Tue, 1 Dec 2026 07:29:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 97A3E606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i7jm8H6f Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-cded48a6a1fso275631a12.2 for ; Mon, 30 Nov 2026 23:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796110194; x=1796714994; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2kckUWA1mwNK0q6ktC+1BzSfly+AgF5c2jnOKJ1DRds=; b=i7jm8H6f/ooPtZTj1dyIl3WStFO2pFUOMAq+lsqkK6cA5aAzBU+b9LpITQD8pAigw2 ILnmuNl2+wAsDNmCVnsZ8AO1yYrHy1oyoY8UYonQh6S1U49XEL5Y6ZXwg48wwQDXRNo6 v6KzWX/wPisorXImqar5Nr5uWdxYTr3dnNPWsBAvmvpX+G1SifRmA2Ncg8W4F9hdx4Ia C6k8pS0zIjDWYODRWO726vT6syR0QFctLco1JNE+rbmyftPZYNphSdPPDiUkjj9sM7S1 1lAbYXHIvdX/dgQMeArHh5GmUiGAAtF/NZMddbJw3zGh+ZVimUyfyqJ+4aaEYnOlb0tC b4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796110194; x=1796714994; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2kckUWA1mwNK0q6ktC+1BzSfly+AgF5c2jnOKJ1DRds=; b=vwZQCWUkrXDyF0o8QGVDqJtQHlPbHcr6AKxD7HFBKbkt0dggFkSbcLgs637CTCjD3j M/QfJ3QtVE/C9TQ0XPTBX79lhTPV/QAgkWtJGZ1c/6Jyn+hitg/7nNInEbWNSjFaOJhw 5dT5SYdm2W7w2BppIazF56xpvAaMAPH0QOgJgm8qIrhXLGezHyF4zDcvdF92Tpezsrsf qEoUc/F3QRRYyMBFyPmtqCUEPKS/LFVqmbGZznTHciqJbmHF+EWS2hH6LLPM5V/xmp4/ 4DgfAMWb1UEgw5a5maGs0VPmlxqNA6MupUcJPjyJ+gGyf97Kr2gdRfgQbPw4pWBuzKNW X3vg== X-Forwarded-Encrypted: i=1; AL+hErHU56GjsSTw+B8lzeckcWeTRlq5RcqIstEPvTgK3XCldgu8uy/d7zc1vGVQCdZcHnLcFYUBHQNp/jYKAtw=@vger.kernel.org X-Gm-Message-State: APuU4Z+cMeAtKWqatwHBcDxIg1AJ3Xftun8IP1iDushzJCuEL79E8HHQ xZwSq0SVswjGNNOPSkNsVd5H8N8RpmwUQFgCfUvDUv9UxCQR6eT86RNK X-Gm-Gg: AZFdTZeDikzGHDUdOw5rT8jBv5yfvhsOTbeBQxAoMy86a1VibzZWhEuXy7q60aIwRE9 igq/lRyxIGHhWpXAw74L8hBqdvv/qcKHr1+gjUUIu+joZgRfFF9uVUTPptJBlFo0VdKTf9UPpdV fq1QBEgUaQUmtCbvPUSMcXsrf/zMqRtXUubKcZ3ZcqisumYg5PHN9Rg7D6esGtn1XCJZyJQkgDI z/34swT6A0FKKXQ+LXlEpUnSBLZxJ2cMcUvptfgTHbeWUz9LC2rxxiBQQ6Ia0Kd/OjCk0ErDLS1 uQKfNAMAt4rbPjvqWHzPVYYfpc8XANsyDjXgwjk069nJa1vQXMSt2c0zopIt7kLw7NmakPZ67l3 zoqhvz0RQ7i7tKNNEtJpAPTIxfzGLRj6Zx4uUr5DxX7tPzMvGSHmgJLUnORD1UJX+idaXrLqFXR l4rlyrS5OrNOeIMPw34pgt4gB4Xf/2a5PsLP1uP7/rwa4tNe9/FDgVUvrMCPw7QN/iAhKm/Au0A qrrvu1DBZQ3SzpmgwilEJ8AyUZFUMMdrOLTcubfibUmwz5IEVyY3HY/Q6SPUZlePONrI042J6mM 7DgGTxE3sSpIWTbsh4psuouPBrEJHFWWcKXJJYkRgGY+ X-Received: by 2002:a05:6a20:cd58:b0:3fc:7f4f:ba46 with SMTP id adf61e73a8af0-4014ae7675fmr38906692637.2.1796110193810; Mon, 30 Nov 2026 23:29:53 -0800 (PST) Received: from gmail.com ([1.202.120.172]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8cbe173453dsm15947291b3a.25.2026.11.30.23.29.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 23:29:53 -0800 (PST) From: Ziyu Zhang To: rafael@kernel.org Cc: pavel@ucw.cz, lenb@kernel.org, gregkh@linuxfoundation.org, dakr@kernel.org, johan@kernel.org, linux-pm@vger.kernel.org, driver-core@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PM: core: Do not wait for a device's own completion Date: Tue, 1 Dec 2026 15:29:44 +0800 Message-Id: <20261201072944.73205-1-ziyuzhang201@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit device_pm_wait_for_dev() waits on the completion of @dev when the subordinate has async suspend enabled. That completion is signaled only after the PM callback of @dev returns, and dpm_resume() reinitializes it when the phase starts, so passing the same device twice waits for a callback that is still running: resume of D device_pm_wait_for_dev(D, D) ---------- ----------------------------- device_resume(D) device_lock(D) resume callback dpm_wait(D, async = true) wait_for_completion( &D->power.completion) /* returns only here */ device_unlock(D) complete_all(&D->power.completion) The wait has no timeout and device_resume() holds D->mutex across the callback, so the resume never finishes and D stays locked for the rest of the transition. ehci_platform is the only caller in the tree that can build this pair. ehci_platform_resume() takes the companion of its controller from the device tree and passes it to device_pm_wait_for_dev() together with the controller. A "companion" phandle that points back at its own node makes both arguments the same device: of_parse_phandle() returns the node and of_find_device_by_node() returns the platform device that is being resumed. Return without waiting when both arguments are the same device. A device cannot depend on a completion that is signaled only after the callback it is running returns, so there is nothing to wait for. The other two callers, in usb/core, always pass two different devices. If two EHCI controllers name each other as companions, their resume callbacks can still wait for each other's completion because the device pointers differ. One option for ehci-platform would be to skip the wait when the companion is another EHCI controller that points back to the first. This would preserve the existing resume ordering between EHCI and OHCI companions. Signed-off-by: Ziyu Zhang --- drivers/base/power/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 88a31e09e4f3..16506c1fac8b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -2401,9 +2401,15 @@ EXPORT_SYMBOL_GPL(__suspend_report_result); * device_pm_wait_for_dev - Wait for suspend/resume of a device to complete. * @subordinate: Device that needs to wait for @dev. * @dev: Device to wait for. + * + * A device that resolves to itself is not waited for: its completion is + * only signaled after the PM callback that is running right now returns. */ int device_pm_wait_for_dev(struct device *subordinate, struct device *dev) { + if (subordinate == dev) + return async_error; + dpm_wait(dev, subordinate->power.async_suspend); return async_error; } -- 2.34.1