linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
@ 2024-10-14 15:25 Mario Limonciello
  2024-10-14 15:45 ` Alex Deucher
  2024-10-15  8:04 ` Luke Jones
  0 siblings, 2 replies; 13+ messages in thread
From: Mario Limonciello @ 2024-10-14 15:25 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher, Luke D . Jones

From: Mario Limonciello <mario.limonciello@amd.com>

The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.

```
65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce RTX 4070 Max-Q / Mobile] (rev a1)
66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Strix [Radeon 880M / 890M] (rev c1)
```

The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
boot VGA device, but really the eDP is connected to the AMD PCI display
device.

Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.

Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Reported-by: Luke D. Jones <luke@ljones.dev>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/pci/vgaarb.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dba..05ac2b672d4b 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
 		return true;
 	}
 
-	/*
-	 * Vgadev has neither IO nor MEM enabled.  If we haven't found any
-	 * other VGA devices, it is the best candidate so far.
-	 */
-	if (!boot_vga)
-		return true;
-
 	return false;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-14 15:25 [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device Mario Limonciello
@ 2024-10-14 15:45 ` Alex Deucher
  2024-10-14 16:12   ` Mario Limonciello
  2024-10-15  8:04 ` Luke Jones
  1 sibling, 1 reply; 13+ messages in thread
From: Alex Deucher @ 2024-10-14 15:45 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Bjorn Helgaas, open list:PCI SUBSYSTEM, open list, dri-devel,
	Mario Limonciello, Alex Deucher, Luke D . Jones

On Mon, Oct 14, 2024 at 11:25 AM Mario Limonciello <superm1@kernel.org> wrote:
>
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>
> ```
> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce RTX 4070 Max-Q / Mobile] (rev a1)
> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Strix [Radeon 880M / 890M] (rev c1)
> ```

For clarity, the iGPU is not a VGA class device.  The "primary" should
not have any dependency on the VGA PCI class, but I'm not sure how
exactly the kernel handles this case.  In this case, the primary
should be the iGPU which is not a VGA PCI class device.

Alex

>
> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
> boot VGA device, but really the eDP is connected to the AMD PCI display
> device.
>
> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>
> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> Reported-by: Luke D. Jones <luke@ljones.dev>
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/pci/vgaarb.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> index 78748e8d2dba..05ac2b672d4b 100644
> --- a/drivers/pci/vgaarb.c
> +++ b/drivers/pci/vgaarb.c
> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>                 return true;
>         }
>
> -       /*
> -        * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> -        * other VGA devices, it is the best candidate so far.
> -        */
> -       if (!boot_vga)
> -               return true;
> -
>         return false;
>  }
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-14 15:45 ` Alex Deucher
@ 2024-10-14 16:12   ` Mario Limonciello
  0 siblings, 0 replies; 13+ messages in thread
From: Mario Limonciello @ 2024-10-14 16:12 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Bjorn Helgaas, open list:PCI SUBSYSTEM, open list, dri-devel,
	Mario Limonciello, Alex Deucher, Luke D . Jones

On 10/14/2024 10:45, Alex Deucher wrote:
> On Mon, Oct 14, 2024 at 11:25 AM Mario Limonciello <superm1@kernel.org> wrote:
>>
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>
>> ```
>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce RTX 4070 Max-Q / Mobile] (rev a1)
>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Strix [Radeon 880M / 890M] (rev c1)
>> ```
> 
> For clarity, the iGPU is not a VGA class device.  The "primary" should
> not have any dependency on the VGA PCI class, but I'm not sure how
> exactly the kernel handles this case.  In this case, the primary
> should be the iGPU which is not a VGA PCI class device.

I think if this code change to vga_is_boot_device() causes problems for 
anything older we'll probably need to add some helper that counts how 
many PCI VGA class devices are there on the system and change it to 
something like:

if (multiple_vga && !boot_vga)

> 
> Alex
> 
>>
>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>> boot VGA device, but really the eDP is connected to the AMD PCI display
>> device.
>>
>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>
>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>> Reported-by: Luke D. Jones <luke@ljones.dev>
>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   drivers/pci/vgaarb.c | 7 -------
>>   1 file changed, 7 deletions(-)
>>
>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>> index 78748e8d2dba..05ac2b672d4b 100644
>> --- a/drivers/pci/vgaarb.c
>> +++ b/drivers/pci/vgaarb.c
>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>                  return true;
>>          }
>>
>> -       /*
>> -        * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>> -        * other VGA devices, it is the best candidate so far.
>> -        */
>> -       if (!boot_vga)
>> -               return true;
>> -
>>          return false;
>>   }
>>
>> --
>> 2.43.0
>>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-14 15:25 [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device Mario Limonciello
  2024-10-14 15:45 ` Alex Deucher
@ 2024-10-15  8:04 ` Luke Jones
  2024-10-22  1:35   ` Kai-Heng Feng
  1 sibling, 1 reply; 13+ messages in thread
From: Luke Jones @ 2024-10-15  8:04 UTC (permalink / raw)
  To: Mario Limonciello, Bjorn Helgaas
  Cc: open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher

