[PATCH 2/2] drm/amdgpu: add module parameter choose runtime method

2020-11-20 Thread Likun Gao
From: Likun Gao 

Default runtime logic not changed.
Provide an alternative runtime method. (set 1 to use BACO; 2 to use BAMACO)
When set reset_method to 4, it will use BACO or BAMACO for gpu reset,
according to runtime value.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  4 +-
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 38 +++
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 7f98cf1bef07..b2a1dd7581bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -304,7 +304,7 @@ module_param_named(aspm, amdgpu_aspm, int, 0444);
  * Override for runtime power management control for dGPUs in PX/HG laptops. 
The amdgpu driver can dynamically power down
  * the dGPU on PX/HG laptops when it is idle. The default is -1 (auto enable). 
Setting the value to 0 disables this functionality.
  */
-MODULE_PARM_DESC(runpm, "PX runtime pm (1 = force enable, 0 = disable, -1 = PX 
only default)");
+MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = 
force enable with BACO, 0 = disable, -1 = PX only default)");
 module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
 
 /**
@@ -790,7 +790,7 @@ module_param_named(tmz, amdgpu_tmz, int, 0444);
  * DOC: reset_method (int)
  * GPU reset method (-1 = auto (default), 0 = legacy, 1 = mode0, 2 = mode1, 3 
= mode2, 4 = baco)
  */
-MODULE_PARM_DESC(reset_method, "GPU reset method (-1 = auto (default), 0 = 
legacy, 1 = mode0, 2 = mode1, 3 = mode2, 4 = baco)");
+MODULE_PARM_DESC(reset_method, "GPU reset method (-1 = auto (default), 0 = 
legacy, 1 = mode0, 2 = mode1, 3 = mode2, 4 = baco/bamaco)");
 module_param_named(reset_method, amdgpu_reset_method, int, 0444);
 
 /**
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 7144ea4c0b78..62c34a01a3e1 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1485,6 +1485,9 @@ enum smu_baco_state smu_v11_0_baco_get_state(struct 
smu_context *smu)
return baco_state;
 }
 
+#define D3HOT_BACO_SEQUENCE 0
+#define D3HOT_BAMACO_SEQUENCE 2
+
 int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state 
state)
 {
struct smu_baco_context *smu_baco = &smu->smu_baco;
@@ -1499,15 +1502,34 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, 
enum smu_baco_state state)
mutex_lock(&smu_baco->mutex);
 
if (state == SMU_BACO_STATE_ENTER) {
-   if (!ras || !ras->supported) {
-   data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
-   data |= 0x8000;
-   WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
-
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 0, NULL);
-   } else {
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 1, NULL);
+   switch (adev->asic_type) {
+   case CHIP_SIENNA_CICHLID:
+   case CHIP_NAVY_FLOUNDER:
+   case CHIP_DIMGREY_CAVEFISH:
+   if (amdgpu_runtime_pm == 2)
+   ret = smu_cmn_send_smc_msg_with_param(smu,
+ 
SMU_MSG_EnterBaco,
+ 
D3HOT_BAMACO_SEQUENCE,
+ NULL);
+   else
+   ret = smu_cmn_send_smc_msg_with_param(smu,
+ 
SMU_MSG_EnterBaco,
+ 
D3HOT_BACO_SEQUENCE,
+ NULL);
+   break;
+   default:
+   if (!ras || !ras->supported) {
+   data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
+   data |= 0x8000;
+   WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
+
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 0, NULL);
+   } else {
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 1, NULL);
+   }
+   break;
}
+
} else {
ret = smu_cmn_send_smc_msg(smu, SMU_MSG_ExitBaco, NULL);
if (ret)
-- 
2.25.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH 2/2] drm/amdgpu: add module parameter choose runtime method

2020-11-20 Thread Feng, Kenneth
[AMD Official Use Only - Internal Distribution Only]

Series is Reviewed-by: Kenneth Feng 


Best Regards
Kenneth

-Original Message-
From: Gao, Likun  
Sent: Friday, November 20, 2020 3:59 PM
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking ; Feng, Kenneth 
; Gao, Likun 
Subject: [PATCH 2/2] drm/amdgpu: add module parameter choose runtime method

From: Likun Gao 

Default runtime logic not changed.
Provide an alternative runtime method. (set 1 to use BACO; 2 to use BAMACO) 
When set reset_method to 4, it will use BACO or BAMACO for gpu reset, according 
to runtime value.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  4 +-
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c| 38 +++
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 7f98cf1bef07..b2a1dd7581bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -304,7 +304,7 @@ module_param_named(aspm, amdgpu_aspm, int, 0444);
  * Override for runtime power management control for dGPUs in PX/HG laptops. 
The amdgpu driver can dynamically power down
  * the dGPU on PX/HG laptops when it is idle. The default is -1 (auto enable). 
Setting the value to 0 disables this functionality.
  */
-MODULE_PARM_DESC(runpm, "PX runtime pm (1 = force enable, 0 = disable, -1 = PX 
only default)");
+MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 
+= force enable with BACO, 0 = disable, -1 = PX only default)");
 module_param_named(runpm, amdgpu_runtime_pm, int, 0444);
 
 /**
@@ -790,7 +790,7 @@ module_param_named(tmz, amdgpu_tmz, int, 0444);
  * DOC: reset_method (int)
  * GPU reset method (-1 = auto (default), 0 = legacy, 1 = mode0, 2 = mode1, 3 
= mode2, 4 = baco)
  */
-MODULE_PARM_DESC(reset_method, "GPU reset method (-1 = auto (default), 0 = 
legacy, 1 = mode0, 2 = mode1, 3 = mode2, 4 = baco)");
+MODULE_PARM_DESC(reset_method, "GPU reset method (-1 = auto (default), 
+0 = legacy, 1 = mode0, 2 = mode1, 3 = mode2, 4 = baco/bamaco)");
 module_param_named(reset_method, amdgpu_reset_method, int, 0444);
 
 /**
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
index 7144ea4c0b78..62c34a01a3e1 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
@@ -1485,6 +1485,9 @@ enum smu_baco_state smu_v11_0_baco_get_state(struct 
smu_context *smu)
return baco_state;
 }
 
+#define D3HOT_BACO_SEQUENCE 0
+#define D3HOT_BAMACO_SEQUENCE 2
+
 int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state 
state)  {
struct smu_baco_context *smu_baco = &smu->smu_baco; @@ -1499,15 
+1502,34 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum 
smu_baco_state state)
mutex_lock(&smu_baco->mutex);
 
if (state == SMU_BACO_STATE_ENTER) {
-   if (!ras || !ras->supported) {
-   data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
-   data |= 0x8000;
-   WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
-
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 0, NULL);
-   } else {
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 1, NULL);
+   switch (adev->asic_type) {
+   case CHIP_SIENNA_CICHLID:
+   case CHIP_NAVY_FLOUNDER:
+   case CHIP_DIMGREY_CAVEFISH:
+   if (amdgpu_runtime_pm == 2)
+   ret = smu_cmn_send_smc_msg_with_param(smu,
+ 
SMU_MSG_EnterBaco,
+ 
D3HOT_BAMACO_SEQUENCE,
+ NULL);
+   else
+   ret = smu_cmn_send_smc_msg_with_param(smu,
+ 
SMU_MSG_EnterBaco,
+ 
D3HOT_BACO_SEQUENCE,
+ NULL);
+   break;
+   default:
+   if (!ras || !ras->supported) {
+   data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL);
+   data |= 0x8000;
+   WREG32_SOC15(THM, 0, mmTHM_BACO_CNTL, data);
+
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 0, NULL);
+   } else {
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_EnterBaco, 1, NULL);
+   }
+   break;
  

[PATCH] drm/amd/display: Avoid HDCP initialization in devices without output

2020-11-20 Thread Rodrigo Siqueira
The HDCP feature requires at least one connector attached to the device;
however, some GPUs do not have a physical output, making the HDCP
initialization irrelevant. This patch disables HDCP initialization when
the graphic card does not have output.

Signed-off-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 1da4ad529309..e213246e3f04 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1109,7 +1109,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
amdgpu_dm_init_color_mod();
 
 #ifdef CONFIG_DRM_AMD_DC_HDCP
-   if (adev->asic_type >= CHIP_RAVEN) {
+   if (adev->dm.dc->caps.max_links > 0 && adev->asic_type >= CHIP_RAVEN) {
adev->dm.hdcp_workqueue = hdcp_create_workqueue(adev, 
&init_params.cp_psp, adev->dm.dc);
 
if (!adev->dm.hdcp_workqueue)
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amd/display: Avoid HDCP initialization in devices without output

2020-11-20 Thread Deucher, Alexander
[AMD Official Use Only - Internal Distribution Only]

Acked-by: Alex Deucher 

From: Siqueira, Rodrigo 
Sent: Friday, November 20, 2020 8:59 AM
To: amd-gfx@lists.freedesktop.org 
Cc: Wentland, Harry ; Deucher, Alexander 

Subject: [PATCH] drm/amd/display: Avoid HDCP initialization in devices without 
output

The HDCP feature requires at least one connector attached to the device;
however, some GPUs do not have a physical output, making the HDCP
initialization irrelevant. This patch disables HDCP initialization when
the graphic card does not have output.

Signed-off-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 1da4ad529309..e213246e3f04 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1109,7 +1109,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 amdgpu_dm_init_color_mod();

 #ifdef CONFIG_DRM_AMD_DC_HDCP
-   if (adev->asic_type >= CHIP_RAVEN) {
+   if (adev->dm.dc->caps.max_links > 0 && adev->asic_type >= CHIP_RAVEN) {
 adev->dm.hdcp_workqueue = hdcp_create_workqueue(adev, 
&init_params.cp_psp, adev->dm.dc);

 if (!adev->dm.hdcp_workqueue)
--
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH] drm/amdgpu: only register VGA devices with the VGA arbiter

2020-11-20 Thread Alex Deucher
We only need to arbitrate VGA access on VGA compatible devices.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f60b7084f4d..2670fb113ba1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3346,7 +3346,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
/* this will fail for cards that aren't VGA class devices, just
 * ignore it */
-   vga_client_register(adev->pdev, adev, NULL, 
amdgpu_device_vga_set_decode);
+   if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+   vga_client_register(adev->pdev, adev, NULL, 
amdgpu_device_vga_set_decode);
 
if (amdgpu_device_supports_boco(ddev))
boco = true;
@@ -3605,7 +3606,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
vga_switcheroo_unregister_client(adev->pdev);
if (amdgpu_device_supports_boco(adev_to_drm(adev)))
vga_switcheroo_fini_domain_pm_ops(adev->dev);
-   vga_client_register(adev->pdev, NULL, NULL, NULL);
+   if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+   vga_client_register(adev->pdev, NULL, NULL, NULL);
if (adev->rio_mem)
pci_iounmap(adev->pdev, adev->rio_mem);
adev->rio_mem = NULL;
-- 
2.25.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH] drm/amdgpu: only register VGA devices with the VGA arbiter

2020-11-20 Thread Xu, Feifei
[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Feifei Xu 

-Original Message-
From: amd-gfx  On Behalf Of Alex Deucher
Sent: Friday, November 20, 2020 10:55 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: [PATCH] drm/amdgpu: only register VGA devices with the VGA arbiter

We only need to arbitrate VGA access on VGA compatible devices.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f60b7084f4d..2670fb113ba1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3346,7 +3346,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
 /* this will fail for cards that aren't VGA class devices, just
  * ignore it */
-vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode);
+if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode);

 if (amdgpu_device_supports_boco(ddev))
 boco = true;
@@ -3605,7 +3606,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 vga_switcheroo_unregister_client(adev->pdev);
 if (amdgpu_device_supports_boco(adev_to_drm(adev)))
 vga_switcheroo_fini_domain_pm_ops(adev->dev);
-vga_client_register(adev->pdev, NULL, NULL, NULL);
+if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+vga_client_register(adev->pdev, NULL, NULL, NULL);
 if (adev->rio_mem)
 pci_iounmap(adev->pdev, adev->rio_mem);
 adev->rio_mem = NULL;
--
2.25.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7CFeifei.Xu%40amd.com%7C8eac65802c2841a4016408d88d645737%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637414809390017528%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4YGYTXm%2FY8MAQiqs4QJ1MUIcy2%2F4waucDrIeob63ogk%3D&reserved=0
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 1/1] drm/amdgpu: use generic DMA API

2020-11-20 Thread Nirmoy Das
Use generic DMA api instead of bus-specific API.

Signed-off-by: Nirmoy Das 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index e01e681d2a60..ea55d66b3ef6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -75,7 +75,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
 
if (adev->dummy_page_addr)
return 0;
-   adev->dummy_page_addr = pci_map_page(adev->pdev, dummy_page, 0,
+   adev->dummy_page_addr = dma_map_page(&adev->pdev->dev, dummy_page, 0,
 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
if (pci_dma_mapping_error(adev->pdev, adev->dummy_page_addr)) {
dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n");
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 1/1] drm/amdgpu: use generic DMA API

2020-11-20 Thread Nirmoy

Sorry, I missed pci_dma_mapping_error() :/ I will resend.


Nirmoy

On 11/20/20 4:41 PM, Nirmoy Das wrote:

Use generic DMA api instead of bus-specific API.

Signed-off-by: Nirmoy Das 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index e01e681d2a60..ea55d66b3ef6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -75,7 +75,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
  
  	if (adev->dummy_page_addr)

return 0;
-   adev->dummy_page_addr = pci_map_page(adev->pdev, dummy_page, 0,
+   adev->dummy_page_addr = dma_map_page(&adev->pdev->dev, dummy_page, 0,
 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
if (pci_dma_mapping_error(adev->pdev, adev->dummy_page_addr)) {
dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n");

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH] drm/amdgpu: only register VGA devices with the VGA arbiter

2020-11-20 Thread Christian König

Reviewed-by: Christian König 

Am 20.11.20 um 16:04 schrieb Xu, Feifei:

[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Feifei Xu 

-Original Message-
From: amd-gfx  On Behalf Of Alex Deucher
Sent: Friday, November 20, 2020 10:55 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander 
Subject: [PATCH] drm/amdgpu: only register VGA devices with the VGA arbiter

We only need to arbitrate VGA access on VGA compatible devices.

Signed-off-by: Alex Deucher 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f60b7084f4d..2670fb113ba1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3346,7 +3346,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
  /* this will fail for cards that aren't VGA class devices, just
   * ignore it */
-vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode);
+if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode);

  if (amdgpu_device_supports_boco(ddev))
  boco = true;
@@ -3605,7 +3606,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  vga_switcheroo_unregister_client(adev->pdev);
  if (amdgpu_device_supports_boco(adev_to_drm(adev)))
  vga_switcheroo_fini_domain_pm_ops(adev->dev);
-vga_client_register(adev->pdev, NULL, NULL, NULL);
+if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
+vga_client_register(adev->pdev, NULL, NULL, NULL);
  if (adev->rio_mem)
  pci_iounmap(adev->pdev, adev->rio_mem);
  adev->rio_mem = NULL;
--
2.25.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7CFeifei.Xu%40amd.com%7C8eac65802c2841a4016408d88d645737%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637414809390017528%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4YGYTXm%2FY8MAQiqs4QJ1MUIcy2%2F4waucDrIeob63ogk%3D&reserved=0
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 1/2] drm/amdgpu: use generic DMA API

2020-11-20 Thread Nirmoy Das
Use generic DMA api instead of bus-specific API.

Signed-off-by: Nirmoy Das 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index e01e681d2a60..0db933026722 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -75,9 +75,9 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
 
if (adev->dummy_page_addr)
return 0;
-   adev->dummy_page_addr = pci_map_page(adev->pdev, dummy_page, 0,
+   adev->dummy_page_addr = dma_map_page(&adev->pdev->dev, dummy_page, 0,
 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
-   if (pci_dma_mapping_error(adev->pdev, adev->dummy_page_addr)) {
+   if (dma_mapping_error(&adev->pdev->dev, adev->dummy_page_addr)) {
dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n");
adev->dummy_page_addr = 0;
return -ENOMEM;
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 2/2] drm/radeon: use generic DMA API

2020-11-20 Thread Nirmoy Das
Use generic DMA api instead of bus-specific API.

Signed-off-by: Nirmoy Das 
---
 drivers/gpu/drm/radeon/radeon_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index 7f384ffe848a..a5588b0a454c 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -784,9 +784,9 @@ int radeon_dummy_page_init(struct radeon_device *rdev)
rdev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO);
if (rdev->dummy_page.page == NULL)
return -ENOMEM;
-   rdev->dummy_page.addr = pci_map_page(rdev->pdev, rdev->dummy_page.page,
+   rdev->dummy_page.addr = dma_map_page(&rdev->pdev->dev, 
rdev->dummy_page.page,
0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
-   if (pci_dma_mapping_error(rdev->pdev, rdev->dummy_page.addr)) {
+   if (dma_mapping_error(&rdev->pdev->dev, rdev->dummy_page.addr)) {
dev_err(&rdev->pdev->dev, "Failed to DMA MAP the dummy page\n");
__free_page(rdev->dummy_page.page);
rdev->dummy_page.page = NULL;
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 2/2] drm/radeon: use generic DMA API

2020-11-20 Thread Alex Deucher
Series is:
Reviewed-by: Alex Deucher 

On Fri, Nov 20, 2020 at 11:04 AM Nirmoy Das  wrote:
>
> Use generic DMA api instead of bus-specific API.
>
> Signed-off-by: Nirmoy Das 
> ---
>  drivers/gpu/drm/radeon/radeon_device.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index 7f384ffe848a..a5588b0a454c 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -784,9 +784,9 @@ int radeon_dummy_page_init(struct radeon_device *rdev)
> rdev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | 
> __GFP_ZERO);
> if (rdev->dummy_page.page == NULL)
> return -ENOMEM;
> -   rdev->dummy_page.addr = pci_map_page(rdev->pdev, 
> rdev->dummy_page.page,
> +   rdev->dummy_page.addr = dma_map_page(&rdev->pdev->dev, 
> rdev->dummy_page.page,
> 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
> -   if (pci_dma_mapping_error(rdev->pdev, rdev->dummy_page.addr)) {
> +   if (dma_mapping_error(&rdev->pdev->dev, rdev->dummy_page.addr)) {
> dev_err(&rdev->pdev->dev, "Failed to DMA MAP the dummy 
> page\n");
> __free_page(rdev->dummy_page.page);
> rdev->dummy_page.page = NULL;
> --
> 2.29.2
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
Hi all,

This series aims to fix almost all remaining fall-through warnings in
order to enable -Wimplicit-fallthrough for Clang.

In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
add multiple break/goto/return/fallthrough statements instead of just
letting the code fall through to the next case.

Notice that in order to enable -Wimplicit-fallthrough for Clang, this
change[1] is meant to be reverted at some point. So, this patch helps
to move in that direction.

Something important to mention is that there is currently a discrepancy
between GCC and Clang when dealing with switch fall-through to empty case
statements or to cases that only contain a break/continue/return
statement[2][3][4].

Now that the -Wimplicit-fallthrough option has been globally enabled[5],
any compiler should really warn on missing either a fallthrough annotation
or any of the other case-terminating statements (break/continue/return/
goto) when falling through to the next case statement. Making exceptions
to this introduces variation in case handling which may continue to lead
to bugs, misunderstandings, and a general lack of robustness. The point
of enabling options like -Wimplicit-fallthrough is to prevent human error
and aid developers in spotting bugs before their code is even built/
submitted/committed, therefore eliminating classes of bugs. So, in order
to really accomplish this, we should, and can, move in the direction of
addressing any error-prone scenarios and get rid of the unintentional
fallthrough bug-class in the kernel, entirely, even if there is some minor
redundancy. Better to have explicit case-ending statements than continue to
have exceptions where one must guess as to the right result. The compiler
will eliminate any actual redundancy.

Note that there is already a patch in mainline that addresses almost
40,000 of these issues[6].

I'm happy to carry this whole series in my own tree if people are OK
with it. :)

[1] commit e2079e93f562c ("kbuild: Do not enable -Wimplicit-fallthrough for 
clang for now")
[2] ClangBuiltLinux#636
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
[4] https://godbolt.org/z/xgkvIh
[5] commit a035d552a93b ("Makefile: Globally enable fall-through warning")
[6] commit 4169e889e588 ("include: jhash/signal: Fix fall-through warnings for 
Clang")

Thanks!

Gustavo A. R. Silva (141):
  afs: Fix fall-through warnings for Clang
  ASoC: codecs: Fix fall-through warnings for Clang
  cifs: Fix fall-through warnings for Clang
  drm/amdgpu: Fix fall-through warnings for Clang
  drm/radeon: Fix fall-through warnings for Clang
  gfs2: Fix fall-through warnings for Clang
  gpio: Fix fall-through warnings for Clang
  IB/hfi1: Fix fall-through warnings for Clang
  igb: Fix fall-through warnings for Clang
  ima: Fix fall-through warnings for Clang
  ipv4: Fix fall-through warnings for Clang
  ixgbe: Fix fall-through warnings for Clang
  media: dvb-frontends: Fix fall-through warnings for Clang
  media: usb: dvb-usb-v2: Fix fall-through warnings for Clang
  netfilter: Fix fall-through warnings for Clang
  nfsd: Fix fall-through warnings for Clang
  nfs: Fix fall-through warnings for Clang
  qed: Fix fall-through warnings for Clang
  qlcnic: Fix fall-through warnings for Clang
  scsi: aic7xxx: Fix fall-through warnings for Clang
  scsi: aic94xx: Fix fall-through warnings for Clang
  scsi: bfa: Fix fall-through warnings for Clang
  staging: rtl8723bs: core: Fix fall-through warnings for Clang
  staging: vt6655: Fix fall-through warnings for Clang
  bnxt_en: Fix fall-through warnings for Clang
  ceph: Fix fall-through warnings for Clang
  drbd: Fix fall-through warnings for Clang
  drm/amd/display: Fix fall-through warnings for Clang
  e1000: Fix fall-through warnings for Clang
  ext2: Fix fall-through warnings for Clang
  ext4: Fix fall-through warnings for Clang
  floppy: Fix fall-through warnings for Clang
  fm10k: Fix fall-through warnings for Clang
  IB/mlx4: Fix fall-through warnings for Clang
  IB/qedr: Fix fall-through warnings for Clang
  ice: Fix fall-through warnings for Clang
  Input: pcspkr - Fix fall-through warnings for Clang
  isofs: Fix fall-through warnings for Clang
  ixgbevf: Fix fall-through warnings for Clang
  kprobes/x86: Fix fall-through warnings for Clang
  mm: Fix fall-through warnings for Clang
  net: 3c509: Fix fall-through warnings for Clang
  net: cassini: Fix fall-through warnings for Clang
  net/mlx4: Fix fall-through warnings for Clang
  net: mscc: ocelot: Fix fall-through warnings for Clang
  netxen_nic: Fix fall-through warnings for Clang
  nfp: Fix fall-through warnings for Clang
  perf/x86: Fix fall-through warnings for Clang
  pinctrl: Fix fall-through warnings for Clang
  RDMA/mlx5: Fix fall-through warnings for Clang
  reiserfs: Fix fall-through warnings for Clang
  security: keys: Fix fall-through warnings for Clang
  selinux: Fix fall-through warnings for Clang
  target: Fix fall-through warnings for Clang
  uprobes/x86: Fix fall-through warni

[PATCH 005/141] drm/radeon: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple fallthrough pseudo-keyword macros,
as replacement for /* fall through */ comments.

Notice that Clang doesn't recognize /* fall through */ comments as
implicit fall-through markings.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/radeon/ci_dpm.c | 2 +-
 drivers/gpu/drm/radeon/r300.c   | 1 +
 drivers/gpu/drm/radeon/si_dpm.c | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index 886e9959496f..3d0a2e81b2de 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -4860,8 +4860,8 @@ static void 
ci_request_link_speed_change_before_state_change(struct radeon_devic
case RADEON_PCIE_GEN2:
if (radeon_acpi_pcie_performance_request(rdev, 
PCIE_PERF_REQ_PECI_GEN2, false) == 0)
break;
+   fallthrough;
 #endif
-   /* fall through */
default:
pi->force_pcie_gen = ci_get_current_pcie_speed(rdev);
break;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 73f67bf222e1..213dc49b6322 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -1162,6 +1162,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
/* valid register only on RV530 */
if (p->rdev->family == CHIP_RV530)
break;
+   fallthrough;
/* fallthrough do not move */
default:
goto fail;
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index d1c73e9db889..d19c08e0ad5a 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -5748,8 +5748,8 @@ static void 
si_request_link_speed_change_before_state_change(struct radeon_devic
case RADEON_PCIE_GEN2:
if (radeon_acpi_pcie_performance_request(rdev, 
PCIE_PERF_REQ_PECI_GEN2, false) == 0)
break;
+   fallthrough;
 #endif
-   /* fall through */
default:
si_pi->force_pcie_gen = si_get_current_pcie_speed(rdev);
break;
-- 
2.27.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 004/141] drm/amdgpu: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements instead of just
letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/vi.c| 1 +
 4 files changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 3579565e0eab..98ca6b976b6e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -8398,6 +8398,7 @@ static int gfx_v10_0_set_priv_inst_fault_state(struct 
amdgpu_device *adev,
WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
   PRIV_INSTR_INT_ENABLE,
   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
+   break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 0d8e203b10ef..e61121629b93 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -5683,6 +5683,7 @@ static int gfx_v9_0_set_priv_inst_fault_state(struct 
amdgpu_device *adev,
WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
   PRIV_INSTR_INT_ENABLE,
   state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
+   break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 3ebbddb63705..584b99b80c29 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -502,6 +502,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct 
amdgpu_device *adev,
WREG32(reg, tmp);
}
}
+   break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index 9bcd0eebc6d7..d56b474b3a21 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -1645,6 +1645,7 @@ static int vi_common_set_clockgating_state(void *handle,
case CHIP_POLARIS12:
case CHIP_VEGAM:
vi_common_set_clockgating_state_by_smu(adev, state);
+   break;
default:
break;
}
-- 
2.27.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 028/141] drm/amd/display: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements instead of just
letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser.c  | 1 +
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 2 ++
 drivers/gpu/drm/amd/display/dc/core/dc_link.c  | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
index ad394aefa5d9..23a373ca94b5 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
@@ -1198,6 +1198,7 @@ static enum bp_result bios_parser_get_embedded_panel_info(
default:
break;
}
+   break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
index 29d64e7e304f..fd1e64fa8744 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
@@ -903,6 +903,7 @@ static enum bp_result bios_parser_get_soc_bb_info(
break;
case 4:
result = get_soc_bb_info_v4_4(bp, soc_bb_info);
+   break;
default:
break;
}
@@ -1019,6 +1020,7 @@ static enum bp_result bios_parser_get_embedded_panel_info(
default:
break;
}
+   break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index fec87a2e210c..b9254a87ee73 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -1052,6 +1052,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
 
return false;
}
+   break;
default:
break;
}
-- 
2.27.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 078/141] drm/amd/pm: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple
of warnings by explicitly adding a break statement instead of letting
the code fall through to the next case, and a fallthrough pseudo-keyword
as a replacement for a /* fall through */ comment,

Notice that Clang doesn't recognize /* fall through */ comments as
implicit fall-through markings.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/amd/pm/powerplay/si_dpm.c  | 2 +-
 drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c 
b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
index b5986d19dc08..afa1711c9620 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
@@ -6200,8 +6200,8 @@ static void 
si_request_link_speed_change_before_state_change(struct amdgpu_devic
case AMDGPU_PCIE_GEN2:
if (amdgpu_acpi_pcie_performance_request(adev, 
PCIE_PERF_REQ_PECI_GEN2, false) == 0)
break;
+   fallthrough;
 #endif
-   /* fall through */
default:
si_pi->force_pcie_gen = si_get_current_pcie_speed(adev);
break;
diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c 
b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
index c3d2e6dcf62a..7d7d698c7976 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
@@ -2272,6 +2272,7 @@ static int polaris10_update_smc_table(struct pp_hwmgr 
*hwmgr, uint32_t type)
break;
case SMU_BIF_TABLE:
polaris10_update_bif_smc_table(hwmgr);
+   break;
default:
break;
}
-- 
2.27.0

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[bugreport] Renoir laptop freezes after "waking up" from suspend, WARNING: CPU: 0 PID: 4573 at drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2548

2020-11-20 Thread honza-bugzilla
Hello, I noticed following bug, I followed 
https://www.kernel.org/doc/html/latest/admin-guide/reporting-bugs.html Please 
let me know if additional info or patch testing is needed (I'm not subscribed 
to the list, so please include me in the reponse).

[1.] One line summary of the problem:
  Laptop with Ryzen 4500U freezes after resuming from suspend
[2.] Full description of the problem/report:
  It can be reproduced on 99% by doing following:
   1. Close laptop lid
   2. Wait a minute
   3. Open laptop lid - screen is black, on/off diode is signaling on state and 
keyboard/or touchpad doesn't react to any input. After next boot, the oops 
message below can be observed in dmesg log from last boot.
  Note: I'm not sure if the laptop even suspends since the battery drains quite 
fast.
[3.] Keywords (i.e., modules, networking, kernel):
  AMD, drivers
[4.] Kernel information
[4.1.] Kernel version (from /proc/version):
  Linux version 5.9.8-200.fc33.x86_64 
(mockbu...@bkernel01.iad2.fedoraproject.org) (gcc (GCC) 10.2.1 20201016 (Red 
Hat 10.2.1-6), GNU ld version 2.35-14.fc33) #1 SMP Tue Nov 10 21:58:19 UTC 2020
[4.2.] Kernel .config file:
[5.] Most recent kernel version which did not have the bug:
[6.] Output of Oops.. message (if applicable) with symbolic information
 resolved (see Documentation/admin-guide/bug-hunting.rst)

WARNING: CPU: 0 PID: 4573 at 
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2548 
dc_link_set_backlight_level+0x8a/0xf0 [amdgpu]
Modules linked in: uinput rfcomm xt_CHECKSUM xt_MASQUERADE xt_conntrack 
ipt_REJECT nf_nat_tftp nf_conntrack_tftp tun bridge stp llc ccm nft_objref 
nf_conntrack_netbios_ns nf_conntrack_broadcast nft_fib_inet nft_fib_ipv4 
nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject 
nft_ct nft_chain_nat ip6table_nat ip6table_mangle ip6table_raw 
ip6table_security iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 
iptable_mangle iptable_raw iptable_security ip_set nf_tables nfnetlink 
ip6table_filter ip6_tables iptable_filter cmac bnep sunrpc snd_acp3x_pdm_dma 
edac_mce_amd snd_soc_dmic snd_acp3x_rn snd_soc_core kvm_amd snd_compress kvm 
ac97_bus snd_pcm_dmaengine irqbypass rapl snd_hda_codec_realtek vfat fat 
snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi pcspkr snd_hda_intel 
snd_intel_dspcfg rtw88_8822ce joydev snd_hda_codec rtw88_8822c btusb rtw88_pci 
btrtl rtw88_core snd_hda_core btbcm btintel snd_hwdep mac80211 bluetooth 
snd_seq snd_seq_device
 sp5100_tco snd_pcm wmi_bmof i2c_piix4 k10temp cfg80211 snd_timer 
snd_rn_pci_acp3x snd_pci_acp3x ecdh_generic ecc snd rfkill soundcore libarc4 
ucsi_acpi typec_ucsi typec acpi_cpufreq zram ip_tables amdgpu hid_multitouch 
crct10dif_pclmul crc32_pclmul iommu_v2 crc32c_intel gpu_sched i2c_algo_bit ttm 
drm_kms_helper ghash_clmulni_intel serio_raw cec drm ccp video wmi i2c_hid 
pinctrl_amd fuse
CPU: 0 PID: 4573 Comm: systemd-sleep Not tainted 5.9.8-200.fc33.x86_64 #1
Hardware name: TIMI RedmiBook 16/TM1953, BIOS RMARN6B0P0909 08/19/2020
RIP: 0010:dc_link_set_backlight_level+0x8a/0xf0 [amdgpu]
Code: 70 03 00 00 31 c0 48 8d 96 c0 01 00 00 48 8b 0a 48 85 c9 74 06 48 3b 59 
08 74 20 83 c0 01 48 81 c2 d8 04 00 00 83 f8 06 75 e3 <0f> 0b 45 31 e4 5b 44 89 
e0 5d 41 5c 41 5d 41 5e c3 48 98 48 69 c0
RSP: 0018:a4a9885efcc0 EFLAGS: 00010246
RAX: 0006 RBX: 97173340a000 RCX: 
RDX: 971616301ed0 RSI: 97161630 RDI: 
RBP: 9717323a R08: 002d R09: 971733fe68f8
R10: 04c69e45 R11: 052707d0 R12: 3701
R13:  R14: 3719 R15: 0002
FS:  7fc4a4f59000() GS:97173f40() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 55dc7de889d8 CR3: 0002d765c000 CR4: 00350ef0
Call Trace:
 amdgpu_dm_backlight_update_status+0xb4/0xc0 [amdgpu]
 backlight_suspend+0x6a/0x80
 ? brightness_store+0x50/0x50
 dpm_run_callback+0x4f/0x140
 __device_suspend+0x11c/0x4a0
 dpm_suspend+0x117/0x250
 dpm_suspend_start+0x77/0x80
 suspend_devices_and_enter+0xe6/0x7f0
 pm_suspend.cold+0x329/0x374
 state_store+0x71/0xd0
 kernfs_fop_write+0xce/0x1b0
 vfs_write+0xc7/0x210
 ksys_write+0x4f/0xc0
 do_syscall_64+0x33/0x40
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fc4a5ef8297
Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 
8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 
c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
RSP: 002b:7ffecd396a68 EFLAGS: 0246 ORIG_RAX: 0001
RAX: ffda RBX: 0004 RCX: 7fc4a5ef8297
RDX: 0004 RSI: 7ffecd396b50 RDI: 0004
RBP: 7ffecd396b50 R08: 55dc7de7f420 R09: 7fc4a5f8f0c0
R10: 7fc4a5f8efc0 R11: 0246 R12: 0004
R13: 55dc7de7e650 R14: 0004 R15: 7fc4a5fcb720

[7.] A small shell script or example program

Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Joe Perches
On Fri, 2020-11-20 at 12:21 -0600, Gustavo A. R. Silva wrote:
> Hi all,
> 
> This series aims to fix almost all remaining fall-through warnings in
> order to enable -Wimplicit-fallthrough for Clang.
> 
> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> add multiple break/goto/return/fallthrough statements instead of just
> letting the code fall through to the next case.
> 
> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
> change[1] is meant to be reverted at some point. So, this patch helps
> to move in that direction.

This was a bit hard to parse for a second or three.

Thanks Gustavo.

How was this change done?


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Jakub Kicinski
On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:
> This series aims to fix almost all remaining fall-through warnings in
> order to enable -Wimplicit-fallthrough for Clang.
> 
> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> add multiple break/goto/return/fallthrough statements instead of just
> letting the code fall through to the next case.
> 
> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
> change[1] is meant to be reverted at some point. So, this patch helps
> to move in that direction.
> 
> Something important to mention is that there is currently a discrepancy
> between GCC and Clang when dealing with switch fall-through to empty case
> statements or to cases that only contain a break/continue/return
> statement[2][3][4].

Are we sure we want to make this change? Was it discussed before?

Are there any bugs Clangs puritanical definition of fallthrough helped
find?

IMVHO compiler warnings are supposed to warn about issues that could
be bugs. Falling through to default: break; can hardly be a bug?!
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva


Hi,

On 11/20/20 12:53, Jakub Kicinski wrote:
> On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:
>> This series aims to fix almost all remaining fall-through warnings in
>> order to enable -Wimplicit-fallthrough for Clang.
>>
>> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
>> add multiple break/goto/return/fallthrough statements instead of just
>> letting the code fall through to the next case.
>>
>> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
>> change[1] is meant to be reverted at some point. So, this patch helps
>> to move in that direction.
>>
>> Something important to mention is that there is currently a discrepancy
>> between GCC and Clang when dealing with switch fall-through to empty case
>> statements or to cases that only contain a break/continue/return
>> statement[2][3][4].
> 
> Are we sure we want to make this change? Was it discussed before?
> 
> Are there any bugs Clangs puritanical definition of fallthrough helped
> find?
> 
> IMVHO compiler warnings are supposed to warn about issues that could
> be bugs. Falling through to default: break; can hardly be a bug?!

The justification for this is explained in this same changelog text:

Now that the -Wimplicit-fallthrough option has been globally enabled[5],
any compiler should really warn on missing either a fallthrough annotation
or any of the other case-terminating statements (break/continue/return/
goto) when falling through to the next case statement. Making exceptions
to this introduces variation in case handling which may continue to lead
to bugs, misunderstandings, and a general lack of robustness. The point
of enabling options like -Wimplicit-fallthrough is to prevent human error
and aid developers in spotting bugs before their code is even built/
submitted/committed, therefore eliminating classes of bugs. So, in order
to really accomplish this, we should, and can, move in the direction of
addressing any error-prone scenarios and get rid of the unintentional
fallthrough bug-class in the kernel, entirely, even if there is some minor
redundancy. Better to have explicit case-ending statements than continue to
have exceptions where one must guess as to the right result. The compiler
will eliminate any actual redundancy.

Note that there is already a patch in mainline that addresses almost
40,000 of these issues[6].

[1] commit e2079e93f562c ("kbuild: Do not enable -Wimplicit-fallthrough for 
clang for now")
[2] ClangBuiltLinux#636
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
[4] https://godbolt.org/z/xgkvIh
[5] commit a035d552a93b ("Makefile: Globally enable fall-through warning")
[6] commit 4169e889e588 ("include: jhash/signal: Fix fall-through warnings for 
Clang")

Thanks
--
Gustavo
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Kees Cook
On Fri, Nov 20, 2020 at 10:53:44AM -0800, Jakub Kicinski wrote:
> On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:
> > This series aims to fix almost all remaining fall-through warnings in
> > order to enable -Wimplicit-fallthrough for Clang.
> > 
> > In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> > add multiple break/goto/return/fallthrough statements instead of just
> > letting the code fall through to the next case.
> > 
> > Notice that in order to enable -Wimplicit-fallthrough for Clang, this
> > change[1] is meant to be reverted at some point. So, this patch helps
> > to move in that direction.
> > 
> > Something important to mention is that there is currently a discrepancy
> > between GCC and Clang when dealing with switch fall-through to empty case
> > statements or to cases that only contain a break/continue/return
> > statement[2][3][4].
> 
> Are we sure we want to make this change? Was it discussed before?
> 
> Are there any bugs Clangs puritanical definition of fallthrough helped
> find?
> 
> IMVHO compiler warnings are supposed to warn about issues that could
> be bugs. Falling through to default: break; can hardly be a bug?!

It's certainly a place where the intent is not always clear. I think
this makes all the cases unambiguous, and doesn't impact the machine
code, since the compiler will happily optimize away any behavioral
redundancy.


-- 
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva



On 11/20/20 12:28, Joe Perches wrote:
> On Fri, 2020-11-20 at 12:21 -0600, Gustavo A. R. Silva wrote:
>> Hi all,
>>
>> This series aims to fix almost all remaining fall-through warnings in
>> order to enable -Wimplicit-fallthrough for Clang.
>>
>> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
>> add multiple break/goto/return/fallthrough statements instead of just
>> letting the code fall through to the next case.
>>
>> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
>> change[1] is meant to be reverted at some point. So, this patch helps
>> to move in that direction.
> 
> This was a bit hard to parse for a second or three.
> 
> Thanks Gustavo.
> 
> How was this change done?

I audited case by case in order to determine the best fit for each
situation. Depending on the surrounding logic, sometimes it makes
more sense a goto or a fallthrough rather than merely a break.

Thanks
--
Gustavo
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Jakub Kicinski
On Fri, 20 Nov 2020 11:30:40 -0800 Kees Cook wrote:
> On Fri, Nov 20, 2020 at 10:53:44AM -0800, Jakub Kicinski wrote:
> > On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:  
> > > This series aims to fix almost all remaining fall-through warnings in
> > > order to enable -Wimplicit-fallthrough for Clang.
> > > 
> > > In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> > > add multiple break/goto/return/fallthrough statements instead of just
> > > letting the code fall through to the next case.
> > > 
> > > Notice that in order to enable -Wimplicit-fallthrough for Clang, this
> > > change[1] is meant to be reverted at some point. So, this patch helps
> > > to move in that direction.
> > > 
> > > Something important to mention is that there is currently a discrepancy
> > > between GCC and Clang when dealing with switch fall-through to empty case
> > > statements or to cases that only contain a break/continue/return
> > > statement[2][3][4].  
> > 
> > Are we sure we want to make this change? Was it discussed before?
> > 
> > Are there any bugs Clangs puritanical definition of fallthrough helped
> > find?
> > 
> > IMVHO compiler warnings are supposed to warn about issues that could
> > be bugs. Falling through to default: break; can hardly be a bug?!  
> 
> It's certainly a place where the intent is not always clear. I think
> this makes all the cases unambiguous, and doesn't impact the machine
> code, since the compiler will happily optimize away any behavioral
> redundancy.

If none of the 140 patches here fix a real bug, and there is no change
to machine code then it sounds to me like a W=2 kind of a warning.

I think clang is just being annoying here, but if I'm the only one who
feels this way chances are I'm wrong :)
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 4/4] drm/amd/display: don't expose rotation prop for cursor plane

2020-11-20 Thread Simon Ser
Setting any rotation on the cursor plane is ignored by amdgpu.
Because of DCE/DCN design, it's not possible to rotate the cursor.
Instead of displaying the wrong result, stop advertising the rotation
property for the cursor plane.

Now that we check all cursor plane properties in amdgpu_dm_atomic_check,
remove the TODO.

Signed-off-by: Simon Ser 
Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 2542571a8993..3283e22241d7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6592,7 +6592,8 @@ static int amdgpu_dm_plane_init(struct 
amdgpu_display_manager *dm,
DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 |
DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270;
 
-   if (dm->adev->asic_type >= CHIP_BONAIRE)
+   if (dm->adev->asic_type >= CHIP_BONAIRE &&
+   plane->type != DRM_PLANE_TYPE_CURSOR)
drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
   supported_rotations);
 
@@ -8887,7 +,6 @@ static int dm_update_plane_state(struct dc *dc,
dm_new_plane_state = to_dm_plane_state(new_plane_state);
dm_old_plane_state = to_dm_plane_state(old_plane_state);
 
-   /*TODO Implement better atomic check for cursor plane */
if (plane->type == DRM_PLANE_TYPE_CURSOR) {
if (!enable || !new_plane_crtc ||
drm_atomic_plane_disabling(plane->state, 
new_plane_state))
-- 
2.29.2


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 1/4] drm/amd/display: add cursor FB size check

2020-11-20 Thread Simon Ser
This patch expands the cursor checks added in "drm/amd/display: add basic
atomic check for cursor plane" to also include a FB size check. Without
this patch, setting a FB smaller than max_cursor_size with an invalid
width would result in amdgpu error messages and a fallback to a 64-byte
width:

[drm:hubp1_cursor_set_attributes [amdgpu]] *ERROR* Invalid cursor pitch of 
100. Only 64/128/256 is supported on DCN.

Note that DC uses the word "pitch" when actually checking the FB width.
Indeed, the function handle_cursor_update does this:

attributes.pitch = attributes.width;

In my tests, the cursor FB actually had a pitch of 512 bytes.

Signed-off-by: Simon Ser 
Reported-by: Pierre-Loup A. Griffais 
Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Nicholas Kazlauskas 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 +++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 2855bb918535..bd63f1c4ae79 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8902,6 +8902,28 @@ static int dm_update_plane_state(struct dc *dc,
return -EINVAL;
}
 
+   if (new_plane_state->fb) {
+   if (new_plane_state->fb->width > 
new_acrtc->max_cursor_width ||
+   new_plane_state->fb->height > 
new_acrtc->max_cursor_height) {
+   DRM_DEBUG_ATOMIC("Bad cursor FB size %dx%d\n",
+new_plane_state->fb->width,
+new_plane_state->fb->height);
+   return -EINVAL;
+   }
+
+   switch (new_plane_state->fb->width) {
+   case 64:
+   case 128:
+   case 256:
+   /* FB width is supported by cursor plane */
+   break;
+   default:
+   DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n",
+new_plane_state->fb->width);
+   return -EINVAL;
+   }
+   }
+
return 0;
}
 
-- 
2.29.2


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 2/4] drm/amd/display: disallow cropping for cursor plane

2020-11-20 Thread Simon Ser
Looking at handle_cursor_update, it doesn't seem like src_{x,y,w,h}
are picked up by DC. I also tried to change these parameters via a
test KMS client, and amdgpu ignored them. Instead of displaying the
wrong result, reject the atomic commit.

Signed-off-by: Simon Ser 
Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bd63f1c4ae79..a7e1af7081cb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8902,6 +8902,11 @@ static int dm_update_plane_state(struct dc *dc,
return -EINVAL;
}
 
+   if (new_plane_state->src_x != 0 || new_plane_state->src_y != 0) 
{
+   DRM_DEBUG_ATOMIC("Cropping not supported for cursor 
plane\n");
+   return -EINVAL;
+   }
+
if (new_plane_state->fb) {
if (new_plane_state->fb->width > 
new_acrtc->max_cursor_width ||
new_plane_state->fb->height > 
new_acrtc->max_cursor_height) {
@@ -8910,6 +8915,11 @@ static int dm_update_plane_state(struct dc *dc,
 new_plane_state->fb->height);
return -EINVAL;
}
+   if (new_plane_state->src_w != 
new_plane_state->fb->width << 16 ||
+   new_plane_state->src_h != 
new_plane_state->fb->height << 16) {
+   DRM_DEBUG_ATOMIC("Cropping not supported for 
cursor plane\n");
+   return -EINVAL;
+   }
 
switch (new_plane_state->fb->width) {
case 64:
-- 
2.29.2


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 0/4] drm/amd/display: add cursor plane checks

2020-11-20 Thread Simon Ser
This series adds checks for all cursor plane properties. This avoids
accepting configurations that we won't be able to display.

I've tested this series against various scenarios using a hacked up
wlroots [1].

[1]: https://github.com/emersion/wlroots/commits/amdgpu-cursor-invalid

Simon Ser (4):
  drm/amd/display: add cursor FB size check
  drm/amd/display: disallow cropping for cursor plane
  drm/amd/display: check cursor scaling
  drm/amd/display: don't expose rotation prop for cursor plane

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 81 +--
 1 file changed, 75 insertions(+), 6 deletions(-)

-- 
2.29.2


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 3/4] drm/amd/display: check cursor scaling

2020-11-20 Thread Simon Ser
Don't allow user-space to set different scaling parameters for the
cursor plane and for the primary plane. Because of DCE/DCN design,
it's not possible to have a mismatch.

The old check in dm_update_plane_state is superseded by this new
check.

Signed-off-by: Simon Ser 
Cc: Alex Deucher 
Cc: Harry Wentland 
Cc: Nicholas Kazlauskas 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 ---
 1 file changed, 44 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a7e1af7081cb..2542571a8993 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8895,13 +8895,6 @@ static int dm_update_plane_state(struct dc *dc,
 
new_acrtc = to_amdgpu_crtc(new_plane_crtc);
 
-   if ((new_plane_state->crtc_w > new_acrtc->max_cursor_width) ||
-   (new_plane_state->crtc_h > 
new_acrtc->max_cursor_height)) {
-   DRM_DEBUG_ATOMIC("Bad cursor size %d x %d\n",
-
new_plane_state->crtc_w, new_plane_state->crtc_h);
-   return -EINVAL;
-   }
-
if (new_plane_state->src_x != 0 || new_plane_state->src_y != 0) 
{
DRM_DEBUG_ATOMIC("Cropping not supported for cursor 
plane\n");
return -EINVAL;
@@ -9055,6 +9048,43 @@ static int dm_update_plane_state(struct dc *dc,
return ret;
 }
 
+static int dm_check_crtc_cursor(struct drm_atomic_state *state,
+   struct drm_crtc *crtc,
+   struct drm_crtc_state *new_crtc_state)
+{
+   struct drm_plane_state *new_cursor_state, *new_primary_state;
+   int cursor_scale_w, cursor_scale_h, primary_scale_w, primary_scale_h;
+
+   /* On DCE and DCN there is no dedicated hardware cursor plane. We get a
+* cursor per pipe but it's going to inherit the scaling and
+* positioning from the underlying pipe. Check the cursor plane's
+* blending properties match the primary plane's. */
+
+   new_cursor_state = drm_atomic_get_new_plane_state(state, crtc->cursor);
+   new_primary_state = drm_atomic_get_new_plane_state(state, 
crtc->primary);
+   if (!new_cursor_state || !new_primary_state || !new_cursor_state->fb) {
+   return 0;
+   }
+
+   cursor_scale_w = new_cursor_state->crtc_w * 1000 /
+(new_cursor_state->src_w >> 16);
+   cursor_scale_h = new_cursor_state->crtc_h * 1000 /
+(new_cursor_state->src_h >> 16);
+
+   primary_scale_w = new_primary_state->crtc_w * 1000 /
+(new_primary_state->src_w >> 16);
+   primary_scale_h = new_primary_state->crtc_h * 1000 /
+(new_primary_state->src_h >> 16);
+
+   if (cursor_scale_w != primary_scale_w ||
+   cursor_scale_h != primary_scale_h) {
+   DRM_DEBUG_ATOMIC("Cursor plane scaling doesn't match primary 
plane\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 #if defined(CONFIG_DRM_AMD_DC_DCN)
 static int add_affected_mst_dsc_crtcs(struct drm_atomic_state *state, struct 
drm_crtc *crtc)
 {
@@ -9267,6 +9297,13 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
if (ret)
goto fail;
 
+   /* Check cursor planes scaling */
+   for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+   ret = dm_check_crtc_cursor(state, crtc, new_crtc_state);
+   if (ret)
+   goto fail;
+   }
+
if (state->legacy_cursor_update) {
/*
 * This is a fast cursor update coming from the plane update
-- 
2.29.2


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 00/18] DC 3.2.113 Patches, November 20, 2020

2020-11-20 Thread Rodrigo Siqueira
This DC patchset brings improvements in multiple areas. In summary, we
highlight:
 
* Power features and optimizations
* Code cleanup
* Enable stutter for DCN3.01
* Bug fixes

Best Regards

Aric Cyr (1):
  drm/amd/display: 3.2.113

Ashley Thomas (1):
  drm/amd/display: Source minimum HBlank support

Camille Cho (1):
  drm/amd/display: To update backlight restore mechanism

Charlene Liu (1):
  drm/amd/display: add i2c speed arbitration for dc_i2c and hdcp_i2c

Chris Park (1):
  drm/amd/display: Update panel register

Eric Yang (1):
  drm/amd/display: expose clk_mgr functions for reuse

Jacky Liao (3):
  drm/amd/display: Add DMCU memory low power support
  drm/amd/display: Add BLNDGAM memory shutdown support
  drm/amd/display: Add GAMCOR memory shutdown support

Sherry (1):
  drm/amd/display: change hw sequence

Sung Joon Kim (1):
  drm/amd/display: enable pipe power gating by default

Tashfique Abdullah (1):
  drm/amd/display: intermittent underflow observed when PIP is toggled
in Full screen

Wyatt Wood (1):
  drm/amd/display: Clear sticky vsc sdp error bit

Yongqiang Sun (5):
  drm/amd/display: Enable stutter for dcn3.01.
  drm/amd/display: Add internal display info
  drm/amd/display: Check multiple internal displays for power
optimization.
  drm/amd/display: remove macro which is in header already
  drm/amd/display: init soc bounding box for dcn3.01.

 .../drm/amd/display/dc/bios/bios_parser2.c|  68 +
 .../display/dc/clk_mgr/dcn301/vg_clk_mgr.c|   8 +-
 .../display/dc/clk_mgr/dcn301/vg_clk_mgr.h|  10 ++
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  16 +++
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |   7 +
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |   3 +-
 drivers/gpu/drm/amd/display/dc/dc.h   |   5 +-
 .../gpu/drm/amd/display/dc/dc_bios_types.h|   5 +
 drivers/gpu/drm/amd/display/dc/dc_link.h  |   1 +
 .../gpu/drm/amd/display/dc/dce/dce_hwseq.h|   7 +-
 .../drm/amd/display/dc/dce/dce_panel_cntl.c   |  36 +++--
 .../display/dc/dce110/dce110_hw_sequencer.c   |  13 +-
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c|   9 ++
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c|   4 +-
 .../gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c  |  13 +-
 .../gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h  |   4 +-
 .../drm/amd/display/dc/dcn30/dcn30_dpp_cm.c   |  12 +-
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c|   7 +
 .../amd/display/dc/dcn301/dcn301_resource.c   | 130 +-
 .../amd/display/dc/dcn302/dcn302_resource.c   |   2 +
 .../amd/display/include/bios_parser_types.h   |   5 +
 drivers/gpu/drm/amd/include/atomfirmware.h|   1 +
 22 files changed, 263 insertions(+), 103 deletions(-)

-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 01/18] drm/amd/display: add i2c speed arbitration for dc_i2c and hdcp_i2c

2020-11-20 Thread Rodrigo Siqueira
From: Charlene Liu 

[why]
HDCP 1.4 failed on SL8800 SW w/a test driver use.

[how]
slower down the HW i2c speed when used by HW i2c.
this request: each acquired_i2c_engine setup the i2c speed needed.
and set the I2c engine for HDCP use at release_engine.

this covers SW using HW I2c engine and HDCP using HW I2c engine. for
dmcu using HW I2c engine, needs add similar logic in dmcufw.

Signed-off-by: Charlene Liu 
Reviewed-by: Chris Park 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index 0006d805b3b2..d15220a4eeb6 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -1759,6 +1759,7 @@ static bool dcn301_resource_construct(
pool->base.mpcc_count = pool->base.res_cap->num_timing_generator;
dc->caps.max_downscale_ratio = 600;
dc->caps.i2c_speed_in_khz = 100;
+   dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a enabled by default*/
dc->caps.max_cursor_size = 256;
dc->caps.dmdata_alloc_size = 2048;
dc->caps.max_slave_planes = 1;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
index 765002e0ff93..15ffd8a21e4e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
@@ -1306,6 +1306,7 @@ static bool dcn302_resource_construct(
pool->mpcc_count = pool->res_cap->num_timing_generator;
dc->caps.max_downscale_ratio = 600;
dc->caps.i2c_speed_in_khz = 100;
+   dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a applied by derfault*/
dc->caps.max_cursor_size = 256;
dc->caps.dmdata_alloc_size = 2048;
 
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 08/18] drm/amd/display: change hw sequence

2020-11-20 Thread Rodrigo Siqueira
From: Sherry 

[Why]
t9 delay func is called twice after setting power off, the unexpected
action results in a doubling of the added 140ms t9 delay

[How]
If the backlight has been turned off, does not turn it off again

Signed-off-by: Sherry 
Reviewed-by: Tony Cheng 
Acked-by: Rodrigo Siqueira 
---
 .../drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index 9f56887029ca..90c85b3e859b 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -939,12 +939,15 @@ void dce110_edp_backlight_control(
return;
}
 
-   if (enable && link->panel_cntl &&
-   
link->panel_cntl->funcs->is_panel_backlight_on(link->panel_cntl)) {
-   DC_LOG_HW_RESUME_S3(
-   "%s: panel already powered up. Do nothing.\n",
+   if (link->panel_cntl) {
+   bool is_backlight_on = 
link->panel_cntl->funcs->is_panel_backlight_on(link->panel_cntl);
+
+   if ((enable && is_backlight_on) || (!enable && 
!is_backlight_on)) {
+   DC_LOG_HW_RESUME_S3(
+   "%s: panel already powered up/off. Do 
nothing.\n",
__func__);
-   return;
+   return;
+   }
}
 
/* Send VBIOS command to control eDP panel backlight */
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 03/18] drm/amd/display: Update panel register

2020-11-20 Thread Rodrigo Siqueira
From: Chris Park 

[Why]
Incorrect panel register settings are applied for power sequence because
the register macro is not defined in resource.

[How]
Implement same register space to future resource files.

Signed-off-by: Chris Park 
Reviewed-by: Joshua Aberback 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index be58134a7954..9ce9d9603942 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -521,6 +521,7 @@ static const struct dcn10_link_enc_hpd_registers 
link_enc_hpd_regs[] = {
 [id] = {\
LE_DCN301_REG_LIST(id), \
UNIPHY_DCN2_REG_LIST(phyid), \
+   SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
 }
 
 static const struct dce110_aux_registers_shift aux_shift = {
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 14/18] drm/amd/display: Add GAMCOR memory shutdown support

2020-11-20 Thread Rodrigo Siqueira
From: Jacky Liao 

[Why]
The GAMCOR memory blocks should be powered down when they're not in use.
This will reduce power consumption.

[How]
Write to GAMCOR_MEM_PWR_FORCE to put memory to shutdown
when GAMCOR is not used.

Signed-off-by: Jacky Liao 
Reviewed-by: Eric Yang 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp_cm.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp_cm.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp_cm.c
index 9ab63c72f21c..9da66e491116 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp_cm.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp_cm.c
@@ -136,9 +136,13 @@ static void dpp3_power_on_gamcor_lut(
uint32_t power_status;
struct dcn3_dpp *dpp = TO_DCN30_DPP(dpp_base);
 
-
-   REG_SET(CM_MEM_PWR_CTRL, 0,
-   GAMCOR_MEM_PWR_DIS, power_on == true ? 0:1);
+   if (dpp_base->ctx->dc->debug.enable_mem_low_power.bits.cm) {
+   REG_UPDATE(CM_MEM_PWR_CTRL, GAMCOR_MEM_PWR_FORCE, power_on ? 0 
: 3);
+   if (power_on)
+   REG_WAIT(CM_MEM_PWR_STATUS, GAMCOR_MEM_PWR_STATE, 0, 1, 
5);
+   } else
+   REG_SET(CM_MEM_PWR_CTRL, 0,
+   GAMCOR_MEM_PWR_DIS, power_on == true ? 0:1);
 
REG_GET(CM_MEM_PWR_STATUS, GAMCOR_MEM_PWR_STATE, &power_status);
if (power_status != 0)
@@ -229,6 +233,8 @@ bool dpp3_program_gamcor_lut(
 
if (params == NULL) { //bypass if we have no pwl data
REG_SET(CM_GAMCOR_CONTROL, 0, CM_GAMCOR_MODE, 0);
+   if (dpp_base->ctx->dc->debug.enable_mem_low_power.bits.cm)
+   dpp3_power_on_gamcor_lut(dpp_base, false);
return false;
}
dpp3_power_on_gamcor_lut(dpp_base, true);
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 04/18] drm/amd/display: Enable stutter for dcn3.01.

2020-11-20 Thread Rodrigo Siqueira
From: Yongqiang Sun 

[Why & How]
Enable stutter for DCN3.01.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Harry Wentland 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index 9ce9d9603942..5f97808bb423 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -855,7 +855,6 @@ static const struct dc_debug_options debug_defaults_drv = {
.disable_clock_gate = true,
.disable_pplib_clock_request = true,
.disable_pplib_wm_range = true,
-   .disable_stutter = true,
.pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
.force_single_disp_pipe_split = false,
.disable_dcc = DCC_ENABLE,
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 05/18] drm/amd/display: Add DMCU memory low power support

2020-11-20 Thread Rodrigo Siqueira
From: Jacky Liao 

[Why]
On some platforms, DMCU is no longer used. In these cases, some DMCU
memory should be completely powered off to save power.

[How]
1. Set DMCU_ERAM_MEM_PWR_FORCE to shutdown memory when DMCU is not in
   use
2. Added a debug option to allow this behaviour to be turned off
3. Set all memory low power debug options to off first, to not
   immediately cause problems

Signed-off-by: Jacky Liao 
Reviewed-by: Eric Yang 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dc.h| 2 ++
 drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h | 7 +--
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 7 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 443b1f1ad546..b170e653febc 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -420,6 +420,8 @@ struct dc_bw_validation_profile {
 union mem_low_power_enable_options {
struct {
bool i2c: 1;
+   bool dmcu: 1;
+   bool cm: 1;
bool mpc: 1;
bool optc: 1;
} bits;
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
index ad0ae1f7b513..fe31abfa6c85 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
@@ -597,6 +597,7 @@ struct dce_hwseq_registers {
uint32_t AZALIA_CONTROLLER_CLOCK_GATING;
uint32_t HPO_TOP_CLOCK_CONTROL;
uint32_t ODM_MEM_PWR_CTRL3;
+   uint32_t DMU_MEM_PWR_CNTL;
 };
  /* set field name */
 #define HWS_SF(blk_name, reg_name, field_name, post_fix)\
@@ -836,7 +837,8 @@ struct dce_hwseq_registers {
HWSEQ_DCN2_MASK_SH_LIST(mask_sh), \
HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh), \
HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_UNASSIGNED_PWR_MODE, mask_sh), \
-   HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh)
+   HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh), \
+   HWS_SF(, DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, mask_sh)
 
 #define HWSEQ_DCN301_MASK_SH_LIST(mask_sh)\
HWSEQ_DCN_MASK_SH_LIST(mask_sh), \
@@ -1046,7 +1048,8 @@ struct dce_hwseq_registers {
type D4VGA_MODE_ENABLE; \
type AZALIA_AUDIO_DTO_MODULE; \
type ODM_MEM_UNASSIGNED_PWR_MODE; \
-   type ODM_MEM_VBLANK_PWR_MODE;
+   type ODM_MEM_VBLANK_PWR_MODE; \
+   type DMCU_ERAM_MEM_PWR_FORCE;
 
 #define HWSEQ_DCN3_REG_FIELD_LIST(type) \
type HPO_HDMISTREAMCLK_GATE_DIS;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
index e76d6ab8d93a..7a7efe9ea961 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
@@ -462,6 +462,13 @@ void dcn30_init_hw(struct dc *dc)
hws->funcs.disable_vga(dc->hwseq);
}
 
+   if (dc->debug.enable_mem_low_power.bits.dmcu) {
+   // Force ERAM to shutdown if DMCU is not enabled
+   if (dc->debug.disable_dmcu || dc->config.disable_dmcu) {
+   REG_UPDATE(DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, 
3);
+   }
+   }
+
// Set default OPTC memory power states
if (dc->debug.enable_mem_low_power.bits.optc) {
// Shutdown when unassigned and light sleep in VBLANK
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 18/18] drm/amd/display: init soc bounding box for dcn3.01.

2020-11-20 Thread Rodrigo Siqueira
From: Yongqiang Sun 

[Why & How]
Update init soc bounding box and bw bounding box for DCN3.01.
Remove pp smu interface which isn't used.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Rodrigo Siqueira 
---
 .../amd/display/dc/dcn301/dcn301_resource.c   | 118 +-
 1 file changed, 60 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index 4b029631a22c..124ae5253d4b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -1345,9 +1345,6 @@ static void dcn301_destruct(struct dcn301_resource_pool 
*pool)
 
if (pool->base.dccg != NULL)
dcn_dccg_destroy(&pool->base.dccg);
-
-   if (pool->base.pp_smu != NULL)
-   dcn301_pp_smu_destroy(&pool->base.pp_smu);
 }
 
 struct hubp *dcn301_hubp_create(
@@ -1600,41 +1597,25 @@ static bool init_soc_bounding_box(struct dc *dc,
}
}
 
-   if (pool->base.pp_smu) {
-   struct pp_smu_nv_clock_table max_clocks = {0};
-   unsigned int uclk_states[8] = {0};
-   unsigned int num_states = 0;
-   enum pp_smu_status status;
-   bool clock_limits_available = false;
-   bool uclk_states_available = false;
+   loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator;
+   loaded_ip->max_num_dpp = pool->base.pipe_count;
+   dcn20_patch_bounding_box(dc, loaded_bb);
 
-   if (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states) {
-   status = 
(pool->base.pp_smu->nv_funcs.get_uclk_dpm_states)
-   (&pool->base.pp_smu->nv_funcs.pp_smu, 
uclk_states, &num_states);
+   if (!bb && dc->ctx->dc_bios->funcs->get_soc_bb_info) {
+   struct bp_soc_bb_info bb_info = {0};
 
-   uclk_states_available = (status == PP_SMU_RESULT_OK);
-   }
+   if (dc->ctx->dc_bios->funcs->get_soc_bb_info(dc->ctx->dc_bios, 
&bb_info) == BP_RESULT_OK) {
+   if (bb_info.dram_clock_change_latency_100ns > 0)
+   dcn3_01_soc.dram_clock_change_latency_us = 
bb_info.dram_clock_change_latency_100ns * 10;
 
-   if (pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks) 
{
-   status = 
(*pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks)
-   (&pool->base.pp_smu->nv_funcs.pp_smu, 
&max_clocks);
-   /* SMU cannot set DCF clock to anything equal to or 
higher than SOC clock
-*/
-   if (max_clocks.dcfClockInKhz >= 
max_clocks.socClockInKhz)
-   max_clocks.dcfClockInKhz = 
max_clocks.socClockInKhz - 1000;
-   clock_limits_available = (status == PP_SMU_RESULT_OK);
-   }
+   if (bb_info.dram_sr_enter_exit_latency_100ns > 0)
+   dcn3_01_soc.sr_enter_plus_exit_time_us = 
bb_info.dram_sr_enter_exit_latency_100ns * 10;
 
-   if (clock_limits_available && uclk_states_available && 
num_states)
-   dcn20_update_bounding_box(dc, loaded_bb, &max_clocks, 
uclk_states, num_states);
-   else if (clock_limits_available)
-   dcn20_cap_soc_clocks(loaded_bb, max_clocks);
+   if (bb_info.dram_sr_exit_latency_100ns > 0)
+   dcn3_01_soc.sr_exit_time_us = 
bb_info.dram_sr_exit_latency_100ns * 10;
+   }
}
 
-   loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator;
-   loaded_ip->max_num_dpp = pool->base.pipe_count;
-   dcn20_patch_bounding_box(dc, loaded_bb);
-
return true;
 }
 
@@ -1682,36 +1663,58 @@ static void set_wm_ranges(
pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges);
 }
 
-static struct pp_smu_funcs *dcn301_pp_smu_create(struct dc_context *ctx)
+static void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params 
*bw_params)
 {
-   struct pp_smu_funcs *pp_smu = kzalloc(sizeof(*pp_smu), GFP_KERNEL);
-
-   if (!pp_smu)
-   return pp_smu;
-
-   if (!IS_FPGA_MAXIMUS_DC(ctx->dce_environment) && 
!IS_DIAG_DC(ctx->dce_environment)) {
-   dm_pp_get_funcs(ctx, pp_smu);
-
-   /* TODO: update once we have n21 smu*/
-   if (pp_smu->ctx.ver != PP_SMU_VER_NV)
-   pp_smu = memset(pp_smu, 0, sizeof(struct pp_smu_funcs));
-   }
-
-   return pp_smu;
-}
+   struct dcn301_resource_pool *pool = TO_DCN301_RES_POOL(dc->res_pool);
+   struct clk_limit_table *clk_table = &bw_params->clk_table;
+   struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
+   unsigned int i, closest_

[PATCH 17/18] drm/amd/display: To update backlight restore mechanism

2020-11-20 Thread Rodrigo Siqueira
From: Camille Cho 

[Why]
Cached backlight is never being updated since panel_cntl specific
registers were moved from abm to panel_cntl.

[How]
Update cached backlight in set_abm_immediate_disable as what we used to
do. Also, update the priority of backlight restore mechanism so that
cached backlight has the highest priority since it is always correct.

Signed-off-by: Camille Cho 
Reviewed-by: Anthony Koo 
Acked-by: Rodrigo Siqueira 
---
 .../drm/amd/display/dc/dce/dce_panel_cntl.c   | 36 +--
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c|  4 ++-
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c
index 74f7619d4154..761fdfc1f5bd 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c
@@ -108,25 +108,17 @@ static uint32_t dce_panel_cntl_hw_init(struct panel_cntl 
*panel_cntl)
 */
REG_GET(BL_PWM_CNTL, BL_ACTIVE_INT_FRAC_CNT, &value);
 
-   if (value == 0 || value == 1) {
-   if (panel_cntl->stored_backlight_registers.BL_PWM_CNTL != 0) {
-   REG_WRITE(BL_PWM_CNTL,
-   
panel_cntl->stored_backlight_registers.BL_PWM_CNTL);
-   REG_WRITE(BL_PWM_CNTL2,
-   
panel_cntl->stored_backlight_registers.BL_PWM_CNTL2);
-   REG_WRITE(BL_PWM_PERIOD_CNTL,
-   
panel_cntl->stored_backlight_registers.BL_PWM_PERIOD_CNTL);
-   REG_UPDATE(PWRSEQ_REF_DIV,
-   BL_PWM_REF_DIV,
-   
panel_cntl->stored_backlight_registers.LVTMA_PWRSEQ_REF_DIV_BL_PWM_REF_DIV);
-   } else {
-   /* TODO: Note: This should not really happen since VBIOS
-* should have initialized PWM registers on boot.
-*/
-   REG_WRITE(BL_PWM_CNTL, 0xC000FA00);
-   REG_WRITE(BL_PWM_PERIOD_CNTL, 0x000C0FA0);
-   }
-   } else {
+   if (panel_cntl->stored_backlight_registers.BL_PWM_CNTL != 0) {
+   REG_WRITE(BL_PWM_CNTL,
+   
panel_cntl->stored_backlight_registers.BL_PWM_CNTL);
+   REG_WRITE(BL_PWM_CNTL2,
+   
panel_cntl->stored_backlight_registers.BL_PWM_CNTL2);
+   REG_WRITE(BL_PWM_PERIOD_CNTL,
+   
panel_cntl->stored_backlight_registers.BL_PWM_PERIOD_CNTL);
+   REG_UPDATE(PWRSEQ_REF_DIV,
+   BL_PWM_REF_DIV,
+   
panel_cntl->stored_backlight_registers.LVTMA_PWRSEQ_REF_DIV_BL_PWM_REF_DIV);
+   } else if ((value != 0) && (value != 1)) {
panel_cntl->stored_backlight_registers.BL_PWM_CNTL =
REG_READ(BL_PWM_CNTL);
panel_cntl->stored_backlight_registers.BL_PWM_CNTL2 =
@@ -136,6 +128,12 @@ static uint32_t dce_panel_cntl_hw_init(struct panel_cntl 
*panel_cntl)
 
REG_GET(PWRSEQ_REF_DIV, BL_PWM_REF_DIV,

&panel_cntl->stored_backlight_registers.LVTMA_PWRSEQ_REF_DIV_BL_PWM_REF_DIV);
+   } else {
+   /* TODO: Note: This should not really happen since VBIOS
+* should have initialized PWM registers on boot.
+*/
+   REG_WRITE(BL_PWM_CNTL, 0x8000FA00);
+   REG_WRITE(BL_PWM_PERIOD_CNTL, 0x000C0FA0);
}
 
// Have driver take backlight control
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
index 1fa193078803..96ee0b82f458 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
@@ -171,9 +171,11 @@ void dcn21_set_abm_immediate_disable(struct pipe_ctx 
*pipe_ctx)
return;
}
 
-   if (abm && panel_cntl)
+   if (abm && panel_cntl) {
dmub_abm_set_pipe(abm, otg_inst, 
SET_ABM_PIPE_IMMEDIATELY_DISABLE,
panel_cntl->inst);
+   panel_cntl->funcs->store_backlight_level(panel_cntl);
+   }
 }
 
 void dcn21_set_pipe(struct pipe_ctx *pipe_ctx)
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 10/18] drm/amd/display: Add BLNDGAM memory shutdown support

2020-11-20 Thread Rodrigo Siqueira
From: Jacky Liao 

[Why]
The BLNDGAM memory blocks should be powered down when they're not in
use. This will reduce power consumption.

[How]
1. Write to BLNDGAM_MEM_PWR_FORCE to put memory to shutdown when BLNDGAM
   is not used.
2. Added a debug option to allow this behaviour to be turned off

Signed-off-by: Jacky Liao 
Reviewed-by: Eric Yang 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c | 13 ++---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h |  4 +++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
index 29231528f052..052bab3e5e8e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
@@ -500,9 +500,14 @@ static void dpp3_power_on_blnd_lut(
 {
struct dcn3_dpp *dpp = TO_DCN30_DPP(dpp_base);
 
-   REG_SET(CM_MEM_PWR_CTRL, 0,
-   BLNDGAM_MEM_PWR_FORCE, power_on == true ? 0:1);
-
+   if (dpp_base->ctx->dc->debug.enable_mem_low_power.bits.cm) {
+   REG_UPDATE(CM_MEM_PWR_CTRL, BLNDGAM_MEM_PWR_FORCE, power_on ? 0 
: 3);
+   if (power_on)
+   REG_WAIT(CM_MEM_PWR_STATUS, BLNDGAM_MEM_PWR_STATE, 0, 
1, 5);
+   } else {
+   REG_SET(CM_MEM_PWR_CTRL, 0,
+   BLNDGAM_MEM_PWR_FORCE, power_on == true ? 0 : 
1);
+   }
 }
 
 static void dpp3_configure_blnd_lut(
@@ -675,6 +680,8 @@ bool dpp3_program_blnd_lut(
 
if (params == NULL) {
REG_SET(CM_BLNDGAM_CONTROL, 0, CM_BLNDGAM_MODE, 0);
+   if (dpp_base->ctx->dc->debug.enable_mem_low_power.bits.cm)
+   dpp3_power_on_blnd_lut(dpp_base, false);
return false;
}
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h
index 81bf2ecc2831..2ae5e1f93dd4 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.h
@@ -343,6 +343,7 @@
TF_SF(DSCL0_DSCL_MEM_PWR_CTRL, LUT_MEM_PWR_FORCE, mask_sh)
 
 #define DPP_REG_LIST_SH_MASK_DCN30_UPDATED(mask_sh)\
+   TF_SF(CM0_CM_MEM_PWR_STATUS, BLNDGAM_MEM_PWR_STATE, mask_sh), \
TF_SF(CM0_CM_BLNDGAM_CONTROL, CM_BLNDGAM_MODE, mask_sh), \
TF_SF(CM0_CM_BLNDGAM_CONTROL, CM_BLNDGAM_MODE_CURRENT, mask_sh), \
TF_SF(CM0_CM_BLNDGAM_CONTROL, CM_BLNDGAM_SELECT_CURRENT, mask_sh), \
@@ -446,7 +447,8 @@
type CM_BLNDGAM_MODE_CURRENT; \
type CM_BLNDGAM_SELECT_CURRENT; \
type CM_BLNDGAM_SELECT; \
-   type GAMCOR_MEM_PWR_STATE
+   type GAMCOR_MEM_PWR_STATE; \
+   type BLNDGAM_MEM_PWR_STATE
 
 struct dcn3_dpp_shift {
DPP_REG_FIELD_LIST_DCN3(uint8_t);
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 15/18] drm/amd/display: enable pipe power gating by default

2020-11-20 Thread Rodrigo Siqueira
From: Sung Joon Kim 

[why]
ASIC requirement.

[how]
Make disable_*_power_gate to false.

Signed-off-by: Sung Joon Kim 
Reviewed-by: Charlene Liu 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index 5f97808bb423..4b029631a22c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -850,8 +850,8 @@ static const struct dc_debug_options debug_defaults_drv = {
.force_abm_enable = false,
.timing_trace = false,
.clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
+   .disable_dpp_power_gate = false,
+   .disable_hubp_power_gate = false,
.disable_clock_gate = true,
.disable_pplib_clock_request = true,
.disable_pplib_wm_range = true,
@@ -873,8 +873,8 @@ static const struct dc_debug_options debug_defaults_diags = 
{
.force_abm_enable = false,
.timing_trace = true,
.clock_trace = true,
-   .disable_dpp_power_gate = true,
-   .disable_hubp_power_gate = true,
+   .disable_dpp_power_gate = false,
+   .disable_hubp_power_gate = false,
.disable_clock_gate = true,
.disable_pplib_clock_request = true,
.disable_pplib_wm_range = true,
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 07/18] drm/amd/display: expose clk_mgr functions for reuse

2020-11-20 Thread Rodrigo Siqueira
From: Eric Yang 

Signed-off-by: Eric Yang 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Rodrigo Siqueira 
---
 .../gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c |  8 
 .../gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.h | 10 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c
index 98cbb0ac095c..9a8e66bba9c0 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c
@@ -32,9 +32,9 @@
 // For dcn20_update_clocks_update_dpp_dto
 #include "dcn20/dcn20_clk_mgr.h"
 
-#include "vg_clk_mgr.h"
 
-#include "dcn301_smu.h"
+
+#include "vg_clk_mgr.h"
 #include "reg_helper.h"
 #include "core_types.h"
 #include "dm_helpers.h"
@@ -631,7 +631,7 @@ static unsigned int find_dcfclk_for_voltage(const struct 
vg_dpm_clocks *clock_ta
return 0;
 }
 
-static void vg_clk_mgr_helper_populate_bw_params(
+void vg_clk_mgr_helper_populate_bw_params(
struct clk_mgr_internal *clk_mgr,
struct integrated_info *bios_info,
const struct vg_dpm_clocks *clock_table)
@@ -709,7 +709,7 @@ static struct vg_dpm_clocks dummy_clocks = {
 
 static struct watermarks dummy_wms = { 0 };
 
-static void vg_get_dpm_table_from_smu(struct clk_mgr_internal *clk_mgr,
+void vg_get_dpm_table_from_smu(struct clk_mgr_internal *clk_mgr,
struct smu_dpm_clks *smu_dpm_clks)
 {
struct vg_dpm_clocks *table = smu_dpm_clks->dpm_clks;
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.h 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.h
index 80497df20ba7..b5115b3123a1 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.h
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.h
@@ -39,5 +39,15 @@ void vg_clk_mgr_construct(struct dc_context *ctx,
 
 void vg_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr);
 
+#include "dcn301_smu.h"
 void vg_notify_wm_ranges(struct clk_mgr *clk_mgr_base);
+
+void vg_get_dpm_table_from_smu(struct clk_mgr_internal *clk_mgr,
+   struct smu_dpm_clks *smu_dpm_clks);
+
+void vg_clk_mgr_helper_populate_bw_params(
+   struct clk_mgr_internal *clk_mgr,
+   struct integrated_info *bios_info,
+   const struct vg_dpm_clocks *clock_table);
+
 #endif //__VG_CLK_MGR_H__
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 06/18] drm/amd/display: intermittent underflow observed when PIP is toggled in Full screen

2020-11-20 Thread Rodrigo Siqueira
From: Tashfique Abdullah 

[Why]
The MPCC may change and request data when the pipes are switching from 2
to 1 or 1 to 2. During the switch there is a possibility of underflow
and flicker/missing data.

[How]
During VBlank the MPCC won't request data. The trick is to delay and
wait on VBlank, ONLY when pipes are either turning on or off, right
before MPCC is reset for the pipes.

Signed-off-by: Tashfique Abdullah 
Reviewed-by: Aric Cyr 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index b9c20e30d99d..abcb06044e6e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -1695,6 +1695,15 @@ void dcn20_program_front_end_for_ctx(
&& context->res_ctx.pipe_ctx[i].stream)
hws->funcs.blank_pixel_data(dc, 
&context->res_ctx.pipe_ctx[i], true);
 
+   /* wait for outstanding pending changes before adding or removing 
planes */
+   for (i = 0; i < dc->res_pool->pipe_count; i++) {
+   if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable ||
+   
context->res_ctx.pipe_ctx[i].update_flags.bits.enable) {
+   dc->hwss.wait_for_pending_cleared(dc, context);
+   break;
+   }
+   }
+
/* Disconnect mpcc */
for (i = 0; i < dc->res_pool->pipe_count; i++)
if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 13/18] drm/amd/display: remove macro which is in header already

2020-11-20 Thread Rodrigo Siqueira
From: Yongqiang Sun 

[Why & How]
Remove temp macro since the enum is in header file already.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
index bb6b546ec6d9..b2a712c7e469 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
@@ -65,11 +65,6 @@
GENERIC_OBJECT_ID_BRACKET_LAYOUT << OBJECT_ID_SHIFT)
 #endif /* GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2 */
 
-
-//TODO: Remove this temp define after atomfirmware.h is updated.
-#define  ATOM_DISP_CONNECTOR_CAPS_RECORD_TYPE 23
-
-
 #define DC_LOGGER \
bp->base.ctx->logger
 
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 16/18] drm/amd/display: 3.2.113

2020-11-20 Thread Rodrigo Siqueira
From: Aric Cyr 

Signed-off-by: Aric Cyr 
Reviewed-by: Aric Cyr 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 115468d3f793..68a192e64418 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -42,7 +42,7 @@
 #include "inc/hw/dmcu.h"
 #include "dml/display_mode_lib.h"
 
-#define DC_VER "3.2.112"
+#define DC_VER "3.2.113"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 02/18] drm/amd/display: Source minimum HBlank support

2020-11-20 Thread Rodrigo Siqueira
From: Ashley Thomas 

[Why]
Some sink devices wish to have access to the minimum HBlank supported by
the ASIC.

[How]
Make the ASIC minimum HBlank available in Source Device information
address 0x340.

Signed-off-by: Ashley Thomas 
Reviewed-by: Anthony Koo 
Reviewed-by: Wenjing Liu 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index d15220a4eeb6..be58134a7954 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -1761,6 +1761,7 @@ static bool dcn301_resource_construct(
dc->caps.i2c_speed_in_khz = 100;
dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a enabled by default*/
dc->caps.max_cursor_size = 256;
+   dc->caps.min_horizontal_blanking_period = 80;
dc->caps.dmdata_alloc_size = 2048;
dc->caps.max_slave_planes = 1;
dc->caps.is_apu = true;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
index 15ffd8a21e4e..87fe84a06301 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
@@ -1308,6 +1308,7 @@ static bool dcn302_resource_construct(
dc->caps.i2c_speed_in_khz = 100;
dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a applied by derfault*/
dc->caps.max_cursor_size = 256;
+   dc->caps.min_horizontal_blanking_period = 80;
dc->caps.dmdata_alloc_size = 2048;
 
dc->caps.max_slave_planes = 1;
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 11/18] drm/amd/display: Add internal display info

2020-11-20 Thread Rodrigo Siqueira
From: Yongqiang Sun 

[Why & How]
Get internal display info from vbios and pass it to dmub fw to determine
if multiple display optmization is needed.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Anthony Koo 
Acked-by: Aric Cyr 
Acked-by: Rodrigo Siqueira 
---
 .../drm/amd/display/dc/bios/bios_parser2.c| 73 +++
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  7 ++
 .../gpu/drm/amd/display/dc/dc_bios_types.h|  5 ++
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  1 +
 .../amd/display/include/bios_parser_types.h   |  5 ++
 drivers/gpu/drm/amd/include/atomfirmware.h|  1 +
 6 files changed, 92 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
index 43922fa358a9..bb6b546ec6d9 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
@@ -65,6 +65,11 @@
GENERIC_OBJECT_ID_BRACKET_LAYOUT << OBJECT_ID_SHIFT)
 #endif /* GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2 */
 
+
+//TODO: Remove this temp define after atomfirmware.h is updated.
+#define  ATOM_DISP_CONNECTOR_CAPS_RECORD_TYPE 23
+
+
 #define DC_LOGGER \
bp->base.ctx->logger
 
@@ -1453,6 +1458,72 @@ static struct atom_encoder_caps_record 
*get_encoder_cap_record(
return NULL;
 }
 
+static struct atom_disp_connector_caps_record *get_disp_connector_caps_record(
+   struct bios_parser *bp,
+   struct atom_display_object_path_v2 *object)
+{
+   struct atom_common_record_header *header;
+   uint32_t offset;
+
+   if (!object) {
+   BREAK_TO_DEBUGGER(); /* Invalid object */
+   return NULL;
+   }
+
+   offset = object->disp_recordoffset + bp->object_info_tbl_offset;
+
+   for (;;) {
+   header = GET_IMAGE(struct atom_common_record_header, offset);
+
+   if (!header)
+   return NULL;
+
+   offset += header->record_size;
+
+   if (header->record_type == LAST_RECORD_TYPE ||
+   !header->record_size)
+   break;
+
+   if (header->record_type != ATOM_DISP_CONNECTOR_CAPS_RECORD_TYPE)
+   continue;
+
+   if (sizeof(struct atom_disp_connector_caps_record) <=
+   header->record_size)
+   return (struct atom_disp_connector_caps_record *)header;
+   }
+
+   return NULL;
+}
+
+static enum bp_result bios_parser_get_disp_connector_caps_info(
+   struct dc_bios *dcb,
+   struct graphics_object_id object_id,
+   struct bp_disp_connector_caps_info *info)
+{
+   struct bios_parser *bp = BP_FROM_DCB(dcb);
+   struct atom_display_object_path_v2 *object;
+   struct atom_disp_connector_caps_record *record = NULL;
+
+   if (!info)
+   return BP_RESULT_BADINPUT;
+
+   object = get_bios_object(bp, object_id);
+
+   if (!object)
+   return BP_RESULT_BADINPUT;
+
+   record = get_disp_connector_caps_record(bp, object);
+   if (!record)
+   return BP_RESULT_NORECORD;
+
+   info->INTERNAL_DISPLAY = (record->connectcaps & 
ATOM_CONNECTOR_CAP_INTERNAL_DISPLAY)
+   ? 1 : 0;
+   info->INTERNAL_DISPLAY_BL = (record->connectcaps & 
ATOM_CONNECTOR_CAP_INTERNAL_DISPLAY_BL)
+   
? 1 : 0;
+
+   return BP_RESULT_OK;
+}
+
 static enum bp_result get_vram_info_v23(
struct bios_parser *bp,
struct dc_vram_info *info)
@@ -2461,6 +2532,8 @@ static const struct dc_vbios_funcs vbios_funcs = {
.enable_lvtma_control = bios_parser_enable_lvtma_control,
 
.get_soc_bb_info = bios_parser_get_soc_bb_info,
+
+   .get_disp_connector_caps_info = 
bios_parser_get_disp_connector_caps_info,
 };
 
 static bool bios_parser2_construct(
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index 5790affc7d61..311a0decd005 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -1368,6 +1368,7 @@ static bool dc_link_construct(struct dc_link *link,
struct integrated_info info = {{{ 0 }}};
struct dc_bios *bios = init_params->dc->ctx->dc_bios;
const struct dc_vbios_funcs *bp_funcs = bios->funcs;
+   struct bp_disp_connector_caps_info disp_connect_caps_info = { 0 };
 
DC_LOGGER_INIT(dc_ctx->logger);
 
@@ -1388,6 +1389,12 @@ static bool dc_link_construct(struct dc_link *link,
link->link_id =
bios->funcs->get_connector_id(bios, 
init_params->connector_index);
 
+
+   if (bios->funcs->get_disp_connector_caps_info) {
+   bios->funcs->get_disp_connector_caps_info(bios, link->link_id, 
&

[PATCH 09/18] drm/amd/display: Clear sticky vsc sdp error bit

2020-11-20 Thread Rodrigo Siqueira
From: Wyatt Wood 

[Why]
Need to clear sticky error bits generated during hpd irq from receiver.

[How]
Clear sticky vsc sdp error bit.

Signed-off-by: Wyatt Wood 
Reviewed-by: Anthony Koo 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 1dfcaf1acbfc..93fbc646f53b 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2570,7 +2570,8 @@ static bool handle_hpd_irq_psr_sink(struct dc_link *link)
psr_sink_psr_status.raw = dpcdbuf[2];
 
if (psr_error_status.bits.LINK_CRC_ERROR ||
-   psr_error_status.bits.RFB_STORAGE_ERROR) {
+   psr_error_status.bits.RFB_STORAGE_ERROR ||
+   psr_error_status.bits.VSC_SDP_ERROR) {
/* Acknowledge and clear error bits */
dm_helpers_dp_write_dpcd(
link->ctx,
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 12/18] drm/amd/display: Check multiple internal displays for power optimization.

2020-11-20 Thread Rodrigo Siqueira
From: Yongqiang Sun 

[Why & How]
only apply multiple display power optimization in case there are more
than one internal display.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Anthony Koo 
Acked-by: Aric Cyr 
Acked-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 16 
 drivers/gpu/drm/amd/display/dc/dc.h  |  1 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 28b856e2686d..903353389edb 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -149,6 +149,20 @@ static void destroy_links(struct dc *dc)
}
 }
 
+static uint32_t get_num_of_internal_disp(struct dc_link **links, uint32_t 
num_links)
+{
+   int i;
+   uint32_t count = 0;
+
+   for (i = 0; i < num_links; i++) {
+   if (links[i]->connector_signal == SIGNAL_TYPE_EDP ||
+   links[i]->is_internal_display)
+   count++;
+   }
+
+   return count;
+}
+
 static bool create_links(
struct dc *dc,
uint32_t num_virtual_links)
@@ -250,6 +264,8 @@ static bool create_links(
virtual_link_encoder_construct(link->link_enc, &enc_init);
}
 
+   dc->caps.num_of_internal_disp = get_num_of_internal_disp(dc->links, 
dc->link_count);
+
return true;
 
 failed_alloc:
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index b170e653febc..115468d3f793 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -169,6 +169,7 @@ struct dc_caps {
bool psp_setup_panel_mode;
bool extended_aux_timeout_support;
bool dmcub_support;
+   uint32_t num_of_internal_disp;
enum dp_protocol_version max_dp_protocol_version;
struct dc_plane_cap planes[MAX_PLANES];
struct dc_color_caps color;
-- 
2.29.2

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 1/4] drm/amd/display: add cursor FB size check

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 3:19 PM Simon Ser  wrote:
>
> This patch expands the cursor checks added in "drm/amd/display: add basic
> atomic check for cursor plane" to also include a FB size check. Without
> this patch, setting a FB smaller than max_cursor_size with an invalid
> width would result in amdgpu error messages and a fallback to a 64-byte
> width:
>
> [drm:hubp1_cursor_set_attributes [amdgpu]] *ERROR* Invalid cursor pitch 
> of 100. Only 64/128/256 is supported on DCN.
>
> Note that DC uses the word "pitch" when actually checking the FB width.
> Indeed, the function handle_cursor_update does this:
>
> attributes.pitch = attributes.width;
>
> In my tests, the cursor FB actually had a pitch of 512 bytes.
>
> Signed-off-by: Simon Ser 
> Reported-by: Pierre-Loup A. Griffais 
> Cc: Alex Deucher 
> Cc: Harry Wentland 
> Cc: Nicholas Kazlauskas 
> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 +++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 2855bb918535..bd63f1c4ae79 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -8902,6 +8902,28 @@ static int dm_update_plane_state(struct dc *dc,
> return -EINVAL;
> }
>
> +   if (new_plane_state->fb) {
> +   if (new_plane_state->fb->width > 
> new_acrtc->max_cursor_width ||
> +   new_plane_state->fb->height > 
> new_acrtc->max_cursor_height) {
> +   DRM_DEBUG_ATOMIC("Bad cursor FB size %dx%d\n",
> +new_plane_state->fb->width,
> +new_plane_state->fb->height);
> +   return -EINVAL;
> +   }
> +
> +   switch (new_plane_state->fb->width) {
> +   case 64:
> +   case 128:
> +   case 256:
> +   /* FB width is supported by cursor plane */

I'm pretty sure DCE6.x only supports 64 and DCE8-12 only supports 128.
I think only DCN supports 256.

Alex


> +   break;
> +   default:
> +   DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n",
> +new_plane_state->fb->width);
> +   return -EINVAL;
> +   }
> +   }
> +
> return 0;
> }
>
> --
> 2.29.2
>
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 1/4] drm/amd/display: add cursor FB size check

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 3:50 PM Alex Deucher  wrote:
>
> On Fri, Nov 20, 2020 at 3:19 PM Simon Ser  wrote:
> >
> > This patch expands the cursor checks added in "drm/amd/display: add basic
> > atomic check for cursor plane" to also include a FB size check. Without
> > this patch, setting a FB smaller than max_cursor_size with an invalid
> > width would result in amdgpu error messages and a fallback to a 64-byte
> > width:
> >
> > [drm:hubp1_cursor_set_attributes [amdgpu]] *ERROR* Invalid cursor pitch 
> > of 100. Only 64/128/256 is supported on DCN.
> >
> > Note that DC uses the word "pitch" when actually checking the FB width.
> > Indeed, the function handle_cursor_update does this:
> >
> > attributes.pitch = attributes.width;
> >
> > In my tests, the cursor FB actually had a pitch of 512 bytes.
> >
> > Signed-off-by: Simon Ser 
> > Reported-by: Pierre-Loup A. Griffais 
> > Cc: Alex Deucher 
> > Cc: Harry Wentland 
> > Cc: Nicholas Kazlauskas 
> > ---
> >  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 +++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 2855bb918535..bd63f1c4ae79 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -8902,6 +8902,28 @@ static int dm_update_plane_state(struct dc *dc,
> > return -EINVAL;
> > }
> >
> > +   if (new_plane_state->fb) {
> > +   if (new_plane_state->fb->width > 
> > new_acrtc->max_cursor_width ||
> > +   new_plane_state->fb->height > 
> > new_acrtc->max_cursor_height) {
> > +   DRM_DEBUG_ATOMIC("Bad cursor FB size 
> > %dx%d\n",
> > +new_plane_state->fb->width,
> > +
> > new_plane_state->fb->height);
> > +   return -EINVAL;
> > +   }
> > +
> > +   switch (new_plane_state->fb->width) {
> > +   case 64:
> > +   case 128:
> > +   case 256:
> > +   /* FB width is supported by cursor plane */
>
> I'm pretty sure DCE6.x only supports 64 and DCE8-12 only supports 128.
> I think only DCN supports 256.

Nevermind, the check above handles this.

Thanks,

>
> Alex
>
>
> > +   break;
> > +   default:
> > +   DRM_DEBUG_ATOMIC("Bad cursor FB width %d\n",
> > +
> > new_plane_state->fb->width);
> > +   return -EINVAL;
> > +   }
> > +   }
> > +
> > return 0;
> > }
> >
> > --
> > 2.29.2
> >
> >
> > ___
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 0/4] drm/amd/display: add cursor plane checks

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 3:19 PM Simon Ser  wrote:
>
> This series adds checks for all cursor plane properties. This avoids
> accepting configurations that we won't be able to display.
>
> I've tested this series against various scenarios using a hacked up
> wlroots [1].
>
> [1]: https://github.com/emersion/wlroots/commits/amdgpu-cursor-invalid

Series is:
Reviewed-by: Alex Deucher 

>
> Simon Ser (4):
>   drm/amd/display: add cursor FB size check
>   drm/amd/display: disallow cropping for cursor plane
>   drm/amd/display: check cursor scaling
>   drm/amd/display: don't expose rotation prop for cursor plane
>
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 81 +--
>  1 file changed, 75 insertions(+), 6 deletions(-)
>
> --
> 2.29.2
>
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Kees Cook
On Fri, Nov 20, 2020 at 11:51:42AM -0800, Jakub Kicinski wrote:
> On Fri, 20 Nov 2020 11:30:40 -0800 Kees Cook wrote:
> > On Fri, Nov 20, 2020 at 10:53:44AM -0800, Jakub Kicinski wrote:
> > > On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:  
> > > > This series aims to fix almost all remaining fall-through warnings in
> > > > order to enable -Wimplicit-fallthrough for Clang.
> > > > 
> > > > In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> > > > add multiple break/goto/return/fallthrough statements instead of just
> > > > letting the code fall through to the next case.
> > > > 
> > > > Notice that in order to enable -Wimplicit-fallthrough for Clang, this
> > > > change[1] is meant to be reverted at some point. So, this patch helps
> > > > to move in that direction.
> > > > 
> > > > Something important to mention is that there is currently a discrepancy
> > > > between GCC and Clang when dealing with switch fall-through to empty 
> > > > case
> > > > statements or to cases that only contain a break/continue/return
> > > > statement[2][3][4].  
> > > 
> > > Are we sure we want to make this change? Was it discussed before?
> > > 
> > > Are there any bugs Clangs puritanical definition of fallthrough helped
> > > find?
> > > 
> > > IMVHO compiler warnings are supposed to warn about issues that could
> > > be bugs. Falling through to default: break; can hardly be a bug?!  
> > 
> > It's certainly a place where the intent is not always clear. I think
> > this makes all the cases unambiguous, and doesn't impact the machine
> > code, since the compiler will happily optimize away any behavioral
> > redundancy.
> 
> If none of the 140 patches here fix a real bug, and there is no change
> to machine code then it sounds to me like a W=2 kind of a warning.

I'd like to avoid splitting common -W options between default and W=2
just based on the compiler. Getting -Wimplicit-fallthrough enabled found
plenty of bugs, so making sure it works correctly for both compilers
feels justified to me. (This is just a subset of the same C language
short-coming.)

> I think clang is just being annoying here, but if I'm the only one who
> feels this way chances are I'm wrong :)

It's being pretty pedantic, but I don't think it's unreasonable to
explicitly state how every case ends. GCC's silence for the case of
"fall through to a break" doesn't really seem justified.

-- 
Kees Cook
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Miguel Ojeda
Hi Gustavo,

On Fri, Nov 20, 2020 at 7:21 PM Gustavo A. R. Silva
 wrote:
>
> Hi all,
>
> This series aims to fix almost all remaining fall-through warnings in
> order to enable -Wimplicit-fallthrough for Clang.

Thanks for this.

Since this warning is reliable in both/all compilers and we are
eventually getting rid of all the cases, what about going even further
and making it an error right after?

Cheers,
Miguel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 004/141] drm/amdgpu: Fix fall-through warnings for Clang

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 1:24 PM Gustavo A. R. Silva
 wrote:
>
> In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
> warnings by explicitly adding multiple break statements instead of just
> letting the code fall through to the next case.
>
> Link: https://github.com/KSPP/linux/issues/115
> Signed-off-by: Gustavo A. R. Silva 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 1 +
>  drivers/gpu/drm/amd/amdgpu/vi.c| 1 +
>  4 files changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> index 3579565e0eab..98ca6b976b6e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> @@ -8398,6 +8398,7 @@ static int gfx_v10_0_set_priv_inst_fault_state(struct 
> amdgpu_device *adev,
> WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
>PRIV_INSTR_INT_ENABLE,
>state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
> +   break;
> default:
> break;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index 0d8e203b10ef..e61121629b93 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -5683,6 +5683,7 @@ static int gfx_v9_0_set_priv_inst_fault_state(struct 
> amdgpu_device *adev,
> WREG32_FIELD15(GC, 0, CP_INT_CNTL_RING0,
>PRIV_INSTR_INT_ENABLE,
>state == AMDGPU_IRQ_STATE_ENABLE ? 1 : 0);
> +   break;
> default:
> break;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 3ebbddb63705..584b99b80c29 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -502,6 +502,7 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct 
> amdgpu_device *adev,
> WREG32(reg, tmp);
> }
> }
> +   break;
> default:
> break;
> }
> diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
> index 9bcd0eebc6d7..d56b474b3a21 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vi.c
> @@ -1645,6 +1645,7 @@ static int vi_common_set_clockgating_state(void *handle,
> case CHIP_POLARIS12:
> case CHIP_VEGAM:
> vi_common_set_clockgating_state_by_smu(adev, state);
> +   break;
> default:
> break;
> }
> --
> 2.27.0
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 005/141] drm/radeon: Fix fall-through warnings for Clang

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 1:24 PM Gustavo A. R. Silva
 wrote:
>
> In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
> warnings by explicitly adding multiple fallthrough pseudo-keyword macros,
> as replacement for /* fall through */ comments.
>
> Notice that Clang doesn't recognize /* fall through */ comments as
> implicit fall-through markings.
>
> Link: https://github.com/KSPP/linux/issues/115
> Signed-off-by: Gustavo A. R. Silva 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/radeon/ci_dpm.c | 2 +-
>  drivers/gpu/drm/radeon/r300.c   | 1 +
>  drivers/gpu/drm/radeon/si_dpm.c | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
> index 886e9959496f..3d0a2e81b2de 100644
> --- a/drivers/gpu/drm/radeon/ci_dpm.c
> +++ b/drivers/gpu/drm/radeon/ci_dpm.c
> @@ -4860,8 +4860,8 @@ static void 
> ci_request_link_speed_change_before_state_change(struct radeon_devic
> case RADEON_PCIE_GEN2:
> if (radeon_acpi_pcie_performance_request(rdev, 
> PCIE_PERF_REQ_PECI_GEN2, false) == 0)
> break;
> +   fallthrough;
>  #endif
> -   /* fall through */
> default:
> pi->force_pcie_gen = ci_get_current_pcie_speed(rdev);
> break;
> diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
> index 73f67bf222e1..213dc49b6322 100644
> --- a/drivers/gpu/drm/radeon/r300.c
> +++ b/drivers/gpu/drm/radeon/r300.c
> @@ -1162,6 +1162,7 @@ static int r300_packet0_check(struct radeon_cs_parser 
> *p,
> /* valid register only on RV530 */
> if (p->rdev->family == CHIP_RV530)
> break;
> +   fallthrough;
> /* fallthrough do not move */
> default:
> goto fail;
> diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
> index d1c73e9db889..d19c08e0ad5a 100644
> --- a/drivers/gpu/drm/radeon/si_dpm.c
> +++ b/drivers/gpu/drm/radeon/si_dpm.c
> @@ -5748,8 +5748,8 @@ static void 
> si_request_link_speed_change_before_state_change(struct radeon_devic
> case RADEON_PCIE_GEN2:
> if (radeon_acpi_pcie_performance_request(rdev, 
> PCIE_PERF_REQ_PECI_GEN2, false) == 0)
> break;
> +   fallthrough;
>  #endif
> -   /* fall through */
> default:
> si_pi->force_pcie_gen = 
> si_get_current_pcie_speed(rdev);
> break;
> --
> 2.27.0
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 028/141] drm/amd/display: Fix fall-through warnings for Clang

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 1:28 PM Gustavo A. R. Silva
 wrote:
>
> In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
> warnings by explicitly adding multiple break statements instead of just
> letting the code fall through to the next case.
>
> Link: https://github.com/KSPP/linux/issues/115
> Signed-off-by: Gustavo A. R. Silva 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/display/dc/bios/bios_parser.c  | 1 +
>  drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 2 ++
>  drivers/gpu/drm/amd/display/dc/core/dc_link.c  | 1 +
>  3 files changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c 
> b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
> index ad394aefa5d9..23a373ca94b5 100644
> --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
> +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
> @@ -1198,6 +1198,7 @@ static enum bp_result 
> bios_parser_get_embedded_panel_info(
> default:
> break;
> }
> +   break;
> default:
> break;
> }
> diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c 
> b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
> index 29d64e7e304f..fd1e64fa8744 100644
> --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
> +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
> @@ -903,6 +903,7 @@ static enum bp_result bios_parser_get_soc_bb_info(
> break;
> case 4:
> result = get_soc_bb_info_v4_4(bp, soc_bb_info);
> +   break;
> default:
> break;
> }
> @@ -1019,6 +1020,7 @@ static enum bp_result 
> bios_parser_get_embedded_panel_info(
> default:
> break;
> }
> +   break;
> default:
> break;
> }
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
> b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> index fec87a2e210c..b9254a87ee73 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
> @@ -1052,6 +1052,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
>
> return false;
> }
> +   break;
> default:
> break;
> }
> --
> 2.27.0
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 078/141] drm/amd/pm: Fix fall-through warnings for Clang

2020-11-20 Thread Alex Deucher
On Fri, Nov 20, 2020 at 1:35 PM Gustavo A. R. Silva
 wrote:
>
> In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple
> of warnings by explicitly adding a break statement instead of letting
> the code fall through to the next case, and a fallthrough pseudo-keyword
> as a replacement for a /* fall through */ comment,
>
> Notice that Clang doesn't recognize /* fall through */ comments as
> implicit fall-through markings.
>
> Link: https://github.com/KSPP/linux/issues/115
> Signed-off-by: Gustavo A. R. Silva 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/pm/powerplay/si_dpm.c  | 2 +-
>  drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c 
> b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> index b5986d19dc08..afa1711c9620 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/si_dpm.c
> @@ -6200,8 +6200,8 @@ static void 
> si_request_link_speed_change_before_state_change(struct amdgpu_devic
> case AMDGPU_PCIE_GEN2:
> if (amdgpu_acpi_pcie_performance_request(adev, 
> PCIE_PERF_REQ_PECI_GEN2, false) == 0)
> break;
> +   fallthrough;
>  #endif
> -   /* fall through */
> default:
> si_pi->force_pcie_gen = 
> si_get_current_pcie_speed(adev);
> break;
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c 
> b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> index c3d2e6dcf62a..7d7d698c7976 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> @@ -2272,6 +2272,7 @@ static int polaris10_update_smc_table(struct pp_hwmgr 
> *hwmgr, uint32_t type)
> break;
> case SMU_BIF_TABLE:
> polaris10_update_bif_smc_table(hwmgr);
> +   break;
> default:
> break;
> }
> --
> 2.27.0
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 00/12] RFC Support hot device unplug in amdgpu

2020-11-20 Thread Andrey Grodzovsky
Until now extracting a card either by physical extraction (e.g. eGPU with 
thunderbolt connection or by emulation through  syfs -> 
/sys/bus/pci/devices/device_id/remove) 
would cause random crashes in user apps. The random crashes in apps were 
mostly due to the app having mapped a device backed BO into its address 
space was still trying to access the BO while the backing device was gone.
To answer this first problem Christian suggested to fix the handling of mapped 
memory in the clients when the device goes away by forcibly unmap all buffers 
the 
user processes has by clearing their respective VMAs mapping the device BOs. 
Then when the VMAs try to fill in the page tables again we check in the fault 
handlerif the device is removed and if so, return an error. This will generate 
a 
SIGBUS to the application which can then cleanly terminate.This indeed was done 
but this in turn created a problem of kernel OOPs were the OOPSes were due to 
the 
fact that while the app was terminating because of the SIGBUSit would trigger 
use 
after free in the driver by calling to accesses device structures that were 
already 
released from the pci remove sequence.This was handled by introducing a 'flush' 
sequence during device removal were we wait for drm file reference to drop to 0 
meaning all user clients directly using this device terminated.

v2:
Based on discussions in the mailing list with Daniel and Pekka [1] and based on 
the document 
produced by Pekka from those discussions [2] the whole approach with returning 
SIGBUS and 
waiting for all user clients having CPU mapping of device BOs to die was 
dropped. 
Instead as per the document suggestion the device structures are kept alive 
until 
the last reference to the device is dropped by user client and in the meanwhile 
all existing and new CPU mappings of the BOs 
belonging to the device directly or by dma-buf import are rerouted to per user 
process dummy rw page.Also, I skipped the 'Requirements for KMS UAPI' section 
of [2] 
since i am trying to get the minimal set of requirements that still give useful 
solution 
to work and this is the'Requirements for Render and Cross-Device UAPI' section 
and so my 
test case is removing a secondary device, which is render only and is not 
involved 
in KMS.

v3:
More updates following comments from v2 such as removing loop to find DRM file 
when rerouting 
page faults to dummy page,getting rid of unnecessary sysfs handling refactoring 
and moving 
prevention of GPU recovery post device unplug from amdgpu to scheduler layer. 
On top of that added unplug support for the IOMMU enabled system.

With these patches I am able to gracefully remove the secondary card using 
sysfs remove hook while glxgears 
is running off of secondary card (DRI_PRIME=1) without kernel oopses or hangs 
and keep working 
with the primary card or soft reset the device without hangs or oopses

TODOs for followup work:
Convert AMDGPU code to use devm (for hw stuff) and drmm (for sw stuff and 
allocations) (Daniel)
Rework AMDGPU sysfs handling using default groups attributes (Greg)
Support plugging the secondary device back after unplug - currently still 
experiencing HW error on plugging back.
Add support for 'Requirements for KMS UAPI' section of [2] - unplugging 
primary, display connected card.

[1] - Discussions during v2 of the patchset 
https://lists.freedesktop.org/archives/amd-gfx/2020-June/050806.html
[2] - drm/doc: device hot-unplug for userspace 
https://www.spinics.net/lists/dri-devel/msg259755.html
[3] - Related gitlab ticket https://gitlab.freedesktop.org/drm/amd/-/issues/1081


Andrey Grodzovsky (12):
  drm: Add dummy page per device or GEM object
  drm: Unamp the entire device address space on device unplug
  drm/ttm: Remap all page faults to per process dummy page.
  drm/ttm: Set dma addr to null after freee
  drm/ttm: Expose ttm_tt_unpopulate for driver use
  drm/sched: Cancel and flush all oustatdning jobs before finish.
  drm/sched: Prevent any job recoveries after device is unplugged.
  drm/amdgpu: Split amdgpu_device_fini into early and late
  drm/amdgpu: Add early fini callback
  drm/amdgpu: Avoid sysfs dirs removal post device unplug
  drm/amdgpu: Register IOMMU topology notifier per device.
  drm/amdgpu: Fix a bunch of sdma code crash post device unplug

 drivers/gpu/drm/amd/amdgpu/amdgpu.h   | 11 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 82 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  7 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 17 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h  |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c   | 24 ---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c   | 12 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c| 10 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h|  2 +
 

[PATCH v3 01/12] drm: Add dummy page per device or GEM object

2020-11-20 Thread Andrey Grodzovsky
Will be used to reroute CPU mapped BO's page faults once
device is removed.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/drm_file.c  |  8 
 drivers/gpu/drm/drm_prime.c | 10 ++
 include/drm/drm_file.h  |  2 ++
 include/drm/drm_gem.h   |  2 ++
 4 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 0ac4566..ff3d39f 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -193,6 +193,12 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
goto out_prime_destroy;
}
 
+   file->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+   if (!file->dummy_page) {
+   ret = -ENOMEM;
+   goto out_prime_destroy;
+   }
+
return file;
 
 out_prime_destroy:
@@ -289,6 +295,8 @@ void drm_file_free(struct drm_file *file)
if (dev->driver->postclose)
dev->driver->postclose(dev, file);
 
+   __free_page(file->dummy_page);
+
drm_prime_destroy_file_private(&file->prime);
 
WARN_ON(!list_empty(&file->event_list));
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1693aa7..987b45c 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -335,6 +335,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
 
ret = drm_prime_add_buf_handle(&file_priv->prime,
dma_buf, *handle);
+
+   if (!ret) {
+   obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+   if (!obj->dummy_page)
+   ret = -ENOMEM;
+   }
+
mutex_unlock(&file_priv->prime.lock);
if (ret)
goto fail;
@@ -1020,6 +1027,9 @@ void drm_prime_gem_destroy(struct drm_gem_object *obj, 
struct sg_table *sg)
dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
dma_buf = attach->dmabuf;
dma_buf_detach(attach->dmabuf, attach);
+
+   __free_page(obj->dummy_page);
+
/* remove the reference */
dma_buf_put(dma_buf);
 }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 716990b..2a011fc 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -346,6 +346,8 @@ struct drm_file {
 */
struct drm_prime_file_private prime;
 
+   struct page *dummy_page;
+
/* private: */
 #if IS_ENABLED(CONFIG_DRM_LEGACY)
unsigned long lock_count; /* DRI1 legacy lock count */
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 337a483..76a97a3 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -311,6 +311,8 @@ struct drm_gem_object {
 *
 */
const struct drm_gem_object_funcs *funcs;
+
+   struct page *dummy_page;
 };
 
 /**
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 02/12] drm: Unamp the entire device address space on device unplug

2020-11-20 Thread Andrey Grodzovsky
Invalidate all BOs CPU mappings once device is removed.

v3: Move the code from TTM into drm_dev_unplug

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 13068fd..d550fd5 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -479,6 +479,9 @@ void drm_dev_unplug(struct drm_device *dev)
synchronize_srcu(&drm_unplug_srcu);
 
drm_dev_unregister(dev);
+
+   /* Clear all CPU mappings pointing to this device */
+   unmap_mapping_range(dev->anon_inode->i_mapping, 0, 0, 1);
 }
 EXPORT_SYMBOL(drm_dev_unplug);
 
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 06/12] drm/sched: Cancel and flush all oustatdning jobs before finish.

2020-11-20 Thread Andrey Grodzovsky
To avoid any possible use after free.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/scheduler/sched_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index da24c4e..c3f0bd0 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -891,6 +891,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
if (sched->thread)
kthread_stop(sched->thread);
 
+   /* Confirm no work left behind accessing device structures */
+   cancel_delayed_work_sync(&sched->work_tdr);
+
sched->ready = false;
 }
 EXPORT_SYMBOL(drm_sched_fini);
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 04/12] drm/ttm: Set dma addr to null after freee

2020-11-20 Thread Andrey Grodzovsky
Fixes oops.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c 
b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index b40a467..b0df328 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -1160,6 +1160,8 @@ void ttm_unmap_and_unpopulate_pages(struct device *dev, 
struct ttm_dma_tt *tt)
dma_unmap_page(dev, tt->dma_address[i], num_pages * PAGE_SIZE,
   DMA_BIDIRECTIONAL);
 
+   tt->dma_address[i] = 0;
+
i += num_pages;
}
ttm_pool_unpopulate(&tt->ttm);
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 03/12] drm/ttm: Remap all page faults to per process dummy page.

2020-11-20 Thread Andrey Grodzovsky
On device removal reroute all CPU mappings to dummy page
per drm_file instance or imported GEM object.

v3:
Remove loop to find DRM file and instead access it
by vma->vm_file->private_data. Move dummy page installation
into a separate function.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 54 +++--
 1 file changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 01693e8..f2dbb93 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -35,6 +35,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -420,23 +422,59 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 }
 EXPORT_SYMBOL(ttm_bo_vm_fault_reserved);
 
+vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf)
+{
+   struct vm_area_struct *vma = vmf->vma;
+   struct ttm_buffer_object *bo = vma->vm_private_data;
+   struct drm_file *file = NULL;
+   struct page *dummy_page = NULL;
+
+   /* We are faulting on imported BO from dma_buf */
+   if (bo->base.dma_buf && bo->base.import_attach) {
+   dummy_page = bo->base.dummy_page;
+   /* We are faulting on local BO */
+   } else {
+   file = vma->vm_file->private_data;
+   dummy_page = file->dummy_page;
+   }
+
+   /* Let do_fault complete the PTE install e.t.c using vmf->page */
+   get_page(dummy_page);
+   vmf->page = dummy_page;
+
+   return 0;
+}
+
 vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
 {
struct vm_area_struct *vma = vmf->vma;
pgprot_t prot;
struct ttm_buffer_object *bo = vma->vm_private_data;
vm_fault_t ret;
+   int idx;
+   struct drm_device *ddev = bo->base.dev;
 
-   ret = ttm_bo_vm_reserve(bo, vmf);
-   if (ret)
-   return ret;
 
-   prot = vma->vm_page_prot;
-   ret = ttm_bo_vm_fault_reserved(vmf, prot, TTM_BO_VM_NUM_PREFAULT, 1);
-   if (ret == VM_FAULT_RETRY && !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT))
-   return ret;
+   if (!drm_dev_enter(ddev, &idx)) {
+   ret = ttm_bo_vm_dummy_page(vmf);
+   if (ret)
+   return ret;
+   } else {
+   ret = ttm_bo_vm_reserve(bo, vmf);
+   if (ret)
+   goto exit;
 
-   dma_resv_unlock(bo->base.resv);
+   prot = vma->vm_page_prot;
+
+   ret = ttm_bo_vm_fault_reserved(vmf, prot, 
TTM_BO_VM_NUM_PREFAULT, 1);
+   if (ret == VM_FAULT_RETRY && !(vmf->flags & 
FAULT_FLAG_RETRY_NOWAIT))
+   goto exit;
+
+   dma_resv_unlock(bo->base.resv);
+
+exit:
+   drm_dev_exit(idx);
+   }
 
