[+cc linux-pci (please cc in the future since the bulk of this patch is in drivers/pci/)] On Wed, Jul 12, 2023 at 12:43:05AM +0800, Sui Jingfeng wrote: > From: Sui Jingfeng <suijingfeng@xxxxxxxxxxx> > > Currently, the strategy of selecting the default boot on a multiple video > card coexistence system is not perfect. Potential problems are: > > 1) This function is a no-op on non-x86 architectures. Which function in particular is a no-op for non-x86? > 2) It does not take the PCI Bar may get relocated into consideration. > 3) It is not effective for the PCI device without a dedicated VRAM Bar. > 4) It is device-agnostic, thus it has to waste the effort to iterate all > of the PCI Bar to find the VRAM aperture. > 5) It has invented lots of methods to determine which one is the default > boot device, but this is still a policy because it doesn't give the > user a choice to override. I don't think we need a list of *potential* problems. We need an example of the specific problem this will solve, i.e., what currently does not work? The drm/ast and maybe drm/loongson patches are the only ones that use the new callback, so I assume there are real problems with those drivers. CONFIG_DRM_AST is a tristate. We're talking about identifying the boot-time console device. So if CONFIG_DRM_AST=m, I guess we don't get the benefit of the new callback unless the module gets loaded? > Also honor the comment: "Clients have *TWO* callback mechanisms they > can use" This refers to the existing vga_client_register() function comment: * vga_client_register - register or unregister a VGA arbitration client * @pdev: pci device of the VGA client * @set_decode: vga decode change callback * * Clients have two callback mechanisms they can use. * * @set_decode callback: If a client can disable its GPU VGA resource, it * will get a callback from this to set the encode/decode state. and the fact that struct vga_device currently only contains *one* callback function pointer: unsigned int (*set_decode)(struct pci_dev *pdev, bool decode); Adding the .is_primary_gpu() callback does mean there will now be two callbacks, as the comment says, but I think it's just confusing to mention this in the commit log, so I would just remove it. > @@ -1509,13 +1543,24 @@ static int pci_notify(struct notifier_block *nb, unsigned long action, > * cases of hotplugable vga cards. > */ > > - if (action == BUS_NOTIFY_ADD_DEVICE) > + switch (action) { > + case BUS_NOTIFY_ADD_DEVICE: > notify = vga_arbiter_add_pci_device(pdev); > - else if (action == BUS_NOTIFY_DEL_DEVICE) > + if (notify) > + vga_arbiter_notify_clients(); > + break; > + case BUS_NOTIFY_DEL_DEVICE: > notify = vga_arbiter_del_pci_device(pdev); > + if (notify) > + vga_arbiter_notify_clients(); > + break; > + case BUS_NOTIFY_BOUND_DRIVER: > + vga_arbiter_do_arbitration(pdev); > + break; > + default: > + break; > + } Changing from if/else to switch makes the patch bigger than necessary for no real benefit and obscures what is really changing. Bjorn