Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3618592pxb; Mon, 24 Jan 2022 13:38:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJziIAUV76IBb9BWzPiNgFKMntXxBkIoch5R6iLcrLJKMqgt1ZoIcjjU9wN5r9b0Gj5Rmjjd X-Received: by 2002:a17:902:d883:b0:14a:4ba5:6e72 with SMTP id b3-20020a170902d88300b0014a4ba56e72mr16478733plz.27.1643060323627; Mon, 24 Jan 2022 13:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060323; cv=none; d=google.com; s=arc-20160816; b=NXZPat2pafjTJDkJLhnQSPaZSdvprG8eIeC2Y7H0dA/7/UsKSE7B2VXwcOrtq6iAcq zV5I8QygFq+n+C3dLnic/lfolfjKYufgk/waPSj39iUJtN34pvdJkerC4DDitzOysy3n XVzmNSsHU3qzyrTnfifChiyTmGpXZ9F0xwmhE6OSxtVk3ZzrMJSNpMYu1tSmLZDWatNa Qjj8yR2GxODXEKp22UKVGxccf2RKBZTp5aUmHXcJrY0GJYBwhtTkfVlu2dELYg8oE7Nt GdBXi4GLDmEh63OQGpN/kWHfweCzxWcTtSROBVvUugS6l6ccEGiJzi8K07MOvlGDeiW8 RJfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E5IGplPfw8K7azaiiMQHXtBsvEyBFYRIisvH8J5O6rI=; b=GQvo0ydbNCDUtRZ496F1WJ0vuanqNu9UQqOJ8gcs5qB8Wv0kTaJCHZ04JqS1lrHrow PZ9ymwJnOgAFz/PMJGM51eSL4JH+nfWa7spmLu00qtfl2gS1U6qmkO5B0u2cKhH0pIck UlfsojIKmoRbBa2fMdgU4P/2t3kHesNf6QG8FfwVNxUbQA+8KV4nq7GJeKhMKO5u5xDP +EUNRMg8B3jJtdnMl3WWO0P4D6N351B0SqeTMMt9amGc8BJcgMoFwFNEU3iuYUwNsWdv 2F4tyF5tp+hhvB5DES0C4J//l4VtDPxupP8mu3lm1t7sfTxFsAdv4tKzwnLNx1dVaDQ3 vvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=abD5uZA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si424886pjn.59.2022.01.24.13.38.32; Mon, 24 Jan 2022 13:38:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=abD5uZA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353256AbiAXVTd (ORCPT + 99 others); Mon, 24 Jan 2022 16:19:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392375AbiAXUvF (ORCPT ); Mon, 24 Jan 2022 15:51:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F0E7C05432D; Mon, 24 Jan 2022 11:58:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E218861028; Mon, 24 Jan 2022 19:58:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B55FFC340E5; Mon, 24 Jan 2022 19:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643054308; bh=ogkFxolfQWRQxJZn/Tdu72Ih6tdiWRo2xRIJQtxu78g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abD5uZA+mkgD4DhYARoDRt+1Zad14ECoS1kZWmrSl3yMShD3xU3sBpAaWRTA669J3 Vi2WljSFa7w1j7Iz2f3vSliPsjGy6jGfBRjE6jqQ7/nk38xVO2U8AWAuD+zej6eFA8 ZF1bCkdXfWxehqOCNLanKVxQDDEcvSpClz11tpr0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.10 346/563] thunderbolt: Runtime PM activate both ends of the device link Date: Mon, 24 Jan 2022 19:41:51 +0100 Message-Id: <20220124184036.381000032@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mika Westerberg [ Upstream commit f3380cac0c0b3a6f49ab161e2a057c363962f48d ] If protocol tunnels are already up when the driver is loaded, for instance if the boot firmware implements connection manager of its own, runtime PM reference count of the consumer devices behind the tunnel might have been increased already before the device link is created but the supplier device runtime PM reference count is not. This leads to a situation where the supplier (the Thunderbolt driver) can runtime suspend even if it should not because the corresponding protocol tunnel needs to be up causing the devices to be removed from the corresponding native bus. Prevent this from happening by making both sides of the link runtime PM active briefly. The pm_runtime_put() for the consumer (PCIe root/downstream port, xHCI) then allows it to runtime suspend again but keeps the supplier runtime resumed the whole time it is runtime active. Signed-off-by: Mika Westerberg Reviewed-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/thunderbolt/acpi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/thunderbolt/acpi.c b/drivers/thunderbolt/acpi.c index b5442f979b4d0..6355fdf7d71a3 100644 --- a/drivers/thunderbolt/acpi.c +++ b/drivers/thunderbolt/acpi.c @@ -7,6 +7,7 @@ */ #include +#include #include "tb.h" @@ -74,8 +75,18 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data, pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM))) { const struct device_link *link; + /* + * Make them both active first to make sure the NHI does + * not runtime suspend before the consumer. The + * pm_runtime_put() below then allows the consumer to + * runtime suspend again (which then allows NHI runtime + * suspend too now that the device link is established). + */ + pm_runtime_get_sync(&pdev->dev); + link = device_link_add(&pdev->dev, &nhi->pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER | + DL_FLAG_RPM_ACTIVE | DL_FLAG_PM_RUNTIME); if (link) { dev_dbg(&nhi->pdev->dev, "created link from %s\n", @@ -84,6 +95,8 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data, dev_warn(&nhi->pdev->dev, "device link creation from %s failed\n", dev_name(&pdev->dev)); } + + pm_runtime_put(&pdev->dev); } out_put: -- 2.34.1