[v1,2/2] ACPI: PCI: hotplug: Avoid setting is_hotplug_bridge for PCIe Upstream Ports
Message ID | 2262230.ElGaqSPkdT@kreacher |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1752930wrr; Mon, 21 Nov 2022 10:19:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf57lewuQV4FOQOs8i1vDWF0hAnrE3Qf4bA20qwVCDlO6XV4uiknukMnd8D8XywaKTZXCg3g X-Received: by 2002:a05:6402:248e:b0:461:e2ab:912d with SMTP id q14-20020a056402248e00b00461e2ab912dmr1072815eda.93.1669054780156; Mon, 21 Nov 2022 10:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669054780; cv=none; d=google.com; s=arc-20160816; b=omLTr93Rw5CTs8Ia/OfOIpLqqpk8IyAnlcqCcX5JEHSKft9j+RS2mFGGx50v5H/D2K d5a7oom6k8OUc+V3Huu5+vFv4GJ6ScJSkCUZIkaBKJRXiyP9VVGWo+IYRRCI0Knj+AMO l9St9lmVW5v1pngZd9e5KwaYEVdtwYK43J/cMRfYL3ComrERnCozy7bni8OBg2OLOkXx O4vDzZ7hLHnTWqOncXzaAUeXZfkTsgpSooN4NKyBhW4LCyirWpaP0p8gNDt8EPwoGrJb BrZQQmMIBy64BjBP1g+hYowxesfu7BonjqT5DprBqPMbrug43X9s+PTdEFFyDLUzhVAK vdrQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RbEQBApYYEmysNoHWH9/7lS/laoPGLyoMlH0r4OxUKk=; b=bcIuwtWavbz6IpneWFWSf27ukvacqCc4nCRPm48T1tvn/qWlLNts/ENxWhR+tvRbLb EnWmv23HPcuqbuBxCv8XKVClAwTh4ZXMU6YIuARan1KduDD3w42FYH0BeiJCjWAnHrhW FYEpRHelfZZt5IL5FjroW5IMS8AxinkFitmhVv8TK6udWP1GinBb1Ss8PuAQauAocwz9 fTZG1MgHXMxtSoveUoNCOyhVVuK/lCH2ie0mZa6ed1oldu2oqP/+sQdy8LjY0Cw1q+tw 3qUFzwHm3Pz+CDa0z0qOoSJ3UMhEMORDKGzLhhRVEOVinr83hvFvw8nn6oEC/CnUucmc a6MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dv25-20020a170906b81900b00787ad97302asi4247702ejb.863.2022.11.21.10.19.14; Mon, 21 Nov 2022 10:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbiKUSS1 (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Mon, 21 Nov 2022 13:18:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiKUSSZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 13:18:25 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B5E2C6BE0; Mon, 21 Nov 2022 10:18:23 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 8955e2bb27aa72ee; Mon, 21 Nov 2022 19:18:19 +0100 Received: from kreacher.localnet (unknown [213.134.163.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 1D520780F76; Mon, 21 Nov 2022 19:18:19 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" <rjw@rjwysocki.net> To: Bjorn Helgaas <helgaas@kernel.org> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>, Lukas Wunner <lukas@wunner.de>, LKML <linux-kernel@vger.kernel.org>, Linux ACPI <linux-acpi@vger.kernel.org>, Linux PCI <linux-pci@vger.kernel.org>, Linux PM <linux-pm@vger.kernel.org>, Mika Westerberg <mika.westerberg@linux.intel.com> Subject: [PATCH v1 2/2] ACPI: PCI: hotplug: Avoid setting is_hotplug_bridge for PCIe Upstream Ports Date: Mon, 21 Nov 2022 19:16:57 +0100 Message-ID: <2262230.ElGaqSPkdT@kreacher> In-Reply-To: <5623410.DvuYhMxLoT@kreacher> References: <5623410.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.163.140 X-CLIENT-HOSTNAME: 213.134.163.140 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrheeigdduudduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrdduieefrddugedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudeifedrudegtddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepkedprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrohgurhhighhordhvihhvihesihhnthgvlhdrtghomhdprhgtphhtthhopehluhhkrghsseifuhhnnhgvrhdruggvpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehv ghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=8 Fuz1=8 Fuz2=8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750130785019757891?= X-GMAIL-MSGID: =?utf-8?q?1750130785019757891?= |
Series |
PCI: hotplug: Add checks to avoid doing hotplug on PCIe Upstream Ports
|
|
Commit Message
Rafael J. Wysocki
Nov. 21, 2022, 6:16 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> It is reported that on some systems pciehp binds to an Upstream Port and attempts to operate it which causes devices below the Port to disappear from the bus. This happens because acpiphp sets is_hotplug_bridge for that Port (after receiving a Device Check notification on it from the platform firmware via ACPI) during the enumeration of PCI devices and so when get_port_device_capability() runs, it sees that is_hotplug_bridge is set and adds PCIE_PORT_SERVICE_HP to Port services (which allows pciehp to bind to the Port in question). Even though this particular problem can be addressed by making the portdrv_core checks more robust, it also causes power management to work differently on the affected systems which generally is not desirable (PCIe Ports with is_hotplug_bridge set have to pass additional tests to be allowed to go into the D3hot/cold power states which affects runtime PM of devices below these Ports). For this reason, amend check_hotplug_bridge() with a PCIe type check to prevent it from setting is_hotplug_bridge for Upstream Ports. Reported-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Suggested-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/pci/hotplug/acpiphp_glue.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Comments
On Mon, Nov 21, 2022 at 07:16:57PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > It is reported that on some systems pciehp binds to an Upstream Port and > attempts to operate it which causes devices below the Port to disappear > from the bus. > > This happens because acpiphp sets is_hotplug_bridge for that Port (after > receiving a Device Check notification on it from the platform firmware > via ACPI) during the enumeration of PCI devices and so when > get_port_device_capability() runs, it sees that is_hotplug_bridge is > set and adds PCIE_PORT_SERVICE_HP to Port services (which allows pciehp > to bind to the Port in question). > > Even though this particular problem can be addressed by making the > portdrv_core checks more robust, it also causes power management to > work differently on the affected systems which generally is not > desirable (PCIe Ports with is_hotplug_bridge set have to pass > additional tests to be allowed to go into the D3hot/cold power > states which affects runtime PM of devices below these Ports). > > For this reason, amend check_hotplug_bridge() with a PCIe type check > to prevent it from setting is_hotplug_bridge for Upstream Ports. > > Reported-by: Rodrigo Vivi <rodrigo.vivi@intel.com> for the series: Tested-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Based on all the explanations you gave and docs you showed to me recently this makes total sense and the double protection seems good to me. Let's see if Lukas agree, but feel free to also use if needed: Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> > Suggested-by: Lukas Wunner <lukas@wunner.de> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > drivers/pci/hotplug/acpiphp_glue.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c > =================================================================== > --- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c > +++ linux-pm/drivers/pci/hotplug/acpiphp_glue.c > @@ -411,6 +411,14 @@ static void check_hotplug_bridge(struct > if (dev->is_hotplug_bridge) > return; > > + /* > + * In the PCIe case, only Root Ports and Downstream Ports are capable of > + * accommodating hotplug devices, so avoid marking Upstream Ports as > + * "hotplug bridges". > + */ > + if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_UPSTREAM) > + return; > + > list_for_each_entry(func, &slot->funcs, sibling) { > if (PCI_FUNC(dev->devfn) == func->function) { > dev->is_hotplug_bridge = 1; > > >
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c =================================================================== --- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c +++ linux-pm/drivers/pci/hotplug/acpiphp_glue.c @@ -411,6 +411,14 @@ static void check_hotplug_bridge(struct if (dev->is_hotplug_bridge) return; + /* + * In the PCIe case, only Root Ports and Downstream Ports are capable of + * accommodating hotplug devices, so avoid marking Upstream Ports as + * "hotplug bridges". + */ + if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_UPSTREAM) + return; + list_for_each_entry(func, &slot->funcs, sibling) { if (PCI_FUNC(dev->devfn) == func->function) { dev->is_hotplug_bridge = 1;