On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>
> ```
> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce 
> RTX 4070 Max-Q / Mobile] (rev a1)
> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] 
> Strix [Radeon 880M / 890M] (rev c1)
> ```
>
> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
> boot VGA device, but really the eDP is connected to the AMD PCI display
> device.
>
> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>
> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> Reported-by: Luke D. Jones <luke@ljones.dev>
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/pci/vgaarb.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> index 78748e8d2dba..05ac2b672d4b 100644
> --- a/drivers/pci/vgaarb.c
> +++ b/drivers/pci/vgaarb.c
> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>  		return true;
>  	}
> 
> -	/*
> -	 * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> -	 * other VGA devices, it is the best candidate so far.
> -	 */
> -	if (!boot_vga)
> -		return true;
> -
>  	return false;
>  }
> 
> -- 
> 2.43.0

Hi Mario,

I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.

Tested-by: Luke D. Jones <luke@ljones.dev>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-15  8:04 ` Luke Jones
@ 2024-10-22  1:35   ` Kai-Heng Feng
  2024-10-22 13:04     ` Alex Deucher
  0 siblings, 1 reply; 13+ messages in thread
From: Kai-Heng Feng @ 2024-10-22  1:35 UTC (permalink / raw)
  To: Luke Jones, Mario Limonciello, Bjorn Helgaas
  Cc: open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher

Hi Luke,

On 2024/10/15 4:04 PM, Luke Jones wrote:
> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>
>> ```
>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>> RTX 4070 Max-Q / Mobile] (rev a1)
>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>> Strix [Radeon 880M / 890M] (rev c1)
>> ```
>>
>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>> boot VGA device, but really the eDP is connected to the AMD PCI display
>> device.
>>
>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>
>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>> Reported-by: Luke D. Jones <luke@ljones.dev>
>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   drivers/pci/vgaarb.c | 7 -------
>>   1 file changed, 7 deletions(-)
>>
>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>> index 78748e8d2dba..05ac2b672d4b 100644
>> --- a/drivers/pci/vgaarb.c
>> +++ b/drivers/pci/vgaarb.c
>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>   		return true;
>>   	}
>>
>> -	/*
>> -	 * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>> -	 * other VGA devices, it is the best candidate so far.
>> -	 */
>> -	if (!boot_vga)
>> -		return true;
>> -
>>   	return false;
>>   }
>>
>> -- 
>> 2.43.0
> 
> Hi Mario,
> 
> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.

Does the following diff work for you?
This variant should be less risky for most systems.

diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dba..3fb734cb9c1b 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
                 return true;
         }

+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+
         /*
          * Vgadev has neither IO nor MEM enabled.  If we haven't found any
          * other VGA devices, it is the best candidate so far.


Kai-Heng

> 
> Tested-by: Luke D. Jones <luke@ljones.dev>


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-22  1:35   ` Kai-Heng Feng
@ 2024-10-22 13:04     ` Alex Deucher
  2024-10-23  1:27       ` Kai-Heng Feng
  0 siblings, 1 reply; 13+ messages in thread
From: Alex Deucher @ 2024-10-22 13:04 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher

On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>
> Hi Luke,
>
> On 2024/10/15 4:04 PM, Luke Jones wrote:
> > On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
> >> From: Mario Limonciello <mario.limonciello@amd.com>
> >>
> >> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
> >>
> >> ```
> >> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
> >> RTX 4070 Max-Q / Mobile] (rev a1)
> >> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
> >> Strix [Radeon 880M / 890M] (rev c1)
> >> ```
> >>
> >> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
> >> boot VGA device, but really the eDP is connected to the AMD PCI display
> >> device.
> >>
> >> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
> >>
> >> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> >> Reported-by: Luke D. Jones <luke@ljones.dev>
> >> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
> >> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> >> ---
> >>   drivers/pci/vgaarb.c | 7 -------
> >>   1 file changed, 7 deletions(-)
> >>
> >> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> >> index 78748e8d2dba..05ac2b672d4b 100644
> >> --- a/drivers/pci/vgaarb.c
> >> +++ b/drivers/pci/vgaarb.c
> >> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
> >>              return true;
> >>      }
> >>
> >> -    /*
> >> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> >> -     * other VGA devices, it is the best candidate so far.
> >> -     */
> >> -    if (!boot_vga)
> >> -            return true;
> >> -
> >>      return false;
> >>   }
> >>
> >> --
> >> 2.43.0
> >
> > Hi Mario,
> >
> > I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>
> Does the following diff work for you?
> This variant should be less risky for most systems.
>
> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> index 78748e8d2dba..3fb734cb9c1b 100644
> --- a/drivers/pci/vgaarb.c
> +++ b/drivers/pci/vgaarb.c
> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>                  return true;
>          }
>
> +       if (vga_arb_integrated_gpu(&pdev->dev))
> +               return true;
> +

The problem is that the integrated graphics does not support VGA.

Alex

