From: "Koenig, Christian" Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or passthrough Date: Thu, 19 Sep 2019 09:06:20 +0000 Message-ID: <5810a3fe-7929-48da-b09c-8ec4f4e2ca23@email.android.com> References: <8cad9ead-c2da-43b1-91d1-0291e02c5fd8@email.android.com> <3b31520d-c5eb-06f9-5468-0161f9adafc8@amd.com> , Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1327305803==" Return-path: In-Reply-To: Content-Language: de-DE List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: "Deng, Emily" Cc: "Zhang, Jack (Jian)" , "Cui, Flora" , "Teng, Rui" , "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org" --===============1327305803== Content-Language: de-DE Content-Type: multipart/alternative; boundary="_000_5810a3fe792948dab09c8ec4f4e2ca23emailandroidcom_" --_000_5810a3fe792948dab09c8ec4f4e2ca23emailandroidcom_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I can create a patch based on this today and push it on Monday. Christian. Am 19.09.2019 11:05 schrieb "Deng, Emily" : Hi Christian, Could you please help to push the code? Best wishes Emily Deng From: Zhang, Jack (Jian) Sent: Thursday, September 19, 2019 11:33 AM To: Deng, Emily ; Koenig, Christian Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, Rui ; Cui, Flora= Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Reviewed & Tested-by: Jack Zhang > BR, Jack From: Deng, Emily > Sent: Thursday, September 19, 2019 10:58 AM To: Koenig, Christian > Cc: Zhang, Jack (Jian) >; a= md-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, R= ui >; Cui, Flora > Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Hi Jack, Could you please give a try about this? Both for passthrough and sriov. Best wishes Emily Deng From: Koenig, Christian > Sent: Wednesday, September 18, 2019 6:47 PM To: Deng, Emily > Cc: Zhang, Jack (Jian) >; a= md-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, R= ui >; Cui, Flora > Subject: Re: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Hi Jack & Emily, asking around a bit helped, we should be able to take a look at the module = state to distinct the two use cases like this: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index 6b96a5738e57..0af134eb03e2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1074,7 +1074,10 @@ amdgpu_pci_remove(struct pci_dev *pdev) { struct drm_device *dev =3D pci_get_drvdata(pdev); - DRM_ERROR("Device removal is currently not supported outside of fbc= on\n"); +#ifdef MODULE + if (THIS_MODULE->state !=3D MODULE_STATE_GOING) +#endif + DRM_ERROR("Device removal is currently not supported outsid= e of fbcon\n"); drm_dev_unplug(dev); drm_dev_put(dev); pci_disable_device(pdev); It's a bit of a hack, but I think that this should work. Regards, Christian. Am 18.09.19 um 12:29 schrieb Christian K=F6nig: Hi Emily, Do you think this is because the wrong use case? Well Jack's use case is correct, but the PCIe hot plug removal use case is = incorrect. Changing it to a warning is most likely not a good idea either because it i= s indeed an error to try to use PCIe hot plug removal. What we need to distinct is why the function is called, if it's because of = pci_unregister_driver(&amdgpu_kms_pci_driver) in amdgpu_exit() then the use= case is valid and we should not print the error. But if it's because somebody does something like "echo 1 > /sys/bus/pci/dev= ices/0000\:0b\:00.1/remove" then that is invalid and we should print it. We could do some hack and look at the stack trace, but that is probably not= reliable either. Maybe we can look at the module reference count or something like that. Regards, Christian. Am 18.09.19 um 12:04 schrieb Deng, Emily: Hi Christian, Do you think this is because the wrong use case? Even we add the error log,= the issue still happens. Could we change this error to warning? As for the= right method to remove the driver, it shouldn=92t occur issues. Best wishes Emily Deng From: Koenig, Christian Sent: Wednesday, September 18, 2019 5:45 PM To: Deng, Emily Cc: Zhang, Jack (Jian) ; a= md-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, R= ui ; Cui, Flora Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Yes, exactly. The problem is that even when output is qxl or the Intel driver our driver = is still loaded and forcefully removing it renders the desktop unusable. Christian. Am 18.09.2019 11:24 schrieb "Deng, Emily" >: Hi Christian, Do you mean, for passthrough mode, the desktop is rendered by our asic, but= enduser is trying to remove the driver by hot plug? Best wishes Emily Deng From: Koenig, Christian > Sent: Wednesday, September 18, 2019 4:44 PM To: Deng, Emily > Cc: Zhang, Jack (Jian) >; a= md-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, R= ui >; Cui, Flora > Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Hi Emily, Yeah, exactly that's the problem: In some cases the driver can be unloaded = while it is still in use! See we added this error message because endusers tried to use PCIe hot plug= to unload the driver to use the hardware for paththrough. But this will completely nuke your desktop, even when amdgpu is only a seco= ndary device like in the qxl case. Jack is using the correct way of doing it, e.g. using "modprobe -r" or rmmo= d. Both commands check the use count before unloading the driver instances. I don't see a way to distingt the two cases and what Jack is doing is unfor= tunate not the common one. Regards, Christian. Am 18.09.2019 10:08 schrieb "Deng, Emily" >: Hi Christian, Before unloading driver, user must sure there is not any userspace to = use of amdgpu, if not, it will report driver is in use. And the unloading d= river is a feature about amdgpu driver which will be easier to replace driv= er without rebooting VM. Do you think it has any issue about driver unloadi= ng path? Best wishes Emily Deng From: Koenig, Christian > Sent: Wednesday, September 18, 2019 3:54 PM To: Zhang, Jack (Jian) > Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Te= ng, Rui >; Deng, Emily >; Cui, Flora > Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or pass= through Hi Jack, Well that believe is unfortunately completely wrong. The point is that ANY use of amdgpu by userspace will prevent correct drive= r unload, that qxl is used for the fbcon doesn't change anything here. So the patch is a clear NAK. Driver unload is not supposed to work even und= er SRIOV. Regards, Christian. Am 18.09.2019 09:32 schrieb "Zhang, Jack (Jian)" >: Hi, Christian and folks, In virtual machines(such virt-manager), there's always a virtual graphics d= evice existed like "qxl" as the default gfx device. So under such condition, we believe it's reasonable to unload amdgpu driver= as it is not treated as the default fbcon device. Would you please help to review this patch? Best wishes, Jack -----Original Message----- From: Jack Zhang > Sent: Wednesday, September 18, 2019 3:25 PM To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: Zhang, Jack (Jian) > Subject: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or passthro= ugh In virtual machine, there would be a qxl or cirrus graphics device as the d= efault master fbcon device. So for PF(passthrough mode) or SRIOV VF, it is reasonable to unload amdgpu = driver. Amdgpu doesn't have to be the only fbcon device under this conditio= n. Signed-off-by: Jack Zhang > --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c index 420888e..ada2b25 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1103,8 +1103,9 @@ static void amdgpu_pci_remove(struct pci_dev *pdev) { struct drm_device *dev =3D pci_get_drvdata(pdev); - - DRM_ERROR("Device removal is currently not supported outside of fbc= on\n"); + struct amdgpu_device *adev =3D dev->dev_private; + if (!amdgpu_sriov_vf(adev) && !amdgpu_passthrough(adev)) + DRM_ERROR(" currently not supported outside of +fbcon\n"); drm_dev_unplug(dev); drm_dev_put(dev); pci_disable_device(pdev); -- 2.7.4 --_000_5810a3fe792948dab09c8ec4f4e2ca23emailandroidcom_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
I can create a patch based on this today and push it on M= onday.

