diff mbox series

PCI/VGA: Don't assume only VGA device found is the boot VGA device

Message ID 20241014152502.1477809-1-superm1@kernel.org (mailing list archive)
State New
Headers show
Series PCI/VGA: Don't assume only VGA device found is the boot VGA device | expand

Commit Message

Mario Limonciello Oct. 14, 2024, 3:25 p.m. UTC
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(-)

Comments

Alex Deucher Oct. 14, 2024, 3:45 p.m. UTC | #1
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
>
Mario Limonciello Oct. 14, 2024, 4:12 p.m. UTC | #2
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
>>
Luke Jones Oct. 15, 2024, 8:04 a.m. UTC | #3
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>
diff mbox series

Patch

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;
 }