>          /*
>           * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>           * other VGA devices, it is the best candidate so far.
>
>
> Kai-Heng
>
> >
> > Tested-by: Luke D. Jones <luke@ljones.dev>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-22 13:04     ` Alex Deucher
@ 2024-10-23  1:27       ` Kai-Heng Feng
  2024-10-23  8:27         ` Luke Jones
  2024-10-23 15:27         ` Alex Deucher
  0 siblings, 2 replies; 13+ messages in thread
From: Kai-Heng Feng @ 2024-10-23  1:27 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher



On 2024/10/22 9:04 PM, Alex Deucher wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>
>> Hi Luke,
>>
>> On 2024/10/15 4:04 PM, Luke Jones wrote:
>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>
>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>>>
>>>> ```
>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>>>> RTX 4070 Max-Q / Mobile] (rev a1)
>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>>>> Strix [Radeon 880M / 890M] (rev c1)
>>>> ```
>>>>
>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
>>>> device.
>>>>
>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>>>
>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>> ---
>>>>    drivers/pci/vgaarb.c | 7 -------
>>>>    1 file changed, 7 deletions(-)
>>>>
>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>> index 78748e8d2dba..05ac2b672d4b 100644
>>>> --- a/drivers/pci/vgaarb.c
>>>> +++ b/drivers/pci/vgaarb.c
>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>               return true;
>>>>       }
>>>>
>>>> -    /*
>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>> -     * other VGA devices, it is the best candidate so far.
>>>> -     */
>>>> -    if (!boot_vga)
>>>> -            return true;
>>>> -
>>>>       return false;
>>>>    }
>>>>
>>>> --
>>>> 2.43.0
>>>
>>> Hi Mario,
>>>
>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>>
>> Does the following diff work for you?
>> This variant should be less risky for most systems.
>>
>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>> index 78748e8d2dba..3fb734cb9c1b 100644
>> --- a/drivers/pci/vgaarb.c
>> +++ b/drivers/pci/vgaarb.c
>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>                   return true;
>>           }
>>
>> +       if (vga_arb_integrated_gpu(&pdev->dev))
>> +               return true;
>> +
> 
> The problem is that the integrated graphics does not support VGA.

Right, so the check has to be used much earlier.

I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't? 
If that's the case, vga_arb_integrated_gpu() can be used to differentiate which 
one is the boot GFX.

Kai-Heng

> 
> Alex
> 
>>           /*
>>            * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>            * other VGA devices, it is the best candidate so far.
>>
>>
>> Kai-Heng
>>
>>>
>>> Tested-by: Luke D. Jones <luke@ljones.dev>
>>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-23  1:27       ` Kai-Heng Feng
@ 2024-10-23  8:27         ` Luke Jones
  2024-10-23 15:27         ` Alex Deucher
  1 sibling, 0 replies; 13+ messages in thread
From: Luke Jones @ 2024-10-23  8:27 UTC (permalink / raw)
  To: Kai-Heng Feng, Alex Deucher
  Cc: Mario Limonciello, Bjorn Helgaas, open list:PCI SUBSYSTEM,
	open list, dri-devel, Mario Limonciello, Alex Deucher



On Wed, 23 Oct 2024, at 3:27 AM, Kai-Heng Feng wrote:
> On 2024/10/22 9:04 PM, Alex Deucher wrote:
>> External email: Use caution opening links or attachments
>> 
>> 
>> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>
>>> Hi Luke,
>>>
>>> On 2024/10/15 4:04 PM, Luke Jones wrote:
>>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>>
>>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>>>>
>>>>> ```
>>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>>>>> RTX 4070 Max-Q / Mobile] (rev a1)
>>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>>>>> Strix [Radeon 880M / 890M] (rev c1)
>>>>> ```
>>>>>
>>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
>>>>> device.
>>>>>
>>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>>>>
>>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
>>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>> ---
>>>>>    drivers/pci/vgaarb.c | 7 -------
>>>>>    1 file changed, 7 deletions(-)
>>>>>
>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>> index 78748e8d2dba..05ac2b672d4b 100644
>>>>> --- a/drivers/pci/vgaarb.c
>>>>> +++ b/drivers/pci/vgaarb.c
>>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>               return true;
>>>>>       }
>>>>>
>>>>> -    /*
>>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>> -     * other VGA devices, it is the best candidate so far.
>>>>> -     */
>>>>> -    if (!boot_vga)
>>>>> -            return true;
>>>>> -
>>>>>       return false;
>>>>>    }
>>>>>
>>>>> --
>>>>> 2.43.0
>>>>
>>>> Hi Mario,
>>>>
>>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>>>
>>> Does the following diff work for you?
>>> This variant should be less risky for most systems.
>>>
>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>> index 78748e8d2dba..3fb734cb9c1b 100644
>>> --- a/drivers/pci/vgaarb.c
>>> +++ b/drivers/pci/vgaarb.c
>>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>                   return true;
>>>           }
>>>
>>> +       if (vga_arb_integrated_gpu(&pdev->dev))
>>> +               return true;
>>> +
>> 
>> The problem is that the integrated graphics does not support VGA.
>
> Right, so the check has to be used much earlier.
>
> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't? 
> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which 
> one is the boot GFX.

Discrete might be missing the _DOS? I'm not sure how to interpret the gpu related DSL. You can see the dump here https://gitlab.com/asus-linux/reverse-engineering/-/tree/master/uncategorized/GA605WI?ref_type=heads

ssdt1.dsl contains _DOD and looks to be the discrete unit, does not contain _DOS. the dsdt contains both under "Device (VGA)"

Regards,
Luke.

> Kai-Heng
>
>> 
>> Alex
>> 
>>>           /*
>>>            * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>            * other VGA devices, it is the best candidate so far.
>>>
>>>
>>> Kai-Heng
>>>
>>>>
>>>> Tested-by: Luke D. Jones <luke@ljones.dev>
>>>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-23  1:27       ` Kai-Heng Feng
  2024-10-23  8:27         ` Luke Jones
@ 2024-10-23 15:27         ` Alex Deucher
  2024-10-25  7:51           ` Kai-Heng Feng
  1 sibling, 1 reply; 13+ messages in thread
From: Alex Deucher @ 2024-10-23 15:27 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher

On Tue, Oct 22, 2024 at 9:27 PM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>
>
>
> On 2024/10/22 9:04 PM, Alex Deucher wrote:
> > External email: Use caution opening links or attachments
> >
> >
> > On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
> >>
> >> Hi Luke,
> >>
> >> On 2024/10/15 4:04 PM, Luke Jones wrote:
> >>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
> >>>> From: Mario Limonciello <mario.limonciello@amd.com>
> >>>>
> >>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
> >>>>
> >>>> ```
> >>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
> >>>> RTX 4070 Max-Q / Mobile] (rev a1)
> >>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
> >>>> Strix [Radeon 880M / 890M] (rev c1)
> >>>> ```
> >>>>
> >>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
> >>>> boot VGA device, but really the eDP is connected to the AMD PCI display
> >>>> device.
> >>>>
> >>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
> >>>>
> >>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> >>>> Reported-by: Luke D. Jones <luke@ljones.dev>
> >>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
> >>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> >>>> ---
> >>>>    drivers/pci/vgaarb.c | 7 -------
> >>>>    1 file changed, 7 deletions(-)
> >>>>
> >>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> >>>> index 78748e8d2dba..05ac2b672d4b 100644
> >>>> --- a/drivers/pci/vgaarb.c
> >>>> +++ b/drivers/pci/vgaarb.c
> >>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
> >>>>               return true;
> >>>>       }
> >>>>
> >>>> -    /*
> >>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> >>>> -     * other VGA devices, it is the best candidate so far.
> >>>> -     */
> >>>> -    if (!boot_vga)
> >>>> -            return true;
> >>>> -
> >>>>       return false;
> >>>>    }
> >>>>
> >>>> --
> >>>> 2.43.0
> >>>
> >>> Hi Mario,
> >>>
> >>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
> >>
> >> Does the following diff work for you?
> >> This variant should be less risky for most systems.
> >>
> >> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> >> index 78748e8d2dba..3fb734cb9c1b 100644
> >> --- a/drivers/pci/vgaarb.c
> >> +++ b/drivers/pci/vgaarb.c
> >> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
> >>                   return true;
> >>           }
> >>
> >> +       if (vga_arb_integrated_gpu(&pdev->dev))
> >> +               return true;
> >> +
> >
> > The problem is that the integrated graphics does not support VGA.
>
> Right, so the check has to be used much earlier.
>
> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't?
> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which
> one is the boot GFX.

I think the problem is that the boot GPU is being conflated with vga
arb.  In this case the iGPU has no VGA so has no reason to be involved
in vga arb.  Trying to mess with any vga related resources on it could
be problematic.  Do higher levels of the stack look at vga arb to
determine the "primary" GPU?

Alex