Christian.

Am 19.09.2019 11:05 schrieb "Deng, Emily&qu= ot; <Emily.Deng-5C7GfCeVMHo@public.gmane.org>:

Hi Christian,

Could you please help to push the code?

 

Best wishes<= /p>

Emily Deng

From:= Zhang, Jack (Jian) <Jack.Zhang1-urvtwAKJhsc@public.gmane.org= m>
Sent: Thursday, September 19, 2019 11:33 AM
To: Deng, Emily <Emily.Deng-5C7GfCeVMHo@public.gmane.org>; Koenig, Christian <Ch= ristian.Koenig-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Teng, Rui <Rui.Teng-5C7GfCeVMHo@public.gmane.org>= ;; Cui, Flora <Flora.Cui-5C7GfCeVMHo@public.gmane.org>
Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

 

 

Reviewed & Tested-by: Jack Zhang <Jack.Zhang1-5C7GfCeVMHo@public.gmane.org>

 

BR,

Jack

From:= Deng, Emily <Emily.Deng-5C7GfCeVMHo@public.gmane.org>
Sent: Thursday, September 19, 2019 10:58 AM
To: Koenig, Christian <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Cc: Zhang, Jack (Jian) <Ja= ck.Zhang1-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32lNgt0PjOBp9/rsn8yoX9R0@public.gmane.org= org; Teng, Rui <Rui.Teng-5C7GfCeVMHo@public.gmane.org= >; Cui, Flora <Flora.Cui@amd= .com>
Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

Hi Jack,

Could you please give a try about this? Both for passthrough and = sriov.

 

Best wishes<= /p>

Emily Deng

From:= Koenig, Christian <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Sent: Wednesday, September 18, 2019 6:47 PM
To: Deng, Emily <Emily.Deng= @amd.com>
Cc: Zhang, Jack (Jian) <Ja= ck.Zhang1-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32lNgt0PjOBp9/rsn8yoX9R0@public.gmane.org= org; Teng, Rui <Rui.Teng-5C7GfCeVMHo@public.gmane.org= >; Cui, Flora <Flora.Cui@amd= .com>
Subject: Re: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

Hi Jack & Emily,

asking around a bit helped, we should be able to take a look at the module = state to distinct the two use cases like this:

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c
index 6b96a5738e57..0af134eb03e2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1074,7 +1074,10 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 {
        struct drm_device *dev =3D pci_g= et_drvdata(pdev);
 
-       DRM_ERROR("Device removal is cur= rently not supported outside of fbcon\n");
+#ifdef MODULE
+       if (THIS_MODULE->state !=3D MO= DULE_STATE_GOING)
+#endif
+           &nbs= p;   DRM_ERROR("Device removal is currently not supported ou= tside of fbcon\n");
        drm_dev_unplug(dev);
        drm_dev_put(dev);
        pci_disable_device(pdev);

It's a bit of a hack, but I think that this should work.

Regards,
Christian.

Am 18.09.19 um 12:29 schrieb Christian K=F6nig:

Hi Emily,

Do you think this is because the wrong use case?

Well Jack's use case is correct, but the PCIe hot pl= ug removal use case is incorrect.

Changing it to a warning is most likely not a good idea either because it i= s indeed an error to try to use PCIe hot plug removal.

What we need to distinct is why the function is called, if it's because of = pci_unregister_driver(&amdgpu_kms_pci_driver) in amdgpu_exit() then the= use case is valid and we should not print the error.

But if it's because somebody does something like "echo 1 > /sys/bus= /pci/devices/0000\:0b\:00.1/remove" then that is invalid and we should= print it.

We could do some hack and look at the stack trace, but that is probably not= reliable either.

Maybe we can look at the module reference count or something like that.

Regards,
Christian.

Am 18.09.19 um 12:04 schrieb Deng, Emily:

Hi Christian,

Do you think this is be= cause the wrong use case? Even we add the error log, the issue still happen= s. Could we change this error to warning? As for the right method to remove= the driver, it shouldn=92t occur issues.

 

Best wishes

Emily Deng

From: Koenig, Christian <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Sent: Wednesday, September 18, 2019 5:45 PM
To: Deng, Emily <Emily.Deng= @amd.com>
Cc: Zhang, Jack (Jian) <Ja= ck.Zhang1-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32lNgt0PjOBp9/rsn8yoX9R0@public.gmane.org= org; Teng, Rui <Rui.Teng-5C7GfCeVMHo@public.gmane.org>; Cui, Flor= a <Flora.Cui-5C7GfCeVMHo@public.gmane.org>
Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

Yes, exactly.

 

The problem is that even when output is qxl or the I= ntel driver our driver is still loaded and forcefully removing it renders t= he desktop unusable.

 

Christian.

 

 

Am 18.09.2019 11:24 schrieb "Deng, Emily" = <Emily.Deng-5C7GfCeVMHo@public.gmane.org>:

Hi Christian,

Do you mean, for passthrough mode, the desk= top is rendered by our asic, but enduser is trying to remove the driver by = hot plug?

 

Best wishes

Emily Deng

From: Koenig, Christian <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Sent: Wednesday, September 18, 2019 4:44 PM
To: Deng, Emily <Emily.Deng= @amd.com>
Cc: Zhang, Jack (Jian) <Ja= ck.Zhang1-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32lNgt0PjOBp9/rsn8yoX9R0@public.gmane.org= org; Teng, Rui <Rui.Teng-5C7GfCeVMHo@public.gmane.org= >; Cui, Flora <Flora.Cui@amd= .com>
Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

Hi Emily,

 

Yeah, exactly that's the problem: In some cases the driver can be unload= ed while it is still in use!

 

See we added this error message because endusers tried to use PCIe hot p= lug to unload the driver to use the hardware for paththrough.

 

But this will completely nuke your desktop, even when amdgpu is only a s= econdary device like in the qxl case.

 

Jack is using the correct way of doing it, e.g. using "modprobe -r&= quot; or rmmod. Both commands check the use count before unloading the driv= er instances.

 

I don't see a way to distingt the two cases and what Jack is doing is un= fortunate not the common one.

 

Regards,

Christian.

 

 

Am 18.09.2019 10:08 schrieb "Deng, Emily" <Emily.Deng-5C7GfCeVMHo@public.gmane.org>:

Hi Christian,

     Before unloading driver, user must sure there i= s not any userspace to use of amdgpu, if not, it will report driver is in u= se. And the unloading driver is a feature about amdgpu driver which will be= easier to replace driver without rebooting VM. Do you think it has any issue about driver unloading path?

 

Best wishes

Emily Deng

From: Koenig, Christian <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>
Sent: Wednesday, September 18, 2019 3:54 PM
To: Zhang, Jack (Jian) <Ja= ck.Zhang1-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx@lists.f= reedesktop.org; Teng, Rui <Rui.T= eng-5C7GfCeVMHo@public.gmane.org>; Deng, Emily <= Emily.Deng-5C7GfCeVMHo@public.gmane.org>; Cui, Flora <Flora.Cui-5C7GfCeVMHo@public.gmane.org>
Subject: RE: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov = or passthrough

 

Hi Jack,

 

Well that believe is unfortunately completely wrong.

 

The point is that ANY use of amdgpu by userspace will prevent correct dr= iver unload, that qxl is used for the fbcon doesn't change anything here.

 

So the patch is a clear NAK. Driver unload is not supposed to work even = under SRIOV.

 

Regards,

Christian.

 

 

 

Am 18.09.2019 09:32 schrieb "Zhang, Jack (Jian)" <Jack.Zhang1-5C7GfCeVMHo@public.gmane.org>:

Hi, Christian and folks,

In virtual machines(such virt-manager), there's always a virtual graphics d= evice existed like "qxl" as the default gfx device.
So under such condition, we believe it's reasonable to unload amdgpu driver= as it is not treated as the default fbcon device.

Would you please help to review this patch?

Best wishes,
Jack

-----Original Message-----
From: Jack Zhang <Jack.Zhang1@amd= .com>
Sent: Wednesday, September 18, 2019 3:25 PM
To: amd-gfx-PD4FTy7X32lzq7FAFJ/aeQ@public.gmane.org= top.org
Cc: Zhang, Jack (Jian) <Jack.Zhan= g1-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH] drm/amdgpu/sriov: omit fbcon error under sriov or passthro= ugh

In virtual machine, there would be a qxl or cirrus graphics device as the d= efault master fbcon device.

So for PF(passthrough mode) or SRIOV VF, it is reasonable to unload amdgpu = driver. Amdgpu doesn't have to be the only fbcon device under this conditio= n.

Signed-off-by: Jack Zhang <Jack.Z= hang1-5C7GfCeVMHo@public.gmane.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_drv.c
index 420888e..ada2b25 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1103,8 +1103,9 @@ static void
 amdgpu_pci_remove(struct pci_dev *pdev)  {
         struct drm_device *dev =3D= pci_get_drvdata(pdev);
-
-       DRM_ERROR("Device removal is cur= rently not supported outside of fbcon\n");
+       struct amdgpu_device *adev =3D de= v->dev_private;
+       if (!amdgpu_sriov_vf(adev) &&= amp; !amdgpu_passthrough(adev))
+           &nbs= p;   DRM_ERROR("     currently not supported = outside of
+fbcon\n");
         drm_dev_unplug(dev);
         drm_dev_put(dev);
         pci_disable_device(pdev);<= br> --
2.7.4

 

 

 

 

--_000_5810a3fe792948dab09c8ec4f4e2ca23emailandroidcom_-- --===============1327305803== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4 --===============1327305803==--