[PATCH] drm/amdgpu: refactor function to init no-psp fw

2021-09-09 Thread Likun Gao
From: Likun Gao 

Refactor the code of amdgpu_ucode_init_single_fw to make it more
readable as too many ucode need to handle on this function currently.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 160 ++
 1 file changed, 75 insertions(+), 85 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index abd8469380e5..5f396936c6ad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -572,6 +572,7 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device 
*adev,
const struct dmcu_firmware_header_v1_0 *dmcu_hdr = NULL;
const struct dmcub_firmware_header_v1_0 *dmcub_hdr = NULL;
const struct mes_firmware_header_v1_0 *mes_hdr = NULL;
+   u8 *ucode_addr;
 
if (NULL == ucode->fw)
return 0;
@@ -588,94 +589,83 @@ static int amdgpu_ucode_init_single_fw(struct 
amdgpu_device *adev,
dmcub_hdr = (const struct dmcub_firmware_header_v1_0 *)ucode->fw->data;
mes_hdr = (const struct mes_firmware_header_v1_0 *)ucode->fw->data;
 
-   if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP ||
-   (ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1 &&
-ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2 &&
-ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC1_JT &&
-ucode->ucode_id != AMDGPU_UCODE_ID_CP_MEC2_JT &&
-ucode->ucode_id != AMDGPU_UCODE_ID_CP_MES &&
-ucode->ucode_id != AMDGPU_UCODE_ID_CP_MES_DATA &&
-ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL &&
-ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_GPM_MEM &&
-ucode->ucode_id != AMDGPU_UCODE_ID_RLC_RESTORE_LIST_SRM_MEM &&
-ucode->ucode_id != AMDGPU_UCODE_ID_RLC_IRAM &&
-ucode->ucode_id != AMDGPU_UCODE_ID_RLC_DRAM &&
-ucode->ucode_id != AMDGPU_UCODE_ID_DMCU_ERAM &&
-ucode->ucode_id != AMDGPU_UCODE_ID_DMCU_INTV &&
-ucode->ucode_id != AMDGPU_UCODE_ID_DMCUB)) {
-   ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes);
-
-   memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data +
- 
le32_to_cpu(header->ucode_array_offset_bytes)),
-  ucode->ucode_size);
-   } else if (ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC1 ||
-  ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC2) {
-   ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes) -
-   le32_to_cpu(cp_hdr->jt_size) * 4;
-
-   memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data +
- 
le32_to_cpu(header->ucode_array_offset_bytes)),
-  ucode->ucode_size);
-   } else if (ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC1_JT ||
-  ucode->ucode_id == AMDGPU_UCODE_ID_CP_MEC2_JT) {
-   ucode->ucode_size = le32_to_cpu(cp_hdr->jt_size) * 4;
-
-   memcpy(ucode->kaddr, (void *)((uint8_t *)ucode->fw->data +
- 
le32_to_cpu(header->ucode_array_offset_bytes) +
- le32_to_cpu(cp_hdr->jt_offset) * 
4),
-  ucode->ucode_size);
-   } else if (ucode->ucode_id == AMDGPU_UCODE_ID_DMCU_ERAM) {
-   ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes) -
+   if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
+   switch (ucode->ucode_id) {
+   case AMDGPU_UCODE_ID_CP_MEC1:
+   case AMDGPU_UCODE_ID_CP_MEC2:
+   ucode->ucode_size = 
le32_to_cpu(header->ucode_size_bytes) -
+   le32_to_cpu(cp_hdr->jt_size) * 4;
+   ucode_addr = (u8 *)ucode->fw->data +
+   le32_to_cpu(header->ucode_array_offset_bytes);
+   break;
+   case AMDGPU_UCODE_ID_CP_MEC1_JT:
+   case AMDGPU_UCODE_ID_CP_MEC2_JT:
+   ucode->ucode_size = le32_to_cpu(cp_hdr->jt_size) * 4;
+   ucode_addr = (u8 *)ucode->fw->data +
+   le32_to_cpu(header->ucode_array_offset_bytes) +
+   le32_to_cpu(cp_hdr->jt_offset) * 4;
+   break;
+   case AMDGPU_UCODE_ID_RLC_RESTORE_LIST_CNTL:
+   ucode->ucode_size = 
adev->gfx.rlc.save_restore_list_cntl_size_bytes;
+   ucode_addr = adev->gfx.rlc.save_rest

[PATCH] drm/amdgpu: adjust fence driver enable sequence

2021-07-28 Thread Likun Gao
From: Likun Gao 

Fence driver was enabled per ring when sw init on per IP block before.
Change to enable all the fence driver at the same time after
amdgpu_device_ip_init finished.
Rename some function related to fence to make it reasonable for read.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  6 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 15 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  4 ++--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d3a4299b1f30..77195a4e5c59 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3675,6 +3675,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
goto release_ras_con;
}
 
+   amdgpu_fence_driver_hw_init(adev);
+
dev_info(adev->dev,
"SE %d, SH per SE %d, CU per SH %d, active_cu_number %d\n",
adev->gfx.config.max_shader_engines,
@@ -3939,7 +3941,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
/* evict vram memory */
amdgpu_bo_evict_vram(adev);
 
-   amdgpu_fence_driver_suspend(adev);
+   amdgpu_fence_driver_hw_fini(adev);
 
amdgpu_device_ip_suspend_phase2(adev);
/* evict remaining vram memory
@@ -3984,7 +3986,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool 
fbcon)
dev_err(adev->dev, "amdgpu_device_ip_resume failed (%d).\n", r);
return r;
}
-   amdgpu_fence_driver_resume(adev);
+   amdgpu_fence_driver_hw_init(adev);
 
 
r = amdgpu_device_ip_late_init(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 72d9b92b1754..e2f606bca779 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -417,9 +417,6 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
}
amdgpu_fence_write(ring, atomic_read(>fence_drv.last_seq));
 
-   if (irq_src)
-   amdgpu_irq_get(adev, irq_src, irq_type);
-
ring->fence_drv.irq_src = irq_src;
ring->fence_drv.irq_type = irq_type;
ring->fence_drv.initialized = true;
@@ -572,14 +569,14 @@ void amdgpu_fence_driver_fini_sw(struct amdgpu_device 
*adev)
 }
 
 /**
- * amdgpu_fence_driver_suspend - suspend the fence driver
+ * amdgpu_fence_driver_hw_fini - disable the fence driver
  * for all possible rings.
  *
  * @adev: amdgpu device pointer
  *
- * Suspend the fence driver for all possible rings (all asics).
+ * Disable the fence driver for all possible rings (all asics).
  */
-void amdgpu_fence_driver_suspend(struct amdgpu_device *adev)
+void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev)
 {
int i, r;
 
@@ -603,18 +600,18 @@ void amdgpu_fence_driver_suspend(struct amdgpu_device 
*adev)
 }
 
 /**
- * amdgpu_fence_driver_resume - resume the fence driver
+ * amdgpu_fence_driver_hw_init - enable the fence driver
  * for all possible rings.
  *
  * @adev: amdgpu device pointer
  *
- * Resume the fence driver for all possible rings (all asics).
+ * Enable the fence driver for all possible rings (all asics).
  * Not all asics have all rings, so each asic will only
  * start the fence driver on the rings it has using
  * amdgpu_fence_driver_start_ring().
  * Returns 0 for success.
  */
-void amdgpu_fence_driver_resume(struct amdgpu_device *adev)
+void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev)
 {
int i;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index e7d3d0dbdd96..64471018f5e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -117,8 +117,8 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
 int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
   struct amdgpu_irq_src *irq_src,
   unsigned irq_type);
-void amdgpu_fence_driver_suspend(struct amdgpu_device *adev);
-void amdgpu_fence_driver_resume(struct amdgpu_device *adev);
+void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev);
+void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev);
 int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence,
  unsigned flags);
 int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s,
-- 
2.25.1

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


[PATCH] drm/amdgpu: update golden setting for sienna_cichlid

2021-07-15 Thread Likun Gao
From: Likun Gao 

Update GFX golden setting for sienna_cichlid.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index cd8dcec7fdbb..7c08818fc142 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3308,6 +3308,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_3[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_PERFCOUNTER7_SELECT, 0xf0f001ff, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_PERFCOUNTER8_SELECT, 0xf0f001ff, 
0x),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_PERFCOUNTER9_SELECT, 0xf0f001ff, 
0x),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmSX_DEBUG_1, 0x0001, 0x00010020),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfff7, 0x0103),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmUTCL1_CTRL, 0xffbf, 0x00a0)
 };
-- 
2.25.1

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


[PATCH 2/2] drm/amdgpu: update the method for harvest IP for specific SKU

2021-05-10 Thread Likun Gao
From: Likun Gao 

Update the method of disabling VCN IP for specific SKU for navi1x ASIC,
it will judge whether should add the related IP at the function of
amdgpu_device_ip_block_add().

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index d261f459c982..0be9038fa350 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -623,6 +623,16 @@ static const struct amdgpu_ip_block_version 
nv_common_ip_block =
.funcs = _common_ip_funcs,
 };
 
+static bool nv_is_headless_sku(struct pci_dev *pdev)
+{
+   if ((pdev->device == 0x731E &&
+   (pdev->revision == 0xC6 || pdev->revision == 0xC7)) ||
+   (pdev->device == 0x7340 && pdev->revision == 0xC9)  ||
+   (pdev->device == 0x7360 && pdev->revision == 0xC7))
+   return true;
+   return false;
+}
+
 static int nv_reg_base_init(struct amdgpu_device *adev)
 {
int r;
@@ -636,6 +646,10 @@ static int nv_reg_base_init(struct amdgpu_device *adev)
}
 
amdgpu_discovery_harvest_ip(adev);
+   if (nv_is_headless_sku(adev->pdev)) {
+   adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
+   adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+   }
 
return 0;
}
@@ -673,16 +687,6 @@ void nv_set_virt_ops(struct amdgpu_device *adev)
adev->virt.ops = _nv_virt_ops;
 }
 
-static bool nv_is_headless_sku(struct pci_dev *pdev)
-{
-   if ((pdev->device == 0x731E &&
-   (pdev->revision == 0xC6 || pdev->revision == 0xC7)) ||
-   (pdev->device == 0x7340 && pdev->revision == 0xC9)  ||
-   (pdev->device == 0x7360 && pdev->revision == 0xC7))
-   return true;
-   return false;
-}
-
 int nv_set_ip_blocks(struct amdgpu_device *adev)
 {
int r;
@@ -730,8 +734,7 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v11_0_ip_block);
-   if (!nv_is_headless_sku(adev->pdev))
-   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
+   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
if (adev->enable_mes)
amdgpu_device_ip_block_add(adev, _v10_1_ip_block);
@@ -754,8 +757,7 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v11_0_ip_block);
-   if (!nv_is_headless_sku(adev->pdev))
-   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
+   amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
if (!amdgpu_sriov_vf(adev))
amdgpu_device_ip_block_add(adev, _v2_0_ip_block);
break;
-- 
2.25.1

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


[PATCH 1/2] drm/amdgpu: add judgement when add ip blocks

2021-05-10 Thread Likun Gao
From: Likun GAO 

Judgement whether to add an sw ip according to the harvest info.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 15 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 30 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h |  1 +
 drivers/gpu/drm/amd/amdgpu/nv.c   |  8 -
 drivers/gpu/drm/amd/include/amd_shared.h  |  6 
 6 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 10d9a8a237fd..3147c1c935c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1010,6 +1010,7 @@ struct amdgpu_device {
struct amdgpu_dfdf;
 
struct amdgpu_ip_block  ip_blocks[AMDGPU_MAX_IP_NUM];
+   uint32_tharvest_ip_mask;
int num_ip_blocks;
struct mutexmn_lock;
DECLARE_HASHTABLE(mn_hash, 7);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b0543f409039..6881015f40be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1683,6 +1683,19 @@ int amdgpu_device_ip_block_add(struct amdgpu_device 
*adev,
if (!ip_block_version)
return -EINVAL;
 
+   switch (ip_block_version->type) {
+   case AMD_IP_BLOCK_TYPE_VCN:
+   if (adev->harvest_ip_mask & AMD_HARVEST_IP_VCN_MASK)
+   return 0;
+   break;
+   case AMD_IP_BLOCK_TYPE_JPEG:
+   if (adev->harvest_ip_mask & AMD_HARVEST_IP_JPEG_MASK)
+   return 0;
+   break;
+   default:
+   break;
+   }
+
DRM_INFO("add ip block number %d <%s>\n", adev->num_ip_blocks,
  ip_block_version->funcs->name);
 
@@ -3111,7 +3124,6 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device 
*adev)
return amdgpu_device_asic_has_dc_support(adev->asic_type);
 }
 
-
 static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
 {
struct amdgpu_device *adev =
@@ -3274,6 +3286,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
adev->vm_manager.vm_pte_funcs = NULL;
adev->vm_manager.vm_pte_num_scheds = 0;
adev->gmc.gmc_funcs = NULL;
+   adev->harvest_ip_mask = 0x0;
adev->fence_context = dma_fence_context_alloc(AMDGPU_MAX_RINGS);
bitmap_zero(adev->gfx.pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index b2dbcb4df020..99255c2f08f4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -373,6 +373,36 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device 
*adev, int hw_id,
return -EINVAL;
 }
 
+void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
+{
+   struct binary_header *bhdr;
+   struct harvest_table *harvest_info;
+   int i;
+
+   bhdr = (struct binary_header *)adev->mman.discovery_bin;
+   harvest_info = (struct harvest_table *)(adev->mman.discovery_bin +
+   le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset));
+
+   for (i = 0; i < 32; i++) {
+   if (le32_to_cpu(harvest_info->list[i].hw_id) == 0)
+   break;
+
+   switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
+   case VCN_HWID:
+   adev->harvest_ip_mask |= 
AMD_HARVEST_IP_VCN_MASK;
+   adev->harvest_ip_mask |= 
AMD_HARVEST_IP_JPEG_MASK;
+   break;
+   case DMU_HWID:
+   adev->harvest_ip_mask |= 
AMD_HARVEST_IP_DMU_MASK;
+   break;
+   default:
+   break;
+   }
+   }
+
+   return;
+}
+
 int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
 {
struct binary_header *bhdr;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
index 8f6183801cb3..1b1ae21b1037 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h
@@ -29,6 +29,7 @@
 
 void amdgpu_discovery_fini(struct amdgpu_device *adev);
 int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
+void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev);
 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
 

[PATCH] drm/amdgpu: remove redundant include of navi10_enum

2021-01-04 Thread Likun Gao
From: Likun Gao 

Remove unnecessary include of navi10_enum header file.

Signed-off-by: Likun Gao 
Change-Id: Id9697d0cf68339b3005b634ab5cf2f7bc39e47ef
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c   | 1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c | 1 -
 drivers/gpu/drm/amd/amdgpu/athub_v2_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/athub_v2_1.c  | 1 -
 4 files changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c
index 1529815838f7..fa7e8ff72dfb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c
@@ -23,7 +23,6 @@
 #include "amdgpu_amdkfd.h"
 #include "gc/gc_10_1_0_offset.h"
 #include "gc/gc_10_1_0_sh_mask.h"
-#include "navi10_enum.h"
 #include "athub/athub_2_0_0_offset.h"
 #include "athub/athub_2_0_0_sh_mask.h"
 #include "oss/osssys_5_0_0_offset.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
index 50016bf9c427..fad3b91f74f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
@@ -24,7 +24,6 @@
 #include "amdgpu_amdkfd.h"
 #include "gc/gc_10_3_0_offset.h"
 #include "gc/gc_10_3_0_sh_mask.h"
-#include "navi10_enum.h"
 #include "oss/osssys_5_0_0_offset.h"
 #include "oss/osssys_5_0_0_sh_mask.h"
 #include "soc15_common.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/athub_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/athub_v2_0.c
index 921a69abda55..5b90efd6f6d0 100644
--- a/drivers/gpu/drm/amd/amdgpu/athub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/athub_v2_0.c
@@ -27,7 +27,6 @@
 #include "athub/athub_2_0_0_offset.h"
 #include "athub/athub_2_0_0_sh_mask.h"
 #include "athub/athub_2_0_0_default.h"
-#include "navi10_enum.h"
 
 #include "soc15_common.h"
 
diff --git a/drivers/gpu/drm/amd/amdgpu/athub_v2_1.c 
b/drivers/gpu/drm/amd/amdgpu/athub_v2_1.c
index 66c183ddd43e..7b1b18350bf9 100644
--- a/drivers/gpu/drm/amd/amdgpu/athub_v2_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/athub_v2_1.c
@@ -26,7 +26,6 @@
 
 #include "athub/athub_2_1_0_offset.h"
 #include "athub/athub_2_1_0_sh_mask.h"
-#include "navi10_enum.h"
 
 #include "soc15_common.h"
 
-- 
2.25.1

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


[V2] drm/amdgpu: switch hdp callback functions for hdp v4

2020-12-28 Thread Likun Gao
From: Likun Gao 

Switch to use the HDP functions which unified on hdp structure instead of
the scattered hdp callback functions.
V2: clean up hdp reset ras error count function.

Signed-off-by: Likun Gao 
Change-Id: I70564d5053e13e119cc8fa44a40350669ed874cf
---
 drivers/gpu/drm/amd/amdgpu/Makefile   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  8 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 21 +--
 drivers/gpu/drm/amd/amdgpu/soc15.c| 91 +++
 4 files changed, 16 insertions(+), 106 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index c6262689e14e..d741fee91a37 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -71,7 +71,7 @@ amdgpu-y += \
vi.o mxgpu_vi.o nbio_v6_1.o soc15.o emu_soc.o mxgpu_ai.o nbio_v7_0.o 
vega10_reg_init.o \
vega20_reg_init.o nbio_v7_4.o nbio_v2_3.o nv.o navi10_reg_init.o 
navi14_reg_init.o \
arct_reg_init.o navi12_reg_init.o mxgpu_nv.o sienna_cichlid_reg_init.o 
vangogh_reg_init.o \
-   nbio_v7_2.o dimgrey_cavefish_reg_init.o
+   nbio_v7_2.o dimgrey_cavefish_reg_init.o hdp_v4_0.o
 
 # add DF block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 92e9d1f1207b..62012b4cf496 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -89,6 +89,7 @@
 #include "amdgpu_gfx.h"
 #include "amdgpu_sdma.h"
 #include "amdgpu_nbio.h"
+#include "amdgpu_hdp.h"
 #include "amdgpu_dm.h"
 #include "amdgpu_virt.h"
 #include "amdgpu_csa.h"
@@ -609,7 +610,6 @@ struct amdgpu_asic_funcs {
/* invalidate hdp read cache */
void (*invalidate_hdp)(struct amdgpu_device *adev,
   struct amdgpu_ring *ring);
-   void (*reset_hdp_ras_error_count)(struct amdgpu_device *adev);
/* check if the asic needs a full reset of if soft reset will work */
bool (*need_full_reset)(struct amdgpu_device *adev);
/* initialize doorbell layout for specific asic*/
@@ -1209,8 +1209,10 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_asic_read_bios_from_rom(adev, b, l) 
(adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))
 #define amdgpu_asic_read_register(adev, se, sh, offset, 
v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))
 #define amdgpu_asic_get_config_memsize(adev) 
(adev)->asic_funcs->get_config_memsize((adev))
-#define amdgpu_asic_flush_hdp(adev, r) (adev)->asic_funcs->flush_hdp((adev), 
(r))
-#define amdgpu_asic_invalidate_hdp(adev, r) 
(adev)->asic_funcs->invalidate_hdp((adev), (r))
+#define amdgpu_asic_flush_hdp(adev, r) \
+   ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), 
(r)) : (adev)->hdp.funcs->flush_hdp((adev), (r)))
+#define amdgpu_asic_invalidate_hdp(adev, r) \
+   ((adev)->asic_funcs->invalidate_hdp ? 
(adev)->asic_funcs->invalidate_hdp((adev), (r)) : 
(adev)->hdp.funcs->invalidate_hdp((adev), (r)))
 #define amdgpu_asic_need_full_reset(adev) 
(adev)->asic_funcs->need_full_reset((adev))
 #define amdgpu_asic_init_doorbell_index(adev) 
(adev)->asic_funcs->init_doorbell_index((adev))
 #define amdgpu_asic_get_pcie_usage(adev, cnt0, cnt1) 
((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index e22268f9dba7..7b1f50fa9dac 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -31,8 +31,6 @@
 #include "amdgpu_atomfirmware.h"
 #include "amdgpu_gem.h"
 
-#include "hdp/hdp_4_0_offset.h"
-#include "hdp/hdp_4_0_sh_mask.h"
 #include "gc/gc_9_0_sh_mask.h"
 #include "dce/dce_12_0_offset.h"
 #include "dce/dce_12_0_sh_mask.h"
@@ -1571,7 +1569,6 @@ static int gmc_v9_0_hw_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
bool value;
int r, i;
-   u32 tmp;
 
/* The sequence of these two function calls matters.*/
gmc_v9_0_init_golden_registers(adev);
@@ -1590,24 +1587,10 @@ static int gmc_v9_0_hw_init(void *handle)
if (adev->mmhub.funcs->update_power_gating)
adev->mmhub.funcs->update_power_gating(adev, true);
 
-   switch (adev->asic_type) {
-   case CHIP_ARCTURUS:
-   WREG32_FIELD15(HDP, 0, HDP_MMHUB_CNTL, HDP_MMHUB_GCC, 1);
-   break;
-   default:
-   break;
-   }
-
-   WREG32_FIELD15(HDP, 0, HDP_MISC_CNTL, FLUSH_INVALIDATE_CACHE, 1);
-
-   tmp = RREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL);
-   WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp);
-
-   WREG32_SOC15(HDP, 0, mmHDP_NONSURFACE_BASE, (a

[PATCH 5/5] drm/amdgpu: remove redundant logic related HDP

2020-12-28 Thread Likun Gao
From: Likun Gao 

Remove hdp_flush function from amdgpu_nbio struct as it have been unfied
into hdp struct.
Remove the include about hdp register which was not used.

Signed-off-by: Likun Gao 
Change-Id: I7b1ce7424a97efe82ccb6ce63505e724530715ac
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h |  1 -
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c|  1 -
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c   | 10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c   | 13 -
 drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c   | 10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c   | 10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   | 10 --
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   |  1 -
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |  1 -
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c|  1 -
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c|  1 -
 11 files changed, 59 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
index e62cc0e1a5ad..4ba0024aedf1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
@@ -57,7 +57,6 @@ struct amdgpu_nbio_funcs {
u32 (*get_pcie_port_data_offset)(struct amdgpu_device *adev);
u32 (*get_rev_id)(struct amdgpu_device *adev);
void (*mc_access_enable)(struct amdgpu_device *adev, bool enable);
-   void (*hdp_flush)(struct amdgpu_device *adev, struct amdgpu_ring *ring);
u32 (*get_memsize)(struct amdgpu_device *adev);
void (*sdma_doorbell_range)(struct amdgpu_device *adev, int instance,
bool use_doorbell, int doorbell_index, int 
doorbell_size);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 5f4805e4d04a..a896e3d0fcf8 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -38,7 +38,6 @@
 #include "gc/gc_9_0_sh_mask.h"
 
 #include "vega10_enum.h"
-#include "hdp/hdp_4_0_offset.h"
 
 #include "soc15_common.h"
 #include "clearstate_gfx9.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c 
b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
index b5c3db16c2b0..b860f1c7b5b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c
@@ -80,15 +80,6 @@ static void nbio_v2_3_mc_access_enable(struct amdgpu_device 
*adev, bool enable)
WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0);
 }
 
-static void nbio_v2_3_hdp_flush(struct amdgpu_device *adev,
-   struct amdgpu_ring *ring)
-{
-   if (!ring || !ring->funcs->emit_wreg)
-   WREG32_NO_KIQ((adev->rmmio_remap.reg_offset + 
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-   else
-   amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + 
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-}
-
 static u32 nbio_v2_3_get_memsize(struct amdgpu_device *adev)
 {
return RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_RCC_CONFIG_MEMSIZE);
@@ -366,7 +357,6 @@ const struct amdgpu_nbio_funcs nbio_v2_3_funcs = {
.get_pcie_data_offset = nbio_v2_3_get_pcie_data_offset,
.get_rev_id = nbio_v2_3_get_rev_id,
.mc_access_enable = nbio_v2_3_mc_access_enable,
-   .hdp_flush = nbio_v2_3_hdp_flush,
.get_memsize = nbio_v2_3_get_memsize,
.sdma_doorbell_range = nbio_v2_3_sdma_doorbell_range,
.vcn_doorbell_range = nbio_v2_3_vcn_doorbell_range,
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c 
b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c
index d2f1fe55d388..8427f10712ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c
@@ -50,18 +50,6 @@ static void nbio_v6_1_mc_access_enable(struct amdgpu_device 
*adev, bool enable)
WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0);
 }
 
-static void nbio_v6_1_hdp_flush(struct amdgpu_device *adev,
-   struct amdgpu_ring *ring)
-{
-   if (!ring || !ring->funcs->emit_wreg)
-   WREG32_SOC15_NO_KIQ(NBIO, 0,
-   mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL,
-   0);
-   else
-   amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
-   NBIO, 0, mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL), 0);
-}
-
 static u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev)
 {
return RREG32_SOC15(NBIO, 0, mmRCC_PF_0_0_RCC_CONFIG_MEMSIZE);
@@ -266,7 +254,6 @@ const struct amdgpu_nbio_funcs nbio_v6_1_funcs = {
.get_pcie_data_offset = nbio_v6_1_get_pcie_data_offset,
.get_rev_id = nbio_v6_1_get_rev_id,
.mc_access_enable = nbio_v6_1_mc_access_enable,
-   .hdp_flush = nbio_v6_1_hdp_flush,
.get_memsize = nbio_v6_1_get_memsize,
.sdma_doorbell_range = nbio_v6_1_sdma_doorbell_range,
.enable_doorbell_aperture = nbio_v6_1_enable_doorbell_aperture,
diff --git a/driver

[PATCH 4/5] drm/amdgpu: switch hdp callback functions for hdp v5

2020-12-28 Thread Likun Gao
From: Likun Gao 

Switch to use the HDP functions which unfied on hdp structure instead of
the scattered hdp callback functions.

Signed-off-by: Likun Gao 
Change-Id: If70683c8cb697a9e7a1ea5a21aa2ed84567e6919
---
 drivers/gpu/drm/amd/amdgpu/Makefile|   2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c |   9 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c |  14 +--
 drivers/gpu/drm/amd/amdgpu/nv.c| 160 +
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c |   2 +-
 5 files changed, 13 insertions(+), 174 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index d741fee91a37..e74cd443063a 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -71,7 +71,7 @@ amdgpu-y += \
vi.o mxgpu_vi.o nbio_v6_1.o soc15.o emu_soc.o mxgpu_ai.o nbio_v7_0.o 
vega10_reg_init.o \
vega20_reg_init.o nbio_v7_4.o nbio_v2_3.o nv.o navi10_reg_init.o 
navi14_reg_init.o \
arct_reg_init.o navi12_reg_init.o mxgpu_nv.o sienna_cichlid_reg_init.o 
vangogh_reg_init.o \
-   nbio_v7_2.o dimgrey_cavefish_reg_init.o hdp_v4_0.o
+   nbio_v7_2.o dimgrey_cavefish_reg_init.o hdp_v4_0.o hdp_v5_0.o
 
 # add DF block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index ba1086784525..10aae0abcffb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -38,7 +38,6 @@
 #include "smuio/smuio_11_0_0_offset.h"
 #include "smuio/smuio_11_0_0_sh_mask.h"
 #include "navi10_enum.h"
-#include "hdp/hdp_5_0_0_offset.h"
 #include "ivsrcid/gfx/irqsrcs_gfx_10_1.h"
 
 #include "soc15.h"
@@ -5691,7 +5690,7 @@ static int gfx_v10_0_cp_gfx_load_pfp_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_PFP_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_PFP_IC_BASE_CNTL, VMID, 0);
@@ -5769,7 +5768,7 @@ static int gfx_v10_0_cp_gfx_load_ce_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_CE_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_CE_IC_BASE_CNTL, VMID, 0);
@@ -5846,7 +5845,7 @@ static int gfx_v10_0_cp_gfx_load_me_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_ME_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_ME_IC_BASE_CNTL, VMID, 0);
@@ -6215,7 +6214,7 @@ static int gfx_v10_0_cp_compute_load_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 5648c48be77f..3b7c6c31fce1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -27,8 +27,6 @@
 #include "gmc_v10_0.h"
 #include "umc_v8_7.h"
 
-#include "hdp/hdp_5_0_0_offset.h"
-#include "hdp/hdp_5_0_0_sh_mask.h"
 #include "athub/athub_2_0_0_sh_mask.h"
 #include "athub/athub_2_0_0_offset.h"
 #include "dcn/dcn_2_0_0_offset.h"
@@ -312,7 +310,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device 
*adev, uint32_t vmid,
int r;
 
/* flush hdp cache */
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
/* For SRIOV run time, driver shouldn't access the register through MMIO
 * Directly use kiq to do the vm invalidation instead
@@ -995,7 +993,6 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device *adev)
 {
int r;
bool value;
-   u32 tmp;
 
if (adev->gart.bo == NULL) {
dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
@@ -1014,15 +1011,10 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device 
*adev)
if (r)
return r;
 
-   tmp = RREG32_SOC15(HDP, 0, mmHDP_MISC_CNTL);
-   tmp |= HDP_MISC_CNTL__FLUSH_INVALIDATE_CACHE_MASK;
-   WREG32_SOC15(HDP, 0, mmHDP_MISC_CNTL, tmp);
-
-   tmp = RREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL);
-   WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp);
+   adev->hdp.funcs->init_registers(adev);
 
   

[PATCH 3/5] drm/amdgpu: switch hdp callback functions for hdp v4

2020-12-28 Thread Likun Gao
From: Likun Gao 

Switch to use the HDP functions which unfied on hdp structure instead of
the scattered hdp callback functions.

Signed-off-by: Likun Gao 
Change-Id: I75016df403eca537fa30519e2918207461ec6f28
---
 drivers/gpu/drm/amd/amdgpu/Makefile   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  7 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 21 +--
 drivers/gpu/drm/amd/amdgpu/soc15.c| 82 +++
 4 files changed, 15 insertions(+), 97 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index c6262689e14e..d741fee91a37 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -71,7 +71,7 @@ amdgpu-y += \
vi.o mxgpu_vi.o nbio_v6_1.o soc15.o emu_soc.o mxgpu_ai.o nbio_v7_0.o 
vega10_reg_init.o \
vega20_reg_init.o nbio_v7_4.o nbio_v2_3.o nv.o navi10_reg_init.o 
navi14_reg_init.o \
arct_reg_init.o navi12_reg_init.o mxgpu_nv.o sienna_cichlid_reg_init.o 
vangogh_reg_init.o \
-   nbio_v7_2.o dimgrey_cavefish_reg_init.o
+   nbio_v7_2.o dimgrey_cavefish_reg_init.o hdp_v4_0.o
 
 # add DF block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 92e9d1f1207b..ae4bcdd630e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -89,6 +89,7 @@
 #include "amdgpu_gfx.h"
 #include "amdgpu_sdma.h"
 #include "amdgpu_nbio.h"
+#include "amdgpu_hdp.h"
 #include "amdgpu_dm.h"
 #include "amdgpu_virt.h"
 #include "amdgpu_csa.h"
@@ -1209,8 +1210,10 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_asic_read_bios_from_rom(adev, b, l) 
(adev)->asic_funcs->read_bios_from_rom((adev), (b), (l))
 #define amdgpu_asic_read_register(adev, se, sh, offset, 
v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v)))
 #define amdgpu_asic_get_config_memsize(adev) 
(adev)->asic_funcs->get_config_memsize((adev))
-#define amdgpu_asic_flush_hdp(adev, r) (adev)->asic_funcs->flush_hdp((adev), 
(r))
-#define amdgpu_asic_invalidate_hdp(adev, r) 
(adev)->asic_funcs->invalidate_hdp((adev), (r))
+#define amdgpu_asic_flush_hdp(adev, r) \
+   ((adev)->asic_funcs->flush_hdp ? (adev)->asic_funcs->flush_hdp((adev), 
(r)) : (adev)->hdp.funcs->flush_hdp((adev), (r)))
+#define amdgpu_asic_invalidate_hdp(adev, r) \
+   ((adev)->asic_funcs->invalidate_hdp ? 
(adev)->asic_funcs->invalidate_hdp((adev), (r)) : 
(adev)->hdp.funcs->invalidate_hdp((adev), (r)))
 #define amdgpu_asic_need_full_reset(adev) 
(adev)->asic_funcs->need_full_reset((adev))
 #define amdgpu_asic_init_doorbell_index(adev) 
(adev)->asic_funcs->init_doorbell_index((adev))
 #define amdgpu_asic_get_pcie_usage(adev, cnt0, cnt1) 
((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index e22268f9dba7..7b1f50fa9dac 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -31,8 +31,6 @@
 #include "amdgpu_atomfirmware.h"
 #include "amdgpu_gem.h"
 
-#include "hdp/hdp_4_0_offset.h"
-#include "hdp/hdp_4_0_sh_mask.h"
 #include "gc/gc_9_0_sh_mask.h"
 #include "dce/dce_12_0_offset.h"
 #include "dce/dce_12_0_sh_mask.h"
@@ -1571,7 +1569,6 @@ static int gmc_v9_0_hw_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
bool value;
int r, i;
-   u32 tmp;
 
/* The sequence of these two function calls matters.*/
gmc_v9_0_init_golden_registers(adev);
@@ -1590,24 +1587,10 @@ static int gmc_v9_0_hw_init(void *handle)
if (adev->mmhub.funcs->update_power_gating)
adev->mmhub.funcs->update_power_gating(adev, true);
 
-   switch (adev->asic_type) {
-   case CHIP_ARCTURUS:
-   WREG32_FIELD15(HDP, 0, HDP_MMHUB_CNTL, HDP_MMHUB_GCC, 1);
-   break;
-   default:
-   break;
-   }
-
-   WREG32_FIELD15(HDP, 0, HDP_MISC_CNTL, FLUSH_INVALIDATE_CACHE, 1);
-
-   tmp = RREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL);
-   WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp);
-
-   WREG32_SOC15(HDP, 0, mmHDP_NONSURFACE_BASE, (adev->gmc.vram_start >> 
8));
-   WREG32_SOC15(HDP, 0, mmHDP_NONSURFACE_BASE_HI, (adev->gmc.vram_start >> 
40));
+   adev->hdp.funcs->init_registers(adev);
 
/* After HDP is initialized, flush HDP.*/
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS)
value = false;
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/

[PATCH 1/5] drm/amdgpu: add hdp version 4 functions

2020-12-28 Thread Likun Gao
From: Likun Gao 

Unfiy hdp related function into hdp structure for hdp version 4.

Signed-off-by: Likun Gao 
Change-Id: I0462a24f0fae08b3d36c01a8f0df81599377c048
---
 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c | 150 ++
 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.h |  31 ++
 2 files changed, 181 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.h

diff --git a/drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c
new file mode 100644
index ..58cf0670d8af
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+#include "amdgpu.h"
+#include "amdgpu_atombios.h"
+#include "hdp_v4_0.h"
+#include "amdgpu_ras.h"
+
+#include "hdp/hdp_4_0_offset.h"
+#include "hdp/hdp_4_0_sh_mask.h"
+#include 
+
+#define mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL   0x00f7
+#define mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL_BASE_IDX  2
+/* for Vega20 register name change */
+#define mmHDP_MEM_POWER_CTRL0x00d4
+#define HDP_MEM_POWER_CTRL__IPH_MEM_POWER_CTRL_EN_MASK  0x0001L
+#define HDP_MEM_POWER_CTRL__IPH_MEM_POWER_LS_EN_MASK0x0002L
+#define HDP_MEM_POWER_CTRL__RC_MEM_POWER_CTRL_EN_MASK   0x0001L
+#define HDP_MEM_POWER_CTRL__RC_MEM_POWER_LS_EN_MASK 0x0002L
+#define mmHDP_MEM_POWER_CTRL_BASE_IDX   0
+
+static void hdp_v4_0_flush_hdp(struct amdgpu_device *adev,
+   struct amdgpu_ring *ring)
+{
+   uint32_t reg_addr;
+
+   if (adev->flags & AMD_IS_APU ||
+   adev->asic_type == CHIP_VEGA20 ||
+   adev->asic_type == CHIP_ARCTURUS)
+   reg_addr = (adev->rmmio_remap.reg_offset +
+   KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2;
+   else
+   reg_addr = SOC15_REG_OFFSET(NBIO, 0,
+   mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL);
+
+   if (!ring || !ring->funcs->emit_wreg)
+   WREG32_NO_KIQ(reg_addr, 0);
+   else
+   amdgpu_ring_emit_wreg(ring, reg_addr, 0);
+}
+
+static void hdp_v4_0_invalidate_hdp(struct amdgpu_device *adev,
+   struct amdgpu_ring *ring)
+{
+   if (!ring || !ring->funcs->emit_wreg)
+   WREG32_SOC15_NO_KIQ(HDP, 0, mmHDP_READ_CACHE_INVALIDATE, 1);
+   else
+   amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
+   HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 1);
+}
+
+static void hdp_v4_0_reset_ras_error_count(struct amdgpu_device *adev)
+{
+   if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__HDP))
+   return;
+   /*read back hdp ras counter to reset it to 0 */
+   RREG32_SOC15(HDP, 0, mmHDP_EDC_CNT);
+}
+
+static void hdp_v4_0_update_clock_gating(struct amdgpu_device *adev,
+bool enable)
+{
+   uint32_t def, data;
+
+   if (adev->asic_type == CHIP_VEGA20 ||
+   adev->asic_type == CHIP_ARCTURUS ||
+   adev->asic_type == CHIP_RENOIR) {
+   def = data = RREG32(SOC15_REG_OFFSET(HDP, 0, 
mmHDP_MEM_POWER_CTRL));
+
+   if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
+   data |= HDP_MEM_POWER_CTRL__IPH_MEM_POWER_CTRL_EN_MASK |
+   HDP_MEM_POWER_CTRL__IPH_MEM_POWER_LS_EN_MASK |
+   HDP_MEM_POWER_CTRL__RC_MEM_POWER_CTRL_EN_MASK |
+   HDP_MEM_POWER_CTRL__RC_MEM_POWER_LS_EN_MASK;
+   else
+   data &= 
~(HDP_MEM_POWER_CTRL__IPH_MEM_POWER_CTRL_EN_MASK |
+ 

[PATCH 2/5] drm/amdgpu: add hdp version 5 functions

2020-12-28 Thread Likun Gao
From: Likun Gao 

Unfiy hdp related function into hdp structure for hdp version 5.

Signed-off-by: Likun Gao 
Change-Id: I5d18a5eb4e4ba20b41b40f0454272ba94224b3b9
---
 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c | 212 ++
 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.h |  31 
 2 files changed, 243 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.h

diff --git a/drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c
new file mode 100644
index ..7a15e669b68d
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+#include "amdgpu.h"
+#include "amdgpu_atombios.h"
+#include "hdp_v5_0.h"
+
+#include "hdp/hdp_5_0_0_offset.h"
+#include "hdp/hdp_5_0_0_sh_mask.h"
+#include 
+
+static void hdp_v5_0_flush_hdp(struct amdgpu_device *adev,
+   struct amdgpu_ring *ring)
+{
+   if (!ring || !ring->funcs->emit_wreg)
+   WREG32_NO_KIQ((adev->rmmio_remap.reg_offset + 
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
+   else
+   amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + 
KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
+}
+
+static void hdp_v5_0_invalidate_hdp(struct amdgpu_device *adev,
+   struct amdgpu_ring *ring)
+{
+   if (!ring || !ring->funcs->emit_wreg) {
+   WREG32_SOC15_NO_KIQ(HDP, 0, mmHDP_READ_CACHE_INVALIDATE, 1);
+   } else {
+   amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
+   HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 
1);
+   }
+}
+
+static void hdp_v5_0_update_mem_power_gating(struct amdgpu_device *adev,
+ bool enable)
+{
+   uint32_t hdp_clk_cntl, hdp_clk_cntl1;
+   uint32_t hdp_mem_pwr_cntl;
+
+   if (!(adev->cg_flags & (AMD_CG_SUPPORT_HDP_LS |
+   AMD_CG_SUPPORT_HDP_DS |
+   AMD_CG_SUPPORT_HDP_SD)))
+   return;
+
+   hdp_clk_cntl = hdp_clk_cntl1 = RREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL);
+   hdp_mem_pwr_cntl = RREG32_SOC15(HDP, 0, mmHDP_MEM_POWER_CTRL);
+
+   /* Before doing clock/power mode switch,
+* forced on IPH & RC clock */
+   hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL,
+IPH_MEM_CLK_SOFT_OVERRIDE, 1);
+   hdp_clk_cntl = REG_SET_FIELD(hdp_clk_cntl, HDP_CLK_CNTL,
+RC_MEM_CLK_SOFT_OVERRIDE, 1);
+   WREG32_SOC15(HDP, 0, mmHDP_CLK_CNTL, hdp_clk_cntl);
+
+   /* HDP 5.0 doesn't support dynamic power mode switch,
+* disable clock and power gating before any changing */
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+IPH_MEM_POWER_CTRL_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+IPH_MEM_POWER_LS_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+IPH_MEM_POWER_DS_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+IPH_MEM_POWER_SD_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+RC_MEM_POWER_CTRL_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_CTRL,
+RC_MEM_POWER_LS_EN, 0);
+   hdp_mem_pwr_cntl = REG_SET_FIELD(hdp_mem_pwr_cntl, HDP_MEM_POWER_

[PATCH 2/2] drm/amdgpu: unfiy hdp function into hdp structure

2020-12-27 Thread Likun Gao
From: Likun Gao 

Separtate HDP related function into hdp structure.
Remove redundant operation related HDP.

Signed-off-by: Likun Gao 
Change-Id: I1549ae2a7860c3b845897e99b3c2351da277bc8c
---
 drivers/gpu/drm/amd/amdgpu/Makefile  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h |   1 -
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c   |   9 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c|   1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c   |  14 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c|  21 +--
 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c| 150 
 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.h|  31 
 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c| 212 +++
 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.h|  31 
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c   |  10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c   |  13 --
 drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c   |  10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v7_2.c   |  10 --
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c   |  10 --
 drivers/gpu/drm/amd/amdgpu/nv.c  | 151 +---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c   |   2 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   |   1 -
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   |   1 -
 drivers/gpu/drm/amd/amdgpu/soc15.c   |  71 +---
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c|   1 -
 drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c|   1 -
 23 files changed, 451 insertions(+), 303 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v4_0.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/hdp_v5_0.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index c6262689e14e..2b379fd12b44 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -71,7 +71,7 @@ amdgpu-y += \
vi.o mxgpu_vi.o nbio_v6_1.o soc15.o emu_soc.o mxgpu_ai.o nbio_v7_0.o 
vega10_reg_init.o \
vega20_reg_init.o nbio_v7_4.o nbio_v2_3.o nv.o navi10_reg_init.o 
navi14_reg_init.o \
arct_reg_init.o navi12_reg_init.o mxgpu_nv.o sienna_cichlid_reg_init.o 
vangogh_reg_init.o \
-   nbio_v7_2.o dimgrey_cavefish_reg_init.o
+   nbio_v7_2.o dimgrey_cavefish_reg_init.o hdp_v5_0.o hdp_v4_0.o
 
 # add DF block
 amdgpu-y += \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 92e9d1f1207b..ec91f5e32b7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -89,6 +89,7 @@
 #include "amdgpu_gfx.h"
 #include "amdgpu_sdma.h"
 #include "amdgpu_nbio.h"
+#include "amdgpu_hdp.h"
 #include "amdgpu_dm.h"
 #include "amdgpu_virt.h"
 #include "amdgpu_csa.h"
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
index e62cc0e1a5ad..4ba0024aedf1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
@@ -57,7 +57,6 @@ struct amdgpu_nbio_funcs {
u32 (*get_pcie_port_data_offset)(struct amdgpu_device *adev);
u32 (*get_rev_id)(struct amdgpu_device *adev);
void (*mc_access_enable)(struct amdgpu_device *adev, bool enable);
-   void (*hdp_flush)(struct amdgpu_device *adev, struct amdgpu_ring *ring);
u32 (*get_memsize)(struct amdgpu_device *adev);
void (*sdma_doorbell_range)(struct amdgpu_device *adev, int instance,
bool use_doorbell, int doorbell_index, int 
doorbell_size);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index ba1086784525..10aae0abcffb 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -38,7 +38,6 @@
 #include "smuio/smuio_11_0_0_offset.h"
 #include "smuio/smuio_11_0_0_sh_mask.h"
 #include "navi10_enum.h"
-#include "hdp/hdp_5_0_0_offset.h"
 #include "ivsrcid/gfx/irqsrcs_gfx_10_1.h"
 
 #include "soc15.h"
@@ -5691,7 +5690,7 @@ static int gfx_v10_0_cp_gfx_load_pfp_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_PFP_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_PFP_IC_BASE_CNTL, VMID, 0);
@@ -5769,7 +5768,7 @@ static int gfx_v10_0_cp_gfx_load_ce_microcode(struct 
amdgpu_device *adev)
}
 
if (amdgpu_emu_mode == 1)
-   adev->nbio.funcs->hdp_flush(adev, NULL);
+   adev->hdp.funcs->flush_hdp(adev, NULL);
 
tmp = RREG32_SOC15(GC, 0, mmCP_CE_IC_BASE_CNTL);
tmp = REG_SET_FIELD(tmp, CP_CE_IC_BASE_CNTL, VMID, 0);
@@ -5846,7 +5845,7 @@ static int gfx_v10_0_

[PATCH 1/2] drm/amdgpu: add amdgpu_hdp structure

2020-12-27 Thread Likun Gao
From: Hawking Zhang 

amdgpu_hdp hold all the callbacks for hdp

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h |  4 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h | 40 +
 2 files changed, 44 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 100a431f0792..92e9d1f1207b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -107,6 +107,7 @@
 #include "amdgpu_gfxhub.h"
 #include "amdgpu_df.h"
 #include "amdgpu_smuio.h"
+#include "amdgpu_hdp.h"
 
 #define MAX_GPU_INSTANCE   16
 
@@ -924,6 +925,9 @@ struct amdgpu_device {
/* nbio */
struct amdgpu_nbio  nbio;
 
+   /* hdp */
+   struct amdgpu_hdp   hdp;
+
/* smuio */
struct amdgpu_smuio smuio;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h
new file mode 100644
index ..43caf9f8cc11
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+#ifndef __AMDGPU_HDP_H__
+#define __AMDGPU_HDP_H__
+
+struct amdgpu_hdp_funcs {
+   void (*flush_hdp)(struct amdgpu_device *adev, struct amdgpu_ring *ring);
+   void (*invalidate_hdp)(struct amdgpu_device *adev,
+  struct amdgpu_ring *ring);
+   void (*reset_ras_error_count)(struct amdgpu_device *adev);
+   void (*update_clock_gating)(struct amdgpu_device *adev, bool enable);
+   void (*get_clock_gating_state)(struct amdgpu_device *adev, u32 *flags);
+   void (*init_registers)(struct amdgpu_device *adev);
+};
+
+struct amdgpu_hdp {
+   const struct amdgpu_hdp_funcs   *funcs;
+};
+
+#endif /* __AMDGPU_HDP_H__ */
-- 
2.25.1

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


[v2] drm/amdgpu: skip vram operation for BAMACO runtime

2020-12-13 Thread Likun Gao
From: Likun Gao 

Skip vram related operation for bamaco rumtime suspend and resume as
vram is alive when BAMACO.
It can save about 32ms when suspend and about 15ms when resume.

v2: add local adev variable for maco enablement which checked by device
MACO support cap and runtime method parameter to have a mix of devices
that support different runtime pm modes.

Signed-off-by: Likun Gao 
Change-Id: I99cbaf720bfeecdc6682057b238d29c4e41cf155
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c|  9 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c   | 72 +++
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  7 +-
 4 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index eed5410947e9..288c41e0b61f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1027,6 +1027,7 @@ struct amdgpu_device {
/* enable runtime pm on the device */
boolrunpm;
boolin_runpm;
+   boolrunpm_maco_en;
 
boolpm_sysfs_en;
boolucode_sysfs_en;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0ec7c28c4d5a..0c608b903ec3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct 
amdgpu_device *adev)
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-   amdgpu_device_fill_reset_magic(adev);
+   if (!adev->runpm_maco_en || !adev->in_runpm)
+   amdgpu_device_fill_reset_magic(adev);
 
r = amdgpu_device_enable_mgpu_fan_boost();
if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
amdgpu_amdkfd_suspend(adev, !fbcon);
 
/* evict vram memory */
-   amdgpu_bo_evict_vram(adev);
+   if (!adev->runpm_maco_en || !adev->in_runpm)
+   amdgpu_bo_evict_vram(adev);
 
amdgpu_fence_driver_suspend(adev);
 
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 * This second call to evict vram is to evict the gart page table
 * using the CPU.
 */
-   amdgpu_bo_evict_vram(adev);
+   if (!adev->runpm_maco_en || !adev->in_runpm)
+   amdgpu_bo_evict_vram(adev);
 
return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 523d22db094b..a198bc5d6a68 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -397,10 +397,12 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
 
-   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
-   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+   if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
  AMDGPU_GEM_DOMAIN_VRAM,
  >tmr_bo, >tmr_mc_addr, pptr);
+   }
 
return ret;
 }
@@ -504,8 +506,10 @@ static int psp_tmr_terminate(struct psp_context *psp)
return ret;
 
/* free TMR memory buffer */
-   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, pptr);
+   if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, pptr);
+   }
 
return 0;
 }
@@ -795,9 +799,10 @@ int psp_xgmi_terminate(struct psp_context *psp)
psp->xgmi_context.initialized = 0;
 
/* free xgmi shared memory */
-   amdgpu_bo_free_kernel(>xgmi_context.xgmi_shared_bo,
-   >xgmi_context.xgmi_shared_mc_addr,
-   >xgmi_context.xgmi_shared_buf);
+   if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+   amdgpu_bo_free_kernel(>xgmi_context.xgmi_shared_bo,
+   >xgmi_context.xgmi_shared_mc_addr,
+   >xgmi_context.xgmi_shared_buf);
 
return 0;
 }
@@ -812,7 +817,8 @@ int psp_xgmi_initialize(struct psp_context *psp)
!psp->adev->psp.ta_xgmi_start_addr)
return -ENOENT;
 
-   if (!psp->xgmi_context.initialized) {
+   if (!psp->xgmi_context.initialized &&
+   

[PATCH] drm/amdgpu: skip vram operation for BAMACO runtime

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

Skip vram related operation for bamaco rumtime suspend and resume as
vram is alive when BAMACO.
It can save about 32ms when suspend and about 15ms when resume.

Signed-off-by: Likun Gao 
Change-Id: I6ad39765de5ed1aac2dc51e96ed7a21a727272cd
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  9 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c| 72 +-
 2 files changed, 50 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 0ec7c28c4d5a..66b790dfb151 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct 
amdgpu_device *adev)
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-   amdgpu_device_fill_reset_magic(adev);
+   if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)
+   amdgpu_device_fill_reset_magic(adev);
 
r = amdgpu_device_enable_mgpu_fan_boost();
if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
amdgpu_amdkfd_suspend(adev, !fbcon);
 
/* evict vram memory */
-   amdgpu_bo_evict_vram(adev);
+   if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)
+   amdgpu_bo_evict_vram(adev);
 
amdgpu_fence_driver_suspend(adev);
 
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 * This second call to evict vram is to evict the gart page table
 * using the CPU.
 */
-   amdgpu_bo_evict_vram(adev);
+   if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)
+   amdgpu_bo_evict_vram(adev);
 
return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 523d22db094b..67e74b43a1ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -397,10 +397,12 @@ static int psp_tmr_init(struct psp_context *psp)
}
}
 
-   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
-   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+   if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm) {
+   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
+   ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
  AMDGPU_GEM_DOMAIN_VRAM,
  >tmr_bo, >tmr_mc_addr, pptr);
+   }
 
return ret;
 }
@@ -504,8 +506,10 @@ static int psp_tmr_terminate(struct psp_context *psp)
return ret;
 
/* free TMR memory buffer */
-   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
-   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, pptr);
+   if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm) {
+   pptr = amdgpu_sriov_vf(psp->adev) ? _buf : NULL;
+   amdgpu_bo_free_kernel(>tmr_bo, >tmr_mc_addr, pptr);
+   }
 
return 0;
 }
@@ -795,9 +799,10 @@ int psp_xgmi_terminate(struct psp_context *psp)
psp->xgmi_context.initialized = 0;
 
/* free xgmi shared memory */
-   amdgpu_bo_free_kernel(>xgmi_context.xgmi_shared_bo,
-   >xgmi_context.xgmi_shared_mc_addr,
-   >xgmi_context.xgmi_shared_buf);
+   if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)
+   amdgpu_bo_free_kernel(>xgmi_context.xgmi_shared_bo,
+   >xgmi_context.xgmi_shared_mc_addr,
+   >xgmi_context.xgmi_shared_buf);
 
return 0;
 }
@@ -812,7 +817,8 @@ int psp_xgmi_initialize(struct psp_context *psp)
!psp->adev->psp.ta_xgmi_start_addr)
return -ENOENT;
 
-   if (!psp->xgmi_context.initialized) {
+   if (!psp->xgmi_context.initialized &&
+   ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {
ret = psp_xgmi_init_shared_buf(psp);
if (ret)
return ret;
@@ -1122,9 +1128,10 @@ static int psp_ras_terminate(struct psp_context *psp)
psp->ras.ras_initialized = false;
 
/* free ras shared memory */
-   amdgpu_bo_free_kernel(>ras.ras_shared_bo,
-   >ras.ras_shared_mc_addr,
-   >ras.ras_shared_buf);
+   if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)
+   amdgpu_bo_free_kernel(>ras.ras_shared_bo,
+   >ras.ras_shared_mc_addr,
+   >ras.ras_shared_buf);
 
return 0;
 }
@@ -1145,7 +1152,8 @@ static int psp_ras_initialize(struct psp_context *psp)
return 0;
}
 
- 

[V2] drm/amdgpu: add judgement for suspend/resume sequence

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

S0ix only makes sense on APUs since they are part of the platform, so
only when the ASIC is APU should set amdgpu_acpi_is_s0ix_supported flag
to deal with the related situation.

Signed-off-by: Likun Gao 
Change-Id: Ic89df206734fa7e6ce3e5a784171f149a07edc80
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h| 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c   | 8 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++---
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 83ac06a3ec05..eed5410947e9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1314,11 +1314,11 @@ int amdgpu_acpi_pcie_notify_device_ready(struct 
amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_device *adev,
struct amdgpu_dm_backlight_caps *caps);
-bool amdgpu_acpi_is_s0ix_supported(void);
+bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
-static inline bool amdgpu_acpi_is_s0ix_supported(void) { return false; }
+static inline bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev) { 
return false; }
 #endif
 
 int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index fd66ac00c7f5..8155c54392c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -901,10 +901,12 @@ void amdgpu_acpi_fini(struct amdgpu_device *adev)
  *
  * returns true if supported, false if not.
  */
-bool amdgpu_acpi_is_s0ix_supported()
+bool amdgpu_acpi_is_s0ix_supported(struct amdgpu_device *adev)
 {
-   if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)
-   return true;
+   if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
+   if (adev->flags & AMD_IS_APU)
+   return true;
+   }
 
return false;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 52d6f1fbe890..66b790dfb151 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2651,7 +2651,7 @@ static int amdgpu_device_ip_suspend_phase1(struct 
amdgpu_device *adev)
 {
int i, r;
 
-   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev)) {
+   if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
}
@@ -3712,7 +3712,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 
amdgpu_fence_driver_suspend(adev);
 
-   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev))
+   if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
r = amdgpu_device_ip_suspend_phase2(adev);
else
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
@@ -3747,7 +3747,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool 
fbcon)
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
 
-   if (amdgpu_acpi_is_s0ix_supported())
+   if (amdgpu_acpi_is_s0ix_supported(adev))
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D0Entry);
 
/* post card */
-- 
2.25.1

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


[PATCH] drm/amdgpu: add judgement for suspend/resume sequence

2020-12-06 Thread Likun Gao
From: Likun Gao 

Only APU should deal with the situation that amdgpu suspend/resume with
s0i3 support to skip RLC/CP/GFX disable during suspend.

Signed-off-by: Likun Gao 
Change-Id: Icca91b3497f12a6d78f005ee63461cf0e8f24958
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 79dd85f71fab..75f40a8c59f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2650,7 +2650,8 @@ static int amdgpu_device_ip_suspend_phase1(struct 
amdgpu_device *adev)
 {
int i, r;
 
-   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev)) {
+   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev) ||
+   !(adev->flags & AMD_IS_APU)) {
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
}
@@ -3710,7 +3711,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool 
fbcon)
 
amdgpu_fence_driver_suspend(adev);
 
-   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev))
+   if (!amdgpu_acpi_is_s0ix_supported() || amdgpu_in_reset(adev) ||
+   !(adev->flags & AMD_IS_APU))
r = amdgpu_device_ip_suspend_phase2(adev);
else
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
@@ -3744,7 +3746,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool 
fbcon)
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
 
-   if (amdgpu_acpi_is_s0ix_supported())
+   if (amdgpu_acpi_is_s0ix_supported() && (adev->flags & AMD_IS_APU))
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D0Entry);
 
/* post card */
-- 
2.25.1

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


[PATCH] drm/amdgpu: increase reserved VRAM size to 8MB

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

4MB reserved VRAM size which used for page tables was not enough for
some condition, increase it to 8MB to reduce page table contention.

Signed-off-by: Likun Gao 
Change-Id: Ibbc0c14a75bd0e57d77e30b7140a144f4030114a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index fa7d181934e5..1ed130d518a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -104,7 +104,7 @@ struct amdgpu_bo_list_entry;
 #define AMDGPU_VM_FAULT_STOP_ALWAYS2
 
 /* Reserve 4MB VRAM for page tables */
-#define AMDGPU_VM_RESERVED_VRAM(4ULL << 20)
+#define AMDGPU_VM_RESERVED_VRAM(8ULL << 20)
 
 /* max number of VMHUB */
 #define AMDGPU_MAX_VMHUBS  3
-- 
2.25.1

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


[PATCH] drm/amdgpu: update golden setting for sienna_cichlid

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

Update golden setting for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: I2f107ced1540c9ec145950cf8b58664c6127756d
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index a6d03931f7fa..2bd6e40d5833 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3148,6 +3148,8 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_3[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0x, 0x0280),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0x, 0x0080),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_EXCEPTION_CONTROL, 0x7fff0f1f, 
0x00b8),
+   SOC15_REG_GOLDEN_VALUE(GC, 0 ,mmGCEA_SDP_TAG_RESERVE0, 0x, 
0x10100100),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCEA_SDP_TAG_RESERVE1, 0x, 
0x1788),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCR_GENERAL_CNTL_Sienna_Cichlid, 
0x1ff1, 0x0500),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCUTCL2_CGTT_CLK_CTRL_Sienna_Cichlid, 
0xff00, 0xff008080),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid, 
0xff00, 0xff008080),
-- 
2.25.1

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


[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_baco;
@@ -1499,15 +1502,34 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, 
enum smu_baco_state state)
mutex_lock(_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


[PATCH 1/2] drm/amd/pm: fix the crash after runtime pm resume

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

Some features are still disabled after runtime pm resume. This can take
the hardware back.
Unlike other projects, this doesn't need pptable retransfer.

Signed-off-by: Kenneth Feng 
Signed-off-by: Likun Gao 
Change-Id: If7c4148380ddb8a08aed06a8ba9afae98075947d
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 8e3e7a5bbffe..17a36a962e31 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -918,11 +918,15 @@ static int smu_smc_hw_setup(struct smu_context *smu)
 {
struct amdgpu_device *adev = smu->adev;
uint32_t pcie_gen = 0, pcie_width = 0;
-   int ret;
+   int ret = 0;
 
if (adev->in_suspend && smu_is_dpm_running(smu)) {
dev_info(adev->dev, "dpm has been enabled\n");
-   return 0;
+   /* this is needed specifically */
+   if ((adev->asic_type >= CHIP_SIENNA_CICHLID) &&
+   (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+   ret = smu_system_features_control(smu, true);
+   return ret;
}
 
ret = smu_init_display_count(smu, 0);
-- 
2.25.1

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


[PATCH] drm/amd/pm: update driver if file for sienna cichlid

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

Update driver if file for sienna cichlid.

Signed-off-by: Likun Gao 
Change-Id: Ibcffb2a668202f941b1e8e7a22924976c910cf35
---
 .../pm/inc/smu11_driver_if_sienna_cichlid.h   | 16 +-
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +-
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 22 ---
 3 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
index e418a46603c8..fa95147b5a63 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,9 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x3A
+#define SMU11_DRIVER_IF_VERSION 0x3B
 
-#define PPTABLE_Sienna_Cichlid_SMU_VERSION 6
+#define PPTABLE_Sienna_Cichlid_SMU_VERSION 7
 
 #define NUM_GFXCLK_DPM_LEVELS  16
 #define NUM_SMNCLK_DPM_LEVELS  2
@@ -437,6 +437,7 @@ typedef enum {
   PIECEWISE_LINEAR_FUSED_MODEL = 0,
   PIECEWISE_LINEAR_PP_MODEL,
   QUADRATIC_PP_MODEL,
+  PERPART_PIECEWISE_LINEAR_PP_MODEL,  
 } DfllDroopModelSelect_e;
 
 typedef struct {
@@ -612,7 +613,9 @@ typedef struct {
   uint16_t   SmnclkDpmFreq[NUM_SMNCLK_DPM_LEVELS];   // in MHz
   uint16_t   SmnclkDpmVoltage [NUM_SMNCLK_DPM_LEVELS];   // mV(Q2)
 
-  uint32_t PaddingAPCC[4];
+  uint32_t   PaddingAPCC;
+  uint16_t   
PerPartDroopVsetGfxDfll[NUM_PIECE_WISE_LINEAR_DROOP_MODEL_VF_POINTS];  //In 
mV(Q2)
+  uint16_t   PaddingPerPartDroop;
 
   // SECTION: Throttler settings
   uint32_t ThrottlerControlMask;   // See Throtter masks defines
@@ -667,7 +670,9 @@ typedef struct {
   uint16_t   FreqTablePhyclk   [NUM_PHYCLK_DPM_LEVELS  ]; // In MHz
   uint16_t   FreqTableDtbclk   [NUM_DTBCLK_DPM_LEVELS  ]; // In MHz
   uint16_t   FreqTableFclk [NUM_FCLK_DPM_LEVELS]; // In MHz
-  uint32_t   Paddingclks[16];
+  uint32_t   Paddingclks;
+
+  DroopInt_t 
PerPartDroopModelGfxDfll[NUM_PIECE_WISE_LINEAR_DROOP_MODEL_VF_POINTS]; //GHz 
->Vstore in IEEE float format
 
   uint32_t   DcModeMaxFreq [PPCLK_COUNT]; // In MHz
   
@@ -1221,7 +1226,8 @@ typedef struct {
 #define WORKLOAD_PPLIB_VR_BIT 4 
 #define WORKLOAD_PPLIB_COMPUTE_BIT5 
 #define WORKLOAD_PPLIB_CUSTOM_BIT 6 
-#define WORKLOAD_PPLIB_COUNT  7 
+#define WORKLOAD_PPLIB_W3D_BIT7 
+#define WORKLOAD_PPLIB_COUNT  8 
 
 
 // These defines are used with the following messages:
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 41bc919dc9f4..eff396c7a281 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x36
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x3A
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x3B
 #define SMU11_DRIVER_IF_VERSION_Navy_Flounder 0x5
 #define SMU11_DRIVER_IF_VERSION_VANGOGH 0x02
 #define SMU11_DRIVER_IF_VERSION_Dimgrey_Cavefish 0xD
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 0600befc6e4c..21c5ea3a4a63 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -1805,11 +1805,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "SmnclkDpmFreq[%d] = 0x%x\n", i, 
pptable->SmnclkDpmFreq[i]);
dev_info(smu->adev->dev, "SmnclkDpmVoltage[%d] = 0x%x\n", i, 
pptable->SmnclkDpmVoltage[i]);
}
-   dev_info(smu->adev->dev, "PaddingAPCC[0] = 0x%x\n", 
pptable->PaddingAPCC[0]);
-   dev_info(smu->adev->dev, "PaddingAPCC[1] = 0x%x\n", 
pptable->PaddingAPCC[1]);
-   dev_info(smu->adev->dev, "PaddingAPCC[2] = 0x%x\n", 
pptable->PaddingAPCC[2]);
-   dev_info(smu->adev->dev, "PaddingAPCC[3] = 0x%x\n", 
pptable->PaddingAPCC[3]);
-
dev_info(smu->adev->dev, "ThrottlerControlMask = 0x%x\n", 
pptable->ThrottlerControlMask);
 
dev_info(smu->adev->dev, "FwDStateMask = 0x%x\n", 
pptable->FwDStateMask);
@@ -2036,23 +2031,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
for (i = 0; i < NUM_FCLK_DPM_LEVELS; i++)
dev_info(smu->adev->dev, "  .[%02d] = 0x%x\n", i, 
pptable->FreqTableFclk[i]);
 
-   dev_info(smu->adev->dev, "Paddingclks[0] = 0x%x\n",  
pptab

[PATCH] drm/amdgpu: update golden setting for sienna_cichlid

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

Update golden setting for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: I968f405a11b640174f5bc03eacc5f4edee47815a
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 270b502f28f2..a6d03931f7fa 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -155,6 +155,11 @@
 #define mmCGTT_SPI_CS_CLK_CTRL 0x507c
 #define mmCGTT_SPI_CS_CLK_CTRL_BASE_IDX 1
 
+#define mmGCUTCL2_CGTT_CLK_CTRL_Sienna_Cichlid 0x16f3
+#define mmGCUTCL2_CGTT_CLK_CTRL_Sienna_Cichlid_BASE_IDX0
+#define mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid  0x15db
+#define mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid_BASE_IDX0
+
 MODULE_FIRMWARE("amdgpu/navi10_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi10_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi10_me.bin");
@@ -3144,6 +3149,8 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_3[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0x, 0x0080),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_EXCEPTION_CONTROL, 0x7fff0f1f, 
0x00b8),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCR_GENERAL_CNTL_Sienna_Cichlid, 
0x1ff1, 0x0500),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCUTCL2_CGTT_CLK_CTRL_Sienna_Cichlid, 
0xff00, 0xff008080),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid, 
0xff00, 0xff008080),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGE_PC_CNTL, 0x003f, 0x00280400),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2A_ADDR_MATCH_MASK, 0x, 
0xffcf),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_ADDR_MATCH_MASK, 0x, 
0xffcf),
-- 
2.25.1

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


[PATCH xf86-video-amdgpu] Fix drmmode_crtc_scanout_create logic

2020-10-29 Thread Likun Gao
From: Likun Gao 

If crtc scanout create successfully, the function of
drmmode_crtc_scanout_create should return TURE.

Signed-off-by: Likun Gao 
Change-Id: I4b7540b0d128c2d55f2b8491569004741435f343
---
 src/drmmode_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index f74106e..465915f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -513,9 +513,10 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr 
*scanout,
ErrorF("failed to create CRTC scanout FB\n");
 error: 
drmmode_crtc_scanout_destroy(scanout);
+   return FALSE;
}
 
-   return FALSE;
+   return TRUE;
 }
 
 static void
-- 
2.25.1

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


[PATCH] drm/amdgpu: correct the cu and rb info for sienna cichlid

2020-10-21 Thread Likun Gao
From: Likun Gao 

Skip disabled sa to correct the cu_info and active_rbs for sienna cichlid.

Signed-off-by: Likun Gao 
Change-Id: I271682e11f3472cb5ba882e04329976059e06a13
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 402fe623c5d8..49ce4aaa2bac 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4579,12 +4579,17 @@ static void gfx_v10_0_setup_rb(struct amdgpu_device 
*adev)
int i, j;
u32 data;
u32 active_rbs = 0;
+   u32 bitmap;
u32 rb_bitmap_width_per_sh = adev->gfx.config.max_backends_per_se /
adev->gfx.config.max_sh_per_se;
 
mutex_lock(>grbm_idx_mutex);
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
+   bitmap = i * adev->gfx.config.max_sh_per_se + j;
+   if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
+   ((gfx_v10_3_get_disabled_sa(adev) >> bitmap) & 1))
+   continue;
gfx_v10_0_select_se_sh(adev, i, j, 0x);
data = gfx_v10_0_get_rb_active_bitmap(adev);
active_rbs |= data << ((i * 
adev->gfx.config.max_sh_per_se + j) *
@@ -8829,6 +8834,10 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device 
*adev,
mutex_lock(>grbm_idx_mutex);
for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
+   bitmap = i * adev->gfx.config.max_sh_per_se + j;
+   if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
+   ((gfx_v10_3_get_disabled_sa(adev) >> bitmap) & 1))
+   continue;
mask = 1;
ao_bitmap = 0;
counter = 0;
-- 
2.25.1

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


[PATCH] drm/amd/pm: update driver if file for sienna cichlid

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

Update driver if file for sienna cichlid.

Signed-off-by: Likun Gao 
Change-Id: Ie386abcd0a00fd904155361c9aa8c0861473552a
---
 .../amd/pm/inc/smu11_driver_if_sienna_cichlid.h| 14 --
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
index 1275246769d9..e418a46603c8 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x39
+#define SMU11_DRIVER_IF_VERSION 0x3A
 
 #define PPTABLE_Sienna_Cichlid_SMU_VERSION 6
 
@@ -226,6 +226,8 @@ typedef enum {
 #define FW_DSTATE_MEM_PLL_PWRDN_BIT 9   
 #define FW_DSTATE_OPTIMIZE_MALL_REFRESH_BIT 10
 #define FW_DSTATE_MEM_PSI_BIT   11
+#define FW_DSTATE_HSR_NON_STROBE_BIT12
+#define FW_DSTATE_MP0_ENTER_WFI_BIT 13
 
 #define FW_DSTATE_SOC_ULV_MASK(1 << FW_DSTATE_SOC_ULV_BIT  
)
 #define FW_DSTATE_G6_HSR_MASK (1 << FW_DSTATE_G6_HSR_BIT   
)
@@ -239,6 +241,8 @@ typedef enum {
 #define FW_DSTATE_MEM_PLL_PWRDN_MASK  (1 << 
FW_DSTATE_MEM_PLL_PWRDN_BIT)
 #define FW_DSTATE_OPTIMIZE_MALL_REFRESH_MASK  (1 << 
FW_DSTATE_OPTIMIZE_MALL_REFRESH_BIT)
 #define FW_DSTATE_MEM_PSI_MASK(1 << FW_DSTATE_MEM_PSI_BIT  
  )
+#define FW_DSTATE_HSR_NON_STROBE_MASK (1 << 
FW_DSTATE_HSR_NON_STROBE_BIT)
+#define FW_DSTATE_MP0_ENTER_WFI_MASK  (1 << 
FW_DSTATE_MP0_ENTER_WFI_BIT)
 
 // GFX GPO Feature Contains PACE and DEM sub features
 #define GFX_GPO_PACE_BIT   0
@@ -804,7 +808,11 @@ typedef struct {
   uint32_t VcBtcVminA;  // A_VMIN
   uint32_t VcBtcVminB;  // B_VMIN  
   
-  uint32_t SkuReserved[9];
+  //GPIO Board feature
+  uint16_t LedGpio;//GeneriA GPIO flag used to control the 
radeon LEDs
+  uint16_t GfxPowerStagesGpio; //Genlk_vsync GPIO flag used to control 
gfx power stages 
+  
+  uint32_t SkuReserved[8];
 
 
   // MAJOR SECTION: BOARD PARAMETERS
@@ -1026,6 +1034,8 @@ typedef struct {
   uint16_t VcnActivityPercentage  ; //place holder, David N. to provide full 
sequence
   uint8_t  PcieRate   ;
   uint8_t  PcieWidth  ;
+  uint16_t AverageGfxclkFrequencyTarget;
+  uint16_t Padding16_2;
 
 } SmuMetrics_t;
 
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 75697b78c13f..820b9d34c997 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x36
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x39
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x3A
 #define SMU11_DRIVER_IF_VERSION_Navy_Flounder 0x4
 
 /* MP Apertures */
-- 
2.25.1

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


[PATCH] drm/amd/pm: fix pcie information for sienna cichlid

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

Fix the function used for sienna cichlid to get correct PCIE information
by pp_dpm_pcie.

Signed-off-by: Likun Gao 
Change-Id: I81e529be6e96f083eb7aa244c16700422bde5fec
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index c8e8790e0871..e00c38b1bd41 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -964,8 +964,8 @@ static int sienna_cichlid_print_clk_levels(struct 
smu_context *smu,
}
break;
case SMU_PCIE:
-   gen_speed = smu_v11_0_get_current_pcie_link_speed(smu);
-   lane_width = smu_v11_0_get_current_pcie_link_width(smu);
+   gen_speed = smu_v11_0_get_current_pcie_link_speed_level(smu);
+   lane_width = smu_v11_0_get_current_pcie_link_width_level(smu);
for (i = 0; i < NUM_LINK_LEVELS; i++)
size += sprintf(buf + size, "%d: %s %s %dMhz %s\n", i,

(dpm_context->dpm_tables.pcie_table.pcie_gen[i] == 0) ? "2.5GT/s," :
-- 
2.25.1

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


[PATCH] drm/amdgpu: add function to program pbb mode for sienna cichlid

2020-10-14 Thread Likun Gao
From: Likun Gao 

Add function for sienna_cichlid to force PBB workload mode to zero by
checking whether there have SE been harvested.

Signed-off-by: Likun Gao 
Change-Id: I3bf2fe0b976affe26c829ac67bee176018f13fe9
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 62 ++
 1 file changed, 62 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 65804137b7f8..aa48eab85c7a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -112,6 +112,22 @@
 #define mmCP_HYP_ME_UCODE_DATA 0x5817
 #define mmCP_HYP_ME_UCODE_DATA_BASE_IDX1
 
+//CC_GC_SA_UNIT_DISABLE
+#define mmCC_GC_SA_UNIT_DISABLE 0x0fe9
+#define mmCC_GC_SA_UNIT_DISABLE_BASE_IDX0
+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT   0x8
+#define CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK 0xFF00L
+//GC_USER_SA_UNIT_DISABLE
+#define mmGC_USER_SA_UNIT_DISABLE   0x0fea
+#define mmGC_USER_SA_UNIT_DISABLE_BASE_IDX  0
+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT 0x8
+#define GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK   0xFF00L
+//PA_SC_ENHANCE_3
+#define mmPA_SC_ENHANCE_3   0x1085
+#define mmPA_SC_ENHANCE_3_BASE_IDX  0
+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO__SHIFT 0x3
+#define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO_MASK   0x0008L
+
 MODULE_FIRMWARE("amdgpu/navi10_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi10_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi10_me.bin");
@@ -3188,6 +3204,8 @@ static int 
gfx_v10_0_wait_for_rlc_autoload_complete(struct amdgpu_device *adev);
 static void gfx_v10_0_ring_emit_ce_meta(struct amdgpu_ring *ring, bool resume);
 static void gfx_v10_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume);
 static void gfx_v10_0_ring_emit_frame_cntl(struct amdgpu_ring *ring, bool 
start, bool secure);
+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev);
+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev);
 
 static void gfx10_kiq_set_resources(struct amdgpu_ring *kiq_ring, uint64_t 
queue_mask)
 {
@@ -6990,6 +7008,9 @@ static int gfx_v10_0_hw_init(void *handle)
if (r)
return r;
 
+   if (adev->asic_type == CHIP_SIENNA_CICHLID)
+   gfx_v10_3_program_pbb_mode(adev);
+
return r;
 }
 
@@ -8841,6 +8862,47 @@ static int gfx_v10_0_get_cu_info(struct amdgpu_device 
*adev,
return 0;
 }
 