>
> Kai-Heng
>
> >
> > Alex
> >
> >>           /*
> >>            * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> >>            * other VGA devices, it is the best candidate so far.
> >>
> >>
> >> Kai-Heng
> >>
> >>>
> >>> Tested-by: Luke D. Jones <luke@ljones.dev>
> >>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-23 15:27         ` Alex Deucher
@ 2024-10-25  7:51           ` Kai-Heng Feng
  2024-10-25 12:55             ` Alex Deucher
  0 siblings, 1 reply; 13+ messages in thread
From: Kai-Heng Feng @ 2024-10-25  7:51 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher



On 2024/10/23 11:27 PM, Alex Deucher wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Tue, Oct 22, 2024 at 9:27 PM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>
>>
>>
>> On 2024/10/22 9:04 PM, Alex Deucher wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>>
>>>> Hi Luke,
>>>>
>>>> On 2024/10/15 4:04 PM, Luke Jones wrote:
>>>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>>>
>>>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>>>>>
>>>>>> ```
>>>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>>>>>> RTX 4070 Max-Q / Mobile] (rev a1)
>>>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>>>>>> Strix [Radeon 880M / 890M] (rev c1)
>>>>>> ```
>>>>>>
>>>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>>>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
>>>>>> device.
>>>>>>
>>>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>>>>>
>>>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>>>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
>>>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>>> ---
>>>>>>     drivers/pci/vgaarb.c | 7 -------
>>>>>>     1 file changed, 7 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>>> index 78748e8d2dba..05ac2b672d4b 100644
>>>>>> --- a/drivers/pci/vgaarb.c
>>>>>> +++ b/drivers/pci/vgaarb.c
>>>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>>                return true;
>>>>>>        }
>>>>>>
>>>>>> -    /*
>>>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>>> -     * other VGA devices, it is the best candidate so far.
>>>>>> -     */
>>>>>> -    if (!boot_vga)
>>>>>> -            return true;
>>>>>> -
>>>>>>        return false;
>>>>>>     }
>>>>>>
>>>>>> --
>>>>>> 2.43.0
>>>>>
>>>>> Hi Mario,
>>>>>
>>>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>>>>
>>>> Does the following diff work for you?
>>>> This variant should be less risky for most systems.
>>>>
>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>> index 78748e8d2dba..3fb734cb9c1b 100644
>>>> --- a/drivers/pci/vgaarb.c
>>>> +++ b/drivers/pci/vgaarb.c
>>>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>                    return true;
>>>>            }
>>>>
>>>> +       if (vga_arb_integrated_gpu(&pdev->dev))
>>>> +               return true;
>>>> +
>>>
>>> The problem is that the integrated graphics does not support VGA.
>>
>> Right, so the check has to be used much earlier.
>>
>> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't?
>> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which
>> one is the boot GFX.
> 
> I think the problem is that the boot GPU is being conflated with vga
> arb.  In this case the iGPU has no VGA so has no reason to be involved
> in vga arb.  Trying to mess with any vga related resources on it could
> be problematic.  Do higher levels of the stack look at vga arb to
> determine the "primary" GPU?

Hmm, I wonder if all those heuristic are needed for EFI based system?

Can we assume that what being used by UEFI GOP is the primary GFX device?

Kai-Heng

> 
> Alex
> 
>>
>> Kai-Heng
>>
>>>
>>> Alex
>>>
>>>>            /*
>>>>             * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>             * other VGA devices, it is the best candidate so far.
>>>>
>>>>
>>>> Kai-Heng
>>>>
>>>>>
>>>>> Tested-by: Luke D. Jones <luke@ljones.dev>
>>>>
>>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-25  7:51           ` Kai-Heng Feng
@ 2024-10-25 12:55             ` Alex Deucher
  2024-10-31  0:58               ` Kai-Heng Feng
  0 siblings, 1 reply; 13+ messages in thread
From: Alex Deucher @ 2024-10-25 12:55 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher

On Fri, Oct 25, 2024 at 3:51 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>
>
>
> On 2024/10/23 11:27 PM, Alex Deucher wrote:
> > External email: Use caution opening links or attachments
> >
> >
> > On Tue, Oct 22, 2024 at 9:27 PM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
> >>
> >>
> >>
> >> On 2024/10/22 9:04 PM, Alex Deucher wrote:
> >>> External email: Use caution opening links or attachments
> >>>
> >>>
> >>> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
> >>>>
> >>>> Hi Luke,
> >>>>
> >>>> On 2024/10/15 4:04 PM, Luke Jones wrote:
> >>>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
> >>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
> >>>>>>
> >>>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
> >>>>>>
> >>>>>> ```
> >>>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
> >>>>>> RTX 4070 Max-Q / Mobile] (rev a1)
> >>>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
> >>>>>> Strix [Radeon 880M / 890M] (rev c1)
> >>>>>> ```
> >>>>>>
> >>>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
> >>>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
> >>>>>> device.
> >>>>>>
> >>>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
> >>>>>>
> >>>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
> >>>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
> >>>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
> >>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> >>>>>> ---
> >>>>>>     drivers/pci/vgaarb.c | 7 -------
> >>>>>>     1 file changed, 7 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> >>>>>> index 78748e8d2dba..05ac2b672d4b 100644
> >>>>>> --- a/drivers/pci/vgaarb.c
> >>>>>> +++ b/drivers/pci/vgaarb.c
> >>>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
> >>>>>>                return true;
> >>>>>>        }
> >>>>>>
> >>>>>> -    /*
> >>>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> >>>>>> -     * other VGA devices, it is the best candidate so far.
> >>>>>> -     */
> >>>>>> -    if (!boot_vga)
> >>>>>> -            return true;
> >>>>>> -
> >>>>>>        return false;
> >>>>>>     }
> >>>>>>
> >>>>>> --
> >>>>>> 2.43.0
> >>>>>
> >>>>> Hi Mario,
> >>>>>
> >>>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
> >>>>
> >>>> Does the following diff work for you?
> >>>> This variant should be less risky for most systems.
> >>>>
> >>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> >>>> index 78748e8d2dba..3fb734cb9c1b 100644
> >>>> --- a/drivers/pci/vgaarb.c
> >>>> +++ b/drivers/pci/vgaarb.c
> >>>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
> >>>>                    return true;
> >>>>            }
> >>>>
> >>>> +       if (vga_arb_integrated_gpu(&pdev->dev))
> >>>> +               return true;
> >>>> +
> >>>
> >>> The problem is that the integrated graphics does not support VGA.
> >>
> >> Right, so the check has to be used much earlier.
> >>
> >> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't?
> >> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which
> >> one is the boot GFX.
> >
> > I think the problem is that the boot GPU is being conflated with vga
> > arb.  In this case the iGPU has no VGA so has no reason to be involved
> > in vga arb.  Trying to mess with any vga related resources on it could
> > be problematic.  Do higher levels of the stack look at vga arb to
> > determine the "primary" GPU?
>
> Hmm, I wonder if all those heuristic are needed for EFI based system?
>
> Can we assume that what being used by UEFI GOP is the primary GFX device?

