[PATCH weston 1/2] pci: add PCI helpers to detect primary GPUs

Sannu K sannumail4foss at gmail.com
Sun Oct 28 02:14:39 PDT 2012


On Sun, Oct 28, 2012 at 1:58 AM, David Herrmann
<dh.herrmann at googlemail.com> wrote:
> Hi Sannu
>
> On Sat, Oct 27, 2012 at 8:38 PM, Sannu K <sannumail4foss at gmail.com> wrote:
>> On Sat, Oct 27, 2012 at 6:24 PM, David Herrmann
>> <dh.herrmann at googlemail.com> wrote:
>>> This adds one global helper which returns a string describing the primary
>>> PCI GPU. This string can later be used to compare with drmGetBusid() to
>>> check whether a given DRM GPU is the primary GPU.
>>
>> What do you mean by the term "Primary GPU"? Is it the GPU that is
>> currently used for acceleration (consider the case where there is
>> Intel and nVidia GPU and currently nVidia GPU is used for doing the 3D
>> stuff - should I call nVidia GPU primary)?
>
> With "primary" I mean the GPU that is used during boot. That is, this
> GPU is guaranteed to have a display-controller and can drive the main
> connectors. If you have multiple GPUs, it is not guaranteed that
> non-primary GPUs can drive connectors. Therefore, using the primary
> GPU guarantees that weston is able to display something.

This makes a lot of sense.

> Of course, it is sometimes also possible that non-primary GPUs can be
> used to drive the connectors. However, this isn't guaranteed so this
> patch tries to find the primary-GPU via some PCI heuristics.

Is there any way to determine which device drives the connectors? May
be hardware dependent way? Kernel or weston or somebody else will make
a note of that while the device is initialized and will use that
later. No idea whether this is possible really but just a thought.

>
>>> +               ++num;
>>> +               if (!pci_device_is_boot_vga(dev))
>>> +                       continue;
>>> +
>>
>> Is it reasonable to generalize boot GPU as Primary GPU? In a system
>> with 2 GPUs (say nvidia and intel), Intel GPU is used at boot time and
>> once there is a need for more power nvidia GPU is used and Intel's is
>> switched off. Will this case happen in practice and valid (if GPU
>> switching support is made available)? In this case which GPU is
>> considered primary GPU? If Intel (as it was boot VGA) - why this when
>> nvidia is currently getting used for 3D stuff?
>
> GPU switching under linux has no stable API. The vga_switcheroo module
> only provides some temporary hacks via debugfs. Therefore, the
> situations you describe are not what this patch tries to address. It
> rather tries to fix the problem where weston uses a
> secondary/auxiliary GPU and then might not be able to drive the
> connectors.
>
> The purpose of this patch is to find the primary GPU. It does not try
> to find the "fastest", "greatest" or whatever GPU. This would need
> proper GPU switching support which the kernel teams are currently
> working on.
> So this patch is only a workaround for systems with two GPUs where
> only one can perform modesetting.
>
> Btw., the xserver uses the same heuristics for all open-source PCI drivers.
>
>> Why VGA is only considered (I am not sure if VGA is used to denote all
>> displays)? There are lot of systems without VGA adapter only with HDMI
>> adapter.
>
> Heh, the VGA test is a fallback when no boot-GPU is found. Also,
> please note that VGA is a graphics standard that does not imply "VGA
> connectors". Almost all graphics cards today have still a VGA mode
> which provides basic modesetting if no proper driver is available. So
> VGA has nothing to do with "VGA adapters" here.

Understood.

>
> Cheers
> David

Thanks a lot for taking the pain of explaining things :).

Thanks,
Sannu K


More information about the wayland-devel mailing list