+static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev)
+{
+   uint32_t efuse_setting, vbios_setting, disabled_sa, max_sa_mask;
+
+   efuse_setting = RREG32_SOC15(GC, 0, mmCC_GC_SA_UNIT_DISABLE);
+   efuse_setting &= CC_GC_SA_UNIT_DISABLE__SA_DISABLE_MASK;
+   efuse_setting >>= CC_GC_SA_UNIT_DISABLE__SA_DISABLE__SHIFT;
+
+   vbios_setting = RREG32_SOC15(GC, 0, mmGC_USER_SA_UNIT_DISABLE);
+   vbios_setting &= GC_USER_SA_UNIT_DISABLE__SA_DISABLE_MASK;
+   vbios_setting >>= GC_USER_SA_UNIT_DISABLE__SA_DISABLE__SHIFT;
+
+   max_sa_mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_sh_per_se *
+   
adev->gfx.config.max_shader_engines);
+   disabled_sa = efuse_setting | vbios_setting;
+   disabled_sa &= max_sa_mask;
+
+   return disabled_sa;
+}
+
+static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev)
+{
+   uint32_t max_sa_per_se, max_sa_per_se_mask, max_shader_engines;
+   uint32_t disabled_sa_mask, se_index, disabled_sa_per_se;
+
+   disabled_sa_mask = gfx_v10_3_get_disabled_sa(adev);
+
+   max_sa_per_se = adev->gfx.config.max_sh_per_se;
+   max_sa_per_se_mask = (1 << max_sa_per_se) - 1;
+   max_shader_engines = adev->gfx.config.max_shader_engines;
+
+   for (se_index = 0; max_shader_engines > se_index; se_index++) {
+   disabled_sa_per_se = disabled_sa_mask >> (se_index * 
max_sa_per_se);
+   disabled_sa_per_se &= max_sa_per_se_mask;
+   if (disabled_sa_per_se == max_sa_per_se_mask) {
+   WREG32_FIELD15(GC, 0, PA_SC_ENHANCE_3, 
FORCE_PBB_WORKLOAD_MODE_TO_ZERO, 1);
+   break;
+   }
+   }
+}
+
 const struct amdgpu_ip_block_version gfx_v10_0_ip_block =
 {
.type = AMD_IP_BLOCK_TYPE_GFX,
-- 
2.25.1

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


[PATCH] drm/amdgpu: update golden setting for sienna_cichlid

2020-10-14 Thread Likun Gao
From: Likun Gao 

Update golden setting for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: I9a1ad84c22748fc100a3327487c6287e237df490
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index c4e9db3be39a..69e995155594 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3138,6 +3138,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_3[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_ADDR_MATCH_MASK, 0x, 
0xffcf),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CM_CTRL1, 0xff8fff0f, 0x580f1008),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGL2C_CTRL3, 0xf7ff, 0x10f80988),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmLDS_CONFIG,  0x0020, 0x0020),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_CL_ENHANCE, 0xf17f, 0x0127),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_TIMEOUT_COUNTER, 
0x, 0x0800),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_2, 0xffbf, 
0x0820),
-- 
2.25.1

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


[PATCH] amdgpu/drm: cleanup navi10 ih logic about older ASIC

2020-09-25 Thread Likun Gao
From: Likun Gao 

The ASIC which is older than navi10 will not call into navi10_ih
related function, so cleanup the related code path.

Signed-off-by: Likun Gao 
Change-Id: Idf73b73f1f4f19031260c220798e5fffbb2cecd2
---
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 105 +++--
 1 file changed, 9 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
index 74b1e7dc49a9..92b5dc2931b6 100644
--- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
@@ -94,14 +94,7 @@ static void navi10_ih_enable_interrupts(struct amdgpu_device 
*adev)
 
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL, RB_ENABLE, 1);
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL, ENABLE_INTR, 1);
-   if (amdgpu_sriov_vf(adev) && adev->asic_type < CHIP_NAVI10) {
-   if (psp_reg_program(>psp, PSP_REG_IH_RB_CNTL, 
ih_rb_cntl)) {
-   DRM_ERROR("PSP program IH_RB_CNTL failed!\n");
-   return;
-   }
-   } else {
-   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL, ih_rb_cntl);
-   }
+   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL, ih_rb_cntl);
 
adev->irq.ih.enabled = true;
 
@@ -109,15 +102,7 @@ static void navi10_ih_enable_interrupts(struct 
amdgpu_device *adev)
ih_rb_cntl = RREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1);
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL_RING1,
   RB_ENABLE, 1);
-   if (amdgpu_sriov_vf(adev) && adev->asic_type < CHIP_NAVI10) {
-   if (psp_reg_program(>psp, 
PSP_REG_IH_RB_CNTL_RING1,
-   ih_rb_cntl)) {
-   DRM_ERROR("program IH_RB_CNTL_RING1 failed!\n");
-   return;
-   }
-   } else {
-   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1, ih_rb_cntl);
-   }
+   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1, ih_rb_cntl);
adev->irq.ih1.enabled = true;
}
 
@@ -125,15 +110,7 @@ static void navi10_ih_enable_interrupts(struct 
amdgpu_device *adev)
ih_rb_cntl = RREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING2);
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL_RING2,
   RB_ENABLE, 1);
-   if (amdgpu_sriov_vf(adev) && adev->asic_type < CHIP_NAVI10) {
-   if (psp_reg_program(>psp, 
PSP_REG_IH_RB_CNTL_RING2,
-   ih_rb_cntl)) {
-   DRM_ERROR("program IH_RB_CNTL_RING2 failed!\n");
-   return;
-   }
-   } else {
-   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING2, ih_rb_cntl);
-   }
+   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING2, ih_rb_cntl);
adev->irq.ih2.enabled = true;
}
 }
@@ -151,14 +128,7 @@ static void navi10_ih_disable_interrupts(struct 
amdgpu_device *adev)
 
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL, RB_ENABLE, 0);
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL, ENABLE_INTR, 0);
-   if (amdgpu_sriov_vf(adev) && adev->asic_type < CHIP_NAVI10) {
-   if (psp_reg_program(>psp, PSP_REG_IH_RB_CNTL, 
ih_rb_cntl)) {
-   DRM_ERROR("PSP program IH_RB_CNTL failed!\n");
-   return;
-   }
-   } else {
-   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL, ih_rb_cntl);
-   }
+   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL, ih_rb_cntl);
 
/* set rptr, wptr to 0 */
WREG32_SOC15(OSSSYS, 0, mmIH_RB_RPTR, 0);
@@ -170,15 +140,7 @@ static void navi10_ih_disable_interrupts(struct 
amdgpu_device *adev)
ih_rb_cntl = RREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1);
ih_rb_cntl = REG_SET_FIELD(ih_rb_cntl, IH_RB_CNTL_RING1,
   RB_ENABLE, 0);
-   if (amdgpu_sriov_vf(adev) && adev->asic_type < CHIP_NAVI10) {
-   if (psp_reg_program(>psp, 
PSP_REG_IH_RB_CNTL_RING1,
-   ih_rb_cntl)) {
-   DRM_ERROR("program IH_RB_CNTL_RING1 failed!\n");
-   return;
-   }
-   } else {
-   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1, ih_rb_cntl);
-   }
+   WREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL_RING1, ih_rb_cntl);
/* set rptr, wptr to 0 */
WREG32_SOC15(OSSSYS, 0, mmIH_RB_RPTR_RING1, 0);
WREG32_SOC15(OSSSYS, 

[PATCH] drm/amd/pm: update driver if file for sienna cichlid

2020-09-21 Thread Likun Gao
From: Likun Gao 

Update driver if file for sienna cichlid.

Signed-off-by: Likun Gao 
Change-Id: I295edda90d156c4cea742e62fab696afb6cd1366
---
 drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h | 4 ++--
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
index 11a6cf96fe0c..1275246769d9 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x37
+#define SMU11_DRIVER_IF_VERSION 0x39
 
 #define PPTABLE_Sienna_Cichlid_SMU_VERSION 6
 
@@ -962,7 +962,7 @@ typedef struct {
   uint8_tFanLinearPwmPoints[NUM_OD_FAN_MAX_POINTS];
   uint8_tFanLinearTempPoints[NUM_OD_FAN_MAX_POINTS];
   uint16_t   MaxOpTemp;// Degree Celcius
-  uint16_t   Padding_16[1];
+  int16_tVddGfxOffset; // in mV
   uint8_tFanZeroRpmEnable;
   uint8_tFanZeroRpmStopTemp;
   uint8_tFanMode;
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 7ae83df83edb..03198d214bba 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x36
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x37
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x39
 #define SMU11_DRIVER_IF_VERSION_Navy_Flounder 0x5
 
 /* MP Apertures */
-- 
2.25.1

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


[PATCH] drm/amd/pm: update driver if file for sienna cichlid

2020-09-10 Thread Likun Gao
From: Likun Gao 

Update drive if file for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: I53e5210acb760901622cd50aaf81193e9699feba
---
 .../pm/inc/smu11_driver_if_sienna_cichlid.h   | 20 ++-
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h|  2 +-
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  5 -
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
index 5ef9c92f57c4..11a6cf96fe0c 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,9 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x35
+#define SMU11_DRIVER_IF_VERSION 0x37
 
-#define PPTABLE_Sienna_Cichlid_SMU_VERSION 5
+#define PPTABLE_Sienna_Cichlid_SMU_VERSION 6
 
 #define NUM_GFXCLK_DPM_LEVELS  16
 #define NUM_SMNCLK_DPM_LEVELS  2
@@ -169,7 +169,7 @@ typedef enum {
 #define DPM_OVERRIDE_DISABLE_DFLL_PLL_SHUTDOWN   0x0200
 #define DPM_OVERRIDE_DISABLE_MEMORY_TEMPERATURE_READ 0x0400
 #define DPM_OVERRIDE_DISABLE_VOLT_LINK_VCN_DCEFCLK   0x0800
-#define DPM_OVERRIDE_ENABLE_FAST_FCLK_TIMER  0x1000
+#define DPM_OVERRIDE_DISABLE_FAST_FCLK_TIMER 0x1000
 #define DPM_OVERRIDE_DISABLE_VCN_PG  0x2000
 #define DPM_OVERRIDE_DISABLE_FMAX_VMAX   0x4000
 
@@ -793,8 +793,18 @@ typedef struct {
 
   // SECTION: Sku Reserved
   uint8_t  CustomerVariant;
-  uint8_t  Spare[3];
-  uint32_t SkuReserved[14];
+
+  //VC BTC parameters are only applicable to VDD_GFX domain
+  uint8_t  VcBtcEnabled;
+  uint16_t VcBtcVminT0; // T0_VMIN
+  uint16_t VcBtcFixedVminAgingOffset;   // FIXED_VMIN_AGING_OFFSET 
+  uint16_t VcBtcVmin2PsmDegrationGb;// VMIN_TO_PSM_DEGRADATION_GB 
+  uint32_t VcBtcPsmA;   // A_PSM
+  uint32_t VcBtcPsmB;   // B_PSM
+  uint32_t VcBtcVminA;  // A_VMIN
+  uint32_t VcBtcVminB;  // B_VMIN  
+  
+  uint32_t SkuReserved[9];
 
 
   // MAJOR SECTION: BOARD PARAMETERS
diff --git a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
index 2a3f1ee4a50b..9dfc1c87b6dd 100644
--- a/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/pm/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x36
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x35
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x37
 #define SMU11_DRIVER_IF_VERSION_Navy_Flounder 0x4
 
 /* MP Apertures */
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index b67931fd64b4..194abaca6948 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -2295,11 +2295,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "SkuReserved[6] = 0x%x\n", 
pptable->SkuReserved[6]);
dev_info(smu->adev->dev, "SkuReserved[7] = 0x%x\n", 
pptable->SkuReserved[7]);
dev_info(smu->adev->dev, "SkuReserved[8] = 0x%x\n", 
pptable->SkuReserved[8]);
-   dev_info(smu->adev->dev, "SkuReserved[9] = 0x%x\n", 
pptable->SkuReserved[9]);
-   dev_info(smu->adev->dev, "SkuReserved[10] = 0x%x\n", 
pptable->SkuReserved[10]);
-   dev_info(smu->adev->dev, "SkuReserved[11] = 0x%x\n", 
pptable->SkuReserved[11]);
-   dev_info(smu->adev->dev, "SkuReserved[12] = 0x%x\n", 
pptable->SkuReserved[12]);
-   dev_info(smu->adev->dev, "SkuReserved[13] = 0x%x\n", 
pptable->SkuReserved[13]);
 
dev_info(smu->adev->dev, "GamingClk[0] = 0x%x\n", 
pptable->GamingClk[0]);
dev_info(smu->adev->dev, "GamingClk[1] = 0x%x\n", 
pptable->GamingClk[1]);
-- 
2.25.1

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


[PATCH] drm/amdgpu: use mode1 reset by default for sienna_cichlid

2020-08-06 Thread Likun Gao
From: Likun Gao 

Swith default gpu reset method for sienna_cichlid to MODE1 reset.

Signed-off-by: Likun Gao 
Change-Id: I775e5a66bbac474f65ca8c999136ccaf9c1dc14e
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 74d02d270d34..da8024c2826e 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -362,10 +362,15 @@ nv_asic_reset_method(struct amdgpu_device *adev)
dev_warn(adev->dev, "Specified reset method:%d isn't supported, 
using AUTO instead.\n",
  amdgpu_reset_method);
 
-   if (smu_baco_is_support(smu))
-   return AMD_RESET_METHOD_BACO;
-   else
+   switch (adev->asic_type) {
+   case CHIP_SIENNA_CICHLID:
return AMD_RESET_METHOD_MODE1;
+   default:
+   if (smu_baco_is_support(smu))
+   return AMD_RESET_METHOD_BACO;
+   else
+   return AMD_RESET_METHOD_MODE1;
+   }
 }
 
 static int nv_asic_reset(struct amdgpu_device *adev)
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: update driver if file for sienna_cichlid

2020-08-06 Thread Likun Gao
From: Likun Gao 

Update drive if file for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: If405461cfbe0133ceb61fa123272b2e53db99755
---
 .../drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h  | 6 +++---
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
index aa2708fccb6d..5ef9c92f57c4 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x34
+#define SMU11_DRIVER_IF_VERSION 0x35
 
 #define PPTABLE_Sienna_Cichlid_SMU_VERSION 5
 
@@ -127,7 +127,7 @@
 #define FEATURE_DF_CSTATE_BIT   45
 #define FEATURE_2_STEP_PSTATE_BIT   46
 #define FEATURE_SMNCLK_DPM_BIT  47
-#define FEATURE_SPARE_48_BIT48
+#define FEATURE_PERLINK_GMIDOWN_BIT 48
 #define FEATURE_GFX_EDC_BIT 49
 #define FEATURE_SPARE_50_BIT50
 #define FEATURE_SPARE_51_BIT51
@@ -169,7 +169,7 @@ typedef enum {
 #define DPM_OVERRIDE_DISABLE_DFLL_PLL_SHUTDOWN   0x0200
 #define DPM_OVERRIDE_DISABLE_MEMORY_TEMPERATURE_READ 0x0400
 #define DPM_OVERRIDE_DISABLE_VOLT_LINK_VCN_DCEFCLK   0x0800
-#define DPM_OVERRIDE_DISABLE_FAST_FCLK_TIMER 0x1000
+#define DPM_OVERRIDE_ENABLE_FAST_FCLK_TIMER  0x1000
 #define DPM_OVERRIDE_DISABLE_VCN_PG  0x2000
 #define DPM_OVERRIDE_DISABLE_FMAX_VMAX   0x4000
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 6a42331aba8a..737b6d14372c 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x33
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x34
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x35
 #define SMU11_DRIVER_IF_VERSION_Navy_Flounder 0x3
 
 /* MP Apertures */
-- 
2.25.1

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


[PATCH] drm/amdgpu: update golden setting for sienna_cichlid

2020-07-23 Thread Likun Gao
From: Likun Gao 

Update golden setting for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: Id71876180033eedc10ecbabe5317369676034e19
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 61e89247faf3..8344c3b0b9b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3082,7 +3082,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_3[] =
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_RA0_CLK_CTRL, 0xff7f0fff, 
0x3100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_RA1_CLK_CTRL, 0xff7f0fff, 
0x7e000100),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_GCR_CNTL, 0x0007, 0xc000),
-   SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0x, 0x0200),
+   SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG3, 0x, 0x0280),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG4, 0x, 0x0080),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_EXCEPTION_CONTROL, 0x7fff0f1f, 
0x00b8),
SOC15_REG_GOLDEN_VALUE(GC, 0, mmGCR_GENERAL_CNTL_Sienna_Cichlid, 
0x1ff1, 0x0500),
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: correct smu message for vf mode

2020-07-21 Thread Likun Gao
From: Likun Gao 

Set valid_in_vf to false for the message not support in vf mode on
sienna cichlid.

Signed-off-by: Likun Gao 
Change-Id: Ib07fe7522eea39a14131945bb76be0b0935598ae
---
 .../drm/amd/powerplay/sienna_cichlid_ppt.c| 70 +--
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index bf3d6bbba930..d4156804bf41 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -71,10 +71,10 @@ static struct cmn2asic_msg_mapping 
sienna_cichlid_message_map[SMU_MSG_MAX_COUNT]
MSG_MAP(TestMessage,PPSMC_MSG_TestMessage,  
   1),
MSG_MAP(GetSmuVersion,  PPSMC_MSG_GetSmuVersion,
   1),
MSG_MAP(GetDriverIfVersion, PPSMC_MSG_GetDriverIfVersion,   
   1),
-   MSG_MAP(SetAllowedFeaturesMaskLow,  
PPSMC_MSG_SetAllowedFeaturesMaskLow,   1),
-   MSG_MAP(SetAllowedFeaturesMaskHigh, 
PPSMC_MSG_SetAllowedFeaturesMaskHigh,  1),
-   MSG_MAP(EnableAllSmuFeatures,   PPSMC_MSG_EnableAllSmuFeatures, 
   1),
-   MSG_MAP(DisableAllSmuFeatures,  
PPSMC_MSG_DisableAllSmuFeatures,   1),
+   MSG_MAP(SetAllowedFeaturesMaskLow,  
PPSMC_MSG_SetAllowedFeaturesMaskLow,   0),
+   MSG_MAP(SetAllowedFeaturesMaskHigh, 
PPSMC_MSG_SetAllowedFeaturesMaskHigh,  0),
+   MSG_MAP(EnableAllSmuFeatures,   PPSMC_MSG_EnableAllSmuFeatures, 
   0),
+   MSG_MAP(DisableAllSmuFeatures,  
PPSMC_MSG_DisableAllSmuFeatures,   0),
MSG_MAP(EnableSmuFeaturesLow,   PPSMC_MSG_EnableSmuFeaturesLow, 
   1),
MSG_MAP(EnableSmuFeaturesHigh,  
PPSMC_MSG_EnableSmuFeaturesHigh,   1),
MSG_MAP(DisableSmuFeaturesLow,  
PPSMC_MSG_DisableSmuFeaturesLow,   1),
@@ -82,43 +82,43 @@ static struct cmn2asic_msg_mapping 
sienna_cichlid_message_map[SMU_MSG_MAX_COUNT]
MSG_MAP(GetEnabledSmuFeaturesLow,   
PPSMC_MSG_GetRunningSmuFeaturesLow,1),
MSG_MAP(GetEnabledSmuFeaturesHigh,  
PPSMC_MSG_GetRunningSmuFeaturesHigh,   1),
MSG_MAP(SetWorkloadMask,PPSMC_MSG_SetWorkloadMask,  
   1),
-   MSG_MAP(SetPptLimit,PPSMC_MSG_SetPptLimit,  
   1),
-   MSG_MAP(SetDriverDramAddrHigh,  
PPSMC_MSG_SetDriverDramAddrHigh,   1),
-   MSG_MAP(SetDriverDramAddrLow,   PPSMC_MSG_SetDriverDramAddrLow, 
   1),
-   MSG_MAP(SetToolsDramAddrHigh,   PPSMC_MSG_SetToolsDramAddrHigh, 
   1),
-   MSG_MAP(SetToolsDramAddrLow,PPSMC_MSG_SetToolsDramAddrLow,  
   1),
-   MSG_MAP(TransferTableSmu2Dram,  
PPSMC_MSG_TransferTableSmu2Dram,   1),
-   MSG_MAP(TransferTableDram2Smu,  
PPSMC_MSG_TransferTableDram2Smu,   1),
-   MSG_MAP(UseDefaultPPTable,  PPSMC_MSG_UseDefaultPPTable,
   1),
-   MSG_MAP(EnterBaco,  PPSMC_MSG_EnterBaco,
   1),
-   MSG_MAP(SetSoftMinByFreq,   PPSMC_MSG_SetSoftMinByFreq, 
   1),
-   MSG_MAP(SetSoftMaxByFreq,   PPSMC_MSG_SetSoftMaxByFreq, 
   1),
+   MSG_MAP(SetPptLimit,PPSMC_MSG_SetPptLimit,  
   0),
+   MSG_MAP(SetDriverDramAddrHigh,  
PPSMC_MSG_SetDriverDramAddrHigh,   0),
+   MSG_MAP(SetDriverDramAddrLow,   PPSMC_MSG_SetDriverDramAddrLow, 
   0),
+   MSG_MAP(SetToolsDramAddrHigh,   PPSMC_MSG_SetToolsDramAddrHigh, 
   0),
+   MSG_MAP(SetToolsDramAddrLow,PPSMC_MSG_SetToolsDramAddrLow,  
   0),
+   MSG_MAP(TransferTableSmu2Dram,  
PPSMC_MSG_TransferTableSmu2Dram,   0),
+   MSG_MAP(TransferTableDram2Smu,  
PPSMC_MSG_TransferTableDram2Smu,   0),
+   MSG_MAP(UseDefaultPPTable,  PPSMC_MSG_UseDefaultPPTable,
   0),
+   MSG_MAP(EnterBaco,  PPSMC_MSG_EnterBaco,
   0),
+   MSG_MAP(SetSoftMinByFreq,   PPSMC_MSG_SetSoftMinByFreq, 
   0),
+   MSG_MAP(SetSoftMaxByFreq,   PPSMC_MSG_SetSoftMaxByFreq, 
   0),
MSG_MAP(SetHardMinByFreq,   PPSMC_MSG_SetHardMinByFreq, 
   1),
-   MSG_MAP(SetHardMaxByFreq,   PPSMC_MSG_SetHardMaxByFreq, 
   1),
+   MSG_MAP(SetHardMaxByFreq,   PPSMC_MSG_SetHardMaxByFreq, 
   0),
MSG_MAP(GetMinDpmFreq,  PPSMC_MSG_GetMinDpmFreq,
   1),
MSG_MAP(GetMaxDpmFreq,  PPSMC_MSG_GetMaxDpmFreq,
   1),
MSG_MAP(GetDpmFreqByIndex,  PPSMC_MSG_GetDpmFreqByIndex,
   1),
-   MSG_MAP(SetGeminiMode,  PPSMC_MSG_SetGeminiMode

[PATCH] drm/amd/powerplay: skip invalid msg when smu set mp1 state

2020-07-21 Thread Likun Gao
From: Likun Gao 

Some asic may not support for some message of set mp1 state.
If the return value of smu_send_smc_msg is -EINVAL, that means it failed
to send msg to smc as it can not map an valid message for the ASIC. And
with that case, smu_set_mp1_state should be skipped as those ASIC was in
fact do not support for that.

Signed-off-by: Likun Gao 
Change-Id: I31b40b87532a1d7549b26155d4ec8145b5e3f101
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index b197dcaed064..237d8ab8b40d 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1590,6 +1590,9 @@ int smu_set_mp1_state(struct smu_context *smu,
}
 
ret = smu_send_smc_msg(smu, msg, NULL);
+   /* some asics may not support those messages */
+   if (ret == -EINVAL)
+   ret = 0;
if (ret)
dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n");
 
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: add msg map for mode1 reset

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

Mapping Mode1Reset message for sienna_cichlid.

Signed-off-by: Likun Gao 
Change-Id: I9b8d39b10c7723af4589577fdbfa4acd5af6e85d
---
 drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index cae8e776fafe..bf3d6bbba930 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -118,6 +118,7 @@ static struct cmn2asic_msg_mapping 
sienna_cichlid_message_map[SMU_MSG_MAX_COUNT]
MSG_MAP(PowerDownJpeg,  PPSMC_MSG_PowerDownJpeg,
   1),
MSG_MAP(BacoAudioD3PME, PPSMC_MSG_BacoAudioD3PME,   
   1),
MSG_MAP(ArmD3,  PPSMC_MSG_ArmD3,
   1),
+   MSG_MAP(Mode1Reset, PPSMC_MSG_Mode1Reset,   
   1),
 };
 
 static struct cmn2asic_mapping sienna_cichlid_clk_map[SMU_CLK_COUNT] = {
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: update driver if file for sienna_cichlid

2020-07-09 Thread Likun Gao
From: Likun Gao 

Update sienna_cichlid driver if header and related files.

Signed-off-by: Likun Gao 
Change-Id: If303e7fca32ebf922ee5d918855bbaca8dc61d38
---
 .../inc/smu11_driver_if_sienna_cichlid.h| 17 +
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h   |  2 +-
 .../gpu/drm/amd/powerplay/sienna_cichlid_ppt.c  |  1 -
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
index 302c2bcf9404..b2232e24d82f 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,9 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x32
+#define SMU11_DRIVER_IF_VERSION 0x33
 
-#define PPTABLE_Sienna_Cichlid_SMU_VERSION 4
+#define PPTABLE_Sienna_Cichlid_SMU_VERSION 5
 
 #define NUM_GFXCLK_DPM_LEVELS  16
 #define NUM_SMNCLK_DPM_LEVELS  2
@@ -128,7 +128,7 @@
 #define FEATURE_2_STEP_PSTATE_BIT   46
 #define FEATURE_SMNCLK_DPM_BIT  47
 #define FEATURE_SPARE_48_BIT48
-#define FEATURE_SPARE_49_BIT49
+#define FEATURE_GFX_EDC_BIT 49
 #define FEATURE_SPARE_50_BIT50
 #define FEATURE_SPARE_51_BIT51
 #define FEATURE_SPARE_52_BIT52
@@ -564,6 +564,12 @@ typedef enum {
   TDC_THROTTLER_COUNT
 } TDC_THROTTLER_e;
 
+typedef enum {
+  CUSTOMER_VARIANT_ROW,
+  CUSTOMER_VARIANT_FALCON,
+  CUSTOMER_VARIANT_COUNT,
+} CUSTOMER_VARIANT_e;
+
 // Used for 2-step UCLK DPM change workaround
 typedef struct {
   uint16_t Fmin;
@@ -786,7 +792,10 @@ typedef struct {
   QuadraticInt_tReservedEquation3; 
 
   // SECTION: Sku Reserved
-  uint32_t SkuReserved[15];
+  uint8_t  CustomerVariant;
+  uint8_t  Spare[3];
+  uint32_t SkuReserved[14];
+
 
   // MAJOR SECTION: BOARD PARAMETERS
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index d07bf4fe6e4a..b2f65438ad8d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x33
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x32
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x33
 
 /* MP Apertures */
 #define MP0_Public 0x0380
diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index dc5ca9121db5..3efa41444ddf 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -2317,7 +2317,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "SkuReserved[11] = 0x%x\n", 
pptable->SkuReserved[11]);
dev_info(smu->adev->dev, "SkuReserved[12] = 0x%x\n", 
pptable->SkuReserved[12]);
dev_info(smu->adev->dev, "SkuReserved[13] = 0x%x\n", 
pptable->SkuReserved[13]);
-   dev_info(smu->adev->dev, "SkuReserved[14] = 0x%x\n", 
pptable->SkuReserved[14]);
 
dev_info(smu->adev->dev, "GamingClk[0] = 0x%x\n", 
pptable->GamingClk[0]);
dev_info(smu->adev->dev, "GamingClk[1] = 0x%x\n", 
pptable->GamingClk[1]);
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: update driver if file for sienna_cichlid

2020-07-09 Thread Likun Gao
From: Likun Gao 

Update sienna_cichlid driver if header and related files.

Signed-off-by: Likun Gao 
Change-Id: If303e7fca32ebf922ee5d918855bbaca8dc61d38
---
 .../inc/smu11_driver_if_sienna_cichlid.h| 17 +
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h   |  2 +-
 .../gpu/drm/amd/powerplay/sienna_cichlid_ppt.c  |  1 -
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
index 302c2bcf9404..b2232e24d82f 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,9 +27,9 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x32
+#define SMU11_DRIVER_IF_VERSION 0x33
 
-#define PPTABLE_Sienna_Cichlid_SMU_VERSION 4
+#define PPTABLE_Sienna_Cichlid_SMU_VERSION 5
 
 #define NUM_GFXCLK_DPM_LEVELS  16
 #define NUM_SMNCLK_DPM_LEVELS  2
@@ -128,7 +128,7 @@
 #define FEATURE_2_STEP_PSTATE_BIT   46
 #define FEATURE_SMNCLK_DPM_BIT  47
 #define FEATURE_SPARE_48_BIT48
-#define FEATURE_SPARE_49_BIT49
+#define FEATURE_GFX_EDC_BIT 49
 #define FEATURE_SPARE_50_BIT50
 #define FEATURE_SPARE_51_BIT51
 #define FEATURE_SPARE_52_BIT52
@@ -564,6 +564,12 @@ typedef enum {
   TDC_THROTTLER_COUNT
 } TDC_THROTTLER_e;
 
+typedef enum {
+  CUSTOMER_VARIANT_ROW,
+  CUSTOMER_VARIANT_FALCON,
+  CUSTOMER_VARIANT_COUNT,
+} CUSTOMER_VARIANT_e;
+
 // Used for 2-step UCLK DPM change workaround
 typedef struct {
   uint16_t Fmin;
@@ -786,7 +792,10 @@ typedef struct {
   QuadraticInt_tReservedEquation3; 
 
   // SECTION: Sku Reserved
-  uint32_t SkuReserved[15];
+  uint8_t  CustomerVariant;
+  uint8_t  Spare[3];
+  uint32_t SkuReserved[14];
+
 
   // MAJOR SECTION: BOARD PARAMETERS
 
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index d07bf4fe6e4a..b2f65438ad8d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x33
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x32
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x33
 
 /* MP Apertures */
 #define MP0_Public 0x0380
diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index dc5ca9121db5..3efa41444ddf 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -2317,7 +2317,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "SkuReserved[11] = 0x%x\n", 
pptable->SkuReserved[11]);
dev_info(smu->adev->dev, "SkuReserved[12] = 0x%x\n", 
pptable->SkuReserved[12]);
dev_info(smu->adev->dev, "SkuReserved[13] = 0x%x\n", 
pptable->SkuReserved[13]);
-   dev_info(smu->adev->dev, "SkuReserved[14] = 0x%x\n", 
pptable->SkuReserved[14]);
 
dev_info(smu->adev->dev, "GamingClk[0] = 0x%x\n", 
pptable->GamingClk[0]);
dev_info(smu->adev->dev, "GamingClk[1] = 0x%x\n", 
pptable->GamingClk[1]);
-- 
2.25.1

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


[v2] drm/amdgpu: remove unnecessary logic of ASIC check

2020-07-07 Thread Likun Gao
From: Likun Gao 

Remove some unused ASIC check logic.
Remove some definition of amdgpu_device which only used by
the removed ASIC check logic.(V2)

Signed-off-by: Likun Gao 
Change-Id: I5b06a51b41790b4df1078099848025851f79c320
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 5 -
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 8 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 4 +---
 3 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 82680ce51cd1..786193a38689 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -7683,14 +7683,9 @@ static void gfx_v10_0_ring_emit_ib_compute(struct 
amdgpu_ring *ring,
 static void gfx_v10_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
 u64 seq, unsigned flags)
 {
-   struct amdgpu_device *adev = ring->adev;
bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if (adev->pdev->device == 0x50)
-   int_sel = false;
-
/* RELEASE_MEM - flush caches, send int */
amdgpu_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 6));
amdgpu_ring_write(ring, (PACKET3_RELEASE_MEM_GCR_SEQ |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 1baeddf2f1e6..abb0ab653b10 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -485,7 +485,6 @@ static void sdma_v5_0_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
 static void sdma_v5_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 
seq,
  unsigned flags)
 {
-   struct amdgpu_device *adev = ring->adev;
bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
/* write the fence */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE) |
@@ -508,8 +507,7 @@ static void sdma_v5_0_ring_emit_fence(struct amdgpu_ring 
*ring, u64 addr, u64 se
amdgpu_ring_write(ring, upper_32_bits(seq));
}
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if ((flags & AMDGPU_FENCE_FLAG_INT) && adev->pdev->device != 0x50) {
+   if (flags & AMDGPU_FENCE_FLAG_INT) {
/* generate an interrupt */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_TRAP));
amdgpu_ring_write(ring, 
SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0));
@@ -887,10 +885,6 @@ static int sdma_v5_0_start(struct amdgpu_device *adev)
r = sdma_v5_0_load_microcode(adev);
if (r)
return r;
-
-   /* The value of mmSDMA_F32_CNTL is invalid the moment after 
loading fw */
-   if (amdgpu_emu_mode == 1 && adev->pdev->device == 0x4d)
-   msleep(1000);
}
 
/* unhalt the MEs */
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index 4dbc11907bc6..1ef14b610a4f 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -417,7 +417,6 @@ static void sdma_v5_2_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
 static void sdma_v5_2_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 
seq,
  unsigned flags)
 {
-   struct amdgpu_device *adev = ring->adev;
bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
/* write the fence */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE) |
@@ -440,8 +439,7 @@ static void sdma_v5_2_ring_emit_fence(struct amdgpu_ring 
*ring, u64 addr, u64 se
amdgpu_ring_write(ring, upper_32_bits(seq));
}
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if ((flags & AMDGPU_FENCE_FLAG_INT) && adev->pdev->device != 0x50) {
+   if (flags & AMDGPU_FENCE_FLAG_INT) {
/* generate an interrupt */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_TRAP));
amdgpu_ring_write(ring, 
SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0));
-- 
2.25.1

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


[PATCH] drm/amdgpu: enable gpu recovery for sienna cichlid

2020-07-07 Thread Likun Gao
From: Likun Gao 

Enable gpu recovery for sienna cichlid by default to trigger
gpu recovery once needed.

Signed-off-by: Likun Gao 
Change-Id: Iaf3cfa145bdc8407771d5a26dabb413570980a85
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7a610850a646..2913e41f63a5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3936,6 +3936,7 @@ bool amdgpu_device_should_recover_gpu(struct 
amdgpu_device *adev)
case CHIP_NAVI10:
case CHIP_NAVI14:
case CHIP_NAVI12:
+   case CHIP_SIENNA_CICHLID:
break;
default:
goto disabled;
-- 
2.25.1

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


[PATCH] drm/amdgpu: remove unnecessary logic of ASIC check

2020-07-07 Thread Likun Gao
From: Likun Gao 

Remove some unused ASIC check logic.

Signed-off-by: Likun Gao 
Change-Id: Ief8bcb77392294b180473754e669b9e460a04826
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 4 
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 7 +--
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 3 +--
 3 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index b8b4cff20013..58221bea377a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -7687,10 +7687,6 @@ static void gfx_v10_0_ring_emit_fence(struct amdgpu_ring 
*ring, u64 addr,
bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if (adev->pdev->device == 0x50)
-   int_sel = false;
-
/* RELEASE_MEM - flush caches, send int */
amdgpu_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 6));
amdgpu_ring_write(ring, (PACKET3_RELEASE_MEM_GCR_SEQ |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 1baeddf2f1e6..203a0e9c5999 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -508,8 +508,7 @@ static void sdma_v5_0_ring_emit_fence(struct amdgpu_ring 
*ring, u64 addr, u64 se
amdgpu_ring_write(ring, upper_32_bits(seq));
}
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if ((flags & AMDGPU_FENCE_FLAG_INT) && adev->pdev->device != 0x50) {
+   if (flags & AMDGPU_FENCE_FLAG_INT) {
/* generate an interrupt */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_TRAP));
amdgpu_ring_write(ring, 
SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0));
@@ -887,10 +886,6 @@ static int sdma_v5_0_start(struct amdgpu_device *adev)
r = sdma_v5_0_load_microcode(adev);
if (r)
return r;
-
-   /* The value of mmSDMA_F32_CNTL is invalid the moment after 
loading fw */
-   if (amdgpu_emu_mode == 1 && adev->pdev->device == 0x4d)
-   msleep(1000);
}
 
/* unhalt the MEs */
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index 4dbc11907bc6..8142fc07f5c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -440,8 +440,7 @@ static void sdma_v5_2_ring_emit_fence(struct amdgpu_ring 
*ring, u64 addr, u64 se
amdgpu_ring_write(ring, upper_32_bits(seq));
}
 
-   /* Interrupt not work fine on GFX10.1 model yet. Use fallback instead */
-   if ((flags & AMDGPU_FENCE_FLAG_INT) && adev->pdev->device != 0x50) {
+   if (flags & AMDGPU_FENCE_FLAG_INT) {
/* generate an interrupt */
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_TRAP));
amdgpu_ring_write(ring, 
SDMA_PKT_TRAP_INT_CONTEXT_INT_CONTEXT(0));
-- 
2.25.1

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


[PATCH] tests/amdgpu: set emit fence flag for multi fence

2020-07-07 Thread Likun Gao
From: Likun Gao 

Set AMDGPU_IB_FLAG_EMIT_MEM_SYNC flag for specific ASIC when test multi
fence.

Signed-off-by: Likun Gao 
Change-Id: I41e5cb19d9ca72c1d396cc28d1b54c31773fe4d5
---
 include/drm/amdgpu_drm.h   | 2 ++
 tests/amdgpu/basic_tests.c | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h
index 4fe35d60..8a4d7da9 100644
--- a/include/drm/amdgpu_drm.h
+++ b/include/drm/amdgpu_drm.h
@@ -586,6 +586,8 @@ union drm_amdgpu_cs {
  */
 #define AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID (1 << 4)
 
+#define AMDGPU_IB_FLAG_EMIT_MEM_SYNC  (1 << 6)
+
 struct drm_amdgpu_cs_chunk_ib {
__u32 _pad;
/** AMDGPU_IB_FLAG_* */
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 57496c82..c0f7ec33 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -45,6 +45,8 @@ static  amdgpu_device_handle device_handle;
 static  uint32_t  major_version;
 static  uint32_t  minor_version;
 static  uint32_t  family_id;
+static  uint32_t  chip_rev;
+static  uint32_t  chip_id;
 
 static void amdgpu_query_info_test(void);
 static void amdgpu_command_submission_gfx(void);
@@ -607,6 +609,8 @@ int suite_basic_tests_init(void)
return CUE_SINIT_FAILED;
 
family_id = gpu_info.family_id;
+   chip_rev = gpu_info.chip_rev;
+   chip_id = gpu_info.chip_external_rev;
 
return CUE_SUCCESS;
 }
@@ -1769,6 +1773,8 @@ static void 
amdgpu_command_submission_multi_fence_wait_all(bool wait_all)
ib_info[0].ib_mc_address = ib_result_ce_mc_address;
ib_info[0].size = i;
ib_info[0].flags = AMDGPU_IB_FLAG_CE;
+   if (chip_id == (chip_rev + 0x28))
+   ib_info[0].flags |= AMDGPU_IB_FLAG_EMIT_MEM_SYNC;
 
/* IT_WAIT_ON_CE_COUNTER */
ptr = ib_result_cpu;
-- 
2.25.1

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


[PATCH 1/2] drm/amdgpu: fix coding error of mmhub pg enablement

2020-07-06 Thread Likun Gao
From: Likun Gao 

MMHUB powergating should be disabled on navi12 and enabled on sienna
cichlid.

Signed-off-by: Likun Gao 
Change-Id: I0b0e6801408df3c13322c4f9ed8e13b6ffc9ec25
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 4b87506cb005..356849136d1d 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -707,8 +707,7 @@ static int nv_common_early_init(void *handle)
adev->pg_flags = AMD_PG_SUPPORT_VCN |
AMD_PG_SUPPORT_VCN_DPG |
AMD_PG_SUPPORT_JPEG |
-   AMD_PG_SUPPORT_ATHUB |
-   AMD_PG_SUPPORT_MMHUB;
+   AMD_PG_SUPPORT_ATHUB;
/* guest vm gets 0x when reading RCC_DEV0_EPF0_STRAP0,
 * as a consequence, the rev_id and external_rev_id are wrong.
 * workaround it by hardcoding rev_id to 0 (default value).
@@ -731,7 +730,8 @@ static int nv_common_early_init(void *handle)
adev->pg_flags = AMD_PG_SUPPORT_VCN |
AMD_PG_SUPPORT_VCN_DPG |
AMD_PG_SUPPORT_JPEG |
-   AMD_PG_SUPPORT_ATHUB;
+   AMD_PG_SUPPORT_ATHUB |
+   AMD_PG_SUPPORT_MMHUB;
adev->external_rev_id = adev->rev_id + 0x28;
break;
default:
-- 
2.25.1

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


[PATCH] drm/amdgpu: use RREG32_KIQ to read register when get cg state

2020-07-06 Thread Likun Gao
From: Likun Gao 

Use RREG32_KIQ to read gfx register when try to get gfx/sdma
clockgating state instead of RREG32, as it will result
to system hard hang when GPU is enter into GFXOFF state.

Signed-off-by: Likun Gao 
Change-Id: I1fc5fe70831e0ec35f1e701a1646cb3e46e121bf
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 10 +-
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 8366c506a8b5..b8b4cff20013 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -7481,12 +7481,12 @@ static void gfx_v10_0_get_clockgating_state(void 
*handle, u32 *flags)
int data;
 
/* AMD_CG_SUPPORT_GFX_MGCG */
-   data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
+   data = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE));
if (!(data & RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK))
*flags |= AMD_CG_SUPPORT_GFX_MGCG;
 
/* AMD_CG_SUPPORT_GFX_CGCG */
-   data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL);
+   data = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL));
if (data & RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK)
*flags |= AMD_CG_SUPPORT_GFX_CGCG;
 
@@ -7495,17 +7495,17 @@ static void gfx_v10_0_get_clockgating_state(void 
*handle, u32 *flags)
*flags |= AMD_CG_SUPPORT_GFX_CGLS;
 
/* AMD_CG_SUPPORT_GFX_RLC_LS */
-   data = RREG32_SOC15(GC, 0, mmRLC_MEM_SLP_CNTL);
+   data = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmRLC_MEM_SLP_CNTL));
if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK)
*flags |= AMD_CG_SUPPORT_GFX_RLC_LS | AMD_CG_SUPPORT_GFX_MGLS;
 
/* AMD_CG_SUPPORT_GFX_CP_LS */
-   data = RREG32_SOC15(GC, 0, mmCP_MEM_SLP_CNTL);
+   data = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmCP_MEM_SLP_CNTL));
if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK)
*flags |= AMD_CG_SUPPORT_GFX_CP_LS | AMD_CG_SUPPORT_GFX_MGLS;
 
/* AMD_CG_SUPPORT_GFX_3D_CGCG */
-   data = RREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D);
+   data = RREG32_KIQ(SOC15_REG_OFFSET(GC, 0, mmRLC_CGCG_CGLS_CTRL_3D));
if (data & RLC_CGCG_CGLS_CTRL_3D__CGCG_EN_MASK)
*flags |= AMD_CG_SUPPORT_GFX_3D_CGCG;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index 318d32e2bbf6..4dbc11907bc6 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -1572,7 +1572,7 @@ static void sdma_v5_2_get_clockgating_state(void *handle, 
u32 *flags)
*flags = 0;
 
/* AMD_CG_SUPPORT_SDMA_LS */
-   data = RREG32(sdma_v5_2_get_reg_offset(adev, 0, mmSDMA0_POWER_CNTL));
+   data = RREG32_KIQ(sdma_v5_2_get_reg_offset(adev, 0, 
mmSDMA0_POWER_CNTL));
if (data & SDMA0_POWER_CNTL__MEM_POWER_OVERRIDE_MASK)
*flags |= AMD_CG_SUPPORT_SDMA_LS;
 }
-- 
2.25.1

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


[PATCH 2/2] drm/amd/powerplay: update driver if file for sienna_cichlid

2020-06-24 Thread Likun Gao
From: Likun Gao 

Update sienna_cichlid driver if header file to match pptable changes.

Signed-off-by: Likun Gao 
Change-Id: Idcc081797f54509ea57503cce1dc915f718f189e
---
 .../powerplay/inc/smu11_driver_if_sienna_cichlid.h   | 12 
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h|  2 +-
 drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c   |  7 +--
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
index 5322f6da3071..302c2bcf9404 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x31
+#define SMU11_DRIVER_IF_VERSION 0x32
 
 #define PPTABLE_Sienna_Cichlid_SMU_VERSION 4
 
@@ -865,8 +865,7 @@ typedef struct {
   uint16_t DfllGfxclkSpreadFreq;  // kHz
   
   // UCLK Spread Spectrum
-  uint8_t  UclkSpreadEnabled;   // on or off
-  uint8_t  UclkSpreadPercent;   // Q4.4
+  uint16_t UclkSpreadPadding;
   uint16_t UclkSpreadFreq;  // kHz
 
   // FCLK Spread Spectrum
@@ -896,8 +895,11 @@ typedef struct {
   uint8_t  VddqOffEnabled;
   uint8_t  PaddingUmcFlags[2];
 
+  // UCLK Spread Spectrum
+  uint8_t  UclkSpreadPercent[16];   
+
   // SECTION: Board Reserved
-  uint32_t BoardReserved[15];
+  uint32_t BoardReserved[11];
 
   // SECTION: Structure Padding
 
@@ -936,10 +938,12 @@ typedef struct {
   int16_tOverDrivePct; // %
   uint16_t   FanMaximumRpm;
   uint16_t   FanMinimumPwm;
+  uint16_t   FanAcousticLimitRpm;
   uint16_t   FanTargetTemperature; // Degree Celcius 
   uint8_tFanLinearPwmPoints[NUM_OD_FAN_MAX_POINTS];
   uint8_tFanLinearTempPoints[NUM_OD_FAN_MAX_POINTS];
   uint16_t   MaxOpTemp;// Degree Celcius
+  uint16_t   Padding_16[1];
   uint8_tFanZeroRpmEnable;
   uint8_tFanZeroRpmStopTemp;
   uint8_tFanMode;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 4fb911d8b49c..d07bf4fe6e4a 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -30,7 +30,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x33
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x31
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x32
 
 /* MP Apertures */
 #define MP0_Public 0x0380
diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index 693ad8963d0a..459a3c62e47b 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -2401,8 +2401,7 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "DfllGfxclkSpreadPercent = 0x%x\n", 
pptable->DfllGfxclkSpreadPercent);
dev_info(smu->adev->dev, "DfllGfxclkSpreadFreq = 0x%x\n",
pptable->DfllGfxclkSpreadFreq);
 
-   dev_info(smu->adev->dev, "UclkSpreadEnabled = 0x%x\n", 
pptable->UclkSpreadEnabled);
-   dev_info(smu->adev->dev, "UclkSpreadPercent = 0x%x\n", 
pptable->UclkSpreadPercent);
+   dev_info(smu->adev->dev, "UclkSpreadPadding = 0x%x\n", 
pptable->UclkSpreadPadding);
dev_info(smu->adev->dev, "UclkSpreadFreq = 0x%x\n", 
pptable->UclkSpreadFreq);
 
dev_info(smu->adev->dev, "FclkSpreadEnabled = 0x%x\n", 
pptable->FclkSpreadEnabled);
@@ -2447,10 +2446,6 @@ static void sienna_cichlid_dump_pptable(struct 
smu_context *smu)
dev_info(smu->adev->dev, "BoardReserved[8] = 0x%x\n", 
pptable->BoardReserved[8]);
dev_info(smu->adev->dev, "BoardReserved[9] = 0x%x\n", 
pptable->BoardReserved[9]);
dev_info(smu->adev->dev, "BoardReserved[10] = 0x%x\n", 
pptable->BoardReserved[10]);
-   dev_info(smu->adev->dev, "BoardReserved[11] = 0x%x\n", 
pptable->BoardReserved[11]);
-   dev_info(smu->adev->dev, "BoardReserved[12] = 0x%x\n", 
pptable->BoardReserved[12]);
-   dev_info(smu->adev->dev, "BoardReserved[13] = 0x%x\n", 
pptable->BoardReserved[13]);
-   dev_info(smu->adev->dev, "BoardReserved[14] = 0x%x\n", 
pptable->BoardReserved[14]);
 
dev_info(smu->adev->dev, "MmHubPadding[0]

[PATCH 1/2] drm/amd/powerplay: change method to set board parameters

2020-06-24 Thread Likun Gao
From: Likun Gao 

Copy board parameters directly instead of set each parameter for
sienna_cichlid.

Signed-off-by: Likun Gao 
---
 .../drm/amd/powerplay/sienna_cichlid_ppt.c| 89 +--
 1 file changed, 2 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c 
b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
index 769e031d489a..693ad8963d0a 100644
--- a/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
@@ -394,7 +394,6 @@ static int sienna_cichlid_append_powerplay_table(struct 
smu_context *smu)
PPTable_t *smc_pptable = table_context->driver_pptable;
struct atom_smc_dpm_info_v4_9 *smc_dpm_table;
int index, ret;
-   int i;
 
index = 
get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
smc_dpm_info);
@@ -405,92 +404,8 @@ static int sienna_cichlid_append_powerplay_table(struct 
smu_context *smu)
return ret;
 
memcpy(smc_pptable->I2cControllers, smc_dpm_table->I2cControllers,
-  sizeof(I2cControllerConfig_t) * NUM_I2C_CONTROLLERS);
-
-   /* SVI2 Board Parameters */
-   smc_pptable->VddGfxVrMapping = smc_dpm_table->VddGfxVrMapping;
-   smc_pptable->VddSocVrMapping = smc_dpm_table->VddSocVrMapping;
-   smc_pptable->VddMem0VrMapping = smc_dpm_table->VddMem0VrMapping;
-   smc_pptable->VddMem1VrMapping = smc_dpm_table->VddMem1VrMapping;
-   smc_pptable->GfxUlvPhaseSheddingMask = 
smc_dpm_table->GfxUlvPhaseSheddingMask;
-   smc_pptable->SocUlvPhaseSheddingMask = 
smc_dpm_table->SocUlvPhaseSheddingMask;
-   smc_pptable->VddciUlvPhaseSheddingMask = 
smc_dpm_table->VddciUlvPhaseSheddingMask;
-   smc_pptable->MvddUlvPhaseSheddingMask = 
smc_dpm_table->MvddUlvPhaseSheddingMask;
-
-   /* Telemetry Settings */
-   smc_pptable->GfxMaxCurrent = smc_dpm_table->GfxMaxCurrent;
-   smc_pptable->GfxOffset = smc_dpm_table->GfxOffset;
-   smc_pptable->Padding_TelemetryGfx = smc_dpm_table->Padding_TelemetryGfx;
-   smc_pptable->SocMaxCurrent = smc_dpm_table->SocMaxCurrent;
-   smc_pptable->SocOffset = smc_dpm_table->SocOffset;
-   smc_pptable->Padding_TelemetrySoc = smc_dpm_table->Padding_TelemetrySoc;
-   smc_pptable->Mem0MaxCurrent = smc_dpm_table->Mem0MaxCurrent;
-   smc_pptable->Mem0Offset = smc_dpm_table->Mem0Offset;
-   smc_pptable->Padding_TelemetryMem0 = 
smc_dpm_table->Padding_TelemetryMem0;
-   smc_pptable->Mem1MaxCurrent = smc_dpm_table->Mem1MaxCurrent;
-   smc_pptable->Mem1Offset = smc_dpm_table->Mem1Offset;
-   smc_pptable->Padding_TelemetryMem1 = 
smc_dpm_table->Padding_TelemetryMem1;
-   smc_pptable->MvddRatio = smc_dpm_table->MvddRatio;
-
-   /* GPIO Settings */
-   smc_pptable->AcDcGpio = smc_dpm_table->AcDcGpio;
-   smc_pptable->AcDcPolarity = smc_dpm_table->AcDcPolarity;
-   smc_pptable->VR0HotGpio = smc_dpm_table->VR0HotGpio;
-   smc_pptable->VR0HotPolarity = smc_dpm_table->VR0HotPolarity;
-   smc_pptable->VR1HotGpio = smc_dpm_table->VR1HotGpio;
-   smc_pptable->VR1HotPolarity = smc_dpm_table->VR1HotPolarity;
-   smc_pptable->GthrGpio = smc_dpm_table->GthrGpio;
-   smc_pptable->GthrPolarity = smc_dpm_table->GthrPolarity;
-
-   /* LED Display Settings */
-   smc_pptable->LedPin0 = smc_dpm_table->LedPin0;
-   smc_pptable->LedPin1 = smc_dpm_table->LedPin1;
-   smc_pptable->LedPin2 = smc_dpm_table->LedPin2;
-   smc_pptable->LedEnableMask = smc_dpm_table->LedEnableMask;
-   smc_pptable->LedPcie = smc_dpm_table->LedPcie;
-   smc_pptable->LedError = smc_dpm_table->LedError;
-   smc_pptable->LedSpare1[0] = smc_dpm_table->LedSpare1[0];
-   smc_pptable->LedSpare1[1] = smc_dpm_table->LedSpare1[1];
-
-   /* GFXCLK PLL Spread Spectrum */
-   smc_pptable->PllGfxclkSpreadEnabled = 
smc_dpm_table->PllGfxclkSpreadEnabled;
-   smc_pptable->PllGfxclkSpreadPercent = 
smc_dpm_table->PllGfxclkSpreadPercent;
-   smc_pptable->PllGfxclkSpreadFreq = smc_dpm_table->PllGfxclkSpreadFreq;
-
-   /* GFXCLK DFLL Spread Spectrum */
-   smc_pptable->DfllGfxclkSpreadEnabled = 
smc_dpm_table->DfllGfxclkSpreadEnabled;
-   smc_pptable->DfllGfxclkSpreadPercent = 
smc_dpm_table->DfllGfxclkSpreadPercent;
-   smc_pptable->DfllGfxclkSpreadFreq = smc_dpm_table->DfllGfxclkSpreadFreq;
-
-   /* UCLK Spread Spectrum */
-   smc_pptable->UclkSpreadEnabled = smc_dpm_table->UclkSpreadEnabled;
-   smc_pptable->UclkSpreadPercent = smc_dpm_table->UclkSpreadPercent;
-   smc_pptable->UclkSpreadFreq = smc_dpm_table->UclkSpreadFr

[PATCH] drm/amdgpu: skip fb size query for navi10 previous asic

2020-06-05 Thread Likun Gao
From: Likun Gao 

Skip for reserved fb size query for the ASIC older than navi10, as those
asic do not need for TMR region reserve and may get an invalid value.

Signed-off-by: Likun Gao 
Change-Id: Idbc57805b8070f27ba6c3cf22f1892d6dab92f06
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index a9adccfda4c0..e2a64ae7bcaf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -603,6 +603,9 @@ int amdgpu_atomfirmware_get_fw_reserved_fb_size(struct 
amdgpu_device *adev)
u8 frev, crev;
int fw_reserved_fb_size;
 
+   if (adev->asic_type < CHIP_NAVI10)
+   return 0;
+
index = 
get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
firmwareinfo);
 
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: update driver if file for sienna_cichlid

2020-06-02 Thread Likun Gao
From: Likun Gao 

Update sienna_cichlid driver if header file to match pptable changes.

Signed-off-by: Likun Gao 
Change-Id: Ie0652935d512124c03f16ae75c44e134567ef5da
---
 .../inc/smu11_driver_if_sienna_cichlid.h| 17 ++---
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h   |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
index bdffba1f0086..5322f6da3071 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if_sienna_cichlid.h
@@ -27,7 +27,7 @@
 // *** IMPORTANT ***
 // SMU TEAM: Always increment the interface version if 
 // any structure is changed in this file
-#define SMU11_DRIVER_IF_VERSION 0x30
+#define SMU11_DRIVER_IF_VERSION 0x31
 
 #define PPTABLE_Sienna_Cichlid_SMU_VERSION 4
 
@@ -914,12 +914,14 @@ typedef struct {
   uint16_t GfxActivityLpfTau;
   uint16_t UclkActivityLpfTau;
   uint16_t SocketPowerLpfTau;  
+  uint16_t VcnClkAverageLpfTau;
+  uint16_t padding16; 
 } DriverSmuConfig_t;
 
 typedef struct {
   DriverSmuConfig_t DriverSmuConfig;
 
-  uint32_t Spare[8];  
+  uint32_t Spare[7];  
   // Padding - ignore
   uint32_t MmHubPadding[8]; // SMU internal use
 } DriverSmuConfigExternal_t;
@@ -984,11 +986,20 @@ typedef struct {
   uint8_t D3HotEntryCountPerMode[D3HOT_SEQUENCE_COUNT];
   uint8_t D3HotExitCountPerMode[D3HOT_SEQUENCE_COUNT];
   uint8_t ArmMsgReceivedCountPerMode[D3HOT_SEQUENCE_COUNT];
+
+  //PMFW-4362
+  uint32_t EnergyAccumulator;
+  uint16_t AverageVclk0Frequency  ;
+  uint16_t AverageDclk0Frequency  ;  
+  uint16_t AverageVclk1Frequency  ;
+  uint16_t AverageDclk1Frequency  ;  
+  uint16_t VcnActivityPercentage ; //place holder, David N. to provide full 
sequence
+  uint16_t padding16_2;
 } SmuMetrics_t;
 
 typedef struct {
   SmuMetrics_t SmuMetrics;
-  uint32_t Spare[5];
+  uint32_t Spare[1];
 
   // Padding - ignore
   uint32_t MmHubPadding[8]; // SMU internal use  
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 4ad3f07891fe..282eb45e7b86 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -31,7 +31,7 @@
 #define SMU11_DRIVER_IF_VERSION_NV10 0x36
 #define SMU11_DRIVER_IF_VERSION_NV12 0x33
 #define SMU11_DRIVER_IF_VERSION_NV14 0x36
-#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x30
+#define SMU11_DRIVER_IF_VERSION_Sienna_Cichlid 0x31
 
 /* MP Apertures */
 #define MP0_Public 0x0380
-- 
2.25.1

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


[PATCH] drm/amd/powerplay: move powerplay table operation out of smu_v11_0.c

2020-06-02 Thread Likun Gao
From: Likun Gao 

move smu_v11_0_get_max_power_limit and smu_v11_0_set_thermal_range
function from smu_v11_0.c to asic specific _ppt.c to avoid powerplay
table conflict with different ASIC with smu11.

Signed-off-by: Likun Gao 
Change-Id: I194f44e9f59daf19fa4758ed746fa13ccece4308
---
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c  | 64 ++-
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h|  2 +
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h |  2 -
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c| 64 ++-
 drivers/gpu/drm/amd/powerplay/smu_internal.h  |  5 ++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 63 +-
 6 files changed, 135 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c 
b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
index 1c66b7d7139c..d5527e834a8e 100644
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
@@ -37,6 +37,8 @@
 #include "arcturus_ppsmc.h"
 #include "nbio/nbio_7_4_offset.h"
 #include "nbio/nbio_7_4_sh_mask.h"
+#include "thm/thm_11_0_2_offset.h"
+#include "thm/thm_11_0_2_sh_mask.h"
 #include "amdgpu_xgmi.h"
 #include 
 #include 
@@ -1324,7 +1326,7 @@ static int arcturus_get_power_limit(struct smu_context 
*smu,
}
 
if (cap)
-   *limit = smu_v11_0_get_max_power_limit(smu);
+   *limit = smu_get_max_power_limit(smu);
else
*limit = smu->power_limit;
 
@@ -2286,6 +2288,64 @@ static int arcturus_set_df_cstate(struct smu_context 
*smu,
return smu_send_smc_msg_with_param(smu, SMU_MSG_DFCstateControl, state, 
NULL);
 }
 
+static int arcturus_set_thermal_range(struct smu_context *smu,
+  struct smu_temperature_range range)
+{
+   struct amdgpu_device *adev = smu->adev;
+   int low = SMU_THERMAL_MINIMUM_ALERT_TEMP;
+   int high = SMU_THERMAL_MAXIMUM_ALERT_TEMP;
+   uint32_t val;
+   struct smu_table_context *table_context = >smu_table;
+   struct smu_11_0_powerplay_table *powerplay_table = 
table_context->power_play_table;
+
+   low = max(SMU_THERMAL_MINIMUM_ALERT_TEMP,
+   range.min / SMU_TEMPERATURE_UNITS_PER_CENTIGRADES);
+   high = min((uint16_t)SMU_THERMAL_MAXIMUM_ALERT_TEMP, 
powerplay_table->software_shutdown_temp);
+
+   if (low > high)
+   return -EINVAL;
+
+   val = RREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL);
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_INTH_MASK, 0);
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_INTL_MASK, 0);
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high & 
0xff));
+   val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low & 
0xff));
+   val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
+
+   WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);
+
+   return 0;
+}
+
+static uint32_t atcturus_get_max_power_limit(struct smu_context *smu) {
+   uint32_t od_limit, max_power_limit;
+   struct smu_11_0_powerplay_table *powerplay_table = NULL;
+   struct smu_table_context *table_context = >smu_table;
+   powerplay_table = table_context->power_play_table;
+
+   max_power_limit = smu_get_pptable_power_limit(smu);
+
+   if (!max_power_limit) {
+   // If we couldn't get the table limit, fall back on first-read 
value
+   if (!smu->default_power_limit)
+   smu->default_power_limit = smu->power_limit;
+   max_power_limit = smu->default_power_limit;
+   }
+
+   if (smu->od_enabled) {
+   od_limit = 
le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+
+   pr_debug("ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", 
od_limit, smu->default_power_limit);
+
+   max_power_limit *= (100 + od_limit);
+   max_power_limit /= 100;
+   }
+
+   return max_power_limit;
+}
+
 static const struct pptable_funcs arcturus_ppt_funcs = {
/* translate smu index into arcturus specific index */
.get_smu_msg_index = arcturus_get_smu_msg_index,
@@ -2379,6 +2439,8 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
.override_pcie_parameters = smu_v11_0_override_pcie_parameters,
.get_pptable_power_limit = arcturus_get_pptable_power_limit,
.set_df_cstate = arcturus_set_df_cstate,
+   .set_thermal_range = arcturus_set_thermal_range,
+   .get_max_power_limit = atcturus_get_max_power_limit,
 };
 
 void arcturus_set_ppt_funcs(struct smu_context *smu)
diff --git a/drivers/gpu/drm/amd/powerplay/inc/a

[PATCH] drm/amdgpu: change memory training to common function

2020-05-21 Thread Likun Gao
From: Likun Gao 

Change memory training init and finit a common function, as it only have
software behavior do not relay on the IP version of PSP.

Signed-off-by: Likun Gao 
Change-Id: I0a81d3c3cd1813480781876101e9bfb6787bce3b
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  6 
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 40 ---
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 7301fdcfb8bc..679d96719410 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -115,6 +115,44 @@ static int psp_early_init(void *handle)
return 0;
 }
 
+static void psp_memory_training_fini(struct psp_context *psp)
+{
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
+   kfree(ctx->sys_cache);
+   ctx->sys_cache = NULL;
+}
+
+static int psp_memory_training_init(struct psp_context *psp)
+{
+   int ret;
+   struct psp_memory_training_context *ctx = >mem_train_ctx;
+
+   if (ctx->init != PSP_MEM_TRAIN_RESERVE_SUCCESS) {
+   DRM_DEBUG("memory training is not supported!\n");
+   return 0;
+   }
+
+   ctx->sys_cache = kzalloc(ctx->train_data_size, GFP_KERNEL);
+   if (ctx->sys_cache == NULL) {
+   DRM_ERROR("alloc mem_train_ctx.sys_cache failed!\n");
+   ret = -ENOMEM;
+   goto Err_out;
+   }
+
+   
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
+ ctx->train_data_size,
+ ctx->p2c_train_data_offset,
+ ctx->c2p_train_data_offset);
+   ctx->init = PSP_MEM_TRAIN_INIT_SUCCESS;
+   return 0;
+
+Err_out:
+   psp_memory_training_fini(psp);
+   return ret;
+}
+
 static int psp_sw_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -127,7 +165,7 @@ static int psp_sw_init(void *handle)
return ret;
}
 
-   ret = psp_mem_training_init(psp);
+   ret = psp_memory_training_init(psp);
if (ret) {
DRM_ERROR("Failed to initialize memory training!\n");
return ret;
@@ -152,7 +190,7 @@ static int psp_sw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-   psp_mem_training_fini(>psp);
+   psp_memory_training_fini(>psp);
release_firmware(adev->psp.sos_fw);
adev->psp.sos_fw = NULL;
release_firmware(adev->psp.asd_fw);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 2a56ad996d83..e19b98d48c98 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,8 +95,6 @@ struct psp_funcs
enum psp_ring_type ring_type);
bool (*smu_reload_quirk)(struct psp_context *psp);
int (*mode1_reset)(struct psp_context *psp);
-   int (*mem_training_init)(struct psp_context *psp);
-   void (*mem_training_fini)(struct psp_context *psp);
int (*mem_training)(struct psp_context *psp, uint32_t ops);
uint32_t (*ring_get_wptr)(struct psp_context *psp);
void (*ring_set_wptr)(struct psp_context *psp, uint32_t value);
@@ -306,10 +304,6 @@ struct amdgpu_psp_funcs {
((psp)->funcs->smu_reload_quirk ? 
(psp)->funcs->smu_reload_quirk((psp)) : false)
 #define psp_mode1_reset(psp) \
((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : 
false)
-#define psp_mem_training_init(psp) \
-   ((psp)->funcs->mem_training_init ? 
(psp)->funcs->mem_training_init((psp)) : 0)
-#define psp_mem_training_fini(psp) \
-   ((psp)->funcs->mem_training_fini ? 
(psp)->funcs->mem_training_fini((psp)) : 0)
 #define psp_mem_training(psp, ops) \
((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) 
: 0)
 
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 1de89cc3c355..9ec6e3819dff 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -555,44 +555,6 @@ static int psp_v11_0_memory_training_send_msg(struct 
psp_context *psp, int msg)
return ret;
 }
 
-static void psp_v11_0_memory_training_fini(struct psp_context *psp)
-{
-   struct psp_memory_training_context *ctx = >mem_train_ctx;
-
-   ctx->init = PSP_MEM_TRAIN_NOT_SUPPORT;
-   kfree(ctx->sys_cache);
-   ctx->sys_cache = NULL;
-}
-
-static int psp_v11_0_memory_training_init(struct psp_context *psp)
-{
-   int ret;
-   struct psp_mem

[PATCH] drm/amdgpu: add condition to set MP1 state on gpu reset

2020-05-18 Thread Likun Gao
From: Likun Gao 

Only ras supportted need to set MP1 state to prepare for unload before
reloading SMU FW.

Signed-off-by: Likun Gao 
Change-Id: I9e49b3f13aa613393381fe15b6b060665026078a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 5de5b27bf4c4..a349cf15f90a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1399,12 +1399,13 @@ static int psp_load_smu_fw(struct psp_context *psp)
struct amdgpu_device* adev = psp->adev;
struct amdgpu_firmware_info *ucode =
>firmware.ucode[AMDGPU_UCODE_ID_SMC];
+   struct amdgpu_ras *ras = psp->ras.ras;
 
if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
return 0;
 
 
-   if (adev->in_gpu_reset) {
+   if (adev->in_gpu_reset && ras && ras->supported) {
ret = amdgpu_dpm_set_mp1_state(adev, PP_MP1_STATE_UNLOAD);
if (ret) {
DRM_WARN("Failed to set MP1 state prepare for 
reload\n");
-- 
2.25.1

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


[PATCH] Revert "drm/amdgpu: change SH MEM alignment mode for gfx10"

2020-04-08 Thread Likun Gao
From: Likun Gao 

This reverts commit 8d2afe375f6ed9d84ddca234d49a53cf875f9042.
Revert the auto alignment mode set of SH MEM config, as it will result
to OCL Conformance Test fail.
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 29c94bb..0a03e2a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -3015,7 +3015,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_rlc_spm_10_1_2_nv12[] =
 
 #define DEFAULT_SH_MEM_CONFIG \
((SH_MEM_ADDRESS_MODE_64 << SH_MEM_CONFIG__ADDRESS_MODE__SHIFT) | \
-(SH_MEM_ALIGNMENT_MODE_DWORD << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) 
| \
+(SH_MEM_ALIGNMENT_MODE_UNALIGNED << 
SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \
 (SH_MEM_RETRY_MODE_ALL << SH_MEM_CONFIG__RETRY_MODE__SHIFT) | \
 (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT))
 
-- 
2.7.4

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


[PATCH] drm/amdgpu: change SH MEM alignment mode for gfx10

2020-04-03 Thread Likun Gao
From: Likun Gao 

Change SH_MEM_CONFIG Alignment mode to Automatic, as:
1)OGL fn_amd_compute_shader will failed with unaligned mode.
2)The default alignment mode was defined to automatic on gfx10
specification.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 5a67306..d8f0c0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -279,7 +279,7 @@ static const struct soc15_reg_golden 
golden_settings_gc_10_1_2_nv12[] =
 
 #define DEFAULT_SH_MEM_CONFIG \
((SH_MEM_ADDRESS_MODE_64 << SH_MEM_CONFIG__ADDRESS_MODE__SHIFT) | \
-(SH_MEM_ALIGNMENT_MODE_UNALIGNED << 
SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \
+(SH_MEM_ALIGNMENT_MODE_DWORD << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) 
| \
 (SH_MEM_RETRY_MODE_ALL << SH_MEM_CONFIG__RETRY_MODE__SHIFT) | \
 (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT))
 
-- 
2.7.4

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


[PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled

2019-12-25 Thread Likun Gao
From: Likun Gao 

Fix smu related NULL pointer issue which occurs when SMU is disabled.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index d07c4f2..3724085 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1905,8 +1905,14 @@ int smu_write_watermarks_table(struct smu_context *smu)
 int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges)
 {
-   struct smu_table *watermarks = 
>smu_table.tables[SMU_TABLE_WATERMARKS];
-   void *table = watermarks->cpu_addr;
+   struct smu_table *watermarks;
+   void *table;
+
+   if (!smu->smu_table.tables)
+   return 0;
+
+   watermarks = >smu_table.tables[SMU_TABLE_WATERMARKS];
+   table = watermarks->cpu_addr;
 
mutex_lock(>mutex);
 
@@ -2398,7 +2404,7 @@ bool smu_baco_is_support(struct smu_context *smu)
 
mutex_lock(>mutex);
 
-   if (smu->ppt_funcs->baco_is_support)
+   if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
ret = smu->ppt_funcs->baco_is_support(smu);
 
mutex_unlock(>mutex);
-- 
2.7.4

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


[PATCH] drm/amdgpu/powerplay: unify smu send message function

2019-12-02 Thread Likun Gao
From: Likun Gao 

Drop smu_send_smc_msg function from ASIC specify structure.
Reuse smu_send_smc_msg_with_param function for smu_send_smc_msg.
Set paramer to 0 for smu_send_msg function, otherwise it will send
with previous paramer value (Not a certain value).

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c |  8 
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c   |  1 -
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h |  3 ++-
 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h  |  2 --
 drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h  |  2 --
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c |  1 -
 drivers/gpu/drm/amd/powerplay/renoir_ppt.c |  1 -
 drivers/gpu/drm/amd/powerplay/smu_internal.h   |  2 --
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c  | 26 --
 drivers/gpu/drm/amd/powerplay/smu_v12_0.c  | 25 -
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c |  1 -
 11 files changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 36001a4..e039904 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -2567,3 +2567,11 @@ uint32_t smu_get_pptable_power_limit(struct smu_context 
*smu)
 
return ret;
 }
+
+int smu_send_smc_msg(struct smu_context *smu, uint16_t msg)
+{
+   int ret;
+
+   ret = smu->ppt_funcs->send_smc_msg_with_param(smu, msg, 0);
+   return ret;
+}
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c 
b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
index 68107de..3f13986 100644
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
@@ -2137,7 +2137,6 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
.set_tool_table_location = smu_v11_0_set_tool_table_location,
.notify_memory_pool_location = smu_v11_0_notify_memory_pool_location,
.system_features_control = smu_v11_0_system_features_control,
-   .send_smc_msg = smu_v11_0_send_msg,
.send_smc_msg_with_param = smu_v11_0_send_msg_with_param,
.read_smc_arg = smu_v11_0_read_arg,
.init_display_count = smu_v11_0_init_display_count,
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index ada4a8d..fae1026 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -500,7 +500,6 @@ struct pptable_funcs {
int (*notify_memory_pool_location)(struct smu_context *smu);
int (*set_last_dcef_min_deep_sleep_clk)(struct smu_context *smu);
int (*system_features_control)(struct smu_context *smu, bool en);
-   int (*send_smc_msg)(struct smu_context *smu, uint16_t msg);
int (*send_smc_msg_with_param)(struct smu_context *smu, uint16_t msg, 
uint32_t param);
int (*read_smc_arg)(struct smu_context *smu, uint32_t *arg);
int (*init_display_count)(struct smu_context *smu, uint32_t count);
@@ -725,4 +724,6 @@ int smu_get_dpm_clock_table(struct smu_context *smu,
 
 uint32_t smu_get_pptable_power_limit(struct smu_context *smu);
 
+int smu_send_smc_msg(struct smu_context *smu, uint16_t msg);
+
 #endif
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
index 5a27713..80b1d20 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h
@@ -177,8 +177,6 @@ int smu_v11_0_notify_memory_pool_location(struct 
smu_context *smu);
 int smu_v11_0_system_features_control(struct smu_context *smu,
 bool en);
 
-int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg);
-
 int
 smu_v11_0_send_msg_with_param(struct smu_context *smu, uint16_t msg,
  uint32_t param);
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h 
b/drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h
index 44c65dd..f709f6e 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v12_0.h
@@ -44,8 +44,6 @@ int smu_v12_0_read_arg(struct smu_context *smu, uint32_t 
*arg);
 
 int smu_v12_0_wait_for_response(struct smu_context *smu);
 
-int smu_v12_0_send_msg(struct smu_context *smu, uint16_t msg);
-
 int
 smu_v12_0_send_msg_with_param(struct smu_context *smu, uint16_t msg,
  uint32_t param);
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c 
b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index f842246..15403b7 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -2083,7 +2083,6 @@ static const struct pptable_funcs navi10_ppt_funcs = {
.set_tool_table_location = smu_v11_0_set_tool_table_location,
.notify_memory_pool_location = smu_v11_0_notify_memory_pool_lo

[PATCH] drm/amdgpu: remove unpin clear_state_obj for gfx v8

2019-08-01 Thread likun Gao
From: Likun Gao 

Remove unpin rlc clear_state_obj for gfx v8 when rlc init,
which will make Stoney pm_suspend hang.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index d290718..0b73c6e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -1292,6 +1292,8 @@ static int gfx_v8_0_cp_jump_table_num(struct 
amdgpu_device *adev)
 
 static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
 {
+   volatile u32 *dst_ptr;
+   u32 dws;
const struct cs_section_def *cs_data;
int r;
 
@@ -1300,10 +1302,24 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
cs_data = adev->gfx.rlc.cs_data;
 
if (cs_data) {
-   /* init clear state block */
-   r = amdgpu_gfx_rlc_init_csb(adev);
-   if (r)
+   /* clear state block */
+   adev->gfx.rlc.clear_state_size = dws = 
adev->gfx.rlc.funcs->get_csb_size(adev);
+   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >gfx.rlc.clear_state_obj,
+ 
>gfx.rlc.clear_state_gpu_addr,
+ (void **)>gfx.rlc.cs_ptr);
+   if (r) {
+   dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
+   amdgpu_gfx_rlc_fini(adev);
return r;
+   }
+
+   /* set up the cs buffer */
+   dst_ptr = adev->gfx.rlc.cs_ptr;
+   adev->gfx.rlc.funcs->get_csb_buffer(adev, dst_ptr);
+   amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj);
+   amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
}
 
if ((adev->asic_type == CHIP_CARRIZO) ||
-- 
2.7.4

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

[PATCH] drm/amdgpu: enable MGCG for PCO

2019-04-19 Thread likun Gao
From: Likun Gao 

Enable MGCG for picasso.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index a136632..4900e49 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -901,7 +901,8 @@ static int soc15_common_early_init(void *handle)
 
adev->pg_flags = AMD_PG_SUPPORT_SDMA | 
AMD_PG_SUPPORT_VCN;
} else if (adev->pdev->device == 0x15d8) {
-   adev->cg_flags = AMD_CG_SUPPORT_GFX_MGLS |
+   adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
+   AMD_CG_SUPPORT_GFX_MGLS |
AMD_CG_SUPPORT_GFX_CP_LS |
AMD_CG_SUPPORT_GFX_3D_CGCG |
AMD_CG_SUPPORT_GFX_3D_CGLS |
-- 
2.7.4

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

[PATCH] drm/amd/powerplay: fix pcie sysfs interface when set wrong value

2019-03-03 Thread likun Gao
From: Likun Gao 

The operation of mutex_unlock smu->mutex should be done when forced level is 
larger than NUM_LINK_LEVELS in the function of force_clk_levels.

Reported-by: Julia Lawall 
Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c 
b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index f7188a7..4b1fc45 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -1206,8 +1206,10 @@ static int vega20_force_clk_levels(struct smu_context 
*smu,
 
case PP_PCIE:
if (soft_min_level >= NUM_LINK_LEVELS ||
-   soft_max_level >= NUM_LINK_LEVELS)
-   return -EINVAL;
+   soft_max_level >= NUM_LINK_LEVELS) {
+   ret = -EINVAL;
+   break;
+   }
 
ret = smu_send_smc_msg_with_param(smu,
SMU_MSG_SetMinLinkDpmByIndex, soft_min_level);
-- 
2.7.4

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

[PATCH v3] drm/amd/powerplay: add limit of pp_feature for smu (v3)

2019-02-27 Thread likun Gao
From: Likun Gao 

Move pp_feature from the struct of amd_powerplay to amdgpu_device.
Add pp_feature limit for overdrive interface.

v2: put pp_feature into struct amdgpu_pm.
v3: merge feature_mask with pp_feature.

Signed-off-by: Likun Gao 
Reviewed-by: Kevin Wang 
Suggested-by: Alex Deucher 
Suggested-by: Huang Rui 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h| 1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h| 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 6 --
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +-
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 2 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 3 +++
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 +
 10 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d1c02fa..b8330a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -706,7 +706,6 @@ enum amd_hw_ip_block_type {
 struct amd_powerplay {
void *pp_handle;
const struct amd_pm_funcs *pp_funcs;
-   uint32_t pp_feature;
 };
 
 #define AMDGPU_RESET_MAGIC_NUM 64
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fcab1fe..a9a45b9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1506,7 +1506,7 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
return -EAGAIN;
}
 
-   adev->powerplay.pp_feature = amdgpu_pp_feature_mask;
+   adev->pm.pp_feature = amdgpu_pp_feature_mask;
 
for (i = 0; i < adev->num_ip_blocks; i++) {
if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index 2fda77f..dca3540 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -445,6 +445,9 @@ struct amdgpu_pm {
uint32_tsmu_prv_buffer_size;
struct amdgpu_bo*smu_prv_buffer;
bool ac_power;
+   /* powerplay feature */
+   uint32_t pp_feature;
+
 };
 
 #define R600_SSTU_DFLT   0
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 97a60da..997932e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -390,7 +390,7 @@ void amdgpu_gfx_compute_mqd_sw_fini(struct amdgpu_device 
*adev)
 
 void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)
 {
-   if (!(adev->powerplay.pp_feature & PP_GFXOFF_MASK))
+   if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
return;
 
if (!adev->powerplay.pp_funcs || 
!adev->powerplay.pp_funcs->set_powergating_by_smu)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index d3efba8..286d9e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -2557,7 +2557,8 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
"pp_power_profile_mode\n");
return ret;
}
-   if (is_support_sw_smu(adev) || hwmgr->od_enabled) {
+   if ((is_support_sw_smu(adev) && adev->smu.od_enabled) ||
+   (!is_support_sw_smu(adev) && hwmgr->od_enabled)) {
ret = device_create_file(adev->dev,
_attr_pp_od_clk_voltage);
if (ret) {
@@ -2633,7 +2634,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
device_remove_file(adev->dev, _attr_pp_mclk_od);
device_remove_file(adev->dev,
_attr_pp_power_profile_mode);
-   if (hwmgr->od_enabled)
+   if ((is_support_sw_smu(adev) && adev->smu.od_enabled) ||
+   (!is_support_sw_smu(adev) && hwmgr->od_enabled))
device_remove_file(adev->dev,
_attr_pp_od_clk_voltage);
device_remove_file(adev->dev, _attr_gpu_busy_percent);
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c 
b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index 0c9a2c0..f2e6b14 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -2824,7 +2824,7 @@ static int kv_dpm_init(struct amdgpu_device *adev)
pi->caps_tcp_ramping = true;
}
 
-   if (adev->powerplay.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
+   if (adev->pm.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
pi->caps_sclk_ds = true;
else
p

[PATCH v2] drm/amd/powerplay: add limit of pp_feature for smu (v2)

2019-02-26 Thread likun Gao
From: Likun Gao 

Move pp_feature from the struct of amd_powerplay to amdgpu_device.
Add pp_feature limit for overdrive interface.

v2: put pp_feature into struct amdgpu_pm.

Signed-off-by: Likun Gao 
Reviewed-by: Kevin Wang 
Suggested-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h| 1 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h| 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 6 --
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c| 2 +-
 drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +-
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 2 +-
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++
 11 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index e4ff186..5b82579 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -704,7 +704,6 @@ enum amd_hw_ip_block_type {
 struct amd_powerplay {
void *pp_handle;
const struct amd_pm_funcs *pp_funcs;
-   uint32_t pp_feature;
 };
 
 #define AMDGPU_RESET_MAGIC_NUM 64
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e20dce4..ec7cb627 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1506,7 +1506,7 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
return -EAGAIN;
}
 
-   adev->powerplay.pp_feature = amdgpu_pp_feature_mask;
+   adev->pm.pp_feature = amdgpu_pp_feature_mask;
 
for (i = 0; i < adev->num_ip_blocks; i++) {
if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
index 2278489..077d710 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
@@ -445,6 +445,9 @@ struct amdgpu_pm {
uint32_tsmu_prv_buffer_size;
struct amdgpu_bo*smu_prv_buffer;
bool ac_power;
+   /* powerplay feature */
+   uint32_t pp_feature;
+
 };
 
 #define R600_SSTU_DFLT   0
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 97a60da..997932e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -390,7 +390,7 @@ void amdgpu_gfx_compute_mqd_sw_fini(struct amdgpu_device 
*adev)
 
 void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable)
 {
-   if (!(adev->powerplay.pp_feature & PP_GFXOFF_MASK))
+   if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
return;
 
if (!adev->powerplay.pp_funcs || 
!adev->powerplay.pp_funcs->set_powergating_by_smu)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index ba9a5c9..2b9bbba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -2557,7 +2557,8 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
"pp_power_profile_mode\n");
return ret;
}
-   if (is_support_sw_smu(adev) || hwmgr->od_enabled) {
+   if ((is_support_sw_smu(adev) && adev->smu.od_enabled) ||
+   (!is_support_sw_smu(adev) && hwmgr->od_enabled)) {
ret = device_create_file(adev->dev,
_attr_pp_od_clk_voltage);
if (ret) {
@@ -2633,7 +2634,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
device_remove_file(adev->dev, _attr_pp_mclk_od);
device_remove_file(adev->dev,
_attr_pp_power_profile_mode);
-   if (hwmgr->od_enabled)
+   if ((is_support_sw_smu(adev) && adev->smu.od_enabled) ||
+   (!is_support_sw_smu(adev) && hwmgr->od_enabled))
device_remove_file(adev->dev,
_attr_pp_od_clk_voltage);
device_remove_file(adev->dev, _attr_gpu_busy_percent);
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c 
b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
index 86e14c7..9ae65bf 100644
--- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c
@@ -5903,7 +5903,7 @@ static int ci_dpm_init(struct amdgpu_device *adev)
pi->pcie_dpm_key_disabled = 0;
pi->thermal_sclk_dpm_enabled = 0;
 
-   if (adev->powerplay.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
+   if (adev->pm.pp_feature & PP_SCLK_DEEP_SLEEP_MASK)
pi->caps_sclk_ds = true;
else

[PATCH v2 2/3] drm/amdgpu: separate amdgpu_rlc into a single file

2018-11-08 Thread likun Gao
From: Likun Gao 

Separate the function and struct of RLC from the file of GFX.
Abstract the function of amdgpu_gfx_rlc_fini.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/Makefile |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 60 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 57 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h | 89 +
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c   | 14 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 16 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 11 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 18 +--
 9 files changed, 160 insertions(+), 107 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index ec4a9d5..f76bcb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -105,6 +105,7 @@ amdgpu-y += \
 # add GFX block
 amdgpu-y += \
amdgpu_gfx.o \
+   amdgpu_rlc.o \
gfx_v8_0.o \
gfx_v9_0.o
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 1a656b8..6a70c0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -25,6 +25,7 @@
 #include 
 #include "amdgpu.h"
 #include "amdgpu_gfx.h"
+#include "amdgpu_rlc.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(100)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index 0a7c285..f790e15 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -29,6 +29,7 @@
  */
 #include "clearstate_defs.h"
 #include "amdgpu_ring.h"
+#include "amdgpu_rlc.h"
 
 /* GFX current status */
 #define AMDGPU_GFX_NORMAL_MODE 0xL
@@ -37,65 +38,6 @@
 #define AMDGPU_GFX_CG_DISABLED_MODE0x0004L
 #define AMDGPU_GFX_LBPW_DISABLED_MODE  0x0008L
 
-
-struct amdgpu_rlc_funcs {
-   void (*enter_safe_mode)(struct amdgpu_device *adev);
-   void (*exit_safe_mode)(struct amdgpu_device *adev);
-   int  (*init)(struct amdgpu_device *adev);
-   void (*fini)(struct amdgpu_device *adev);
-   int  (*resume)(struct amdgpu_device *adev);
-   void (*stop)(struct amdgpu_device *adev);
-   void (*reset)(struct amdgpu_device *adev);
-   void (*start)(struct amdgpu_device *adev);
-};
-
-struct amdgpu_rlc {
-   /* for power gating */
-   struct amdgpu_bo*save_restore_obj;
-   uint64_tsave_restore_gpu_addr;
-   volatile uint32_t   *sr_ptr;
-   const u32   *reg_list;
-   u32 reg_list_size;
-   /* for clear state */
-   struct amdgpu_bo*clear_state_obj;
-   uint64_tclear_state_gpu_addr;
-   volatile uint32_t   *cs_ptr;
-   const struct cs_section_def   *cs_data;
-   u32 clear_state_size;
-   /* for cp tables */
-   struct amdgpu_bo*cp_table_obj;
-   uint64_tcp_table_gpu_addr;
-   volatile uint32_t   *cp_table_ptr;
-   u32 cp_table_size;
-
-   /* safe mode for updating CG/PG state */
-   bool in_safe_mode;
-   const struct amdgpu_rlc_funcs *funcs;
-
-   /* for firmware data */
-   u32 save_and_restore_offset;
-   u32 clear_state_descriptor_offset;
-   u32 avail_scratch_ram_locations;
-   u32 reg_restore_list_size;
-   u32 reg_list_format_start;
-   u32 reg_list_format_separate_start;
-   u32 starting_offsets_start;
-   u32 reg_list_format_size_bytes;
-   u32 reg_list_size_bytes;
-   u32 reg_list_format_direct_reg_list_length;
-   u32 save_restore_list_cntl_size_bytes;
-   u32 save_restore_list_gpm_size_bytes;
-   u32 save_restore_list_srm_size_bytes;
-
-   u32 *register_list_format;
-   u32 *register_restore;
-   u8 *save_restore_list_cntl;
-   u8 *save_restore_list_gpm;
-   u8 *save_restore_list_srm;
-
-   bool is_rlc_v2_1;
-};
-
 #define AMDGPU_MAX_COMPUTE_QUEUES KGD_MAX_QUEUES
 
 struct amdgpu_mec {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
new file mode 100644
index 000..c5459ab
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
@@ -0,0 +1,57 @@
+
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ * Copyright 2008 Red Hat Inc.
+ * Copyright 2009 Jerome Glisse.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Sof

[PATCH v2 3/3] drm/amdgpu: abstract the function of enter/exit safe mode for RLC

2018-11-08 Thread likun Gao
From: Likun Gao 

Abstract the function of amdgpu_gfx_rlc_enter/exit_safe_mode and some part of
rlc_init to improve the reusability of RLC.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c| 229 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h|  33 +--
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c|   6 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c  |  24 +--
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  | 148 +++--
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 201 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 183 
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c|   6 +-
 .../gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c   |  12 +-
 .../gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c |  36 ++--
 10 files changed, 408 insertions(+), 470 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
index c5459ab..c8793e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2014 Advanced Micro Devices, Inc.
  * Copyright 2008 Red Hat Inc.
@@ -23,12 +22,238 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
-
+#include 
 #include "amdgpu.h"
 #include "amdgpu_gfx.h"
 #include "amdgpu_rlc.h"
 
 /**
+ * amdgpu_gfx_rlc_enter_safe_mode - Set RLC into safe mode
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Set RLC enter into safe mode if RLC is enabled and haven't in safe mode.
+ */
+void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev)
+{
+   if (adev->gfx.rlc.in_safe_mode)
+   return;
+
+   /* if RLC is not enabled, do nothing */
+   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
+   return;
+
+   if (adev->cg_flags &
+   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
+AMD_CG_SUPPORT_GFX_3D_CGCG)) {
+   adev->gfx.rlc.funcs->set_safe_mode(adev);
+   adev->gfx.rlc.in_safe_mode = true;
+   }
+}
+
+/**
+ * amdgpu_gfx_rlc_exit_safe_mode - Set RLC out of safe mode
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Set RLC exit safe mode if RLC is enabled and have entered into safe mode.
+ */
+void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev)
+{
+   if (!(adev->gfx.rlc.in_safe_mode))
+   return;
+
+   /* if RLC is not enabled, do nothing */
+   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
+   return;
+
+   if (adev->cg_flags &
+   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
+AMD_CG_SUPPORT_GFX_3D_CGCG)) {
+   adev->gfx.rlc.funcs->unset_safe_mode(adev);
+   adev->gfx.rlc.in_safe_mode = false;
+   }
+}
+
+/**
+ * amdgpu_gfx_rlc_init_sr - Init save restore block
+ *
+ * @adev: amdgpu_device pointer
+ * @dws: the size of save restore block
+ *
+ * Allocate and setup value to save restore block of rlc.
+ * Returns 0 on succeess or negative error code if allocate failed.
+ */
+int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws)
+{
+   const u32 *src_ptr;
+   volatile u32 *dst_ptr;
+   u32 i;
+   int r;
+
+   /* allocate save restore block */
+   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >gfx.rlc.save_restore_obj,
+ >gfx.rlc.save_restore_gpu_addr,
+ (void **)>gfx.rlc.sr_ptr);
+   if (r) {
+   dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r);
+   amdgpu_gfx_rlc_fini(adev);
+   return r;
+   }
+
+   /* write the sr buffer */
+   src_ptr = adev->gfx.rlc.reg_list;
+   dst_ptr = adev->gfx.rlc.sr_ptr;
+   for (i = 0; i < adev->gfx.rlc.reg_list_size; i++)
+   dst_ptr[i] = cpu_to_le32(src_ptr[i]);
+   amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj);
+   amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj);
+
+   return 0;
+}
+
+/**
+ * amdgpu_gfx_rlc_init_csb - Init clear state block
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Allocate and setup value to clear state block of rlc.
+ * Returns 0 on succeess or negative error code if allocate failed.
+ */
+int amdgpu_gfx_rlc_init_csb(struct amdgpu_device *adev)
+{
+   volatile u32 *dst_ptr;
+   u32 dws;
+   int r;
+
+   /* allocate clear state block */
+   adev->gfx.rlc.clear_state_size = dws = 
adev->gfx.rlc.funcs->get_csb_size(adev);
+   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >gfx.rlc.clear_state_obj,
+  

[PATCH v2 1/3] drm/amdgpu: unify rlc function into structure

2018-11-08 Thread likun Gao
From: Likun Gao 

Put function rlc_init,rlc_fini,rlc_resume,rlc_stop,rlc_start into structure
amdgpu_rlc_funcs and change the method to call rlc function for each verssion of
GFX.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  6 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c   | 28 +++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 30 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 28 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 30 ++
 5 files changed, 78 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index b61b5c1..0a7c285 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -41,6 +41,12 @@
 struct amdgpu_rlc_funcs {
void (*enter_safe_mode)(struct amdgpu_device *adev);
void (*exit_safe_mode)(struct amdgpu_device *adev);
+   int  (*init)(struct amdgpu_device *adev);
+   void (*fini)(struct amdgpu_device *adev);
+   int  (*resume)(struct amdgpu_device *adev);
+   void (*stop)(struct amdgpu_device *adev);
+   void (*reset)(struct amdgpu_device *adev);
+   void (*start)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_rlc {
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index 5b25c26..2082347 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -2386,7 +2386,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
if (r) {
dev_warn(adev->dev, "(%d) create RLC sr bo failed\n",
 r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
return r;
}
 
@@ -2411,7 +2411,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.cs_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
return r;
}
 
@@ -2532,8 +2532,8 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
if (!adev->gfx.rlc_fw)
return -EINVAL;
 
-   gfx_v6_0_rlc_stop(adev);
-   gfx_v6_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->stop(adev);
+   adev->gfx.rlc.funcs->reset(adev);
gfx_v6_0_init_pg(adev);
gfx_v6_0_init_cg(adev);
 
@@ -2561,7 +2561,7 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
WREG32(mmRLC_UCODE_ADDR, 0);
 
gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev));
-   gfx_v6_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->start(adev);
 
return 0;
 }
@@ -3058,6 +3058,15 @@ static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs 
= {
.select_me_pipe_q = _v6_0_select_me_pipe_q
 };
 
+static const struct amdgpu_rlc_funcs gfx_v6_0_rlc_funcs = {
+   .init = gfx_v6_0_rlc_init,
+   .fini = gfx_v6_0_rlc_fini,
+   .resume = gfx_v6_0_rlc_resume,
+   .stop = gfx_v6_0_rlc_stop,
+   .reset = gfx_v6_0_rlc_reset,
+   .start = gfx_v6_0_rlc_start
+};
+
 static int gfx_v6_0_early_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -3065,6 +3074,7 @@ static int gfx_v6_0_early_init(void *handle)
adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
adev->gfx.funcs = _v6_0_gfx_funcs;
+   adev->gfx.rlc.funcs = _v6_0_rlc_funcs;
gfx_v6_0_set_ring_funcs(adev);
gfx_v6_0_set_irq_funcs(adev);
 
@@ -3097,7 +3107,7 @@ static int gfx_v6_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v6_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -3148,7 +3158,7 @@ static int gfx_v6_0_sw_fini(void *handle)
for (i = 0; i < adev->gfx.num_compute_rings; i++)
amdgpu_ring_fini(>gfx.compute_ring[i]);
 
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
 
return 0;
 }
@@ -3160,7 +3170,7 @@ static int gfx_v6_0_hw_init(void *handle)
 
gfx_v6_0_constants_init(adev);
 
-   r = gfx_v6_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->resume(adev);
if (r)
return r;
 
@@ -3178,7 +3188,7 @@ static int gfx_v6_0_hw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
gfx_v6_0_cp_enable(adev, false);
-   gfx_v6_0_rlc_stop

[PATCH v2 0/3] RLC kernel code update to improve resuabillity

2018-11-08 Thread likun Gao
From: Likun Gao 

Hi,

Patches for RLC which is used for improving the resuabillity of
RLC's code have update, the changes between the old patch are as follow:
PATCH 1/3: have not changed and it unified RLC's function into the struct
amdgpu_rlc_funcs and change the method of calling RLC.
PATCH 2/3 and 3/3: 1.Changed the sequence 2/3 and 3/3, separte the file rlc from
gfx first, and move the function related to rlc from amdgpu_gfx in the later
patch. 2.Apply to rlc kernel function doucmentation to the added rlc common
function.
Please help to review, thanks.

Regards,
Likun 

Likun Gao (3):
  drm/amdgpu: unify rlc function into structure
  drm/amdgpu: separate amdgpu_rlc into a single file
  drm/amdgpu: abstract the function of enter/exit safe mode for RLC

 drivers/gpu/drm/amd/amdgpu/Makefile|   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c|   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h|  54 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c| 282 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h|  98 +++
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c|   6 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c  |  56 ++--
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  | 176 +++--
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 230 ++---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 215 
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c|   6 +-
 .../gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c   |  12 +-
 .../gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c |  36 +--
 13 files changed, 599 insertions(+), 574 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h

-- 
2.7.4

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


[PATCH 2/3] drm/amdgpu: abstract the function of enter/exit safe mode for RLC.

2018-11-05 Thread likun Gao
From: Likun Gao 

abstract the function of amdgpu_gfx_rlc_enter/exit_safe_mode,
amdgpu_gfx_rlc_fini and some part of rlc_init to improve the reusability of RLC.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 201 
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h|  16 +-
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c|   6 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c  |  36 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  | 158 +++-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 210 ++---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 197 +--
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c|   6 +-
 .../gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c   |  12 +-
 .../gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c |  36 ++--
 10 files changed, 378 insertions(+), 500 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 1a656b8..7821768 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -22,6 +22,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+#include 
 #include 
 #include "amdgpu.h"
 #include "amdgpu_gfx.h"
@@ -412,3 +413,203 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool 
enable)
 
mutex_unlock(>gfx.gfx_off_mutex);
 }
+
+void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev)
+{
+   if (adev->gfx.rlc.in_safe_mode)
+   return;
+
+   /* if RLC is not enabled, do nothing */
+   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
+   return;
+
+   if (adev->cg_flags &
+   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
+AMD_CG_SUPPORT_GFX_3D_CGCG)) {
+   adev->gfx.rlc.funcs->set_safe_mode(adev);
+   adev->gfx.rlc.in_safe_mode = true;
+   }
+}
+
+void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev)
+{
+   if (!(adev->gfx.rlc.in_safe_mode))
+   return;
+
+   /* if RLC is not enabled, do nothing */
+   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
+   return;
+
+   if (adev->cg_flags &
+   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
+AMD_CG_SUPPORT_GFX_3D_CGCG)) {
+   adev->gfx.rlc.funcs->unset_safe_mode(adev);
+   adev->gfx.rlc.in_safe_mode = false;
+   }
+}
+
+int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws)
+{
+   const u32 *src_ptr;
+   volatile u32 *dst_ptr;
+   u32 i;
+   int r;
+
+   /* allocate save restore block */
+   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >gfx.rlc.save_restore_obj,
+ >gfx.rlc.save_restore_gpu_addr,
+ (void **)>gfx.rlc.sr_ptr);
+   if (r) {
+   dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r);
+   amdgpu_gfx_rlc_fini(adev);
+   return r;
+   }
+
+   /* write the sr buffer */
+   src_ptr = adev->gfx.rlc.reg_list;
+   dst_ptr = adev->gfx.rlc.sr_ptr;
+   for (i = 0; i < adev->gfx.rlc.reg_list_size; i++)
+   dst_ptr[i] = cpu_to_le32(src_ptr[i]);
+   amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj);
+   amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj);
+
+   return 0;
+}
+
+int amdgpu_gfx_rlc_init_csb(struct amdgpu_device *adev)
+{
+   volatile u32 *dst_ptr;
+   u32 dws;
+   int r;
+
+   /* allocate clear state block */
+   adev->gfx.rlc.clear_state_size = dws = 
adev->gfx.rlc.funcs->get_csb_size(adev);
+   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ >gfx.rlc.clear_state_obj,
+ >gfx.rlc.clear_state_gpu_addr,
+ (void **)>gfx.rlc.cs_ptr);
+   if (r) {
+   dev_err(adev->dev, "(%d) failed to create rlc csb bo\n", r);
+   amdgpu_gfx_rlc_fini(adev);
+   return r;
+   }
+
+   /* set up the cs buffer */
+   dst_ptr = adev->gfx.rlc.cs_ptr;
+   adev->gfx.rlc.funcs->get_csb_buffer(adev, dst_ptr);
+   amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj);
+   amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
+   amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
+
+   return 0;
+}
+
+int amdgpu_gfx_rlc_init_cpt(struct amdgpu_device *adev)
+{
+   int r;
+
+   r = amdgpu_bo_create_reserved(adev, adev->gfx.rlc.cp_table_size,
+

[PATCH 3/3] drm/amdgpu: separate amdgpu_rlc into a single file.

2018-11-05 Thread likun Gao
From: Likun Gao 

separate the function and struct of RLC from the file of GFX

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/Makefile |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 202 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  70 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c | 228 
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h |  98 ++
 5 files changed, 329 insertions(+), 270 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index ec4a9d5..f76bcb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -105,6 +105,7 @@ amdgpu-y += \
 # add GFX block
 amdgpu-y += \
amdgpu_gfx.o \
+   amdgpu_rlc.o \
gfx_v8_0.o \
gfx_v9_0.o
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 7821768..6a70c0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -22,10 +22,10 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
-#include 
 #include 
 #include "amdgpu.h"
 #include "amdgpu_gfx.h"
+#include "amdgpu_rlc.h"
 
 /* delay 0.1 second to enable gfx off feature */
 #define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(100)
@@ -413,203 +413,3 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool 
enable)
 
mutex_unlock(>gfx.gfx_off_mutex);
 }