Yes, I believe so.  The SBIOS should use the GOP device as determined
by the user preference.  I.e.., in the bios configuration you can
generally select iGPU or PEG for the primary display.

Alex

>
> Kai-Heng
>
> >
> > Alex
> >
> >>
> >> Kai-Heng
> >>
> >>>
> >>> Alex
> >>>
> >>>>            /*
> >>>>             * Vgadev has neither IO nor MEM enabled.  If we haven't found any
> >>>>             * other VGA devices, it is the best candidate so far.
> >>>>
> >>>>
> >>>> Kai-Heng
> >>>>
> >>>>>
> >>>>> Tested-by: Luke D. Jones <luke@ljones.dev>
> >>>>
> >>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-25 12:55             ` Alex Deucher
@ 2024-10-31  0:58               ` Kai-Heng Feng
  2024-10-31 10:51                 ` Luke Jones
  0 siblings, 1 reply; 13+ messages in thread
From: Kai-Heng Feng @ 2024-10-31  0:58 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Luke Jones, Mario Limonciello, Bjorn Helgaas,
	open list:PCI SUBSYSTEM, open list, dri-devel, Mario Limonciello,
	Alex Deucher



On 2024/10/25 8:55 PM, Alex Deucher wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Fri, Oct 25, 2024 at 3:51 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>
>>
>>
>> On 2024/10/23 11:27 PM, Alex Deucher wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> On Tue, Oct 22, 2024 at 9:27 PM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>>
>>>>
>>>>
>>>> On 2024/10/22 9:04 PM, Alex Deucher wrote:
>>>>> External email: Use caution opening links or attachments
>>>>>
>>>>>
>>>>> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>>>>
>>>>>> Hi Luke,
>>>>>>
>>>>>> On 2024/10/15 4:04 PM, Luke Jones wrote:
>>>>>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>>>>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>>>>>
>>>>>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>>>>>>>
>>>>>>>> ```
>>>>>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>>>>>>>> RTX 4070 Max-Q / Mobile] (rev a1)
>>>>>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>>>>>>>> Strix [Radeon 880M / 890M] (rev c1)
>>>>>>>> ```
>>>>>>>>
>>>>>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>>>>>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
>>>>>>>> device.
>>>>>>>>
>>>>>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>>>>>>>
>>>>>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>>>>>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
>>>>>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>>>>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>>>>> ---
>>>>>>>>      drivers/pci/vgaarb.c | 7 -------
>>>>>>>>      1 file changed, 7 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>>>>> index 78748e8d2dba..05ac2b672d4b 100644
>>>>>>>> --- a/drivers/pci/vgaarb.c
>>>>>>>> +++ b/drivers/pci/vgaarb.c
>>>>>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>>>>                 return true;
>>>>>>>>         }
>>>>>>>>
>>>>>>>> -    /*
>>>>>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>>>>> -     * other VGA devices, it is the best candidate so far.
>>>>>>>> -     */
>>>>>>>> -    if (!boot_vga)
>>>>>>>> -            return true;
>>>>>>>> -
>>>>>>>>         return false;
>>>>>>>>      }
>>>>>>>>
>>>>>>>> --
>>>>>>>> 2.43.0
>>>>>>>
>>>>>>> Hi Mario,
>>>>>>>
>>>>>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>>>>>>
>>>>>> Does the following diff work for you?
>>>>>> This variant should be less risky for most systems.
>>>>>>
>>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>>> index 78748e8d2dba..3fb734cb9c1b 100644
>>>>>> --- a/drivers/pci/vgaarb.c
>>>>>> +++ b/drivers/pci/vgaarb.c
>>>>>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>>                     return true;
>>>>>>             }
>>>>>>
>>>>>> +       if (vga_arb_integrated_gpu(&pdev->dev))
>>>>>> +               return true;
>>>>>> +
>>>>>
>>>>> The problem is that the integrated graphics does not support VGA.
>>>>
>>>> Right, so the check has to be used much earlier.
>>>>
>>>> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't?
>>>> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which
>>>> one is the boot GFX.
>>>
>>> I think the problem is that the boot GPU is being conflated with vga
>>> arb.  In this case the iGPU has no VGA so has no reason to be involved
>>> in vga arb.  Trying to mess with any vga related resources on it could
>>> be problematic.  Do higher levels of the stack look at vga arb to
>>> determine the "primary" GPU?
>>
>> Hmm, I wonder if all those heuristic are needed for EFI based system?
>>
>> Can we assume that what being used by UEFI GOP is the primary GFX device?
> 
> Yes, I believe so.  The SBIOS should use the GOP device as determined
> by the user preference.  I.e.., in the bios configuration you can
> generally select iGPU or PEG for the primary display.

