Christian König
2023-Sep-06 06:45 UTC
[Nouveau] [RFC, drm-misc-next v4 0/9] PCI/VGA: Allowing the user to select the primary video adapter at boot time
Am 05.09.23 um 15:30 schrieb suijingfeng:> Hi, > > > On 2023/9/5 18:45, Thomas Zimmermann wrote: >> Hi >> >> Am 04.09.23 um 21:57 schrieb Sui Jingfeng: >>> From: Sui Jingfeng <suijingfeng at loongson.cn> >>> >>> On a machine with multiple GPUs, a Linux user has no control over which >>> one is primary at boot time. This series tries to solve above mentioned >> >> If anything, the primary graphics adapter is the one initialized by >> the firmware. I think our boot-up graphics also make this assumption >> implicitly. >> > > Yes, but by the time of DRM drivers get loaded successfully,the > boot-up graphics already finished.This is an incorrect assumption. drm_aperture_remove_conflicting_pci_framebuffers() and co don't kill the framebuffer, they just remove the current framebuffer driver to avoid further updates. So what happens (at least for amdgpu) is that we take over the framebuffer, including both mode and it's contents, and provide a new framebuffer interface until DRM masters like X or Wayland take over.> Firmware framebuffer device already get killed by the > drm_aperture_remove_conflicting_pci_framebuffers() > function (or its siblings). So, this series is definitely not to > interact with the firmware framebuffer > (or more intelligent framebuffer drivers).? It is for user space > program, such as X server and Wayland > compositor. Its for Linux user or drm drivers testers, which allow > them to direct graphic display server > using right hardware of interested as primary video card. > > Also, I believe that X server and Wayland compositor are the best test > examples. > If a specific DRM driver can't work with X server as a primary, > then there probably have something wrong. > > >> But what's the use case for overriding this setting? >> > > On a specific machine with multiple GPUs mounted, > only the primary graphics get POST-ed (initialized) by the firmware. > Therefore, the DRM drivers for the rest video cards, have to choose to > work without the prerequisite setups done by firmware, This is called > as POST.Well, you don't seem to understand the background here. This is perfectly normal behavior. Secondary cards are posted after loading the appropriate DRM driver. At least for amdgpu this is done by calling the appropriate functions in the BIOS.> > One of the use cases of this series is to test if a specific DRM > driver could works properly, > even though there is no prerequisite works have been done by firmware > at all. > And it seems that the results is not satisfying in all cases. > > drm/ast is the first drm drivers which refused to work if not being > POST-ed by the firmware.As far as I know this is expected as well. AST is a relatively simple driver and when it's not the primary one during boot the assumption is that it isn't used at all. Regards, Christian.> > Before apply this series, I was unable make drm/ast as the primary > video card easily. On a > multiple video card configuration, the monitor connected with the > AST2400 not light up. > While confusing, a naive programmer may suspect the PRIME is not working. > > After applied this series and passing ast.modeset=10 on the kernel cmd > line, > I found that the monitor connected with my ast2400 video card still > black, > It doesn't display and doesn't show image to me. > > While in the process of study drm/ast, I know that drm/ast driver has > the POST code shipped. > See the ast_post_gpu() function,?then, I was wondering why this > function doesn't works. > After a short-time (hasty) debugging, I found that the the > ast_post_gpu() function > didn't get run. Because it have something to do with the > ast->config_mode. > > Without thinking too much, I hardcoded the ast->config_mode as > ast_use_p2a to > force the ast_post_gpu() function get run. > > ``` > > --- a/drivers/gpu/drm/ast/ast_main.c > +++ b/drivers/gpu/drm/ast/ast_main.c > @@ -132,6 +132,8 @@ static int ast_device_config_init(struct > ast_device *ast) > ??????????????? } > ??????? } > > +?????? ast->config_mode = ast_use_p2a; > + > ??????? switch (ast->config_mode) { > ??????? case ast_use_defaults: > ??????????????? drm_info(dev, "Using default configuration\n"); > > ``` > > Then, the monitor light up, it display the Ubuntu greeter to me. > Therefore, my patch is helpful, at lease for the Linux drm driver > tester and developer. > It allow programmers to test the specific part of the specific drive > without changing a line of the source code and without the need of > sudo authority. > It helps to improve efficiency of the testing and patch verification. > > I know the PrimaryGPU option of Xorg conf, but this approach will > remember the setup > have been made, you need modify it with root authority each time you > want to switch > the primary. But on rapid developing and/or testing multiple video > drivers, with > only one computer hardware resource available. What we really want > probably is a > one-shoot command as this series provide. > > So, this is the first use case. This probably also help to test full > modeset, > PRIME and reverse PRIME on multiple video card machine. > > >> Best regards >> Thomas >> >
suijingfeng
2023-Sep-06 09:08 UTC
[Nouveau] [RFC, drm-misc-next v4 0/9] PCI/VGA: Allowing the user to select the primary video adapter at boot time
Hi, On 2023/9/6 14:45, Christian K?nig wrote:> Am 05.09.23 um 15:30 schrieb suijingfeng: >> Hi, >> >> >> On 2023/9/5 18:45, Thomas Zimmermann wrote: >>> Hi >>> >>> Am 04.09.23 um 21:57 schrieb Sui Jingfeng: >>>> From: Sui Jingfeng <suijingfeng at loongson.cn> >>>> >>>> On a machine with multiple GPUs, a Linux user has no control over >>>> which >>>> one is primary at boot time. This series tries to solve above >>>> mentioned >>> >>> If anything, the primary graphics adapter is the one initialized by >>> the firmware. I think our boot-up graphics also make this assumption >>> implicitly. >>> >> >> Yes, but by the time of DRM drivers get loaded successfully,the >> boot-up graphics already finished. > > This is an incorrect assumption. > > drm_aperture_remove_conflicting_pci_framebuffers() and co don't kill > the framebuffer,Well, my original description to this technique point is that 1) "Firmware framebuffer device already get killed by the drm_aperture_remove_conflicting_pci_framebuffers() function (or its siblings)" 2) "By the time of DRM drivers get loaded successfully, the boot-up graphics already finished." The word "killed" here is rough and coarse description about how does the drm device driver take over the firmware framebuffer. Since there seems have something obscure our communication, lets make the things clear. See below for more elaborate description.> they just remove the current framebuffer driver to avoid further updates. >This statement doesn't sound right, for UEFI environment, a correct description is that they remove the platform device, not the framebuffer driver. For the machines with the UEFI firmware, framebuffer driver here definitely refer to the efifb. The efifb still reside in the system(linux kernel). Please see the aperture_detach_platform_device() function in video/aperture.c> So what happens (at least for amdgpu) is that we take over the > framebuffer,This statement here is also not an accurate description. Strictly speaking, drm/amdgpu takes over the device (the VRAM hardware), not the framebuffer. The word "take over" here is also dubious, because drm/amdgpu takes over nothing. From the perspective of device-driver model, the GPU hardware *belongs* to the amdgpu drivers. Why you need to take over a thing originally and belong to you? If you could build the drm/amdgpu into the kernel and make it get loaded before the efifb. Then, there no need to use the firmware framebuffer ( the talking is limited to the display boot graphics purpose here). On such a case, the so-called "take over" will not happen. The truth is that the efifb create a platform device, which *occupy* part of the VRAM hardware resource. Thus, the efifb and the drm/amdgpu form the conflict. There are conflict because they share the same hardware resource. It is the hardware resources(address ranges) used by two different driver are conflict. Not the efifb driver itself conflict with drm/amdgpu driver. Thus, drm_aperture_remove_conflicting_xxxxxx() function have to kill one of the device are conflicting. Not to kill the driver. Therefore, the correct word would be the "reclaim". drm/amdgpu *reclaim* the hardware resource (vram address range) originally belong to you. The modeset state (including the framebuffer content) still reside in the amdgpu device. You just get the dirty framebuffer image in the framebuffer object. But the framebuffer object already dirty since it in the UEFI firmware stage. In conclusion, *reclaim* is more accurate than the "take over". And as far as I'm understanding, the drm/amdgpu take over nothing, no gains. Well, welcome to correct me if I'm wrong.
Sui Jingfeng
2023-Sep-06 10:31 UTC
[Nouveau] [RFC, drm-misc-next v4 0/9] PCI/VGA: Allowing the user to select the primary video adapter at boot time
Hi, On 2023/9/6 14:45, Christian K?nig wrote:>> Firmware framebuffer device already get killed by the >> drm_aperture_remove_conflicting_pci_framebuffers() >> function (or its siblings). So, this series is definitely not to >> interact with the firmware framebuffer >> (or more intelligent framebuffer drivers).? It is for user space >> program, such as X server and Wayland >> compositor. Its for Linux user or drm drivers testers, which allow >> them to direct graphic display server >> using right hardware of interested as primary video card. >> >> Also, I believe that X server and Wayland compositor are the best >> test examples. >> If a specific DRM driver can't work with X server as a primary, >> then there probably have something wrong. >> >> >>> But what's the use case for overriding this setting? >>> >> >> On a specific machine with multiple GPUs mounted, >> only the primary graphics get POST-ed (initialized) by the firmware. >> Therefore, the DRM drivers for the rest video cards, have to choose to >> work without the prerequisite setups done by firmware, This is called >> as POST. > > Well, you don't seem to understand the background here. This is > perfectly normal behavior. > > Secondary cards are posted after loading the appropriate DRM driver. > At least for amdgpu this is done by calling the appropriate functions > in the BIOS.Well, thanks for you tell me this. You know more than me and definitely have a better understanding. Are you telling me that the POST function for AMDGPU reside in the BIOS? The kernel call into the BIOS? Does the BIOS here refer to the UEFI runtime or ATOM BIOS or something else? But the POST function for the drm ast, reside in the kernel space (in other word, in ast.ko). Is this statement correct? I means that for ASpeed BMC chip, if the firmware not POST the display controller. Then we have to POST it at the kernel space before doing various modeset option. We can only POST this chip by directly operate the various registers. Am I correct for the judgement about ast drm driver? Thanks for your reviews.