-
-void amdgpu_gfx_rlc_enter_safe_mode(struct amdgpu_device *adev)
-{
-   if (adev->gfx.rlc.in_safe_mode)
-   return;
-
-   /* if RLC is not enabled, do nothing */
-   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
-   return;
-
-   if (adev->cg_flags &
-   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
-AMD_CG_SUPPORT_GFX_3D_CGCG)) {
-   adev->gfx.rlc.funcs->set_safe_mode(adev);
-   adev->gfx.rlc.in_safe_mode = true;
-   }
-}
-
-void amdgpu_gfx_rlc_exit_safe_mode(struct amdgpu_device *adev)
-{
-   if (!(adev->gfx.rlc.in_safe_mode))
-   return;
-
-   /* if RLC is not enabled, do nothing */
-   if (!adev->gfx.rlc.funcs->is_rlc_enabled(adev))
-   return;
-
-   if (adev->cg_flags &
-   (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG |
-AMD_CG_SUPPORT_GFX_3D_CGCG)) {
-   adev->gfx.rlc.funcs->unset_safe_mode(adev);
-   adev->gfx.rlc.in_safe_mode = false;
-   }
-}
-
-int amdgpu_gfx_rlc_init_sr(struct amdgpu_device *adev, u32 dws)
-{
-   const u32 *src_ptr;
-   volatile u32 *dst_ptr;
-   u32 i;
-   int r;
-
-   /* allocate save restore block */
-   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
- AMDGPU_GEM_DOMAIN_VRAM,
- >gfx.rlc.save_restore_obj,
- >gfx.rlc.save_restore_gpu_addr,
- (void **)>gfx.rlc.sr_ptr);
-   if (r) {
-   dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r);
-   amdgpu_gfx_rlc_fini(adev);
-   return r;
-   }
-
-   /* write the sr buffer */
-   src_ptr = adev->gfx.rlc.reg_list;
-   dst_ptr = adev->gfx.rlc.sr_ptr;
-   for (i = 0; i < adev->gfx.rlc.reg_list_size; i++)
-   dst_ptr[i] = cpu_to_le32(src_ptr[i]);
-   amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj);
-   amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj);
-
-   return 0;
-}
-
-int amdgpu_gfx_rlc_init_csb(struct amdgpu_device *adev)
-{
-   volatile u32 *dst_ptr;
-   u32 dws;
-   int r;
-
-   /* allocate clear state block */
-   adev->gfx.rlc.clear_state_size = dws = 
adev->gfx.rlc.funcs->get_csb_size(adev);
-   r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
- AMDGPU_GEM_DOMAIN_VRAM,
- >gfx.rlc.clear_state_obj,
- >gfx.rlc.clear_state_gpu_addr,
- (void **)>gfx.rlc.cs_ptr);
-   if (r) {
-   dev_err(adev->dev, "(%d) failed to create rlc csb bo\n", r);
-   amdgpu_gfx_rlc_fini(adev);
-   return r;
-   }
-
-   /* set up the cs buffer */
-   dst_ptr = adev->gfx.rlc.cs_ptr;
-   adev->gfx.rlc.funcs->get_csb_buffer(adev, dst_ptr);
-   amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj);
-   amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
-   amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
-

[PATCH 0/3] RLC kernel code update to improve resuabillity

2018-11-05 Thread likun Gao
From: Likun Gao 

Hi,

Those series of patch modified the code of RLC to improve the resuabillity of
RLC's code. The process was separate into three part:
Part1[PATCH 1/3]: Unify RLC's function into the struct amdgpu_rlc_funcs and 
change the
method of calling RLC.
Part2[PATCH 2/3]: Abstract RLC's function from the function struct for each
version of GFX to improve the resuability of RLC's function code.
Part3[PATCH 3/3]: Separate RLC's code from the file of amdgpu_gfx.

Please help to review.

Regards,
Likun

Likun Gao (3):
  drm/amdgpu: unify rlc function into structure
  drm/amdgpu: abstract the function of enter/exit safe mode for RLC.
  drm/amdgpu: separate amdgpu_rlc into a single file.

 drivers/gpu/drm/amd/amdgpu/Makefile|   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c|   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h|  54 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c| 228 
 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h|  98 +
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c|   6 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c  |  56 ++---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  | 176 
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 230 +++--
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 215 +--
 drivers/gpu/drm/amd/amdgpu/kv_dpm.c|   6 +-
 .../gpu/drm/amd/powerplay/hwmgr/smu7_powertune.c   |  12 +-
 .../gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c |  36 ++--
 13 files changed, 545 insertions(+), 574 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_rlc.h

-- 
2.7.4

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


[PATCH 1/3] drm/amdgpu: unify rlc function into structure

2018-11-05 Thread likun Gao
From: Likun Gao 

Put function rlc_init,rlc_fini,rlc_resume,rlc_stop,rlc_start into structure
amdgpu_rlc_funcs and change the method to call rlc function for each verssion of
GFX.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  6 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c   | 28 +++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 30 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 28 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 30 ++
 5 files changed, 78 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index b61b5c1..0a7c285 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -41,6 +41,12 @@
 struct amdgpu_rlc_funcs {
void (*enter_safe_mode)(struct amdgpu_device *adev);
void (*exit_safe_mode)(struct amdgpu_device *adev);
+   int  (*init)(struct amdgpu_device *adev);
+   void (*fini)(struct amdgpu_device *adev);
+   int  (*resume)(struct amdgpu_device *adev);
+   void (*stop)(struct amdgpu_device *adev);
+   void (*reset)(struct amdgpu_device *adev);
+   void (*start)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_rlc {
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index 5b25c26..2082347 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -2386,7 +2386,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
if (r) {
dev_warn(adev->dev, "(%d) create RLC sr bo failed\n",
 r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
return r;
}
 
@@ -2411,7 +2411,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.cs_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
return r;
}
 
@@ -2532,8 +2532,8 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
if (!adev->gfx.rlc_fw)
return -EINVAL;
 
-   gfx_v6_0_rlc_stop(adev);
-   gfx_v6_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->stop(adev);
+   adev->gfx.rlc.funcs->reset(adev);
gfx_v6_0_init_pg(adev);
gfx_v6_0_init_cg(adev);
 
@@ -2561,7 +2561,7 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
WREG32(mmRLC_UCODE_ADDR, 0);
 
gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev));
-   gfx_v6_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->start(adev);
 
return 0;
 }
@@ -3058,6 +3058,15 @@ static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs 
= {
.select_me_pipe_q = _v6_0_select_me_pipe_q
 };
 
+static const struct amdgpu_rlc_funcs gfx_v6_0_rlc_funcs = {
+   .init = gfx_v6_0_rlc_init,
+   .fini = gfx_v6_0_rlc_fini,
+   .resume = gfx_v6_0_rlc_resume,
+   .stop = gfx_v6_0_rlc_stop,
+   .reset = gfx_v6_0_rlc_reset,
+   .start = gfx_v6_0_rlc_start
+};
+
 static int gfx_v6_0_early_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -3065,6 +3074,7 @@ static int gfx_v6_0_early_init(void *handle)
adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
adev->gfx.funcs = _v6_0_gfx_funcs;
+   adev->gfx.rlc.funcs = _v6_0_rlc_funcs;
gfx_v6_0_set_ring_funcs(adev);
gfx_v6_0_set_irq_funcs(adev);
 
@@ -3097,7 +3107,7 @@ static int gfx_v6_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v6_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -3148,7 +3158,7 @@ static int gfx_v6_0_sw_fini(void *handle)
for (i = 0; i < adev->gfx.num_compute_rings; i++)
amdgpu_ring_fini(>gfx.compute_ring[i]);
 
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->fini(adev);
 
return 0;
 }
@@ -3160,7 +3170,7 @@ static int gfx_v6_0_hw_init(void *handle)
 
gfx_v6_0_constants_init(adev);
 
-   r = gfx_v6_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->resume(adev);
if (r)
return r;
 
@@ -3178,7 +3188,7 @@ static int gfx_v6_0_hw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
gfx_v6_0_cp_enable(adev, false);
-   gfx_v6_0_rlc_stop

[PATCH 3/5] drm/amdgpu/rlc: gfx_v7 change the method to call rlc function

2018-10-10 Thread likun Gao
From: Likun Gao 

Use struct pointer to call rlc function.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index 0e72bc0..8826f59 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -3314,7 +3314,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.sr_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create, pin or map of RLC sr 
bo failed\n", r);
-   gfx_v7_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -3337,7 +3337,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.cs_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
-   gfx_v7_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -3357,7 +3357,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
  (void 
**)>gfx.rlc.cp_table_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC cp table bo 
failed\n", r);
-   gfx_v7_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -3545,13 +3545,13 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device 
*adev)
adev->gfx.rlc_feature_version = le32_to_cpu(
hdr->ucode_feature_version);
 
-   gfx_v7_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
/* disable CG */
tmp = RREG32(mmRLC_CGCG_CGLS_CTRL) & 0xfffc;
WREG32(mmRLC_CGCG_CGLS_CTRL, tmp);
 
-   gfx_v7_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->rlc_reset(adev);
 
gfx_v7_0_init_pg(adev);
 
@@ -3582,7 +3582,7 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device *adev)
if (adev->asic_type == CHIP_BONAIRE)
WREG32(mmRLC_DRIVER_CPDMA_STATUS, 0);
 
-   gfx_v7_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->rlc_start(adev);
 
return 0;
 }
@@ -4289,7 +4289,13 @@ static const struct amdgpu_gfx_funcs gfx_v7_0_gfx_funcs 
= {
 
 static const struct amdgpu_rlc_funcs gfx_v7_0_rlc_funcs = {
.enter_safe_mode = gfx_v7_0_enter_rlc_safe_mode,
-   .exit_safe_mode = gfx_v7_0_exit_rlc_safe_mode
+   .exit_safe_mode = gfx_v7_0_exit_rlc_safe_mode,
+   .rlc_init = gfx_v7_0_rlc_init,
+   .rlc_fini = gfx_v7_0_rlc_fini,
+   .rlc_resume = gfx_v7_0_rlc_resume,
+   .rlc_stop = gfx_v7_0_rlc_stop,
+   .rlc_reset = gfx_v7_0_rlc_reset,
+   .rlc_start = gfx_v7_0_rlc_start
 };
 
 static int gfx_v7_0_early_init(void *handle)
@@ -4540,7 +4546,7 @@ static int gfx_v7_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v7_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->rlc_init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -4604,7 +4610,7 @@ static int gfx_v7_0_sw_fini(void *handle)
amdgpu_ring_fini(>gfx.compute_ring[i]);
 
gfx_v7_0_cp_compute_fini(adev);
-   gfx_v7_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
gfx_v7_0_mec_fini(adev);
amdgpu_bo_free_kernel(>gfx.rlc.clear_state_obj,
>gfx.rlc.clear_state_gpu_addr,
@@ -4627,7 +4633,7 @@ static int gfx_v7_0_hw_init(void *handle)
gfx_v7_0_constants_init(adev);
 
/* init rlc */
-   r = gfx_v7_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->rlc_resume(adev);
if (r)
return r;
 
@@ -4645,7 +4651,7 @@ static int gfx_v7_0_hw_fini(void *handle)
amdgpu_irq_put(adev, >gfx.priv_reg_irq, 0);
amdgpu_irq_put(adev, >gfx.priv_inst_irq, 0);
gfx_v7_0_cp_enable(adev, false);
-   gfx_v7_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
gfx_v7_0_fini_pg(adev);
 
return 0;
@@ -4730,7 +4736,7 @@ static int gfx_v7_0_soft_reset(void *handle)
gfx_v7_0_update_cg(adev, false);
 
/* stop the rlc */
-   gfx_v7_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
/* Disable GFX parsing/prefetching */
WREG32(mmCP_ME_CNTL, CP_ME_CNTL__ME_HALT_MASK | 
CP_ME_CNTL__PFP_HALT_MASK | CP_ME_CNTL__CE_HALT_MA

[PATCH 5/5] drm/amdgpu/rlc: gfx_v9 change the method to call rlc function

2018-10-10 Thread likun Gao
From: Likun Gao 

Use struct pointer to call rlc function.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index d6b5069..16798f7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1152,7 +1152,7 @@ static int gfx_v9_0_rlc_init(struct amdgpu_device *adev)
if (r) {
dev_err(adev->dev, "(%d) failed to create rlc csb bo\n",
r);
-   gfx_v9_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
/* set up the cs buffer */
@@ -1174,7 +1174,7 @@ static int gfx_v9_0_rlc_init(struct amdgpu_device *adev)
if (r) {
dev_err(adev->dev,
"(%d) failed to create cp table bo\n", r);
-   gfx_v9_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -1738,7 +1738,7 @@ static int gfx_v9_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v9_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->rlc_init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -2488,12 +2488,12 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device 
*adev)
return 0;
}
 
-   gfx_v9_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
/* disable CG */
WREG32_SOC15(GC, 0, mmRLC_CGCG_CGLS_CTRL, 0);
 
-   gfx_v9_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->rlc_reset(adev);
 
gfx_v9_0_init_pg(adev);
 
@@ -2512,7 +2512,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
gfx_v9_0_enable_lbpw(adev, false);
}
 
-   gfx_v9_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->rlc_start(adev);
 
return 0;
 }
@@ -3343,7 +3343,7 @@ static int gfx_v9_0_hw_init(void *handle)
if (r)
return r;
 
-   r = gfx_v9_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->rlc_resume(adev);
if (r)
return r;
 
@@ -3423,7 +3423,7 @@ static int gfx_v9_0_hw_fini(void *handle)
}
 
gfx_v9_0_cp_enable(adev, false);
-   gfx_v9_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
gfx_v9_0_csb_vram_unpin(adev);
 
@@ -3498,7 +3498,7 @@ static int gfx_v9_0_soft_reset(void *handle)
 
if (grbm_soft_reset) {
/* stop the rlc */
-   gfx_v9_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
/* Disable GFX parsing/prefetching */
gfx_v9_0_cp_gfx_enable(adev, false);
@@ -3654,7 +3654,7 @@ static void gfx_v9_0_exit_rlc_safe_mode(struct 
amdgpu_device *adev)
 static void gfx_v9_0_update_gfx_cg_power_gating(struct amdgpu_device *adev,
bool enable)
 {
-   gfx_v9_0_enter_rlc_safe_mode(adev);
+   adev->gfx.rlc.funcs->enter_safe_mode(adev);
 
if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) && enable) {
gfx_v9_0_enable_gfx_cg_power_gating(adev, true);
@@ -3665,7 +3665,7 @@ static void gfx_v9_0_update_gfx_cg_power_gating(struct 
amdgpu_device *adev,
gfx_v9_0_enable_gfx_pipeline_powergating(adev, false);
}
 
-   gfx_v9_0_exit_rlc_safe_mode(adev);
+   adev->gfx.rlc.funcs->exit_safe_mode(adev);
 }
 
 static void gfx_v9_0_update_gfx_mg_power_gating(struct amdgpu_device *adev,
@@ -3881,7 +3881,13 @@ static int gfx_v9_0_update_gfx_clock_gating(struct 
amdgpu_device *adev,
 
 static const struct amdgpu_rlc_funcs gfx_v9_0_rlc_funcs = {
.enter_safe_mode = gfx_v9_0_enter_rlc_safe_mode,
-   .exit_safe_mode = gfx_v9_0_exit_rlc_safe_mode
+   .exit_safe_mode = gfx_v9_0_exit_rlc_safe_mode,
+   .rlc_init = gfx_v9_0_rlc_init,
+   .rlc_fini = gfx_v9_0_rlc_fini,
+   .rlc_resume = gfx_v9_0_rlc_resume,
+   .rlc_stop = gfx_v9_0_rlc_stop,
+   .rlc_reset = gfx_v9_0_rlc_reset,
+   .rlc_start = gfx_v9_0_rlc_start
 };
 
 static int gfx_v9_0_set_powergating_state(void *handle,
-- 
2.7.4

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


[PATCH 4/5] drm/amdgpu/rlc: gfx_v8 change the method to call rlc function

2018-10-10 Thread likun Gao
From: Likun Gao 

Use struct pointer to call rlc function.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 8439f9a..7735545 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -1391,7 +1391,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.cs_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
-   gfx_v8_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -2088,7 +2088,7 @@ static int gfx_v8_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v8_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->rlc_init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -2181,7 +2181,7 @@ static int gfx_v8_0_sw_fini(void *handle)
amdgpu_gfx_kiq_fini(adev);
 
gfx_v8_0_mec_fini(adev);
-   gfx_v8_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
amdgpu_bo_free_kernel(>gfx.rlc.clear_state_obj,
>gfx.rlc.clear_state_gpu_addr,
(void **)>gfx.rlc.cs_ptr);
@@ -4177,8 +4177,8 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
 {
int r;
 
-   gfx_v8_0_rlc_stop(adev);
-   gfx_v8_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_reset(adev);
gfx_v8_0_init_pg(adev);
 
if (adev->powerplay.pp_funcs->load_firmware) {
@@ -4189,7 +4189,7 @@ static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
}
}
 
-   gfx_v8_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->rlc_start(adev);
 
return 0;
 }
@@ -4876,7 +4876,7 @@ static int gfx_v8_0_hw_init(void *handle)
gfx_v8_0_init_golden_registers(adev);
gfx_v8_0_constants_init(adev);
 
-   r = gfx_v8_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->rlc_resume(adev);
if (r)
return r;
 
@@ -4988,7 +4988,7 @@ static int gfx_v8_0_hw_fini(void *handle)
else
pr_err("cp is busy, skip halt cp\n");
if (!gfx_v8_0_wait_for_rlc_idle(adev))
-   gfx_v8_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
else
pr_err("rlc is busy, skip halt rlc\n");
adev->gfx.rlc.funcs->exit_safe_mode(adev);
@@ -5080,7 +5080,7 @@ static int gfx_v8_0_pre_soft_reset(void *handle)
srbm_soft_reset = adev->gfx.srbm_soft_reset;
 
/* stop the rlc */
-   gfx_v8_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
 
if (REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET, SOFT_RESET_CP) ||
REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET, SOFT_RESET_GFX))
@@ -5206,7 +5206,7 @@ static int gfx_v8_0_post_soft_reset(void *handle)
REG_GET_FIELD(grbm_soft_reset, GRBM_SOFT_RESET, SOFT_RESET_GFX))
gfx_v8_0_cp_gfx_resume(adev);
 
-   gfx_v8_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->rlc_start(adev);
 
return 0;
 }
@@ -5663,7 +5663,13 @@ static void iceland_exit_rlc_safe_mode(struct 
amdgpu_device *adev)
 
 static const struct amdgpu_rlc_funcs iceland_rlc_funcs = {
.enter_safe_mode = iceland_enter_rlc_safe_mode,
-   .exit_safe_mode = iceland_exit_rlc_safe_mode
+   .exit_safe_mode = iceland_exit_rlc_safe_mode,
+   .rlc_init = gfx_v8_0_rlc_init,
+   .rlc_fini = gfx_v8_0_rlc_fini,
+   .rlc_resume = gfx_v8_0_rlc_resume,
+   .rlc_stop = gfx_v8_0_rlc_stop,
+   .rlc_reset = gfx_v8_0_rlc_reset,
+   .rlc_start = gfx_v8_0_rlc_start
 };
 
 static void gfx_v8_0_update_medium_grain_clock_gating(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 2/5] drm/amdgpu/rlc: gfx_v6 change the method to call rlc function

2018-10-10 Thread likun Gao
From: Likun Gao 

Use struct pointer to call rlc function.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index d76eb27..9b5523d 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -2403,7 +2403,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
if (r) {
dev_warn(adev->dev, "(%d) create RLC sr bo failed\n",
 r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -2428,7 +2428,7 @@ static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
  (void **)>gfx.rlc.cs_ptr);
if (r) {
dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
return r;
}
 
@@ -2549,8 +2549,8 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
if (!adev->gfx.rlc_fw)
return -EINVAL;
 
-   gfx_v6_0_rlc_stop(adev);
-   gfx_v6_0_rlc_reset(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_reset(adev);
gfx_v6_0_init_pg(adev);
gfx_v6_0_init_cg(adev);
 
@@ -2578,7 +2578,7 @@ static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
WREG32(mmRLC_UCODE_ADDR, 0);
 
gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev));
-   gfx_v6_0_rlc_start(adev);
+   adev->gfx.rlc.funcs->rlc_start(adev);
 
return 0;
 }
@@ -3075,6 +3075,15 @@ static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs 
= {
.select_me_pipe_q = _v6_0_select_me_pipe_q
 };
 
+static const struct amdgpu_rlc_funcs gfx_v6_0_rlc_funcs = {
+   .rlc_init = gfx_v6_0_rlc_init,
+   .rlc_fini = gfx_v6_0_rlc_fini,
+   .rlc_resume = gfx_v6_0_rlc_resume,
+   .rlc_stop = gfx_v6_0_rlc_stop,
+   .rlc_reset = gfx_v6_0_rlc_reset,
+   .rlc_start = gfx_v6_0_rlc_start
+};
+
 static int gfx_v6_0_early_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -3082,6 +3091,7 @@ static int gfx_v6_0_early_init(void *handle)
adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
adev->gfx.funcs = _v6_0_gfx_funcs;
+   adev->gfx.rlc.funcs = _v6_0_rlc_funcs;
gfx_v6_0_set_ring_funcs(adev);
gfx_v6_0_set_irq_funcs(adev);
 
@@ -3114,7 +3124,7 @@ static int gfx_v6_0_sw_init(void *handle)
return r;
}
 
-   r = gfx_v6_0_rlc_init(adev);
+   r = adev->gfx.rlc.funcs->rlc_init(adev);
if (r) {
DRM_ERROR("Failed to init rlc BOs!\n");
return r;
@@ -3165,7 +3175,7 @@ static int gfx_v6_0_sw_fini(void *handle)
for (i = 0; i < adev->gfx.num_compute_rings; i++)
amdgpu_ring_fini(>gfx.compute_ring[i]);
 
-   gfx_v6_0_rlc_fini(adev);
+   adev->gfx.rlc.funcs->rlc_fini(adev);
 
return 0;
 }
@@ -3177,7 +3187,7 @@ static int gfx_v6_0_hw_init(void *handle)
 
gfx_v6_0_constants_init(adev);
 
-   r = gfx_v6_0_rlc_resume(adev);
+   r = adev->gfx.rlc.funcs->rlc_resume(adev);
if (r)
return r;
 
@@ -3195,7 +3205,7 @@ static int gfx_v6_0_hw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
gfx_v6_0_cp_enable(adev, false);
-   gfx_v6_0_rlc_stop(adev);
+   adev->gfx.rlc.funcs->rlc_stop(adev);
gfx_v6_0_fini_pg(adev);
 
return 0;
-- 
2.7.4

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


[PATCH 1/5] drm/amdgpu/rlc: unify rlc function into structure

2018-10-10 Thread likun Gao
From: Likun Gao 

Put function rlc_init,rlc_fini,rlc_resume,rlc_stop,rlc_start into structure
amdgpu_rlc_funcs.

Signed-off-by: Likun Gao 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index b61b5c1..bb7b1ad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
@@ -41,6 +41,12 @@
 struct amdgpu_rlc_funcs {
void (*enter_safe_mode)(struct amdgpu_device *adev);
void (*exit_safe_mode)(struct amdgpu_device *adev);
+   int  (*rlc_init)(struct amdgpu_device *adev);
+   void (*rlc_fini)(struct amdgpu_device *adev);
+   int  (*rlc_resume)(struct amdgpu_device *adev);
+   void (*rlc_stop)(struct amdgpu_device *adev);
+   void (*rlc_reset)(struct amdgpu_device *adev);
+   void (*rlc_start)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_rlc {
-- 
2.7.4

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


[PATCH 0/5] RLC kernel code update for unified RLC function

2018-10-10 Thread likun Gao
From: Likun Gao 

Hi all,

Code modified about RLC will be operated to improve the resuability of RLC's
code, and this process will operated with two steps:

STEP1(completed):
- Unify RLC's function into the structure amdgpu_rlc_funcs and use structure
  pointer to call RLC functions.
- The modified of the step have completed, and the related code change have
  patched in the following patches.

Please help to review.

STEP2(underway):
- Will modified the code to unify the RLC function for each version of GFX to
  improve the resuability of RLC's function code.

Regards,
Likun

Likun Gao (5):
  drm/amdgpu/rlc: unify rlc function into structure
  drm/amdgpu/rlc: gfx_v6 change the method to call rlc function
  drm/amdgpu/rlc: gfx_v7 change the method to call rlc function
  drm/amdgpu/rlc: gfx_v8 change the method to call rlc function
  drm/amdgpu/rlc: gfx_v9 change the method to call rlc function

 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h |  6 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c   | 28 +++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 30 ++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 28 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 30 ++
 5 files changed, 78 insertions(+), 44 deletions(-)

-- 
2.7.4

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


[PATCH libdrm] amdgpu: Disable deadlock test suite for RV/RV2/PCO

2018-08-14 Thread likun Gao
From: Likun Gao 

disable deadlock test suite for RV/RV2/PCO

Signed-off-by: Likun Gao 
---
 tests/amdgpu/deadlock_tests.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/amdgpu/deadlock_tests.c b/tests/amdgpu/deadlock_tests.c
index 1eb5761..304482d 100644
--- a/tests/amdgpu/deadlock_tests.c
+++ b/tests/amdgpu/deadlock_tests.c
@@ -93,7 +93,8 @@ CU_BOOL suite_deadlock_tests_enable(void)
return CU_FALSE;
 
if (device_handle->info.family_id == AMDGPU_FAMILY_AI ||
-   device_handle->info.family_id == AMDGPU_FAMILY_SI) {
+   device_handle->info.family_id == AMDGPU_FAMILY_SI ||
+   device_handle->info.family_id == AMDGPU_FAMILY_RV) {
printf("\n\nCurrently hangs the CP on this ASIC, deadlock suite 
disabled\n");
enable = CU_FALSE;
}
-- 
2.7.4

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