UEFI spec, 10.3.3.1 ACPI _ADR Device Path

"The _ADR device path is used to contain video output device attributes to 
support the Graphics Output Protocol. The device path can contain multiple _ADR 
entries if multiple video output devices are displaying the same output."

Luke, can you please see what are the _ADR values of the iGPU and dGPU? Maybe we 
can find which one was used by GOP this way.

Kai-Heng

> 
> Alex
> 
>>
>> Kai-Heng
>>
>>>
>>> Alex
>>>
>>>>
>>>> Kai-Heng
>>>>
>>>>>
>>>>> Alex
>>>>>
>>>>>>             /*
>>>>>>              * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>>>              * other VGA devices, it is the best candidate so far.
>>>>>>
>>>>>>
>>>>>> Kai-Heng
>>>>>>
>>>>>>>
>>>>>>> Tested-by: Luke D. Jones <luke@ljones.dev>
>>>>>>
>>>>
>>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device
  2024-10-31  0:58               ` Kai-Heng Feng
@ 2024-10-31 10:51                 ` Luke Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Luke Jones @ 2024-10-31 10:51 UTC (permalink / raw)
  To: Kai-Heng Feng, Alex Deucher
  Cc: Mario Limonciello, Bjorn Helgaas, open list:PCI SUBSYSTEM,
	open list, dri-devel, Mario Limonciello, Alex Deucher

On Thu, 31 Oct 2024, at 1:58 AM, Kai-Heng Feng wrote:
> On 2024/10/25 8:55 PM, Alex Deucher wrote:
>> External email: Use caution opening links or attachments
>> 
>> 
>> On Fri, Oct 25, 2024 at 3:51 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>
>>>
>>>
>>> On 2024/10/23 11:27 PM, Alex Deucher wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> On Tue, Oct 22, 2024 at 9:27 PM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>>>
>>>>>
>>>>>
>>>>> On 2024/10/22 9:04 PM, Alex Deucher wrote:
>>>>>> External email: Use caution opening links or attachments
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 22, 2024 at 2:31 AM Kai-Heng Feng <kaihengf@nvidia.com> wrote:
>>>>>>>
>>>>>>> Hi Luke,
>>>>>>>
>>>>>>> On 2024/10/15 4:04 PM, Luke Jones wrote:
>>>>>>>> On Mon, 14 Oct 2024, at 5:25 PM, Mario Limonciello wrote:
>>>>>>>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>>>>>>>
>>>>>>>>> The ASUS GA605W has a NVIDIA PCI VGA device and an AMD PCI display device.
>>>>>>>>>
>>>>>>>>> ```
>>>>>>>>> 65:00.0 VGA compatible controller: NVIDIA Corporation AD106M [GeForce
>>>>>>>>> RTX 4070 Max-Q / Mobile] (rev a1)
>>>>>>>>> 66:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
>>>>>>>>> Strix [Radeon 880M / 890M] (rev c1)
>>>>>>>>> ```
>>>>>>>>>
>>>>>>>>> The fallback logic in vga_is_boot_device() flags the NVIDIA dGPU as the
>>>>>>>>> boot VGA device, but really the eDP is connected to the AMD PCI display
>>>>>>>>> device.
>>>>>>>>>
>>>>>>>>> Drop this case to avoid marking the NVIDIA dGPU as the boot VGA device.
>>>>>>>>>
>>>>>>>>> Suggested-by: Alex Deucher <alexander.deucher@amd.com>
>>>>>>>>> Reported-by: Luke D. Jones <luke@ljones.dev>
>>>>>>>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3673
>>>>>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>>>>>> ---
>>>>>>>>>      drivers/pci/vgaarb.c | 7 -------
>>>>>>>>>      1 file changed, 7 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>>>>>> index 78748e8d2dba..05ac2b672d4b 100644
>>>>>>>>> --- a/drivers/pci/vgaarb.c
>>>>>>>>> +++ b/drivers/pci/vgaarb.c
>>>>>>>>> @@ -675,13 +675,6 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>>>>>                 return true;
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>> -    /*
>>>>>>>>> -     * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>>>>>> -     * other VGA devices, it is the best candidate so far.
>>>>>>>>> -     */
>>>>>>>>> -    if (!boot_vga)
>>>>>>>>> -            return true;
>>>>>>>>> -
>>>>>>>>>         return false;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> 2.43.0
>>>>>>>>
>>>>>>>> Hi Mario,
>>>>>>>>
>>>>>>>> I can verify that this does leave the `boot_vga` attribute set as 0 for the NVIDIA device.
>>>>>>>
>>>>>>> Does the following diff work for you?
>>>>>>> This variant should be less risky for most systems.
>>>>>>>
>>>>>>> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
>>>>>>> index 78748e8d2dba..3fb734cb9c1b 100644
>>>>>>> --- a/drivers/pci/vgaarb.c
>>>>>>> +++ b/drivers/pci/vgaarb.c
>>>>>>> @@ -675,6 +675,9 @@ static bool vga_is_boot_device(struct vga_device *vgadev)
>>>>>>>                     return true;
>>>>>>>             }
>>>>>>>
>>>>>>> +       if (vga_arb_integrated_gpu(&pdev->dev))
>>>>>>> +               return true;
>>>>>>> +
>>>>>>
>>>>>> The problem is that the integrated graphics does not support VGA.
>>>>>
>>>>> Right, so the check has to be used much earlier.
>>>>>
>>>>> I wonder does the integrated GFX have _DOD/_DOS while the discrete one doesn't?
>>>>> If that's the case, vga_arb_integrated_gpu() can be used to differentiate which
>>>>> one is the boot GFX.
>>>>
>>>> I think the problem is that the boot GPU is being conflated with vga
>>>> arb.  In this case the iGPU has no VGA so has no reason to be involved
>>>> in vga arb.  Trying to mess with any vga related resources on it could
>>>> be problematic.  Do higher levels of the stack look at vga arb to
>>>> determine the "primary" GPU?
>>>
>>> Hmm, I wonder if all those heuristic are needed for EFI based system?
>>>
>>> Can we assume that what being used by UEFI GOP is the primary GFX device?
>> 
>> Yes, I believe so.  The SBIOS should use the GOP device as determined
>> by the user preference.  I.e.., in the bios configuration you can
>> generally select iGPU or PEG for the primary display.
>
> UEFI spec, 10.3.3.1 ACPI _ADR Device Path
>
> "The _ADR device path is used to contain video output device attributes to 
> support the Graphics Output Protocol. The device path can contain multiple _ADR 
> entries if multiple video output devices are displaying the same output."
>
> Luke, can you please see what are the _ADR values of the iGPU and dGPU? 
> Maybe we 
> can find which one was used by GOP this way.