return ret;
 }
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 05/12] drm/ttm: Expose ttm_tt_unpopulate for driver use

2020-11-20 Thread Andrey Grodzovsky
It's needed to drop iommu backed pages on device unplug
before device's IOMMU group is released.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/ttm/ttm_tt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 1ccf1ef..29248a5 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -495,3 +495,4 @@ void ttm_tt_unpopulate(struct ttm_tt *ttm)
else
ttm_pool_unpopulate(ttm);
 }
+EXPORT_SYMBOL(ttm_tt_unpopulate);
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 08/12] drm/amdgpu: Split amdgpu_device_fini into early and late

2020-11-20 Thread Andrey Grodzovsky
Some of the stuff in amdgpu_device_fini such as HW interrupts
disable and pending fences finilization must be done right away on
pci_remove while most of the stuff which relates to finilizing and
releasing driver data structures can be kept until
drm_driver.release hook is called, i.e. when the last device
reference is dropped.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c|  7 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 15 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c| 24 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c| 12 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c|  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  3 ++-
 9 files changed, 65 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 83ac06a..6243f6d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1063,7 +1063,9 @@ static inline struct amdgpu_device 
*amdgpu_ttm_adev(struct ttm_bo_device *bdev)
 
 int amdgpu_device_init(struct amdgpu_device *adev,
   uint32_t flags);
