Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1547226ybj; Fri, 20 Sep 2019 12:14:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPkhfIxGIPbpzXuQuenpkEEopyv3xqMFJuampCeLluurFFLft7Xmm1lxjV/Q1LJWunh36i X-Received: by 2002:a05:6402:782:: with SMTP id d2mr22270734edy.296.1569006898575; Fri, 20 Sep 2019 12:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569006898; cv=none; d=google.com; s=arc-20160816; b=LTUDwNYpRitMWfO0qw99AB8iSo++1HorbX3LU1jLMHG5oGsbzMvNvK4ZnSf1BEXTZY Oz+NuF3KPY1dTODSOjAPSBfoubDRMr73G7xB8/L3O3tvujKTewqgbXI0RNGG98iF1eRY nfbtaaHe5f8W2yTVN/fCgWDjPKxei3t/F8blj14Kfd09CxzVZpnCxF6LtiSo7As5NspO N8ZYA4/4mfYoMd0M4kpDeddmxYMk9quWeGReeYroIvOvQdkqOMBXAIqr91oYz8SiRocY VoIpzGsVTqy6U4g9bL/JGv7DDwwoW01M3BNx3WqopYYOrdMc73Qw/zKoHB375fvNSjDP VNSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=iV27nI8Jtkumr2nEeO8gy6V9pQ8fT+/smrbZCaOLJgg=; b=MW2hvzjpCWVJv/oWwKgP9Gq0Z1i7u7HVY9oUL7cqtHdE7VrfKD+9EPmJ8uvUmXlwQU wm8gH4eszJZE8Tc7fkliX+ZNFaD149O5mZmSOFLIdgcLPARjbRrNCzCt+iWSSC8GTIaJ q2dG49a7Py3PXp5YECXbgsG874IO2Ibi7lLBMGiuglv8zsnLp6cc9zr/gP/4UkCKsztE eo6kBEIgBo+7gtm7J4uy79yVFppSkjbzHzKTmOhF2hl6WOFOGXjbbgoMbqm6W9OvTFMo wH/DVyujEUrrvU8urpaPTzH/VFGrNZuu8M1lw6BX2oxycyHkQjZbA6p4ETzuZ/pE++Ik nxYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pw28si1016462ejb.43.2019.09.20.12.14.35; Fri, 20 Sep 2019 12:14:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438167AbfITLXg (ORCPT + 99 others); Fri, 20 Sep 2019 07:23:36 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45684 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393608AbfITLXg (ORCPT ); Fri, 20 Sep 2019 07:23:36 -0400 Received: from mail-ot1-f71.google.com ([209.85.210.71]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iBH0f-0002aL-Be for linux-kernel@vger.kernel.org; Fri, 20 Sep 2019 11:23:33 +0000 Received: by mail-ot1-f71.google.com with SMTP id l21so3417251otr.12 for ; Fri, 20 Sep 2019 04:23:33 -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=iV27nI8Jtkumr2nEeO8gy6V9pQ8fT+/smrbZCaOLJgg=; b=sL+SyiYLnYuUUhJ8zNOJ8SJdke9CRPiromrJRjdh4yHsoDuDNHVahQIqfOwJWiwr8U Juk/p5UAEnU7hnsoOo6qfEkUuYd/75k29zWbpYioQ0rCFcgSHb+k1+MWa4Mzzwrq2mXw ek5gH5Nd8IGQTEPHJAl16lCGwpopQbAKFsfGZWbHkjiKT+gqJhODaZXlkSyYYvmLB/Gz Ir0V92T5wTH9ExvfVnf2rwXnieTbqhtT+XhZv2i1QjqUddXmZpRkPQ4quJ1TU9Ybtzod /AAkxRGFloViPJekGwK+u/Wa1z2uoBYzuSDJWcJ0JXBozj/+oMDKHAThnlX0JOnBFqjG EqdQ== X-Gm-Message-State: APjAAAWCSe00JLUk4bSOIlmcVWWLFeqz+Iauh7QoUT5BpembI9L7UGtN lVTRfkX3FIVeL+LDHZOomP7z2dVc3IavL/s4T7TIoll5McwZG1g5a+0/4oAW7hvUS6M3fapA5+6 GCoJHcvFl4i/YzRYXUMhV70Lbz8svp6HV/debKKlK6I2cQ/OYNceRNi9pyA== X-Received: by 2002:aca:d9c3:: with SMTP id q186mr2385459oig.53.1568978612345; Fri, 20 Sep 2019 04:23:32 -0700 (PDT) X-Received: by 2002:aca:d9c3:: with SMTP id q186mr2385434oig.53.1568978612029; Fri, 20 Sep 2019 04:23:32 -0700 (PDT) MIME-Version: 1.0 References: <20190827134756.10807-1-kai.heng.feng@canonical.com> <20190909114129.GT103977@google.com> In-Reply-To: <20190909114129.GT103977@google.com> From: Kai-Heng Feng Date: Fri, 20 Sep 2019 13:23:20 +0200 Message-ID: Subject: Re: [PATCH 1/2] PCI: Add a helper to check Power Resource Requirements _PR3 existence To: Bjorn Helgaas Cc: tiwai@suse.com, Linux PCI , alsa-devel@alsa-project.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bjorn, I didn't find your reply in my mailbox earlier. On Mon, Sep 9, 2019 at 1:41 PM Bjorn Helgaas wrote: > > Maybe: > > PCI: Add pci_pr3_present() to check for Power Resources for D3hot Ok, this is a good title. > > On Tue, Aug 27, 2019 at 09:47:55PM +0800, Kai-Heng Feng wrote: > > A driver may want to know the existence of _PR3, to choose different > > runtime suspend behavior. A user will be add in next patch. > > Maybe include something like this in the commit lot? > > Add pci_pr3_present() to check whether the platform supplies _PR3 to > tell us which power resources the device depends on when in D3hot. Ok. > > > This is mostly the same as nouveau_pr3_present(). > > > > Signed-off-by: Kai-Heng Feng > > --- > > drivers/pci/pci.c | 20 ++++++++++++++++++++ > > include/linux/pci.h | 2 ++ > > 2 files changed, 22 insertions(+) > > > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > > index 1b27b5af3d55..776af15b92c2 100644 > > --- a/drivers/pci/pci.c > > +++ b/drivers/pci/pci.c > > @@ -5856,6 +5856,26 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode, > > return 0; > > } > > > > +bool pci_pr3_present(struct pci_dev *pdev) > > +{ > > + struct pci_dev *parent_pdev = pci_upstream_bridge(pdev); > > + struct acpi_device *parent_adev; > > + > > + if (acpi_disabled) > > + return false; > > + > > + if (!parent_pdev) > > + return false; > > + > > + parent_adev = ACPI_COMPANION(&parent_pdev->dev); > > + if (!parent_adev) > > + return false; > > + > > + return parent_adev->power.flags.power_resources && > > + acpi_has_method(parent_adev->handle, "_PR3"); > > I think this is generally OK, but it doesn't actually check whether > *pdev* has a _PR3; it checks whether pdev's *parent* does. So does > that mean this is dependent on the GPU topology, i.e., does it assume > that there is an upstream bridge and that power for everything under > that bridge can be managed together? Yes, the power resource is managed by its upstream port. > > I'm wondering whether the "parent_pdev = pci_upstream_bridge()" part > should be in the caller rather than in pci_pr3_present()? This will make the function more align to its name, but needs more work from caller side. How about rename the function to pci_upstream_pr3_present()? > > I can't connect any of the dots from _PR3 through to > "need_eld_notify_link" (whatever "eld" is :)) and the uses of > hda_intel.need_eld_notify_link (and needs_eld_notify_link()). > > But that's beyond the scope of *this* patch and it makes sense that > you do want to discover the _PR3 existence, so I'm fine with this once > we figure out the pdev vs parent question. Thanks for your review. Kai-Heng > > > +} > > +EXPORT_SYMBOL_GPL(pci_pr3_present); > > + > > /** > > * pci_add_dma_alias - Add a DMA devfn alias for a device > > * @dev: the PCI device for which alias is added > > diff --git a/include/linux/pci.h b/include/linux/pci.h > > index 82e4cd1b7ac3..9b6f7b67fac9 100644 > > --- a/include/linux/pci.h > > +++ b/include/linux/pci.h > > @@ -2348,9 +2348,11 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus); > > > > void > > pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *)); > > +bool pci_pr3_present(struct pci_dev *pdev); > > #else > > static inline struct irq_domain * > > pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } > > +static bool pci_pr3_present(struct pci_dev *pdev) { return false; } > > #endif > > > > #ifdef CONFIG_EEH > > -- > > 2.17.1 > >