I'm not sure what I'm looking at here, but initial search shows:

                Device (VGA)
                {
                    Name (_ADR, Zero)  // _ADR: Address
                    Name (DOSA, Zero)
                    Method (_DOS, 1, NotSerialized)  // _DOS: Disable Output Switching
                    {
                        DOSA = Arg0
                    }

                    Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
                    {
                        M460 ("PLA-ASL-\\_SB.PCI0.GPPA.VGA._DOD\n", Zero, Zero, Zero, Zero, Zero, Zero)
                        Return (Package (0x07)
                        {
                            0x00010110, 
                            0x00010210, 
                            0x00010220, 
                            0x00010230, 
                            0x00010240, 
                            0x00031000, 
                            0x00032000
                        })
                    }

                    Device (LCD)
                    {
                        Name (_ADR, 0x0110)  // _ADR: Address
                        Name (BCLB, Package (0x34)
                        {

https://gitlab.com/asus-linux/reverse-engineering/-/blob/master/uncategorized/GA605WI/dsdt.dsl?ref_type=heads#L4666

And:

            Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
            {
                Return (Package (0x01)
                {
                    0x8000A450
                })
            }

            Device (LCD0)
            {
                Method (_ADR, 0, Serialized)  // _ADR: Address
                {
                    Return (0x8000A450)
                }

https://gitlab.com/asus-linux/reverse-engineering/-/blob/master/uncategorized/GA605WI/ssdt1.dsl?ref_type=heads#L411

The links are direct to the lines I thought were relevant in the dumped DSDT.

Luke.

>
> Kai-Heng
>
>> 
>> Alex
>> 
>>>
>>> Kai-Heng
>>>
>>>>
>>>> Alex
>>>>
>>>>>
>>>>> Kai-Heng
>>>>>
>>>>>>
>>>>>> Alex
>>>>>>
>>>>>>>             /*
>>>>>>>              * Vgadev has neither IO nor MEM enabled.  If we haven't found any
>>>>>>>              * other VGA devices, it is the best candidate so far.
>>>>>>>
>>>>>>>
>>>>>>> Kai-Heng
>>>>>>>
>>>>>>>>
>>>>>>>> Tested-by: Luke D. Jones <luke@ljones.dev>
>>>>>>>
>>>>>
>>>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-10-31 10:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 15:25 [PATCH] PCI/VGA: Don't assume only VGA device found is the boot VGA device Mario Limonciello
2024-10-14 15:45 ` Alex Deucher
2024-10-14 16:12   ` Mario Limonciello
2024-10-15  8:04 ` Luke Jones
2024-10-22  1:35   ` Kai-Heng Feng
2024-10-22 13:04     ` Alex Deucher
2024-10-23  1:27       ` Kai-Heng Feng
2024-10-23  8:27         ` Luke Jones
2024-10-23 15:27         ` Alex Deucher
2024-10-25  7:51           ` Kai-Heng Feng
2024-10-25 12:55             ` Alex Deucher
2024-10-31  0:58               ` Kai-Heng Feng
2024-10-31 10:51                 ` Luke Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).