On Thu, Jun 28, 2018 at 2:22 AM, Jim Qu Jim.Qu@amd.com wrote:
Please resend and send it to dri-devel and alsa-devel@alsa-project.org since this patch touches multiple subsystems. I would propose we merge this through the drm tree if possible.
Alex
HI,
Any comments for the patch?
Thanks JimQu
________________________________________ 发件人: Alex Deucher alexdeucher@gmail.com 发送时间: 2018年6月28日 20:43 收件人: Qu, Jim; alsa-devel@alsa-project.org; Maling list - DRI developers 抄送: amd-gfx list; Deucher, Alexander 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Thu, Jun 28, 2018 at 2:22 AM, Jim Qu Jim.Qu@amd.com wrote:
Please resend and send it to dri-devel and alsa-devel@alsa-project.org since this patch touches multiple subsystems. I would propose we merge this through the drm tree if possible.
Alex
Please explain what you mean by UMA here. Are you referring to dual GPU systems where both GPUs are by AMD? And the integrated GPU is incorrectly assigned VGA_SWITCHEROO_DIS?
Starting with v4.17, the only reason the audio driver registers with vga_switcheroo is because it can be powered down if manual power control is used. However manual power control is not the default, it's primary use case nowadays is MacBook Pros, and there are no MacBook Pros with dual AMD GPUs. So I don't understand what real world use case you're trying to fix. Please explain.
Unlike the other changes in your patch, this one would seem perfectly valid to me. However it's a separate issue, so please put it in a separate patch.
Instead of adding a check for PCI_CLASS_DISPLAY_OTHER, I'd prefer you replacing the existing check for PCI_CLASS_DISPLAY_VGA with a check for PCI_BASE_CLASS_DISPLAY, like so:
- if ((p->class >> 8) == PCI_CLASS_DISPLAY_VGA) + if ((p->class >> 16) == PCI_BASE_CLASS_DISPLAY)
Thanks,
Lukas
Hi Lukas,
Thanks to your response, please see comments in line.
Thanks JimQu
________________________________________ 发件人: Lukas Wunner lukas@wunner.de 发送时间: 2018年6月29日 16:06 收件人: Qu, Jim 抄送: alsa-devel@alsa-project.org; dri-devel@lists.freedesktop.org; Deucher, Alexander; amd-gfx@lists.freedesktop.org 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
Jim: Yeah, this a laptop which has two GPUs, iGPU has a HD audio for HDMI output. dGPU is headless which is only for offload render. This is a grapchis offloading solution for hybird GFX.
When our dGPU does suspend by runtime pm. amdgpu driver for dgpu will also call vgaswtichroo to power off its audio. vgaswitchroo driver will find audio codec by vgaswitchroo dgpu client id(VGA_SWITCHEROO_DIS).
Current HDA driver will register iGPU's audio client to vgaswitchroo as VGA_SWITCHEROO_DIS. so iGPU's audio has been powered off. It causes the issue that no sound on the HDMI device.
I think the issue should be observed on both Intel+AMD or AMD+AMD platform which has the same HW configuration.
1.if dGPU has no audio codec. the issue should be always observed. 2.if both iGPU and dGPU has audio codecs, the issue should be random, it depends on the first audio found by vgaswitchroo driver is on iGPU or dGPU.
Jim: That is fine, will update it.
Thanks,
Lukas
On Fri, Jun 29, 2018 at 08:55:40AM +0000, Qu, Jim wrote:
That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").
Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.
On discrete AMD and Nvidia GPUs, the HDA controller is function 1 and the GPU is function 0 in the same PCI slot.
On Intel chipsets, the HDA controller and the GPU have completely different PCI device numbers, e.g. the GPU might be 0000:00:02.0 and the HDA controller might be 0000:00:1b.0.
get_bound_vga() checks that the HDA controller is function 1 and there's a GPU in function 0 of the same slot.
Thus get_bound_vga() always returns NULL for an Intel HDA controller and the controller is never registered with vga_switcheroo (which is fine).
Thanks,
Lukas
indeed?I used 4.13 on the platform. let me have a try with the patch you mentioned
thinks jimqu
?? Outlook for Androidhttps://aka.ms/ghei36
________________________________ From: Lukas Wunner lukas@wunner.de Sent: Friday, June 29, 2018 5:21:38 PM To: Qu, Jim Cc: alsa-devel@alsa-project.org; dri-devel@lists.freedesktop.org; Deucher, Alexander; amd-gfx@lists.freedesktop.org Subject: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Fri, Jun 29, 2018 at 08:55:40AM +0000, Qu, Jim wrote:
That is no longer the case since v4.17. The HDA controller now runtime suspends autonomously, see commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").
Your patch appears to be geared towards an older kernel version. Please retest on the laptop in question with a v4.17+ kernel.
On discrete AMD and Nvidia GPUs, the HDA controller is function 1 and the GPU is function 0 in the same PCI slot.
On Intel chipsets, the HDA controller and the GPU have completely different PCI device numbers, e.g. the GPU might be 0000:00:02.0 and the HDA controller might be 0000:00:1b.0.
get_bound_vga() checks that the HDA controller is function 1 and there's a GPU in function 0 of the same slot.
Thus get_bound_vga() always returns NULL for an Intel HDA controller and the controller is never registered with vga_switcheroo (which is fine).
Thanks,
Lukas
On Fri, Jun 29, 2018 at 10:40:50AM +0000, Qu, Jim wrote:
The commit can't be cherry-picked by itself onto v4.13, it was part of a larger series. It's best to use a stock v4.17 kernel.
Note, a fix went into Linus' tree yesterday, commit 57cb54e53bdd ("ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI"). Not sure if it's needed on your machine.
Thanks,
Lukas
Hi Lukas,
Our OEM report the issue also can be observed with v4.17rc7 of test platform, and I also backported these 7 patches to v4.15, have confirmed the issue.
Now, I found the audio device will auto suspend even if the gpu is active, and if I plug in a HDMI device it also do not resume back.
1. Did you encounter similar issue before? 2. audio will auto suspend as default at beginning of boot, is it expect behaviour?
Device links help us handle two things:
1. make the audio/gpu suspend/resume/poweroff processing in an orderly way with the DL_FLAG_STATELESS flag. 2. it can guarantee the audio can be accessed if gpu is poweroffed by setting the DL_FLAG_PM_RUNTIME flag.
So, in my opinion, audio's suspend/resume should be processed with gpu suspend/resume.
Thanks JimQu
________________________________________ 发件人: Lukas Wunner lukas@wunner.de 发送时间: 2018年6月29日 19:11 收件人: Qu, Jim 抄送: alsa-devel@alsa-project.org; dri-devel@lists.freedesktop.org; Deucher, Alexander; amd-gfx@lists.freedesktop.org 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Fri, Jun 29, 2018 at 10:40:50AM +0000, Qu, Jim wrote:
The commit can't be cherry-picked by itself onto v4.13, it was part of a larger series. It's best to use a stock v4.17 kernel.
Note, a fix went into Linus' tree yesterday, commit 57cb54e53bdd ("ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI"). Not sure if it's needed on your machine.
Thanks,
Lukas
On Mon, Jul 09, 2018 at 08:52:33AM +0000, Qu, Jim wrote:
Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.
Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?
You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?
Thanks,
Lukas
Hi Lukas,
Thanks to your explanation, and see comments in line.
Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?
Jim: OEM system uses pactl to queiry audio card and audio output sink, since the audio has power down by runtime pm, so the audio card and output sink are all unavailable. they could not select the available HDMI audio for audio playing.
You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?
Jim: So far, I do not find any code about audio response HPD in kernel. the HPD interrupt will sent to user mode via uevent, not sure whether audio user mode driver can receive the event or not.
Thanks JimQu
________________________________________ 发件人: Lukas Wunner lukas@wunner.de 发送时间: 2018年7月9日 17:27 收件人: Qu, Jim 抄送: alsa-devel@alsa-project.org; dri-devel@lists.freedesktop.org; Deucher, Alexander; amd-gfx@lists.freedesktop.org 主题: Re: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Mon, Jul 09, 2018 at 08:52:33AM +0000, Qu, Jim wrote:
Yes, that's expected. Once you start streaming audio to attached displays, user space opens the codec device and this causes the HDA controller to runtime resume. If the discrete GPU is suspended at that moment, it will be powered on and kept powered on as long as user space is streaming audio.
Do you need to runtime resume the HDA controller even if user space isn't streaming audio? Why, and in which situation exactly?
You're saying above that the HDA controller isn't runtime resumed on hotplug of a display. Is that necessary to retrieve ELD or something? I'm not sure if there's code in the HDA driver to acquire a runtime PM ref on HPD, but maybe it's necessary. Or maybe the code is there but somehow no HPD interrupt is received by the HDA driver?
Thanks,
Lukas
On Mon, Jul 9, 2018 at 6:16 AM, Qu, Jim Jim.Qu@amd.com wrote:
On the gfx side at least, we can get a hotplug event via ACPI (depending on the OEM design) if displays are attached/detached while the dGPU is powered down. I suppose the gfx driver could call into the audio driver during one of those events. On the gfx side at least we just generate the gfx hotplug event and let userspace deal with it.
Alex
On Mon, 09 Jul 2018 15:58:51 +0200, Alex Deucher wrote:
IMO, a more proper way would be to have the direct communication between the graphics driver and the audio driver like i915 driver does. Then the audio driver can get plug/unplug event at more accurate timing without races.
(Though, it will cause another mess wrt the weak module dependency, but it's another story :)
thanks,
Takashi
On Mon, Jul 09, 2018 at 05:04:22PM +0200, Takashi Iwai wrote:
Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)
If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.
Thanks,
Lukas
On Mon, 09 Jul 2018 17:47:34 +0200, Lukas Wunner wrote:
It's not about the PCI power state, but the problem is that the detection of the HDMI and its ELD read is somewhat asynchronous. Basically it's handled via the hardware unsolicited event emitted over HD-audio bus, which was originally generated by GPU at dealing with the hotplug/unplug. So, this part is racy and not 100% reliable -- although usually it shouldn't be a big problem.
That said, it's not the exact "need" but it would make things more reliable and accurate (even consumes less power as we don't need to power up/down just for the HDMI detection).
Takashi
On Mon, Jul 9, 2018 at 11:52 AM, Takashi Iwai tiwai@suse.de wrote:
Well for display detection, we don't actually have to wake the GPU, we get the notification from the embedded controller via ACPI if the GPU is powered down, so in the GPU driver we just pass the event along to userspace if the GPU is asleep. I think if we wanted to pass the info along to the audio driver, we'd need to wake both the GPU and the audio to update the audio connect status.
Alex
On Mon, 09 Jul 2018 17:59:00 +0200, Alex Deucher wrote:
I guess that It's not enough to have an ACPI event but we need to read ELD upon hotplugging (not at unplugging, of course, though). So a GPU wakeup would be mandatory, if I'm not mistaken.
Takashi
On Mon, Jul 09, 2018 at 05:52:49PM +0200, Takashi Iwai wrote:
Okay. If amdgpu triggers the event on the HDA bus, it should call pm_runtime_get_sync() on the HDA device beforehand. Which device needs to be resumed exactly to ensure ELD reception, the PCI one or the codec?
Thanks,
Lukas
On Mon, Jul 9, 2018 at 12:06 PM, Lukas Wunner lukas@wunner.de wrote:
I don't think it makes sense to power up anything until the user wants to do something with the event. On AMD hardware, the ELD is not actually used. The gpu passes the ELD info internally via shared registers. So as soon as the GPU driver parses the EDID and updates the shared registers, the audio driver will know the state just by reading back the shared registers. That said, there no reason to act on the event unless the user actually wants to do something with it. E.g., the desktop manager sees the event and decides to call down to the kernel to query the display topology (or not). At which point the hw can be powered up, etc.
Alex
On Mon, 09 Jul 2018 18:15:32 +0200, Alex Deucher wrote:
It needs to power up to read even the shared registers; they are accessed via HD-audio verbs, so we need the whole runtime resume of the bus & codec just for reading ELD information that are stored by GPU.
And, ELD info is mandatory for informing the hotplug information to user-space, not only the connection/disconnection state.
If ELD and hoptlug info are passed directly from GPU by other means, we can avoid the power up/down in the audio side, indeed. That's what Intel driver serves, after all.
Takashi
Hi All,
Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.
Thanks JimQu
-----邮件原件----- 发件人: Lukas Wunner lukas@wunner.de 发送时间: 2018年7月9日 23:48 收件人: Takashi Iwai tiwai@suse.de 抄送: Alex Deucher alexdeucher@gmail.com; alsa-devel@alsa-project.org; amd-gfx@lists.freedesktop.org; Qu, Jim Jim.Qu@amd.com; dri-devel@lists.freedesktop.org; Deucher, Alexander Alexander.Deucher@amd.com 主题: Re: [alsa-devel] ??????: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Mon, Jul 09, 2018 at 05:04:22PM +0200, Takashi Iwai wrote:
Since v4.17, every time the GPU is powered up, the HDA controller is runtime resumed to PCI_D0. (See the call to pci_wakeup_bus() in vga_switcheroo_runtime_resume() added by dcac86b7d0.)
If the HDA controller can't detect presence of an HDMI display even if it's in PCI_D0, then I suppose that needs to be adressed in the HDA driver. Thus so far I don't see the need to call from amdgpu into the HDA driver.
Thanks,
Lukas
On Mon, 09 Jul 2018 17:53:19 +0200, Qu, Jim wrote:
Hi All,
Here, I want to clarify the audio device is bound to iGPU. There is no audio codec for dGPU.
I'm confused. So you mean that the HDMI detection on Intel GPU doesn't work with the hybrid GPUs? And no audio codec on discrete GPU...? Why do we need vga_switcheroo at all, then?
Takashi
On Mon, Jul 9, 2018 at 11:57 AM, Takashi Iwai tiwai@suse.de wrote:
The original problem is the audio codec is getting associated with dGPU rather than the iGPU so switcheroo tries to power down the audio codec when it powers down the dGPU. We got a bit sidetracked in the discussion however.
Alex
On Mon, 09 Jul 2018 18:03:48 +0200, Alex Deucher wrote:
Ah, thanks, that clarifies better, but still I'm lost about what's going on...
Can anyone summarize the problem and the results with the recent (>= 4.17) Linux kernel...?
thanks,
Takashi
On Mon, Jul 09, 2018 at 05:04:22PM +0200, Takashi Iwai wrote:
Just don't do what snd-hda-intel did and instead implement the component stuff properly :-) -Daniel
Hi Takashi,
Not intel, but it is AMD APU+ AMD GFX, the APU has a local HDMI port for extension. And dGPU is only for offloading render via PRIME.
Originally, the HDA driver before v4.17, there is a bug, that all the audio is set to CLIENT_DIS, so the when the dGPU suspend, the audio which is bound to iGPU will also be suspend.
Now, after Lukas' patches. The audio will auto suspend. It make ubuntu audio setting could not detect HDMI audio, even if HDMI has light up.
Thanks JimQu
-----邮件原件----- 发件人: Takashi Iwai tiwai@suse.de 发送时间: 2018年7月9日 23:58 收件人: Daniel Vetter daniel@ffwll.ch 抄送: Alex Deucher alexdeucher@gmail.com; alsa-devel@alsa-project.org; amd-gfx@lists.freedesktop.org; Qu, Jim Jim.Qu@amd.com; dri-devel@lists.freedesktop.org; Deucher, Alexander Alexander.Deucher@amd.com 主题: Re: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Mon, 09 Jul 2018 17:56:43 +0200, Daniel Vetter wrote:
A patch is welcome :)
thanks,
Takashi
On Mon, 09 Jul 2018 18:05:09 +0200, Qu, Jim wrote:
OK, and it has all necessary patches including the one Lukas suggested, right?
If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?
Takashi
Hi Takashi,
I am not expert in audio driver, so I just update some test result, please help triage the issue.
With audio runtime pm:
1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm. 2. cat /proc/asound/card0/eld* can get nothing.
Without audio runtime pm: 1. pactl can get available audio output/sink 2. can get eld info from eld#0.1
IMO, the issue should be:
Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, can select a available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.
Thanks JimQu
________________________________________ 发件人: Takashi Iwai tiwai@suse.de 发送时间: 2018年7月10日 1:09 收件人: Qu, Jim 抄送: Daniel Vetter; Alex Deucher; alsa-devel@alsa-project.org; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; Deucher, Alexander 主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Mon, 09 Jul 2018 18:05:09 +0200, Qu, Jim wrote:
OK, and it has all necessary patches including the one Lukas suggested, right?
If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?
Takashi
Sorry, correct the typo.
IMO, the issue should be:
Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, it can not select an available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.
Thanks JimQu
________________________________________ 发件人: Qu, Jim 发送时间: 2018年7月10日 15:44:42 收件人: Takashi Iwai 抄送: Daniel Vetter; Alex Deucher; alsa-devel@alsa-project.org; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; Deucher, Alexander 主题: 答复: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
Hi Takashi,
I am not expert in audio driver, so I just update some test result, please help triage the issue.
With audio runtime pm:
1. ubuntu audio setting use pactl to query audio card/output sink. Attachment is pactl output with audio runtime pm. 2. cat /proc/asound/card0/eld* can get nothing.
Without audio runtime pm: 1. pactl can get available audio output/sink 2. can get eld info from eld#0.1
IMO, the issue should be:
Current operations like HDMI hotplug in/out, pactl command, they do not access audio HW, so the audio could not resume back at this period. Therefore, upper software could not get HDMI ELD info, can select a available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.
Thanks JimQu
________________________________________ 发件人: Takashi Iwai tiwai@suse.de 发送时间: 2018年7月10日 1:09 收件人: Qu, Jim 抄送: Daniel Vetter; Alex Deucher; alsa-devel@alsa-project.org; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; Deucher, Alexander 主题: Re: 答复: [alsa-devel] 答复: [PATCH] vgaswitchroo: set audio client id according to bound gpu client id
On Mon, 09 Jul 2018 18:05:09 +0200, Qu, Jim wrote:
OK, and it has all necessary patches including the one Lukas suggested, right?
If so, figure out what you're actually seeing as "PA could not detect HDMI audio". For example, is it the HDMI (jack) detection (giving false even if it's connected)? Or is it an error at opening the given device? Does the driver give the proper ELD bytes as well as the jack state?
Takashi
On Tue, 10 Jul 2018 09:44:42 +0200, Qu, Jim wrote:
What does this mean? Is it the stock 4.17.x (or 4.18-rc)? Please clarify your test environment at first: which kernel, which hardware setup.
Sorry, not understood. Why they don't access the audio hardware?
Therefore, upper software could not get HDMI ELD info, can select a available card/output sink. I am also confuse that if there is no ELD info, how driver to steam audio device to wake up itself? It's sort of a chicken-or-egg question.
As long as it's i915 and HD-audio, the hotplug and ELD info transfer doesn't trigger the runtime PM since it's done via the direct callback. And ELD value is cached in HD-audio side.
The exception is that if the notification is done during the PM operation. But, the connection and ELD query is performed at the end of codec resume, hence it'll be covered there.
So in theory, ELD information should be passed from the GPU to HD-audio no matter whether runtime PM is enabled or not.
BTW, please stop top-posting. It makes the thread readability awfully worse.
thanks,
Takashi
On 2018年07月10日 16:01, Takashi Iwai wrote:
This is v4.15 which backport Lukas' patches and also one bug fix https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=5.... The platform is AMDAPU(with audio) + AMD dGPU , it is a hybird GFX platform. In generic, dGPU will always be suspended.
This is my guess, since I do not get azx_runtime_resume() print info which I added. it maybe access HW during this period, but do not trigger audio resume progress. https://elixir.bootlin.com/linux/v4.18-rc3/ident/azx_runtime_resume
Yeah, I have reviewed these code, it constructs ELD after reading EDID, and write them into HW buffer when set display mode.
Sorry, I justed used outlook client.
On Tue, 10 Jul 2018 11:13:27 +0200, jimqu wrote:
Ah, so it's AMD+AMD, not Intel+AMD combo. Now I understand the situation better, thanks.
If the controller chip supports "wake-enable" feature (HD-audio WAKEEN register), it could be woken up at unsolicited event even during the link power down. But, your report implies that AMD controller doesn't do this, or something missing there. That's the likely cause of the missing hotplug event.
So, if my understanding is right, the situation won't be different even if you have a single AMD GPU. And possibly a side-effect of the latest fix to force link-down for AMD GPU. Need to check it...
Takashi
On 2018年07月10日 17:50, Takashi Iwai wrote:
Is there any method to confirm it?
Before Lukas' patches, it is relative with dGPU, because audio power is controlled by vgaswitchreroo and GFX driver, but now it won't. revert the fix of amdgpu suspend issue, audio issue also can be observed.
On Tue, 10 Jul 2018 13:11:20 +0200, jimqu wrote:
The driver always sets WAKEEN bit, see azx_runtime_suspend() in hda_intel.c. If it still doesn't behave as expected, it means that the feature isn't supported on that chip :)
Right, and this is the correct behavior.
revert the fix of amdgpu suspend issue, audio issue also can be observed.
Did you check the behavior with the single AMD GPU hardware? If confirmed, we can forget about vga_switcheroo.
Takashi
On Tue, 10 Jul 2018 13:21:00 +0200, Takashi Iwai wrote:
... and taking a look back at the recent changes, I guess it can be the forced runtime PM enablement, not directly with vga_switcheroo action itself.
Jim, could you tell me which PCI devices are handled as vga_switcheroo audio client? The kernel should show all messages "xxx: Handle vga_switcheroo audio client".
At best, give the full dmesg output and the lspci -nv output.
thanks,
Takashi
On 2018年07月11日 15:19, Takashi Iwai wrote:
Yeah, the function vga_switcheroo_set_dynamic_switch() has discarded, so there is no way GFX driver to control audio power. However, keep in mind, current audio is bound to iGPU, that mean the issue should be nothing about vgaswtichreoo. since current audio pci bus is different from dGPU, that means the pci_bus_set_current_state() in vga_switcheroo_runtime_suspend() and pci_wakeup_bus() in vga_switcheroo_runtime_resume() could not touch the audio pci power state from dGPU instance.
This is a feedback got from our OEM developer, it is the overview of audio detect process.
If the description is correct. I think there are maybe two problems.
1. audio will auto power off after setup device link duo to usage_count=0. 2. duo to audio is power down, it could not get the HDMI jack insert event.
How do you think?
[ 4.311095] snd_hda_intel 0000:06:00.1: enabling device (0000 -> 0002) [ 4.314286] snd_hda_intel 0000:06:00.1: Handle vga_switcheroo audio client [ 4.314822] snd_hda_intel 0000:06:00.6: enabling device (0000 -> 0002)
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:699f] (rev c3) 06:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15dd] (rev d1) 06:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Device [1002:15de]
Thanks JimQu
On Wed, 11 Jul 2018 10:41:38 +0200, jimqu wrote:
OK this sheds a brighter light, finally.
If my understanding is correct, the issue is a false vga_switcheroo audio detection, after all. This is the primary GPU and it shouldn't be registered as a vga_switcheroo discrete GPU.
Below is a very ugly workaround for this particular case. It assumes that the AMD+AMD combo will never have audio outputs on both but only for the primary, and it's possibly wrong.
Is there a handy way to identify whether the given VGA PCI entry is a discrete GPU or not? The amdgpu and radeon seem checking ATPX ACPI.
Takashi
--- --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1418,8 +1418,18 @@ static int azx_dev_free(struct snd_device *device) */ static struct pci_dev *get_bound_vga(struct pci_dev *pci) { + static const struct pci_device_id ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16 }, + {} + }; struct pci_dev *p;
+ /* check whether Intel graphics is present as primary GPU */ + if (!pci_dev_present(ids)) + return NULL; + /* check only discrete GPU */ switch (pci->vendor) { case PCI_VENDOR_ID_ATI:
On 2018年07月11日 17:04, Takashi Iwai wrote:
This is no issue about this topic, in amdgpu driver, both iGPU/dGPU will register as VGA_SWITCHEROO_UNKNOWN_ID, and the client id will be re-initialized in vgaswitchreoo_enable() via ATPX call. Then, iGPU will set as VGA_SWITCHEROO_IGD, and dGPU will set as VGA_SWITCHEROO_DIS.
I think current focus should be how to detect HDMI audio device under audio suspend state.
Thanks JimQu
On Wed, 11 Jul 2018 11:26:11 +0200, jimqu wrote:
Please check the patch. It's not about AMDGPU driver but the vga switcheroo detection in HD-audio driver. Not the GPU side but the audio side.
The issues are two folds: - We register each AMD controller associated with a GPU always as a discrete GPU vga_switcheroo audio. - And when it's registered as a vga_switcheroo client, we forcibly enable runtime PM of the controller, since discrete GPU needs the runtime suspend.
So a workaround in your case is just not to register as a vga switcheroo audio client. Then the runtime PM isn't enabled in the AMD HDMI audio controller, and the HDMI detection remains active.
Takashi
On 2018年07月11日 17:53, Takashi Iwai wrote:
OK, I got your point. Let me have a try.
BTW, what about the patch in this thread, I think it is also need for current code. although audio power is not controlled by vgaswitchreoo, we also can encounter the issue(audio which is bound to iGPU will suspend with dGPU) if user debugfs to control the client power.
Thanks JimQu
On Wed, 11 Jul 2018 12:21:03 +0200, jimqu wrote:
That'd do a trick in most cases, too, but I guess one scenario is overseen: when HD-audio driver is probed / registered before the graphics driver, it may get a false client id, too.
And the forced runtime PM is still an issue, and this would need the other notification mechanism than the HD-audio unsolicited event as AMD HDMI controller doesn't honor the HD-audio WAKEEN bit.
Takashi
On Wed, 11 Jul 2018 13:12:01 +0200, Takashi Iwai wrote:
Since we had a nice "hack week" in this week at SUSE, I spent some time to write some patches for the support of the direct hotplug notification / ELD query between HD-audio and radeon/amdgpu. It re-utilizes the audio component framework for i915 but in a slightly more flexible way.
The patches are found in topic/hda-acomp branch of my sound.git tree: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
The following commits are relevant: drm/i915: Split audio component to a generic type ALSA: hda/i915: Allow delayed i915 audio component binding ALSA: hda/i915: Associate audio component with devres ALSA: hda: Make audio component support more generic ALSA: hda/hdmi: Allow audio component for AMD/ATI HDMI ALSA: hda/hdmi: Use single mutex unlock in error paths drm/radeon: Add audio component support drm/amdgpu: Add audio component support
The branch should be cleanly pullable onto the latest 4.18-rc.
I couldn't test amdgpu but the test with a radeon driver on an old laptop seemed working through a very quick test.
Please give it a try.
thanks,
Takashi
在 2018/7/13 23:07, Takashi Iwai 写道:
That is really wonderful work. I will check it on our AMD platform. BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.
Thanks JimQu
thanks,
Takashi
On Sat, 14 Jul 2018 14:03:26 +0200, jimqu wrote:
Thanks, it'll be great if you can check whether the current code works or not. I'd love to push the stuff for 4.19. Hopefully I'll start submitting the preparation patches in the next week.
Basically this also opens the door of the similar capability for nouveau, and I guess it's also trivial enough.
BTW, For display, AMD has moved to use DC to support new asics. so there also need a patch for amdgpu in DC code.
Could you give a more hint? I'll try adapt the code if such a change is already in upstream tree.
Takashi
On Sat, Jul 14, 2018 at 12:31 PM, Takashi Iwai tiwai@suse.de wrote:
The new code is in drivers/gpu/drm/amd/display.
Alex
On 2018-07-15 10:36 AM, Alex Deucher wrote:
In particular, I imagine all you need should be in display/amdgpu_dm, although there's chance you might have to touch display/dc/dce/dce_audio.c if you have to do anything with the unsolicited event.
I see you're using the GPL license, rather than MIT in amdgpu_audio.c. Since the code in display/dc is shared with other OSes and internal test frameworks it has to be MIT. Not entirely sure about display/amdgpu_dm, but if GPL is fine in amd/amdgpu it's probably fine there as well.
Harry
On Mon, 16 Jul 2018 17:10:43 +0200, Harry Wentland wrote:
Thanks, I'm currently struggling to read down the whole complex DC code tree, and it's a very helpful hint.
How is the audio enable/disable call associated with the pipe index? IOW, if I add a hook to call a notifier callback to pass the pipe index that is enabled/disabled, how can it be deduced?
Similarly, when DC driver gets the query about the ELD on the given pipe, where can I convert it to which object?
DC is quite another beast, so I still haven't figured out the structures yet...
I see you're using the GPL license, rather than MIT in amdgpu_audio.c. Since the code in display/dc is shared with other OSes and internal test frameworks it has to be MIT. Not entirely sure about display/amdgpu_dm, but if GPL is fine in amd/amdgpu it's probably fine there as well.
Oh I just didn't know that amdgpu code was with MIT. Indeed the driver module is provided via "GPL and additional rights".
I'm fine to change the license to follow other code bits there. What exactly SPDX tag should be put there?
thanks,
Takashi
On Mon, Jul 16, 2018 at 11:25 AM, Takashi Iwai tiwai@suse.de wrote:
Preferably: SPDX-License-Identifier: MIT or I suppose dual licensing (MIT or GPL 2.0) is ok too.
Alex
thanks,
Takashi
On Mon, Jul 9, 2018 at 6:16 AM, Qu, Jim Jim.Qu@amd.com wrote:
Sounds like a bug in the HDA driver. The HDA driver should cache what it needs or power it back up when there is an ioctl/etc. that requires something that can't be cached.
Alex
On Mon, 09 Jul 2018 16:02:48 +0200, Alex Deucher wrote:
Actually I'm not sure whether the analysis above is correct. If PA shows it's unavailable, it implies rather that the HDMI is seen as unconnected. PA doesn't matter about the runtime PM state. If a runtime PM fails, it'd result in a "failure", not "unavailable".
Takashi
dri-devel@lists.freedesktop.org