{"id":2220765,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220765/?format=json","web_url":"http://patchwork.ozlabs.org/project/ubuntu-kernel/patch/20260408003919.235501-2-acelan.kao@canonical.com/","project":{"id":15,"url":"http://patchwork.ozlabs.org/api/1.1/projects/15/?format=json","name":"Ubuntu Kernel","link_name":"ubuntu-kernel","list_id":"kernel-team.lists.ubuntu.com","list_email":"kernel-team@lists.ubuntu.com","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260408003919.235501-2-acelan.kao@canonical.com>","date":"2026-04-08T00:39:17","name":"[SRU,R,1/1] UBUNTU: SAUCE: thunderbolt: Fix PCIe device enumeration with delayed rescan","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3b82a3c08faf72d6216490c73888fc4e96322953","submitter":{"id":2976,"url":"http://patchwork.ozlabs.org/api/1.1/people/2976/?format=json","name":"AceLan Kao","email":"acelan.kao@canonical.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ubuntu-kernel/patch/20260408003919.235501-2-acelan.kao@canonical.com/mbox/","series":[{"id":499054,"url":"http://patchwork.ozlabs.org/api/1.1/series/499054/?format=json","web_url":"http://patchwork.ozlabs.org/project/ubuntu-kernel/list/?series=499054","date":"2026-04-08T00:39:16","name":"The second tbt storage plugged on the dock will not be recognized","version":1,"mbox":"http://patchwork.ozlabs.org/series/499054/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220765/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220765/checks/","tags":{},"headers":{"Return-Path":"<kernel-team-bounces@lists.ubuntu.com>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=rYySVgow;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com\n (client-ip=185.125.189.65; helo=lists.ubuntu.com;\n envelope-from=kernel-team-bounces@lists.ubuntu.com;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fr42d5Mggz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 10:39:37 +1000 (AEST)","from localhost ([127.0.0.1] helo=lists.ubuntu.com)\n\tby lists.ubuntu.com with esmtp (Exim 4.86_2)\n\t(envelope-from <kernel-team-bounces@lists.ubuntu.com>)\n\tid 1wAGx8-0008Se-OX; Wed, 08 Apr 2026 00:39:30 +0000","from mail-qk1-f171.google.com ([209.85.222.171])\n by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.86_2) (envelope-from <acelan@gmail.com>) id 1wAGx7-0008QY-Pt\n for kernel-team@lists.ubuntu.com; Wed, 08 Apr 2026 00:39:30 +0000","by mail-qk1-f171.google.com with SMTP id\n af79cd13be357-8d67a483d3eso362697785a.1\n for <kernel-team@lists.ubuntu.com>; Tue, 07 Apr 2026 17:39:29 -0700 (PDT)","from localhost (211-75-139-220.hinet-ip.hinet.net. [211.75.139.220])\n by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8d2a5392d35sm1395294685a.10.2026.04.07.17.39.25\n for <kernel-team@lists.ubuntu.com>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 07 Apr 2026 17:39:26 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775608767; x=1776213567; darn=lists.ubuntu.com;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:to:from:sender:from:to:cc:subject:date\n :message-id:reply-to;\n bh=2rFDFDa/Ga8Vxl28WjZAt+5GtYblZjDJ+xRGyWCQ78U=;\n b=rYySVgowiuLMFm7K4A0IAlHCb9Czv+byxPAFRN+JOV5xEzFO3B0SSKs/r70ohHtS2e\n GtXvngI2BblbPKAJRlmPXVy1AyN3Z0jhRL6J55iD7Hi7feOB9c2DvVZh69GsXIB8zITP\n /MkCVDD5GrL8EmOEiyUs+6uzST1QwjhbroObJ5aXDOKpXPGe6siUXNiUdDqsj6cGn9Mk\n aOXaeV+TBnOGqz0JnBImt9hdAcbaVKKS0XYzdiJs0K08a+UFvtRiY8Ry9wXWBAbA0/oq\n 0BQbNWx3DHyp1kxkOnXozAZKCS+B9t7vjP/RRSF2NqHhbgxegDLLG0jdL7CKzsw0nDkj\n 9VyQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775608767; x=1776213567;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:to:from:sender:x-gm-gg:x-gm-message-state\n :from:to:cc:subject:date:message-id:reply-to;\n bh=2rFDFDa/Ga8Vxl28WjZAt+5GtYblZjDJ+xRGyWCQ78U=;\n b=jcpvOqL2aqpuJhF2akgRTuutYIW4po9gut7n/lGCX6R/k6+Ri6GDLYTM9orhlgB5dS\n yJ4ISQDzH5RueEFMPGe58FRce4SQigTLobzrFlRrshb+4yeh1//Myut4earDWEytZmsa\n S319cy1L+kX/chqrelePpHihoiTpTidc3bQAyNyIiAW4Tw8DLtIgfAplQNBdpjRHslJU\n dGTyL4z/F5Sm343QoC4mk82OnfqRuaGgWWdLg+gMjt+B7gF9XyAI9M/2jKc//PfPLzhv\n /BpyWTUjgfZHOtWLEgvF6cT+1Un9PEL3+tKYbiSoFwsD1g+ifVFYd7+c4NfkWdMR+Cnx\n PjOA==","X-Gm-Message-State":"AOJu0YzTxY0z4XT0xzKttB1mrf42XMEXGVZpVvOsCdveAtVovG68uBqv\n zZEPnoiWsOSiJVfuK+/tXJ1F2TitbsJBExEcTRAQpQD1teFKWp5SA86J+f3QvQ==","X-Gm-Gg":"AeBDies+vTle0Oj1j0Q+dbKt/fLL/oWYQzgeppKJ2axygeV/Sgih5gyzvp0WsMmKhNJ\n +gMedrZe5t6EA/VM/1cS/uymHsTKu9ZI16yup2SDforGXyJhUbLTekaQGtRQlXXE2a1pXjhHvES\n hR8t4SparVsHjvLCOdjNTXpmTZEjHYuTNRbKUTSBh0sF594y+gcG5WhFos1uy+DJtwKW45j8GI2\n KLxyogAlvC4OYJBuvmXwnS2yWd6GFoPuIt2K/4ncIAePQehNYijIMMtgthHyBZmdc398BZcQVKM\n jkaxhN7x7NlBFHwYPpbZ3tqPu5Z62+2SSCAiFQPA0hUAyOoOtkUIHkhGYXiA0VFlfVlGgclrX1G\n 9KtUpvHBtj1YU9INNsLJtmJaseq3u8eJrPo2LnckAY5IaS86HwOsZRhvzBskzacEfUuFHMWIJzc\n JBe9yAv+UiKwglG0j3qP8CmoxBqZkuUQU10lM/upoTpuUsZol9Juaf","X-Received":"by 2002:a05:620a:2a0e:b0:8cd:9b31:23b1 with SMTP id\n af79cd13be357-8d41e04543bmr2785152685a.53.1775608766993;\n Tue, 07 Apr 2026 17:39:26 -0700 (PDT)","From":"AceLan Kao <acelan.kao@canonical.com>","To":"kernel-team@lists.ubuntu.com","Subject":"[SRU][R][PATCH 1/1] UBUNTU: SAUCE: thunderbolt: Fix PCIe device\n enumeration with delayed rescan","Date":"Wed,  8 Apr 2026 08:39:17 +0800","Message-ID":"<20260408003919.235501-2-acelan.kao@canonical.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260408003919.235501-1-acelan.kao@canonical.com>","References":"<20260408003919.235501-1-acelan.kao@canonical.com>","MIME-Version":"1.0","Received-SPF":"pass client-ip=209.85.222.171; envelope-from=acelan@gmail.com;\n helo=mail-qk1-f171.google.com","X-BeenThere":"kernel-team@lists.ubuntu.com","X-Mailman-Version":"2.1.20","Precedence":"list","List-Id":"Kernel team discussions <kernel-team.lists.ubuntu.com>","List-Unsubscribe":"<https://lists.ubuntu.com/mailman/options/kernel-team>,\n <mailto:kernel-team-request@lists.ubuntu.com?subject=unsubscribe>","List-Archive":"<https://lists.ubuntu.com/archives/kernel-team>","List-Post":"<mailto:kernel-team@lists.ubuntu.com>","List-Help":"<mailto:kernel-team-request@lists.ubuntu.com?subject=help>","List-Subscribe":"<https://lists.ubuntu.com/mailman/listinfo/kernel-team>,\n <mailto:kernel-team-request@lists.ubuntu.com?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"kernel-team-bounces@lists.ubuntu.com","Sender":"\"kernel-team\" <kernel-team-bounces@lists.ubuntu.com>"},"content":"From: \"Chia-Lin Kao (AceLan)\" <acelan.kao@canonical.com>\n\nBugLink: https://bugs.launchpad.net/bugs/2139572\n\nPCIe devices behind Thunderbolt tunnels may fail to enumerate when\nspurious hotplug events prevent pciehp from detecting link-up.\n\nRoot cause:\n\nSpurious unplug events occur immediately after tunnel activation:\n\n  [  932.438] thunderbolt: acking hot unplug event on 702:2\n  [  932.852] thunderbolt: PCIe Up path activation complete\n  [  932.855] thunderbolt: hotplug event for upstream port 702:2\n            (unplug: 0)\n  [  932.855] thunderbolt: hotplug event for upstream port 702:2\n            (unplug: 1)\n\nThese events disrupt pciehp timing, causing device enumeration to fail\n~70% of the time on affected hardware. Manual PCI rescan succeeds,\nproving devices are present and functional on the bus.\n\nSolution:\n\nSchedule a delayed pci_rescan_bus() (300ms) after tunnel activation.\nSince pci_rescan_bus() is idempotent and won't re-add already-enumerated\ndevices, we unconditionally rescan rather than comparing device counts.\nThis is non-blocking and avoids overhead on systems where pciehp works\ncorrectly, as the rescan is a no-op when devices are already present.\n\nSigned-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>\n(cherry picked from commit https://lore.kernel.org/lkml/20260121060857.237777-1-acelan.kao@canonical.com/T/#u)\nSigned-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>\n---\n drivers/thunderbolt/tb.c | 35 +++++++++++++++++++++++++++++++++++\n 1 file changed, 35 insertions(+)","diff":"diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c\nindex c69c323e6952a..4967ceab83109 100644\n--- a/drivers/thunderbolt/tb.c\n+++ b/drivers/thunderbolt/tb.c\n@@ -11,6 +11,7 @@\n #include <linux/delay.h>\n #include <linux/pm_runtime.h>\n #include <linux/platform_data/x86/apple.h>\n+#include <linux/pci.h>\n \n #include \"tb.h\"\n #include \"tb_regs.h\"\n@@ -18,6 +19,7 @@\n \n #define TB_TIMEOUT\t\t100\t/* ms */\n #define TB_RELEASE_BW_TIMEOUT\t10000\t/* ms */\n+#define TB_PCIEHP_ENUMERATION_DELAY 300\t/* ms */\n \n /*\n  * How many time bandwidth allocation request from graphics driver is\n@@ -83,6 +85,12 @@ struct tb_hotplug_event {\n \tint retry;\n };\n \n+/* Delayed work to rescan PCIe bus after tunnel activation */\n+struct tb_pci_rescan_work {\n+\tstruct delayed_work work;\n+\tstruct pci_bus *bus;\n+};\n+\n static void tb_scan_port(struct tb_port *port);\n static void tb_handle_hotplug(struct work_struct *work);\n static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port,\n@@ -90,6 +98,17 @@ static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port,\n static void tb_queue_dp_bandwidth_request(struct tb *tb, u64 route, u8 port,\n \t\t\t\t\t  int retry, unsigned long delay);\n \n+static void tb_pci_rescan_work_fn(struct work_struct *work)\n+{\n+\tstruct tb_pci_rescan_work *rescan_work =\n+\t\tcontainer_of(work, typeof(*rescan_work), work.work);\n+\n+\tpci_lock_rescan_remove();\n+\tpci_rescan_bus(rescan_work->bus);\n+\tpci_unlock_rescan_remove();\n+\tkfree(rescan_work);\n+}\n+\n static void tb_queue_hotplug(struct tb *tb, u64 route, u8 port, bool unplug)\n {\n \tstruct tb_hotplug_event *ev;\n@@ -2313,6 +2332,22 @@ static int tb_tunnel_pci(struct tb *tb, struct tb_switch *sw)\n \t\ttb_sw_warn(sw, \"failed to connect xHCI\\n\");\n \n \tlist_add_tail(&tunnel->list, &tcm->tunnel_list);\n+\n+\t/* Schedule a delayed PCIe bus rescan in case pciehp misses devices */\n+\tif (tb->nhi && tb->nhi->pdev && tb->nhi->pdev->bus) {\n+\t\tstruct pci_bus *bus = tb->nhi->pdev->bus;\n+\t\tstruct tb_pci_rescan_work *rescan_work;\n+\n+\t\trescan_work = kmalloc(sizeof(*rescan_work), GFP_KERNEL);\n+\t\tif (!rescan_work)\n+\t\t\treturn 0;\n+\n+\t\trescan_work->bus = bus->parent ? bus->parent : bus;\n+\t\tINIT_DELAYED_WORK(&rescan_work->work, tb_pci_rescan_work_fn);\n+\t\tqueue_delayed_work(tb->wq, &rescan_work->work,\n+\t\t\t\t   msecs_to_jiffies(TB_PCIEHP_ENUMERATION_DELAY));\n+\t}\n+\n \treturn 0;\n }\n \n","prefixes":["SRU","R","1/1"]}