From: Orlando Chamberlain <orlandoch.dev@gmail.com>
To: Alex Deucher <alexdeucher@gmail.com>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
alsa-devel@alsa-project.org, "Pan, Xinhui" <Xinhui.Pan@amd.com>,
"Lijo Lazar" <lijo.lazar@amd.com>,
"Rander Wang" <rander.wang@intel.com>,
"YiPeng Chai" <YiPeng.Chai@amd.com>,
"Mario Limonciello" <mario.limonciello@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
"Evan Quan" <evan.quan@amd.com>,
"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
"Yong Zhi" <yong.zhi@intel.com>,
"Aun-Ali Zaidi" <admin@kodeit.net>,
"Bokun Zhang" <Bokun.Zhang@amd.com>,
"Mark Gross" <markgross@kernel.org>,
"Kerem Karabay" <kekrby@gmail.com>,
"Jaroslav Kysela" <perex@perex.cz>,
"Jack Xiao" <Jack.Xiao@amd.com>,
"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
"Somalapuram Amaranath" <Amaranath.Somalapuram@amd.com>,
"Takashi Iwai" <tiwai@suse.com>,
"Aditya Garg" <gargaditya08@live.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Hawking Zhang" <Hawking.Zhang@amd.com>
Subject: Re: [RFC PATCH 9/9] drm/amdgpu: register a vga_switcheroo client for all GPUs that are not thunderbolt attached
Date: Sat, 11 Feb 2023 10:54:47 +1100 [thread overview]
Message-ID: <20230211105447.0d8dda6b@redecorated-mbp> (raw)
In-Reply-To: <CADnq5_PXa=d8ie8jj7sGxvxfn+ZNwed-eSyNg89PfWCvpo8LCw@mail.gmail.com>
On Fri, 10 Feb 2023 11:37:08 -0500
Alex Deucher <alexdeucher@gmail.com> wrote:
> On Fri, Feb 10, 2023 at 11:07 AM Hans de Goede <hdegoede@redhat.com>
> wrote:
> >
> > Hi,
> >
> > On 2/10/23 16:53, Alex Deucher wrote:
> > > On Fri, Feb 10, 2023 at 3:04 AM Orlando Chamberlain
> > > <orlandoch.dev@gmail.com> wrote:
> > >>
> > >> From: Kerem Karabay <kekrby@gmail.com>
> > >>
> > >> Commit 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and
> > >> vga_switcheroo") made amdgpu only register a vga_switcheroo
> > >> client for GPU's with PX, however AMD GPUs in dual gpu Apple
> > >> Macbooks do need to register, but don't have PX. Instead of
> > >> AMD's PX, they use apple-gmux.
> > >
> > > Is there a way to detect apple-gmux instead? Otherwise, we
> > > register vga_switcheroo on any system with multiple GPUs which is
> > > not what we want.
> >
> > Yes since 6.1.y (either stable series or just take 6.2.0) the
> > apple-gmux detect code has been factored out into a stand-alone
> > apple_gmux_detect() helper inside:
> >
> > include/linux/apple-gmux.h
> >
> > For usage outside of the actual apple-gmux driver you can simply
> > pass NULL for both arguments.
> >
> > This was necessary to reliably check if the apple-gmux should be
> > used for backlight control.
> >
> > Note there also is the older apple_gmux_present() helper, which is
> > already used in some drm code. That function is not reliable though
> > it detects if the ACPI tables contain an ACPI device describing
> > the presence of a gmux, but it turns out even Apple has buggy ACPI
> > tables and the mere presence of that ACPI device is not a reliable
> > indicator the gmux is actually there.
> >
> > I have not changed over any of the existing apple_gmux_present()
> > users for fear of unwanted side effects...
>
> Looks like we could maybe use the PWRD ACPI check like patch 8 does
> as well.
I wasn't using apple_gmux_detect as I mistakenly thought
pnp_get_resource would fail if apple-gmux had bound to the resource but
it looks like I was wrong about that so we can use that to determine if
the system has a gmux. I think I'll do that in v2.
As far as I know there's only one internal (non
thunderbolt) amd gpu inside all Macbooks with gmux so we probably
wouldn't need to check for PWRD to ensure it's the right gpu.
With PWRD, I don't know if its present on all Dual GPU Macbooks, I've
only found the acpi tables for Macbookpro14,x to Macbookpro16,x, so I
don't know if it will work on older Macs (I'm also not sure if those
macs are using radeon or amdgpu).
> Alex
>
> >
> > Regards,
> >
> > Hans
> >
> >
> >
> >
> > >> Revert to the old logic of registering for all non-thunderbolt
> > >> gpus, like radeon and nouveau.
> > >>
> > >> Fixes: 3840c5bcc245 ("drm/amdgpu: disentangle runtime pm and
> > >> vga_switcheroo") Signed-off-by: Kerem Karabay <kekrby@gmail.com>
> > >> [Orlando Chamberlain <orlandoch.dev@gmail.com>: add commit
> > >> description] Signed-off-by: Orlando Chamberlain
> > >> <orlandoch.dev@gmail.com> ---
> > >> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 18
> > >> +++++++++++------- 1 file changed, 11 insertions(+), 7
> > >> deletions(-)
> > >>
> > >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index
> > >> 2f28a8c02f64..0bb553a61552 100644 ---
> > >> a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++
> > >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3919,12
> > >> +3919,13 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> > >> if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> > >> vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
> > >>
> > >> - if (amdgpu_device_supports_px(ddev)) {
> > >> - px = true;
> > >> - vga_switcheroo_register_client(adev->pdev,
> > >> -
> > >> &amdgpu_switcheroo_ops, px);
> > >> + px = amdgpu_device_supports_px(ddev);
> > >> +
> > >> + if (!pci_is_thunderbolt_attached(adev->pdev))
> > >> + vga_switcheroo_register_client(adev->pdev,
> > >> &amdgpu_switcheroo_ops, px); +
> > >> + if (px)
> > >> vga_switcheroo_init_domain_pm_ops(adev->dev,
> > >> &adev->vga_pm_domain);
> > >> - }
> > >>
> > >> if (adev->gmc.xgmi.pending_reset)
> > >> queue_delayed_work(system_wq,
> > >> &mgpu_info.delayed_reset_work, @@ -4048,10 +4049,13 @@ void
> > >> amdgpu_device_fini_sw(struct amdgpu_device *adev)
> > >>
> > >> kfree(adev->bios);
> > >> adev->bios = NULL;
> > >> - if (amdgpu_device_supports_px(adev_to_drm(adev))) {
> > >> +
> > >> + if (!pci_is_thunderbolt_attached(adev->pdev))
> > >> vga_switcheroo_unregister_client(adev->pdev);
> > >> +
> > >> + if (amdgpu_device_supports_px(adev_to_drm(adev)))
> > >> vga_switcheroo_fini_domain_pm_ops(adev->dev);
> > >> - }
> > >> +
> > >> if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> > >> vga_client_unregister(adev->pdev);
> > >>
> > >> --
> > >> 2.39.1
> > >>
> > >
> >
next prev parent reply other threads:[~2023-02-10 23:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 4:48 [RFC PATCH 0/9] apple-gmux: support MMIO gmux type on T2 Macs Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 1/9] apple-gmux: use cpu_to_be32 instead of manual reorder Orlando Chamberlain
2023-02-10 19:09 ` Hans de Goede
2023-02-10 19:19 ` Hans de Goede
2023-02-10 23:30 ` Orlando Chamberlain
2023-02-11 11:27 ` Hans de Goede
2023-02-10 19:33 ` Hans de Goede
2023-02-10 22:52 ` David Laight
2023-02-10 4:48 ` [RFC PATCH 2/9] apple-gmux: consolidate version reading Orlando Chamberlain
2023-02-10 19:41 ` Hans de Goede
2023-02-10 23:36 ` Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 3/9] apple-gmux: use first bit to check switch state Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 4/9] apple-gmux: refactor gmux types Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 5/9] apple-gmux: Use GMSP acpi method for interrupt clear Orlando Chamberlain
2023-02-10 19:43 ` Hans de Goede
2023-02-10 23:40 ` Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 6/9] apple-gmux: support MMIO gmux on T2 Macs Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 7/9] apple-gmux: add sysfs interface Orlando Chamberlain
2023-02-10 20:15 ` Hans de Goede
2023-02-10 20:23 ` Hans de Goede
2023-02-10 23:44 ` Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 8/9] hda/hdmi: Register with vga_switcheroo on Dual GPU Macbooks Orlando Chamberlain
2023-02-10 4:48 ` [RFC PATCH 9/9] drm/amdgpu: register a vga_switcheroo client for all GPUs that are not thunderbolt attached Orlando Chamberlain
2023-02-10 15:53 ` Alex Deucher
2023-02-10 16:07 ` Hans de Goede
2023-02-10 16:37 ` Alex Deucher
2023-02-10 23:54 ` Orlando Chamberlain [this message]
2023-02-10 16:30 ` [RFC PATCH 0/9] apple-gmux: support MMIO gmux type on T2 Macs Alex Deucher
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=20230211105447.0d8dda6b@redecorated-mbp \
--to=orlandoch.dev@gmail.com \
--cc=Amaranath.Somalapuram@amd.com \
--cc=Bokun.Zhang@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Jack.Xiao@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=YiPeng.Chai@amd.com \
--cc=admin@kodeit.net \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=evan.quan@amd.com \
--cc=gargaditya08@live.com \
--cc=hdegoede@redhat.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=kekrby@gmail.com \
--cc=lijo.lazar@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=markgross@kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rander.wang@intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=yong.zhi@intel.com \
/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