Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1419651pxb; Fri, 22 Oct 2021 00:03:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkOSLO4miHtlh/7KNJKQltRGap3M5byHfW2md4hcLVF23+WUhiSGU3vDz+EnucV69N6OCA X-Received: by 2002:a17:906:4f8c:: with SMTP id o12mr13306450eju.115.1634886187924; Fri, 22 Oct 2021 00:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634886187; cv=none; d=google.com; s=arc-20160816; b=iXXYEcZpjBs8ME6UtAMs1ObdbVN2vNjKFSJa4PY4t6jPi5WazBnCHT326fbI1aVxzO by9nHRnirfe9yRjTCCXqNxqtxS8Qu74XfFjyYtSMp7TfUOdaxl1xV5s4/nidooRlLamL AyyL/uJFW2JiEW6iyH4xnVW6Woatm4U3VYWiT1pbXmctgdYb6ElA62yoS4riUwcyuLXJ Oz+bPsTfPgU3Or1I8zRP3m2BdtucROnUQRp3tTW15eiOvLYAoQo6xpwWzjS/KijQvv7p XDOtOh63kpOI/bW1md8IRQ4wz+zEClSu2Qrc9zZxXFIhqB9cwiJJpLX1xtR9iSY9EOVw 6dDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=OPld/N878SAabCStFx+te53y4u3KtQGJmf/1TC+cWi0=; b=twO02WfaX0uVDolhoAqNNkWRgjNswnmAgItVG4UKlOpDhGd0+Y2SHkAC1iNmS/8kCQ XHudnaziQGf1nJmxVZisTyF4mUe4Id1fyynn75KSR8Q0OMOnYMwnMxuwAXtVNf+oOBPt bBTXpzsfwwXHUN3F5KN5XUeifssrCs2al78v3WYyZpgHzSFeUCrqFPbkl7tGd8DyPx41 445Bu/TfeKc7ClsZ3kaDryp+7J5FZEiX1HnPjTEdXMQ3plXf7grMQ5PQD2NX3uKkUlkG q0nJUlz30/5Fnuy7sT9CknetzyuoRzVjsLHBkPKJo3mt7Z+ru5Y1QzorAxsvF5CKm0YB JjFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq21si9941961ejc.236.2021.10.22.00.02.37; Fri, 22 Oct 2021 00:03:07 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232032AbhJVHDG (ORCPT + 99 others); Fri, 22 Oct 2021 03:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbhJVHDF (ORCPT ); Fri, 22 Oct 2021 03:03:05 -0400 X-Greylist: delayed 462 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 22 Oct 2021 00:00:48 PDT Received: from bmailout2.hostsharing.net (bmailout2.hostsharing.net [IPv6:2a01:37:3000::53df:4ef0:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F973C061764; Fri, 22 Oct 2021 00:00:48 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id 9F2392800C91C; Fri, 22 Oct 2021 08:53:01 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 925C3189034; Fri, 22 Oct 2021 08:53:01 +0200 (CEST) Date: Fri, 22 Oct 2021 08:53:01 +0200 From: Lukas Wunner To: "Rafael J. Wysocki" Cc: Kai-Heng Feng , Bjorn Helgaas , Mika Westerberg , "open list:PCI SUBSYSTEM" , open list , Linux PM Subject: Re: [PATCH v2] PCI: Check PCIe upstream port for PME support Message-ID: <20211022065301.GA17656@wunner.de> References: <20210812153944.813949-1-kai.heng.feng@canonical.com> <6289c754-3580-4102-8ff2-666c3cad8da2@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6289c754-3580-4102-8ff2-666c3cad8da2@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 09:13:29PM +0200, Rafael J. Wysocki wrote: > On 10/21/2021 8:56 AM, Kai-Heng Feng wrote: > > On Thu, Aug 12, 2021 at 11:39 PM Kai-Heng Feng wrote: > > > Some platforms cannot detect ethernet hotplug once its upstream port is > > > runtime suspended because PME isn't granted by BIOS _OSC. The issue can > > > be workarounded by "pcie_ports=native". > > > > > > The vendor confirmed that the PME in _OSC is disabled intentionally for > > > system stability issues on the other OS, so we should also honor the PME > > > setting here. > > > > > > So before marking PME support status for the device, check > > > PCI_EXP_RTCTL_PMEIE bit to ensure PME interrupt is either enabled by > > > firmware or OS. > > So you basically want to check whether or not the PME interrupts are > configured on the port? This platform doesn't grant PME handling to OSPM, but the platform doesn't handle PME itself either (recognizable by the fact that it didn't set the PME Interrupt Enable bit in the Root Control Register). The rationale of the patch is to recognize this situation and rely on PME polling instead. That is achieved by assuming no PME support for the device, despite the device claiming that PME is supported. (This information should probably be included in the commit message.) > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > > > index aacf575c15cf..4344dc302edd 100644 > > > --- a/drivers/pci/pci.c > > > +++ b/drivers/pci/pci.c > > > @@ -2294,6 +2294,32 @@ void pci_pme_wakeup_bus(struct pci_bus *bus) > > > pci_walk_bus(bus, pci_pme_wakeup, (void *)true); > > > } > > > > > > +#ifdef CONFIG_PCIE_PME > > > +static bool pci_pcie_port_pme_enabled(struct pci_dev *dev) > > > +{ > > > + struct pci_dev *bridge = pci_upstream_bridge(dev); > > > + u16 val; > > > + int ret; > > > + > > > + if (!bridge) > > > + return true; > > > + > > > + if (pci_pcie_type(bridge) != PCI_EXP_TYPE_ROOT_PORT && > > > + pci_pcie_type(bridge) != PCI_EXP_TYPE_RC_EC) > > > + return true; > > > + > > > + ret = pcie_capability_read_word(bridge, PCI_EXP_RTCTL, &val); > > > + if (ret) > > > + return false; > > > + > > > + return val & PCI_EXP_RTCTL_PMEIE; > > > +} > > > +#else > > > +static bool pci_pcie_port_pme_enabled(struct pci_dev *dev) > > > +{ > > > + return true; > > > +} > > > +#endif > > > > > > /** > > > * pci_pme_capable - check the capability of PCI device to generate PME# > > > @@ -3095,7 +3121,7 @@ void pci_pm_init(struct pci_dev *dev) > > > } > > > > > > pmc &= PCI_PM_CAP_PME_MASK; > > > - if (pmc) { > > > + if (pmc && pci_pcie_port_pme_enabled(dev)) { > > > pci_info(dev, "PME# supported from%s%s%s%s%s\n", > > > (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "", > > > (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "", > > > -- > > > 2.32.0