From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=60.244.123.138 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459654; b=XNhjELAVnmNBkPmfaRrSt/6hsHnFwp79l/D9FGy+71Knd8a9X4Ba03OtDKtklq8fdgPb pRZmzvGPdxWINveBlhcpRwKexPcA6TwdgAxuX1RhB05CPjnN3LcKkJkqxCEcRi2hXgM2A 0jcZlRRfuDWJ5N5fsYnlmRRmW7npupdle0uxPu0KB7lyejtarr7sFe5N7HFhoR2tuXEKz RJDcwXmJR1vXEJgsdFsG/nPQGLoeGgtJJLMmS5qur0wvZuCEFTEVZ1ahnh/FEIdfrThDY 1irMjarqPtrxPzvVS5ZqwwJMSQ9ceGF1HTTdFHjsmZfRx9Q+OCitunvvx+BrSevNdqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459654; h=DMARC-Filter:X-UUID:DKIM-Signature:X-CID-P-RULE:X-CID-O-INFO: X-CID-META:X-CID-BVR:X-CID-BAS:X-CID-FACTOR:X-CID-RHF:X-UUID:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-MTK; bh=CFVvGkV0j7EO69jIR9ekbFlmUEzuyO35NAyReIrU4xY=; b=YV1IjQMGdz5mAWrWNQFstrKyJ9LlDEfnUo+R1EYXerugn+wzhXEhAPOYKV9nMoZZl1iP I44srdRBlWZUyyb6B83AiCwok94DXNemw0CCDKyumKcfDlUNO50rfu1DEb2tYs7WjvJc2 vqCnRaqUaX05mOW6/hB/tb3reO8ojLRplVLwUX+99Jc5VTBsqZThYN3BDA35NYaVEVi88 IS/zAzgs5Ly5AiXl/fumR35e8074ayPQpyEGQtrZJtMB1OLnXc+Z1Pvk7weO689EVO8m3 RmoeOj6BxJMZTT1mQGQ+rFTdoOc5C67J0nHrp/9J/8NyHAHNS43Wd4peCn1jBFCBn/w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=piFXZaCZ; arc=none smtp.remote-ip=60.244.123.138 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E032606A68B; Sat, 5 Dec 2026 08:34:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E032606A68B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=piFXZaCZ X-UUID: a5d7e2f8f08611f1b9cf3d4034dccee2-20261205 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=CFVvGkV0j7EO69jIR9ekbFlmUEzuyO35NAyReIrU4xY=; b=piFXZaCZseHZrRddkgV1vYUptK19SHaKXRUV9zXi5hJ7oQQQEFwGNRJe9d/2XtDsldihFjKK+65bcSSPRW8ouC6g7qR/NLSW7DGRXdAPXPMCDkDmRGo9qTIZn7v5H2D7GzQx7jrcijyZA/T9AbnYlVKNnLYLibLEp2RGyXFSbdc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.22,REQID:84207f18-d63a-41c9-b72e-472ba644448e,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:d36851b,CLOUDID:bc63c631-f289-4656-bb36-27baf4489f11,B ulkID:nil,BulkQuantity:0,SF:81|82|102|836|865|888|898,TC:-5,Content:0|15|5 0|99,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0 ,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: a5d7e2f8f08611f1b9cf3d4034dccee2-20261205 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2040470958; Sat, 05 Dec 2026 16:34:12 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Sat, 5 Dec 2026 16:34:08 +0800 Received: from gcnsap21.gcn.mediatek.inc (10.17.81.22) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.56 via Frontend Transport; Sat, 5 Dec 2026 16:34:08 +0800 From: Chunfeng Yun To: Mika Westerberg CC: Andreas Noever , Konrad Dybcio , Sven Peter , Yehezkel Bernat , Matthias Brugger , Greg Kroah-Hartman , AngeloGioacchino Del Regno , , , , , Chunfeng Yun Subject: [PATCH v4 14/14] thunderbolt: Drop WARN_ON() in tb_disconnect_pci() Date: Sat, 5 Dec 2026 16:33:39 +0800 Message-ID: <20261205083342.4009278-15-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> References: <20261205083342.4009278-1-chunfeng.yun@mediatek.com> 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 Content-Type: text/plain X-MTK: N tb_disconnect_pci() uses WARN_ON() if the upstream PCIe adapter port or the associated PCIe tunnel cannot be found. This triggers a full kernel stack trace in dmesg. However, tb_disconnect_pci() is invoked when userspace deauthorizes a router via sysfs (writing 0 to 'authorized'). Under dynamic runtime conditions, an upstream port or active tunnel may not exist. For example: - If a USB4 router fails to resume or is unplugged during system/link sleep, the disconnect flow may tear down and free the PCIe tunnel before userspace deauthorization runs. - If PCIe tunnel activation previously failed (e.g., due to link training or Type-C handshake hiccups), the tunnel was never established in the first place. it seems unnecessary due to it does not indicate a kernel bug. Furthermore, it causes unnecessary kernel panics on systems booted with panic_on_warn. Since -ENODEV is already returned to notify callers, simply drop the WARN_ON() checks while keeping the -ENODEV return. Fixes: 3da88be24997 ("thunderbolt: Add support for de-authorizing devices") Signed-off-by: Chunfeng Yun --- v4: Add Fixes in commit message v3: * Modify commit message. * Reworked sw->is_unplugged checks to directly drop the WARN_ON(!up) and WARN_ON(!tunnel) checks in tb_disconnect_pci() v2: no changes --- drivers/thunderbolt/tb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 57c11ba13459..5f674c305d43 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -2267,11 +2267,11 @@ static int tb_disconnect_pci(struct tb *tb, struct tb_switch *sw) struct tb_port *up; up = tb_switch_find_port(sw, TB_TYPE_PCIE_UP); - if (WARN_ON(!up)) + if (!up) return -ENODEV; tunnel = tb_find_tunnel(tb, TB_TUNNEL_PCI, NULL, up); - if (WARN_ON(!tunnel)) + if (!tunnel) return -ENODEV; tb_switch_xhci_disconnect(sw); -- 2.45.2