-void amdgpu_device_fini(struct amdgpu_device *adev);
+void amdgpu_device_fini_early(struct amdgpu_device *adev);
+void amdgpu_device_fini_late(struct amdgpu_device *adev);
+
 int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev);
 
 void amdgpu_device_vram_access(struct amdgpu_device *adev, loff_t pos,
@@ -1275,6 +1277,8 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev);
 int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
 void amdgpu_driver_postclose_kms(struct drm_device *dev,
 struct drm_file *file_priv);
+void amdgpu_driver_release_kms(struct drm_device *dev);
+
 int amdgpu_device_ip_suspend(struct amdgpu_device *adev);
 int amdgpu_device_suspend(struct drm_device *dev, bool fbcon);
 int amdgpu_device_resume(struct drm_device *dev, bool fbcon);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2f60b70..797d94d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3557,14 +3557,12 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  * Tear down the driver info (all asics).
  * Called at driver shutdown.
  */
-void amdgpu_device_fini(struct amdgpu_device *adev)
+void amdgpu_device_fini_early(struct amdgpu_device *adev)
 {
dev_info(adev->dev, "amdgpu: finishing device.\n");
flush_delayed_work(&adev->delayed_init_work);
adev->shutdown = true;
 
-   kfree(adev->pci_state);
-
/* make sure IB test finished before entering exclusive mode
 * to avoid preemption on IB test
 * */
@@ -3581,11 +3579,18 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
else
drm_atomic_helper_shutdown(adev_to_drm(adev));
}
-   amdgpu_fence_driver_fini(adev);
+   amdgpu_fence_driver_fini_early(adev);
if (adev->pm_sysfs_en)
amdgpu_pm_sysfs_fini(adev);
amdgpu_fbdev_fini(adev);
+
+   amdgpu_irq_fini_early(adev);
+}
+
+void amdgpu_device_fini_late(struct amdgpu_device *adev)
+{
amdgpu_device_ip_fini(adev);
+   amdgpu_fence_driver_fini_late(adev);
release_firmware(adev->firmware.gpu_info_fw);
adev->firmware.gpu_info_fw = NULL;
adev->accel_working = false;
@@ -3621,6 +3626,9 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
amdgpu_pmu_fini(adev);
if (adev->mman.discovery_bin)
amdgpu_discovery_fini(adev);
+
+   kfree(adev->pci_state);
+
 }
 
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 7f98cf1..3d130fc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1244,14 +1244,10 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-#ifdef MODULE
-   if (THIS_MODULE->state != MODULE_STATE_GOING)
-#endif
-   DRM_ERROR("Hotplug removal is not supported\n");
drm_dev_unplug(dev);
amdgpu_driver_unload_kms(dev);
+
pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
drm_dev_put(dev);
 }
 
