From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Dave Airlie <airlied@gmail.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] vga_switcheroo: add power support for windows 10 machines.
Date: Thu, 10 Mar 2016 21:57:09 +0100 [thread overview]
Message-ID: <2736217.utxPzJExd5@vostro.rjw.lan> (raw)
In-Reply-To: <CAPM=9tzAf=464v3uSjert7NVh35EXUG8iy_xEuR36NUMhdJSWw@mail.gmail.com>
On Thursday, March 10, 2016 07:56:41 AM Dave Airlie wrote:
> On 9 March 2016 at 23:19, Rafael J. Wysocki <rafael@kernel.org> wrote:
> > On Wed, Mar 9, 2016 at 7:14 AM, Dave Airlie <airlied@gmail.com> wrote:
> >> From: Dave Airlie <airlied@redhat.com>
> >>
> >> Windows 10 seems to have standardised power control for the
> >> optimus/powerxpress laptops using PR3 power resource hooks.
> >>
> >> I'm not sure this is definitely the correct place to be
> >> doing this, but it works for me here.
> >>
> >> The ACPI device for the GPU I have is \_SB_.PCI0.PEG_.VID_
> >> but the power resource hooks are on \_SB_.PCI0.PEG_, so
> >> this patch creates a new power domain to turn the GPU
> >> device parent off using standard ACPI calls.
> >>
> >> Signed-off-by: Dave Airlie <airlied@redhat.com>
> >> ---
> >> drivers/gpu/vga/vga_switcheroo.c | 54 +++++++++++++++++++++++++++++++++++++++-
> >> include/linux/vga_switcheroo.h | 3 ++-
> >> 2 files changed, 55 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
> >> index 665ab9f..be32cb2 100644
> >> --- a/drivers/gpu/vga/vga_switcheroo.c
> >> +++ b/drivers/gpu/vga/vga_switcheroo.c
> >> @@ -42,7 +42,7 @@
> >> #include <linux/uaccess.h>
> >> #include <linux/vgaarb.h>
> >> #include <linux/vga_switcheroo.h>
> >> -
> >> +#include <linux/acpi.h>
> >> /**
> >> * DOC: Overview
> >> *
> >> @@ -997,3 +997,55 @@ vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev,
> >> return -EINVAL;
> >> }
> >> EXPORT_SYMBOL(vga_switcheroo_init_domain_pm_optimus_hdmi_audio);
> >> +
> >> +/* With Windows 10 the runtime suspend/resume can use power
> >> + resources on the parent device */
> >> +static int vga_acpi_switcheroo_runtime_suspend(struct device *dev)
> >> +{
> >> + struct pci_dev *pdev = to_pci_dev(dev);
> >> + int ret;
> >> + struct acpi_device *adev;
> >> +
> >> + ret = dev->bus->pm->runtime_suspend(dev);
> >> + if (ret)
> >> + return ret;
> >> +
> >> + ret = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev);
> >
> > You can use ACPI_COMPANION(&pdev->dev) for that.
> >
> >> + if (!ret)
> >> + acpi_device_set_power(adev->parent, ACPI_STATE_D3_COLD);
> >
> > Won't that mess up with the PM of the parent? Or do we know that the
> > parent won't do its own PM?
>
> The parent is always going to be pcieport.
I see.
> It doesn't seem to do any runtime PM,
> I do wonder if pcieport should be doing it's own runtime PM handling,
> but that is a
> larger task than I'm thinking to tackle here.
PCIe ports don't do PM - yet. Mika has posted a series of patches to implement
that, however, that are waiting for comments now:
https://patchwork.kernel.org/patch/8453311/
https://patchwork.kernel.org/patch/8453381/
https://patchwork.kernel.org/patch/8453391/
https://patchwork.kernel.org/patch/8453411/
https://patchwork.kernel.org/patch/8453371/
https://patchwork.kernel.org/patch/8453351/
> Maybe I should be doing
>
> pci_set_power_state(pdev->bus->self, PCI_D3cold) ? I'm not really sure.
Using pci_set_power_state() would be more appropriate IMO, but you can get
to the bridge via dev->parent too, can't you?
In any case, it looks like you and Mika need to talk. :-)
> I'm guessing on Windows this all happens automatically.
PCIe ports are power-managend by (newer) Windows AFAICS, but we know for a fact
that this simply doesn't work reliably on some older hardware which is why
we don't do that. I suppose that the Windows in question uses a cut-off date
or similar to decide what do do with PCIe ports PM.
Thanks,
Rafael
next prev parent reply other threads:[~2016-03-10 20:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 6:14 [PATCH 1/2] vga_switcheroo: add power support for windows 10 machines Dave Airlie
2016-03-09 6:14 ` [PATCH 2/2] nouveau: use new vga_switcheroo power domain Dave Airlie
2016-03-09 13:20 ` Rafael J. Wysocki
2016-03-09 14:40 ` Lukas Wunner
2016-03-09 22:04 ` Dave Airlie
2016-03-15 20:47 ` Lukas Wunner
2016-03-09 13:19 ` [PATCH 1/2] vga_switcheroo: add power support for windows 10 machines Rafael J. Wysocki
2016-03-09 21:56 ` Dave Airlie
2016-03-10 20:57 ` Rafael J. Wysocki [this message]
2016-03-11 10:58 ` Mika Westerberg
2016-03-11 13:45 ` Rafael J. Wysocki
2016-03-14 2:19 ` Dave Airlie
2016-03-14 9:43 ` Mika Westerberg
2016-03-14 9:47 ` Dave Airlie
2016-03-14 10:02 ` Daniel Vetter
2016-03-14 10:23 ` Mika Westerberg
2016-03-14 12:50 ` Rafael J. Wysocki
2016-03-14 14:30 ` Mika Westerberg
2016-03-15 13:39 ` Lukas Wunner
2016-03-15 13:57 ` Mika Westerberg
2016-03-14 14:30 ` Alex Deucher
2016-03-09 14:33 ` Lukas Wunner
2016-03-09 16:52 ` Alex Deucher
2016-03-09 20:17 ` Lukas Wunner
2016-03-09 20:22 ` Alex Deucher
2016-03-09 22:02 ` Dave Airlie
2016-03-09 22:00 ` Dave Airlie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2736217.utxPzJExd5@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox