From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796460648; b=NzxE0EL/dm1sh89HpeKfwX0i8GHdkyfu4J+dkb5JtM3409U1TgVjossT/qG3jwtSsn7z nyqm6dQFAnvcp0OVgiDRbT1DUi9x0SBFYhSS7BUhlmnluAUspyY2HwDjY+K37IF+KtooG xgysGCm0O9f+JTJD+rmDe/lgzwWnekuNqOo7dHZ0TMBhYwKcwkgDbAnsBup4n1ka6hw88 /1HyTG/ghchZxKbP18ZFaRhS80T88gry07K9hXr9GGRymAl4ouZCrWnLg8RQEOwtSCB2f d8tp7wS67zN9QNNzwQkJ0dD13yrHzw5tdfuuZS0dtdqdbpxcNJTYcMBuALmSxBq5gCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460648; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=WQxeDoMtSqIb8EKm5gSzN0UXPfmNlcazS3wXBWnBp3U=; b=OcX/I9pLUgSP1ZiY31cXk3Mrya8ybnmLw3szmX8qg/NntugUCv26zm8DCrGbmmj2Dt0Q U9z5cw/KfQwSNd5pW12C/rkXs/Nwz5Nr3SQthyC2NBIW9z3w+SUBogx3loX6P8/6vQtft DEKQkwJu96gm0rJ5yOryhIA7v5q2Cb62ElXJprNmb/6XKjRF/gAJhg8VBplKRJnGm2XtA sMWcoTeOhy8/1wEtIermdXrp4UEiH1chNeNbzmPliSnSGUOoqp6lREsH9ttmlf+pxk5c4 slQ6PC2ryMDVaFOgx2Gt1T1Xk6H0AQsrIBDxKn/wdXoLECMXJp3FJLqymlGg12wW+3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FlYlps34; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72EE5606A32F for ; Sat, 5 Dec 2026 08:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FlYlps34 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05C541F00936; Sat, 5 Dec 2026 08:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796460648; bh=WQxeDoMtSqIb8EKm5gSzN0UXPfmNlcazS3wXBWnBp3U=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FlYlps34AkOUR/rnOv0R1UHWOoXZ095c0Ydbk6DTIHX1SY9C6YjGDSYJzx9IA9IQZ kO7Ac7Y8tbNkqUD9tyOfRMk04OMAQT/vJ2CQZBU+QxekQEsw+BmgzNl5Bkg0IXj7Th M0oXzcUyDYQZPOHae7A8tJkiPA9YBqNFRiTHsgOh1d62lEhwJPE2FRC6XmwIsghJDx 5JuExHyVGFKpfbYerdIMN85iMZRld/E+RKnYSICygbpSEjEBWugY+4zAdnDlr0cxSv oxT6XrKiQh69VfDPddIRHl/UMJBHgFM8bwnjMj0jHsnECrWbe+ZEGHOiJ5D6WLY0pM aCNaTdcHLJcpA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 06/14] thunderbolt: Consolidate domain and NHI teardown into tb_nhi_remove() Reply-To: sashiko-reviews@lists.linux.dev To: "Chunfeng Yun" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261205083342.4009278-7-chunfeng.yun@mediatek.com> References: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> <20261205083342.4009278-7-chunfeng.yun@mediatek.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 08:50:47 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] thunderbolt: split pm_runtime_allow() and undocumented tb_nhi_remove() PM -- commit 836a017990ff5baedafc35035fd228fa66590e97 Author: Chunfeng Yun thunderbolt: Consolidate domain and NHI teardown into tb_nhi_remove() This commit moves the common domain and NHI teardown steps from nhi_pci_do_remove() into a new tb_nhi_remove() helper in nhi.c and makes nhi_shutdown() static. > diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c > index 41a6ec03c4e74..cf83ce54fca40 100644 > --- a/drivers/thunderbolt/nhi.c > +++ b/drivers/thunderbolt/nhi.c [ ... ] > @@ -1404,6 +1404,35 @@ int tb_nhi_probe(struct tb_nhi *nhi) > return res; > } > =20 > +/** > + * tb_nhi_remove() - Remove and release NHI instance and its domain > + * @nhi: Pointer to the NHI structure > + * @reset: Whether to force a host router reset (e.g. on shutdown/reboot) > + * > + * Common teardown sequence across all bus types. Stops and unregisters > + * the domain, waits for domain release, and shuts down the NHI hardware. > + */ > +void tb_nhi_remove(struct tb_nhi *nhi, bool reset) > +{ [ ... ] > + pm_runtime_get_sync(dev); > + pm_runtime_dont_use_autosuspend(dev); > + > + tb_domain_remove(tb); > + wait_for_completion(&nhi->domain_released); > + nhi_shutdown(nhi); > +} [ ... ] > diff --git a/drivers/thunderbolt/pci.c b/drivers/thunderbolt/pci.c > index 96280942e7083..9e48946c1d6bd 100644 > --- a/drivers/thunderbolt/pci.c > +++ b/drivers/thunderbolt/pci.c > @@ -568,21 +568,11 @@ static void nhi_pci_do_remove(struct pci_dev *pdev,= bool reset) > struct tb *tb =3D pci_get_drvdata(pdev); > struct tb_nhi *nhi =3D tb->nhi; > =20 > - /* > - * On system shutdown/reboot force a host router reset so the > - * connection manager asserts DPR on connected Thunderbolt 3 devices > - * before the router tree is removed (see tb_stop()). > - */ > - if (reset) > - nhi->host_reset =3D true; > - > - pm_runtime_get_sync(&pdev->dev); > - pm_runtime_dont_use_autosuspend(&pdev->dev); > + /* Restore PCI device to forbid state */ > pm_runtime_forbid(&pdev->dev); > =20 > - tb_domain_remove(tb); > - wait_for_completion(&nhi->domain_released); > - nhi_shutdown(nhi); > + tb_nhi_remove(nhi, reset); > + > nhi_pci_release_msi(nhi_to_pci(nhi)); > } [Severity: Medium] Should pm_runtime_allow() also move into nhi_pci_probe() now that pm_runtime_forbid() stays in nhi_pci_do_remove()? PCI devices start forbidden in pci_pm_init(), while non-PCI devices start allowed. Leaving pm_runtime_allow(dev) in tb_nhi_probe() silently overrides userspace power/control=3Don on platform NHI devices (commit "thunderbolt: Add platform NHI driver"), allowing runtime suspend. Also, tb_nhi_remove() takes an unbalanced pm_runtime_get_sync(dev), so callers must keep runtime PM enabled on entry and drop the reference afterwards. That contract is undocumented in kernel-doc and contradicts the commit message saying backends only handle PM before tb_nhi_remove(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205083342.4009= 278-1-chunfeng.yun@mediatek.com?part=3D6