@@ -1557,6 +1553,7 @@ static struct drm_driver kms_driver = {
.dumb_create = amdgpu_mode_dumb_create,
.dumb_map_offset = amdgpu_mode_dumb_mmap,
.fops = &amdgpu_driver_kms_fops,
+   .release = &amdgpu_driver_release_kms,
 
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_

[PATCH v3 09/12] drm/amdgpu: Add early fini callback

2020-11-20 Thread Andrey Grodzovsky
Use it to call disply code dependent on device->drv_data
before it's set to NULL on device unplug

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 20 
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++--
 drivers/gpu/drm/amd/include/amd_shared.h  |  2 ++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 797d94d..96368a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2508,6 +2508,24 @@ static int amdgpu_device_ip_late_init(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
+{
+   int i, r;
+
+   for (i = 0; i < adev->num_ip_blocks; i++) {
+   if (!adev->ip_blocks[i].version->funcs->early_fini)
+   continue;
+
+   r = adev->ip_blocks[i].version->funcs->early_fini((void *)adev);
+   if (r) {
+   DRM_DEBUG("early_fini of IP block <%s> failed %d\n",
+ adev->ip_blocks[i].version->funcs->name, r);
+   }
+   }
+
+   return 0;
+}
+
 /**
  * amdgpu_device_ip_fini - run fini for hardware IPs
  *
@@ -3585,6 +3603,8 @@ void amdgpu_device_fini_early(struct amdgpu_device *adev)
amdgpu_fbdev_fini(adev);
 
amdgpu_irq_fini_early(adev);
+
+   amdgpu_device_ip_fini_early(adev);
 }
 
 void amdgpu_device_fini_late(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 1da4ad5..278d1f6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1158,6 +1158,15 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
return -EINVAL;
 }
 
+static int amdgpu_dm_early_fini(void *handle)
+{
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   amdgpu_dm_audio_fini(adev);
+
+   return 0;
+}
+
 static void amdgpu_dm_fini(struct amdgpu_device *adev)
 {
int i;
@@ -1166,8 +1175,6 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
drm_encoder_cleanup(&adev->dm.mst_encoders[i].base);
}
 
-   amdgpu_dm_audio_fini(adev);
-
amdgpu_dm_destroy_drm_device(&adev->dm);
 
 #ifdef CONFIG_DRM_AMD_DC_HDCP
@@ -2150,6 +2157,7 @@ static const struct amd_ip_funcs amdgpu_dm_funcs = {
.late_init = dm_late_init,
.sw_init = dm_sw_init,
.sw_fini = dm_sw_fini,
+   .early_fini = amdgpu_dm_early_fini,
.hw_init = dm_hw_init,
.hw_fini = dm_hw_fini,
.suspend = dm_suspend,
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
b/drivers/gpu/drm/amd/include/amd_shared.h
index 9676016..63bb846 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -239,6 +239,7 @@ enum amd_dpm_forced_level;
  * @late_init: sets up late driver/hw state (post hw_init) - Optional
  * @sw_init: sets up driver state, does not configure hw
  * @sw_fini: tears down driver state, does not configure hw
+ * @early_fini: tears down stuff before dev detached from driver
  * @hw_init: sets up the hw state
  * @hw_fini: tears down the hw state
  * @late_fini: final cleanup
@@ -267,6 +268,7 @@ struct amd_ip_funcs {
int (*late_init)(void *handle);
int (*sw_init)(void *handle);
int (*sw_fini)(void *handle);
+   int (*early_fini)(void *handle);
int (*hw_init)(void *handle);
int (*hw_fini)(void *handle);
void (*late_fini)(void *handle);
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 10/12] drm/amdgpu: Avoid sysfs dirs removal post device unplug

2020-11-20 Thread Andrey Grodzovsky
Avoids NULL ptr due to kobj->sd being unset on device removal.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c   | 4 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index caf828a..812e592 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "amdgpu.h"
 #include "amdgpu_ras.h"
@@ -1043,7 +1044,8 @@ static int amdgpu_ras_sysfs_remove_feature_node(struct 
amdgpu_device *adev)
.attrs = attrs,
};
 
-   sysfs_remove_group(&adev->dev->kobj, &group);
+   if (!drm_dev_is_unplugged(&adev->ddev))
+   sysfs_remove_group(&adev->dev->kobj, &group);
 
return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index 2b7c90b..54331fc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "amdgpu.h"
 #include "amdgpu_ucode.h"
@@ -464,7 +465,8 @@ int amdgpu_ucode_sysfs_init(struct amdgpu_device *adev)
 
 void amdgpu_ucode_sysfs_fini(struct amdgpu_device *adev)
 {
-   sysfs_remove_group(&adev->dev->kobj, &fw_attr_group);
+   if (!drm_dev_is_unplugged(&adev->ddev))
+   sysfs_remove_group(&adev->dev->kobj, &fw_attr_group);
 }
 
 static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v3 07/12] drm/sched: Prevent any job recoveries after device is unplugged.

2020-11-20 Thread Andrey Grodzovsky
No point to try recovery if device is gone, it's meaningless.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c |  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_sched.c   |  3 ++-
 drivers/gpu/drm/lima/lima_sched.c |  3 ++-
 drivers/gpu/drm/panfrost/panfrost_job.c   |  2 +-
 drivers/gpu/drm/scheduler/sched_main.c| 15 ++-
 drivers/gpu/drm/v3d/v3d_sched.c   | 15 ++-
 include/drm/gpu_scheduler.h   |  6 +-
 7 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index d56f402..d0b0021 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -487,7 +487,7 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
 
r = drm_sched_init(&ring->sched, &amdgpu_sched_ops,
   num_hw_submission, amdgpu_job_hang_limit,
-  timeout, ring->name);
+  timeout, ring->name, &adev->ddev);
if (r) {
DRM_ERROR("Failed to create scheduler on ring %s.\n",
  ring->name);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c 
b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
index cd46c88..7678287 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
@@ -185,7 +185,8 @@ int etnaviv_sched_init(struct etnaviv_gpu *gpu)
 
ret = drm_sched_init(&gpu->sched, &etnaviv_sched_ops,
 etnaviv_hw_jobs_limit, etnaviv_job_hang_limit,
-msecs_to_jiffies(500), dev_name(gpu->dev));
+msecs_to_jiffies(500), dev_name(gpu->dev),
+gpu->drm);
if (ret)
return ret;
 
diff --git a/drivers/gpu/drm/lima/lima_sched.c 
b/drivers/gpu/drm/lima/lima_sched.c
index dc6df9e..8a7e5d7ca 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -505,7 +505,8 @@ int lima_sched_pipe_init(struct lima_sched_pipe *pipe, 
const char *name)
 
return drm_sched_init(&pipe->base, &lima_sched_ops, 1,
  lima_job_hang_limit, msecs_to_jiffies(timeout),
- name);
+ name,
+ pipe->ldev->ddev);
 }
 
 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe)
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c 
b/drivers/gpu/drm/panfrost/panfrost_job.c
index 30e7b71..37b03b01 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -520,7 +520,7 @@ int panfrost_job_init(struct panfrost_device *pfdev)
ret = drm_sched_init(&js->queue[j].sched,
 &panfrost_sched_ops,
 1, 0, msecs_to_jiffies(500),
-"pan_js");
+"pan_js", pfdev->ddev);
if (ret) {
dev_err(pfdev->dev, "Failed to create scheduler: %d.", 
ret);
goto err_sched;
diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index c3f0bd0..95db8c6 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -53,6 +53,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include "gpu_scheduler_trace.h"
@@ -283,8 +284,16 @@ static void drm_sched_job_timedout(struct work_struct 
*work)
struct drm_gpu_scheduler *sched;
struct drm_sched_job *job;
 
+   int idx;
+
sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
 
+   if (!drm_dev_enter(sched->ddev, &idx)) {
+   DRM_INFO("%s - device unplugged skipping recovery on 
scheduler:%s",
+__func__, sched->name);
+   return;
+   }
+
/* Protects against concurrent deletion in drm_sched_get_cleanup_job */
spin_lock(&sched->job_list_lock);
job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,6 +325,8 @@ static void drm_sched_job_timedout(struct work_struct *work)
spin_lock(&sched->job_list_lock);
drm_sched_start_timeout(sched);
spin_unlock(&sched->job_list_lock);
+
+   drm_dev_exit(idx);
 }
 
  /**
@@ -845,7 +856,8 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
   unsigned hw_submission,
   unsigned hang_limit,
   long timeout,
-  const char *name)
+  const char *name,
+  struct drm_device *ddev)
 {
int i, ret;
sched->ops = ops;
@@ -853,6 +865,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
sched->name = name;
   

[PATCH v3 11/12] drm/amdgpu: Register IOMMU topology notifier per device.

2020-11-20 Thread Andrey Grodzovsky
Handle all DMA IOMMU gropup related dependencies before the
group is removed.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  5 
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 ++
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 6243f6d..c41957e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1044,6 +1045,10 @@ struct amdgpu_device {
 
boolin_pci_err_recovery;
struct pci_saved_state  *pci_state;
+
+   struct notifier_block   nb;
+   struct blocking_notifier_head   notifier;
+   struct list_headdevice_bo_list;
 };
 
 static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 96368a8..bc84c20 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -70,6 +70,8 @@
 #include 
 #include 
 
+#include 
+
 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
@@ -3179,6 +3181,39 @@ static const struct attribute *amdgpu_dev_attributes[] = 
{
 };
 
 
+static int amdgpu_iommu_group_notifier(struct notifier_block *nb,
+unsigned long action, void *data)
+{
+   struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, nb);
+   struct amdgpu_bo *bo = NULL;
+
+   /*
+* Following is a set of IOMMU group dependencies taken care of before
+* device's IOMMU group is removed
+*/
+   if (action == IOMMU_GROUP_NOTIFY_DEL_DEVICE) {
+
+   spin_lock(&ttm_bo_glob.lru_lock);
+   list_for_each_entry(bo, &adev->device_bo_list, bo) {
+   if (bo->tbo.ttm)
+   ttm_tt_unpopulate(bo->tbo.ttm);
+   }
+   spin_unlock(&ttm_bo_glob.lru_lock);
+
+   if (adev->irq.ih.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih);
+   if (adev->irq.ih1.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
+   if (adev->irq.ih2.use_bus_addr)
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
+
+   amdgpu_gart_dummy_page_fini(adev);
+   }
+
+   return NOTIFY_OK;
+}
+
+
 /**
  * amdgpu_device_init - initialize the driver
  *
@@ -3283,6 +3318,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
INIT_WORK(&adev->xgmi_reset_work, amdgpu_device_xgmi_reset_func);
 
+   INIT_LIST_HEAD(&adev->device_bo_list);
+
adev->gfx.gfx_off_req_count = 1;
adev->pm.ac_power = power_supply_is_system_supplied() > 0;
 
@@ -3553,6 +3590,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
if (amdgpu_device_cache_pci_state(adev->pdev))
pci_restore_state(pdev);
 
+   BLOCKING_INIT_NOTIFIER_HEAD(&adev->notifier);
+   adev->nb.notifier_call = amdgpu_iommu_group_notifier;
+
+   if (adev->dev->iommu_group) {
+   r = iommu_group_register_notifier(adev->dev->iommu_group, 
&adev->nb);
+   if (r)
+   goto failed;
+   }
+
return 0;
 
 failed:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index e01e681..34c17bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -92,7 +92,7 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device 
*adev)
  *
  * Frees the dummy page used by the driver (all asics).
  */
-static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev)
 {
if (!adev->dummy_page_addr)
return;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
index afa2e28..5678d9c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
@@ -61,6 +61,7 @@ int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
 void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
 int amdgpu_gart_init(struct amdgpu_device *adev);
 void amdgpu_gart_fini(struct amdgpu_device *adev);
+void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev);
 int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
   int pages);
 

[PATCH v3 12/12] drm/amdgpu: Fix a bunch of sdma code crash post device unplug

2020-11-20 Thread Andrey Grodzovsky
We can't allocate and submit IBs post device unplug.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index fdbe7d4..a62ad20 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 #include "amdgpu_amdkfd.h"
@@ -1602,7 +1603,10 @@ static int amdgpu_vm_bo_update_mapping(struct 
amdgpu_device *adev,
struct amdgpu_vm_update_params params;
enum amdgpu_sync_mode sync_mode;
uint64_t pfn;
-   int r;
+   int r, idx;
+
+   if (!drm_dev_enter(&adev->ddev, &idx))
+   return -ENOENT;
 
memset(¶ms, 0, sizeof(params));
params.adev = adev;
@@ -1645,6 +1649,8 @@ static int amdgpu_vm_bo_update_mapping(struct 
amdgpu_device *adev,
if (r)
goto error_unlock;
 
+
+   drm_dev_exit(idx);
do {
uint64_t tmp, num_entries, addr;
 
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx