drm/amdgpu: set DRIVER_ATOMIC flag early
Subsystems (3)
PATCH 1/1 drm/amdgpu: set DRIVER_ATOMIC flag early
The atomic debugfs stuff gets created in drm_dev_alloc() but this gets called before we've enumerated all of our IPs, so move the DRIVER_ATOMIC flag setting to fix that.
Since DRIVER_ATOMIC is a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.
This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12 -0
@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + +if (!amdgpu_virtual_display && +amdgpu_device_asic_has_dc_support (flags &AMD_ASIC_MASK )) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"
@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret; +/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" ); +/* support atomic early so the atomic debugfs stuff gets created */ +if (supports_atomic) + kms_driver.driver_features |=DRIVER_ATOMIC ; + dev =drm_dev_alloc (&kms_driver, &pdev->dev);if (IS_ERR (dev))return PTR_ERR (dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
@@ -1625,8 +1625,6 @@ static int dm_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->ddev->driver->driver_features |=DRIVER_ATOMIC ; -switch (adev->asic_type) {case CHIP_BONAIRE :case CHIP_HAWAII :
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180123221026.7212-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
Quoted 23 lines · Alex Deucher
The atomic debugfs stuff gets created in
drm_dev_alloc()but this gets called before we've enumerated all of our IPs, so move theDRIVER_ATOMICflag setting to fix that.Since
DRIVER_ATOMICis a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 583
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + + if (!amdgpu_virtual_display &&
Virtual display can be enabled only for specific GPUs, so this could result in supports_atomic == false when it should be true.
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 608
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0+ amdgpu_device_asic_has_dc_support(flags & AMD_ASIC_MASK)) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret; +/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" );
This won't catch cases where the first GPU probed has supports_atomic == false, then a later one has supports_atomic == true.
All in all this seems a bit messy, it might be worth looking into converting DRIVER_ATOMIC to a per-device flag instead.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 35 lines · Alex Deucher
The atomic debugfs stuff gets created in
drm_dev_alloc()but this gets called before we've enumerated all of our IPs, so move theDRIVER_ATOMICflag setting to fix that.Since
DRIVER_ATOMICis a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + +if (!amdgpu_virtual_display && +amdgpu_device_asic_has_dc_support (flags &AMD_ASIC_MASK )) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 608
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret; +/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" );
Would it make sense to make kms_driver non-static to deal with the DRIVER_ATOMIC flag correctly for multi-GPU?
Harry
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0+/* support atomic early so the atomic debugfs stuff gets created */ +if (supports_atomic) + kms_driver.driver_features |=DRIVER_ATOMIC ; + dev =drm_dev_alloc (&kms_driver, &pdev->dev);if (IS_ERR (dev))return PTR_ERR (dev);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_early_init(void *handle) · line 1630
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2@@ -1625,8 +1625,6 @@ static int dm_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; - adev->ddev->driver->driver_features |=DRIVER_ATOMIC ; -switch (adev->asic_type) {case CHIP_BONAIRE :case CHIP_HAWAII :
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 398e3188-1d5d-e14b-29e7-717e244c2bdb-5C7GfCeVMHo@public.gmane.org
Quoted 39 lines · Harry Wentland
Quoted 38 lines · Alex Deucher
The atomic debugfs stuff gets created in
drm_dev_alloc()but this gets called before we've enumerated all of our IPs, so move theDRIVER_ATOMICflag setting to fix that.Since
DRIVER_ATOMICis a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + +if (!amdgpu_virtual_display && +amdgpu_device_asic_has_dc_support (flags &AMD_ASIC_MASK )) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret;
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 608
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0+/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" );Would it make sense to make
kms_drivernon-static to deal with theDRIVER_ATOMICflag correctly for multi-GPU?
We'd need two driver structs with the only difference being the ATOMIC bit. Ideally this flag would be per device rather than per driver.
There are two issues here.
1. We need to set the ATOMIC bit early enough that the atomic debugfs stuff gets created. We already set the flag when dc initializes anyway so there is no change in behavior here other than that the debugfs stuff gets created. So it seems like a net benefit to at least set the flag early if dc is enabled.
2. Change the flag to be per device. This is a lot more involved since we need to switch all the drivers. That part is not too bad since most are either atomic or not. Where is gets tricky with amdgpu (and possibly other drivers) is that we would need to fix up the ordering of debugfs init and the drm load callbacks in drm_dev_register() because the debugfs atomic files are added before the driver load callback is called. I'm not sure how much other drivers depend on that current ordering.
Alex
Quoted 18 lines
Harry
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0+/* support atomic early so the atomic debugfs stuff gets created */ +if (supports_atomic) + kms_driver.driver_features |=DRIVER_ATOMIC ; + dev =drm_dev_alloc (&kms_driver, &pdev->dev);if (IS_ERR (dev))return PTR_ERR (dev);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -1625,8 +1625,6 @@ static int dm_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_early_init(void *handle) · line 1630
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2- adev->ddev->driver->driver_features |=DRIVER_ATOMIC ; -switch (adev->asic_type) {case CHIP_BONAIRE :case CHIP_HAWAII :
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_Ot0L4z2MuPXxdddUmzStrJH=Ss3g80CqWgw_B9WofQeA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 57 lines · Alex Deucher
Quoted 39 lines · Harry Wentland
Quoted 38 lines · Alex Deucher
The atomic debugfs stuff gets created in
drm_dev_alloc()but this gets called before we've enumerated all of our IPs, so move theDRIVER_ATOMICflag setting to fix that.Since
DRIVER_ATOMICis a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + +if (!amdgpu_virtual_display && +amdgpu_device_asic_has_dc_support (flags &AMD_ASIC_MASK )) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret;Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 608
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0+/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" );Would it make sense to make
kms_drivernon-static to deal with theDRIVER_ATOMICflag correctly for multi-GPU?We'd need two driver structs with the only difference being the ATOMIC bit. Ideally this flag would be per device rather than per driver.
There are two issues here.
1. We need to set the ATOMIC bit early enough that the atomic debugfs stuff gets created. We already set the flag when dc initializes anyway so there is no change in behavior here other than that the debugfs stuff gets created. So it seems like a net benefit to at least set the flag early if dc is enabled.
Quoted 8 lines
2. Change the flag to be per device. This is a lot more involved since we need to switch all the drivers. That part is not too bad since most are either atomic or not. Where is gets tricky with amdgpu (and possibly other drivers) is that we would need to fix up the ordering of debugfs init and the drm load callbacks in
drm_dev_register()because the debugfs atomic files are added before the driver load callback is called. I'm not sure how much other drivers depend on that current ordering.
and the driver load callback is where we determine the conditions to enable atomic or not.
Alex
Quoted 22 lines
Alex
Quoted 18 lines
Harry
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0+/* support atomic early so the atomic debugfs stuff gets created */ +if (supports_atomic) + kms_driver.driver_features |=DRIVER_ATOMIC ; + dev =drm_dev_alloc (&kms_driver, &pdev->dev);if (IS_ERR (dev))return PTR_ERR (dev);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -1625,8 +1625,6 @@ static int dm_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_early_init(void *handle) · line 1630
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2- adev->ddev->driver->driver_features |=DRIVER_ATOMIC ; -switch (adev->asic_type) {case CHIP_BONAIRE :case CHIP_HAWAII :
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_P+pq7Pu+SZJT_nUUzeneVkB+bz_wcVJNpm9x-k6T0r3g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Harry Wentland
Acked-byQuoted 67 lines · Alex Deucher
Quoted 57 lines · Alex Deucher
Quoted 39 lines · Harry Wentland
Quoted 38 lines · Alex Deucher
The atomic debugfs stuff gets created in
drm_dev_alloc()but this gets called before we've enumerated all of our IPs, so move theDRIVER_ATOMICflag setting to fix that.Since
DRIVER_ATOMICis a driver flag it's currently global to the driver so setting it affects all GPUs driven by the driver. Unfortunately, not all GPUs support atomic. Warn the user if that is the case.This is the same as our current behavior, but at least the atomic debugfs stuff gets created now.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 ++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5
-0@@ -578,6 +578,11 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,struct drm_device *dev;unsigned long flags = ent->driver_data;int ret, retry =0 ; +bool supports_atomic = false; + +if (!amdgpu_virtual_display && +amdgpu_device_asic_has_dc_support (flags &AMD_ASIC_MASK )) + supports_atomic = true;if ((flags &AMD_EXP_HW_SUPPORT ) && !amdgpu_exp_hw_support) { DRM_INFO("This hardware requires experimental hardware support.\n"@@ -598,6 +603,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,if (ret)return ret;Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 608
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-0+/* warn the user if they mix atomic and non-atomic capable GPUs */ +if ((kms_driver.driver_features &DRIVER_ATOMIC ) && !supports_atomic) +DRM_ERROR ("Mixing atomic and non-atomic capable GPUs!\n" );Would it make sense to make
kms_drivernon-static to deal with theDRIVER_ATOMICflag correctly for multi-GPU?We'd need two driver structs with the only difference being the ATOMIC bit. Ideally this flag would be per device rather than per driver.
There are two issues here.
1. We need to set the ATOMIC bit early enough that the atomic debugfs stuff gets created. We already set the flag when dc initializes anyway so there is no change in behavior here other than that the debugfs stuff gets created. So it seems like a net benefit to at least set the flag early if dc is enabled.
Quoted 8 lines
2. Change the flag to be per device. This is a lot more involved since we need to switch all the drivers. That part is not too bad since most are either atomic or not. Where is gets tricky with amdgpu (and possibly other drivers) is that we would need to fix up the ordering of debugfs init and the drm load callbacks in
drm_dev_register()because the debugfs atomic files are added before the driver load callback is called. I'm not sure how much other drivers depend on that current ordering.
Quoted 3 lines
and the driver load callback is where we determine the conditions to enable atomic or not.
Make sense. I understand the problem now.
I agree this improves the situation on many systems, even though it's messy and might be unpredictable to the end-user, because of those things Michel mentioned.
Feel free to add a somewhat reluctant
I guess without reworking drm_dev_register's debugfs init and drm load callback we'd only be able to properly fix this if all ASICs had DC support and we moved virtual_display support to DC. Not sure if that's even something we want to do. Either way it'd be a lot of work.
Harry
Quoted 24 lines
Alex
Quoted 22 lines
Alex
Quoted 18 lines
Harry
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0+/* support atomic early so the atomic debugfs stuff gets created */ +if (supports_atomic) + kms_driver.driver_features |=DRIVER_ATOMIC ; + dev =drm_dev_alloc (&kms_driver, &pdev->dev);if (IS_ERR (dev))return PTR_ERR (dev);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -1625,8 +1625,6 @@ static int dm_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_early_init(void *handle) · line 1630
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2- adev->ddev->driver->driver_features |=DRIVER_ATOMIC ; -switch (adev->asic_type) {case CHIP_BONAIRE :case CHIP_HAWAII :
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx