From patchwork Mon Dec 20 02:54:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1570804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=LdNYaEcY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JHPLx2r2zz9t55 for ; Mon, 20 Dec 2021 13:54:32 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mz8of-0004Of-4f; Mon, 20 Dec 2021 02:54:21 +0000 Received: from mail-pf1-f181.google.com ([209.85.210.181]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mz8oc-0004N8-9u for kernel-team@lists.ubuntu.com; Mon, 20 Dec 2021 02:54:18 +0000 Received: by mail-pf1-f181.google.com with SMTP id u20so2550668pfi.12 for ; Sun, 19 Dec 2021 18:54:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2fxYNgi+/Aoh4NG7F2OV89RBidipcrNULIJQTaYa4Co=; b=LdNYaEcY6s2o3u4cL2J+lxunUBMYTyb4XTX7tHurN7II/eurcBGWJUO2FLjqj1T8J/ oGF/g6e4y3bCt3aH0yef6eaiAbnPlluI36kbiXqzC2zyhsthWORstrbfrlKh606v2Yd2 WSN258t2tEDY/hxVulOU14CvBYNTonkVZqXV3AEC7lvCY0WX0w3qQcPtIUtJet4auMLl pYNw+OSr7cWCNTV8epAO9x/tbpKz5sYCIyx4j4nbsntzdNIhbxmlq2isqzk2KjzKD9lD ujKopMPcw145wR4JO34CFjEX1hoFk2Er3CLIl3036fKViYnlgdCSV37nSnWuhIBmc8ZV osrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=2fxYNgi+/Aoh4NG7F2OV89RBidipcrNULIJQTaYa4Co=; b=xvwbB4Dm+9j/T65bb+9evLo1BhbPR+WMXbiHoDNBvJt5LBe9JYp/WFQI5COmV66eqZ ki3IZW1WsNg8wr9y9hPt/NIm2Ke0KjwQABP5k6wsdxZNLjoMdYmXOGDI0uvTLuWnn8oL UcjgJoIZMBG9o11Nu1MhN95sbgqeBsPUEKwffdyfyt961Si9zvl6Ab0jaELweK/IoC7T 7p4tGTW4wZ0wzaBXxDjkq4vNoPc1Svf4r8kQI+2kJz/VQ0MTKarr/YbYPVUoYg2UWkf8 3wBw4dOmxdtQGLeuoR7c89xClWYod3j9YVEaaqp1qfFASjfKdqoPv9fbybGEzMJHPECk IOqA== X-Gm-Message-State: AOAM5303KvE5NMMCwO8sJ68BjIZBouwSKH5bjpRAlSZS/ZRalgwLaMJy fTsQ80xVLg9K5SI4VyEoRcF4MQ+bZAQ= X-Google-Smtp-Source: ABdhPJzvudJyTkQCophcAxdtAOrkb0ufNeM/d9B1r392g169LrZxFF5CS9oSS28bccOqLWhNQmMH1A== X-Received: by 2002:a63:6e0c:: with SMTP id j12mr13294752pgc.117.1639968856107; Sun, 19 Dec 2021 18:54:16 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id e7sm16931214pfv.156.2021.12.19.18.54.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Dec 2021 18:54:15 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH v2 3/6][SRU][J][OEM-5.14] UBUNTU: SAUCE: thunderbolt: Runtime resume USB4 port when retimers are scanned Date: Mon, 20 Dec 2021 10:54:04 +0800 Message-Id: <20211220025407.1321424-4-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211220025407.1321424-1-acelan.kao@canonical.com> References: <20211220025407.1321424-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.181; envelope-from=acelan@gmail.com; helo=mail-pf1-f181.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 Sometimes when plugging in a USB4 device we might see following error: thunderbolt 1-0:3.1: runtime PM trying to activate child device 1-0:3.1 but parent (usb4_port3) is not active This happens because the parent USB4 port was still runtime suspended. Fix this by runtime resuming the USB4 port before scanning the retimers below it. Signed-off-by: Mika Westerberg (cherry picked from https://patchwork.kernel.org/project/linux-usb/patch/20211125073733.74902-4-mika.westerberg@linux.intel.com/) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/retimer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c index 722694052f4a8..8c29bd556ae04 100644 --- a/drivers/thunderbolt/retimer.c +++ b/drivers/thunderbolt/retimer.c @@ -324,15 +324,10 @@ struct device_type tb_retimer_type = { static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status) { - struct usb4_port *usb4; struct tb_retimer *rt; u32 vendor, device; int ret; - usb4 = port->usb4; - if (!usb4) - return -EINVAL; - ret = usb4_port_retimer_read(port, index, USB4_SB_VENDOR_ID, &vendor, sizeof(vendor)); if (ret) { @@ -374,7 +369,7 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status) rt->port = port; rt->tb = port->sw->tb; - rt->dev.parent = &usb4->dev; + rt->dev.parent = &port->usb4->dev; rt->dev.bus = &tb_bus_type; rt->dev.type = &tb_retimer_type; dev_set_name(&rt->dev, "%s:%u.%u", dev_name(&port->sw->dev), @@ -453,6 +448,13 @@ int tb_retimer_scan(struct tb_port *port, bool add) { u32 status[TB_MAX_RETIMER_INDEX + 1] = {}; int ret, i, last_idx = 0; + struct usb4_port *usb4; + + usb4 = port->usb4; + if (!usb4) + return 0; + + pm_runtime_get_sync(&usb4->dev); /* * Send broadcast RT to make sure retimer indices facing this @@ -460,7 +462,7 @@ int tb_retimer_scan(struct tb_port *port, bool add) */ ret = usb4_port_enumerate_retimers(port); if (ret) - return ret; + goto out; /* * Enable sideband channel for each retimer. We can do this @@ -490,8 +492,10 @@ int tb_retimer_scan(struct tb_port *port, bool add) break; } - if (!last_idx) - return 0; + if (!last_idx) { + ret = 0; + goto out; + } /* Add on-board retimers if they do not exist already */ for (i = 1; i <= last_idx; i++) { @@ -507,7 +511,11 @@ int tb_retimer_scan(struct tb_port *port, bool add) } } - return 0; +out: + pm_runtime_mark_last_busy(&usb4->dev); + pm_runtime_put_autosuspend(&usb4->dev); + + return ret; } static int remove_retimer(struct device *dev, void *data)