Skip to contentSkip to conversation

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

PATCH In review Mario Limonciello 4 participants 13 messages Oct 14, 2024 – Oct 31, 2024 PCI

lore
Share & tools
lore
#0 lore raw

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

From: Mario Limonciello <[email protected]>

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.

---
 drivers/pci/vgaarb.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
 }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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

Quoted 36 lines

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.

---
 drivers/pci/vgaarb.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -8
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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

#2 lore raw
Quoted 11 lines · Alex Deucher
Quoted 9 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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)
```
Quoted 4 lines

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)

Quoted 39 lines

Alex

Quoted 36 lines

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.

---
  drivers/pci/vgaarb.c | 7 -------
  1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -8
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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

Tested-by on v1 1/1
#3 lore raw
In reply to Mario Limonciello
Quoted 45 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
 drivers/pci/vgaarb.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
 }
 
Signature · 1 line
2.43.0

Hi Mario,

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

#4 lore raw

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
  drivers/pci/vgaarb.c | 7 -------
  1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
  }
 
Quoted 6 lines
Quoted 2 lines
Signature · 1 line
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.

drivers/pci/vgaarb.c +3 -0
index 78748e8d2dba..3fb734cb9c1b 100644
@@ -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

Quoted 2 lines
#5 lore raw
Quoted 63 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
  drivers/pci/vgaarb.c | 7 -------
  1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
  }
 
Quoted 6 lines
Quoted 2 lines

--
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.

drivers/pci/vgaarb.c +0 -0
index 78748e8d2dba..3fb734cb9c1b 100644

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 6 lines
drivers/pci/vgaarb.c +3 -0
@@ -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

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
         /*
          * 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

Quoted 2 lines
#6 lore raw
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
   drivers/pci/vgaarb.c | 7 -------
   1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
   }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       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

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
          /*
           * 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

Quoted 2 lines
#7 lore raw
Quoted 77 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
   drivers/pci/vgaarb.c | 7 -------
   1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
   }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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.

Quoted 15 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
          /*
           * 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

Quoted 2 lines
#8 lore raw
In reply to Kai-Heng Feng
Quoted 80 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
   drivers/pci/vgaarb.c | 7 -------
   1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
   }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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

Quoted 17 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
          /*
           * 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

Quoted 2 lines
#9 lore raw
Quoted 90 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 80 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
    drivers/pci/vgaarb.c | 7 -------
    1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
    }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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.

Quoted 5 lines

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

Quoted 20 lines

Alex

Quoted 17 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
           /*
            * 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

Quoted 2 lines
#10 lore raw
Quoted 100 lines · Kai-Heng Feng
Quoted 90 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 80 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
    drivers/pci/vgaarb.c | 7 -------
    1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
    }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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.

Quoted 5 lines

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?

Quoted 3 lines

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

Quoted 24 lines

Kai-Heng

Quoted 20 lines

Alex

Quoted 17 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
           /*
            * 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

Quoted 2 lines
#11 lore raw
Quoted 104 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 100 lines · Kai-Heng Feng
Quoted 95 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 80 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
     drivers/pci/vgaarb.c | 7 -------
     1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
     }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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?

Quoted 7 lines
Quoted 3 lines

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

Quoted 27 lines

Alex

Quoted 24 lines

Kai-Heng

Quoted 20 lines

Alex

Quoted 17 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
            /*
             * 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

Quoted 2 lines
#12 lore raw
Quoted 115 lines · Kai-Heng Feng
Quoted 104 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 100 lines · Kai-Heng Feng
Quoted 95 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 80 lines · Kai-Heng Feng
Quoted 70 lines · Alex Deucher

External email: Use caution opening links or attachments

Quoted 66 lines · Kai-Heng Feng

Hi Luke,

Quoted 44 lines · Luke Jones
Quoted 43 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

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.

---
     drivers/pci/vgaarb.c | 7 -------
     1 file changed, 7 deletions(-)
drivers/pci/vgaarb.c +0 -7
index 78748e8d2dba..05ac2b672d4b 100644
@@ -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;
     }
 
Quoted 6 lines
Quoted 2 lines

--
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.

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

drivers/pci/vgaarb.c static bool vga_is_boot_device(struct vga_device *vgadev) · line 680

Quoted 3 lines
drivers/pci/vgaarb.c +3 -0
+       if (vga_arb_integrated_gpu(&pdev->dev))
+               return true;
+

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

Quoted 5 lines

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?

Quoted 7 lines
Quoted 3 lines

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

Quoted 7 lines

"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.

Quoted 30 lines

Kai-Heng

Quoted 27 lines

Alex

Quoted 24 lines

Kai-Heng

Quoted 20 lines

Alex

Quoted 17 lines

Kai-Heng

Quoted 13 lines

Alex

Quoted 10 lines
drivers/pci/vgaarb.c +0 -0
            /*
             * 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

Quoted 2 lines