Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3717328pxt; Tue, 10 Aug 2021 09:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweeZ3cfifvdd0ZiXfANmqeYoPuZZBVOn3mA5WUjdd7yr9DI0fFJWQmjSKC3DHW97OIDcPt X-Received: by 2002:a92:c843:: with SMTP id b3mr157803ilq.42.1628613762256; Tue, 10 Aug 2021 09:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628613762; cv=none; d=google.com; s=arc-20160816; b=z4uKA/qwRog2iyLyDC/OzTysLBX5ABsB6yQPPXP1hOkfmbvS7Vts4u7RRGkwCK+ika x+nYZGbZra6U7412UWPJhDGVn3TL1q8rJpd9W4ut9fgenuha2fotQMGGIsyBofutrQSe dsTDJ9XG3RMGSeQKLw8pezBNkeAQHAIDR0euU8icmwVzvMBL0wy95zs4PoPMBeowO9n8 XQZb5ttx34d8E0JplVNXElqNEL6u/BTr56bQO1o1bkagfy7NbC8qGaxcsnXbFbxnhba+ FyggzL+niRAsRt+dDOTDkcgOZhAQ2MhUKzYRGn55F2fMmOfCNfT2supnEIQ4YCPpLrcz ilGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=V4JCrLtO4cRvhqN1sG1W5Ma2FLvhmCKkVeREp756lBA=; b=fgWJjmycrZOMj9+d2LmgNpH86hzE1cn68jQrEnaTI9DjW3lNAHj8xsGcJXlFIbgXyS DAUkXYZduxDvN5TLxs2fLLUNlW/Dfe5qDf884Gwp5kYPW5SBkWcrdkRdRVd1LYvwp8vZ yJQi3SMiPrde/HZJ8lwFFTvmpLiYImrZeNbN8GkWqivHTvw1P+pAKokylDEwDGeOnOhl TuqkHpyLmdCUXcIH0MIjYZhYXWRGaS270hi13i3OgxsAb26wVUq8VMsATVMubmQDAs0l IVt8KjDS1U5L2MIC5nYisFV4SqT3x46MhbQktoyif5fpZmfzppn9iJx9HFZXoQHxMI8z zEkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=NHGnd8yj; 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si20413643ion.51.2021.08.10.09.42.30; Tue, 10 Aug 2021 09:42:42 -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; dkim=pass header.i=@canonical.com header.s=20210705 header.b=NHGnd8yj; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243270AbhHJPhy (ORCPT + 99 others); Tue, 10 Aug 2021 11:37:54 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:42358 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243269AbhHJPhw (ORCPT ); Tue, 10 Aug 2021 11:37:52 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (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 smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 807963F107 for ; Tue, 10 Aug 2021 15:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628609849; bh=V4JCrLtO4cRvhqN1sG1W5Ma2FLvhmCKkVeREp756lBA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=NHGnd8yj29JBgnvB3oWve0BipQxHbotTVZFJxJFqAFIlnb8dY7lJ+5zzNYQthgz3m zVWBnXur64Ow7A6zR6xvr/FUyiFITTRR1MnVIfGpHAJX09PpQZ4/dbzzHgbNvT6yw2 vmckRdDpI0/x8yo8edlEiS1b52ZYcRbH+ByVeGSPgzxWP7ZX+Ojilq+TbpjFuWS38V SbPEyohwhnsfRlE5NnGWgC3KDrWcKgZPQsQ+nGrLoqEvh4ZxZBmgA51mmEzfx7qIIg LweWZ/FVG4mYiPtsgv0jFvjQa73Xcew3UfLFh9xxMMw0TrCxUttYvYMQTkkLsH0Utw rlJd6ygHGkZhQ== Received: by mail-ed1-f72.google.com with SMTP id u25-20020aa7d8990000b02903bb6a903d90so10957362edq.17 for ; Tue, 10 Aug 2021 08:37:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V4JCrLtO4cRvhqN1sG1W5Ma2FLvhmCKkVeREp756lBA=; b=NqaSm51AfAf7VsfQgkENpfbaoHFi17Q5DigWoURAqc1c1zpbMJ36lHDFGOg2kC9EJk m7d06/pfru7o6wQicvnhe1N/jPYRnBY9Eb/ZCxI/dIOyNXONUoy67c8CQPacDZMfiY8e Cq4GI/k6fiYdwPthk9WFCb98E8SC+NeHOGOet3zhiqsHfrkberwNMBOuKfiTtVVwQuKq aiOmFUOWICy5VxiRe74j5SGP/ipWzx62iDxiAiaUoQbf3tK9BAxTFAzGIgLyJ/WUfhxq 1rjibvTWZ9edWBrM+OZORzvZZni5uG8e6UoVjjD+A8tdtz7blxJmgEw1uHF4mSbkyKv9 hmkQ== X-Gm-Message-State: AOAM530Cgcsm1LcT9Sx34dBbTuBNOYtfiQgDpDF6IOjnhGINbN58/EeB CpBxBDqy3aqAoceLfbLJ3oNKh7xkpcqAncGGD1VggQImScy1shxuHwTwWWwPSX1i7VQXwvVQyPN K5Y9e7yuEug7W+kIhE1slqghr7Z3O+UOsjHwcdC8OfM76miQin7UtbvQSQw== X-Received: by 2002:a17:906:5855:: with SMTP id h21mr8750089ejs.230.1628609848111; Tue, 10 Aug 2021 08:37:28 -0700 (PDT) X-Received: by 2002:a17:906:5855:: with SMTP id h21mr8749848ejs.230.1628609844666; Tue, 10 Aug 2021 08:37:24 -0700 (PDT) MIME-Version: 1.0 References: <20210713075726.1232938-1-kai.heng.feng@canonical.com> <20210809042414.107430-1-kai.heng.feng@canonical.com> <20210809094731.GA16595@wunner.de> <20210809150005.GA6916@wunner.de> In-Reply-To: <20210809150005.GA6916@wunner.de> From: Kai-Heng Feng Date: Tue, 10 Aug 2021 23:37:12 +0800 Message-ID: Subject: Re: [PATCH] PCI/portdrv: Disallow runtime suspend when waekup is required but PME service isn't supported To: Lukas Wunner Cc: Bjorn Helgaas , Sean V Kelley , Jonathan Cameron , Qiuxu Zhuo , Kuppuswamy Sathyanarayanan , Keith Busch , "open list:PCI SUBSYSTEM" , open list , Mika Westerberg , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 9, 2021 at 11:00 PM Lukas Wunner wrote: > > [cc += Rafael] > > On Mon, Aug 09, 2021 at 06:40:41PM +0800, Kai-Heng Feng wrote: > > On Mon, Aug 9, 2021 at 5:47 PM Lukas Wunner wrote: > > > On Mon, Aug 09, 2021 at 12:24:12PM +0800, Kai-Heng Feng wrote: > > > > Some platforms cannot detect ethernet hotplug once its upstream port is > > > > runtime suspended because PME isn't enabled in _OSC. > > > > > > If PME is not handled natively, why does the NIC runtime suspend? > > > Shouldn't this be fixed in the NIC driver by keeping the device > > > runtime active if PME cannot be used? > > > > That means we need to fix every user of pci_dev_run_wake(), or fix the > > issue in pci_dev_run_wake() helper itself. > > If PME is not granted to the OS, the only consequence is that the PME > port service is not instantiated at the root port. But PME is still > enabled for downstream devices. Maybe that's a mistake? I think the > ACPI spec is a little unclear what to do if PME control is *not* granted. > It only specifies what to do if PME control is *granted*: So do you prefer to just disable runtime PM for the downstream device? > > "If the OS successfully receives control of this feature, it must > handle power management events as described in the PCI Express Base > Specification." > > "If firmware allows the OS control of this feature, then in the context > of the _OSC method it must ensure that all PMEs are routed to root port > interrupts as described in the PCI Express Base Specification. > Additionally, after control is transferred to the OS, firmware must not > update the PME Status field in the Root Status register or the PME > Interrupt Enable field in the Root Control register. If control of this > feature was requested and denied or was not requested, firmware returns > this bit set to 0." > > Perhaps something like the below is appropriate, I'm not sure. > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 091b4a4..7e64185 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -3099,7 +3099,7 @@ void pci_pm_init(struct pci_dev *dev) > } > > pmc &= PCI_PM_CAP_PME_MASK; > - if (pmc) { > + if (pmc && pci_find_host_bridge(dev->bus)->native_pme) { > 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" : "", > > I think this will also prevent non-root port devices from using PME. [snipped] > > > > I think PME IRQ and D3cold are different things here. > > The root port of the affected NIC doesn't support D3cold because > > there's no power resource. > > If a bridge is runtime suspended to D3, the hierarchy below it is > inaccessible, which is basically the same as if it's put in D3cold, > hence the name pci_dev_check_d3cold(). That function allows a device > to block an upstream bridge from runtime suspending because the device > is not allowed to go to D3cold. The function specifically checks whether > a device is PME-capable from D3cold. The NIC claims it's capable but > the PME event has no effect because PME control wasn't granted to the > OS and firmware neglected to set PME Interrupt Enable in the Root Control > register. We could check for this case and block runtime PM of bridges > based on the rationale that PME polling is needed to detect wakeup. So for this case, should we prevent the downstream devices from runtime suspending, or let it suspend but keep the root port active in order to make pci_pme_list_scan() work? Kai-Heng > > Thanks, > > Lukas