[PATCH] PCI: Add vf reset notification for pf

2024-02-03 Thread Emily Deng
When a vf has been reset, the pf wants to get notification to remove the vf
out of schedule.

Solution:
Add the callback function in pci_driver sriov_vf_reset_notification. When
vf reset happens, then call this callback function.

Signed-off-by: Emily Deng 
---
 drivers/pci/pci.c   | 8 
 include/linux/pci.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0..aca937b05531 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4780,6 +4780,14 @@ EXPORT_SYMBOL_GPL(pcie_flr);
  */
 int pcie_reset_flr(struct pci_dev *dev, bool probe)
 {
+   struct pci_dev *pf_dev;
+
+   if (dev->is_virtfn) {
+   pf_dev = dev->physfn;
+   if (pf_dev->driver->sriov_vf_reset_notification)
+   pf_dev->driver->sriov_vf_reset_notification(pf_dev, 
dev);
+   }
+
if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET)
return -ENOTTY;
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c69a2cc1f412..4fa31d9b0aa7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -926,6 +926,7 @@ struct pci_driver {
int  (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
int  (*sriov_set_msix_vec_count)(struct pci_dev *vf, int 
msix_vec_count); /* On PF */
u32  (*sriov_get_vf_total_msix)(struct pci_dev *pf);
+   void  (*sriov_vf_reset_notification)(struct pci_dev *pf, struct pci_dev 
*vf);
const struct pci_error_handlers *err_handler;
const struct attribute_group **groups;
const struct attribute_group **dev_groups;
-- 
2.36.1



[PATCH 2/2] drm/amdgpu: Add timeout for sync wait

2023-10-20 Thread Emily Deng
Issue: Dead heappen during gpu recover, the call sequence as below:

amdgpu_device_gpu_recover->amdgpu_amdkfd_pre_reset->flush_delayed_work->
amdgpu_amdkfd_gpuvm_restore_process_bos->amdgpu_sync_wait

It is because the amdgpu_sync_wait is waiting for the bad job's fence, and
never return, so the recover couldn't continue.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index dcd8c066bc1f..9d4f122a7bf0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -406,8 +406,15 @@ int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr)
int i, r;
 
hash_for_each_safe(sync->fences, i, tmp, e, node) {
-   r = dma_fence_wait(e->fence, intr);
-   if (r)
+   struct drm_sched_fence *s_fence = to_drm_sched_fence(e->fence);
+   long timeout = msecs_to_jiffies(1);
+
+   if (s_fence)
+   timeout = s_fence->sched->timeout;
+   r = dma_fence_wait_timeout(e->fence, intr, timeout);
+   if (r == 0)
+   r = -ETIMEDOUT;
+   if (r < 0)
return r;
 
amdgpu_sync_entry_free(e);
-- 
2.36.1



[PATCH 1/2] drm/amdgpu: handle the return for sync wait

2023-10-20 Thread Emily Deng
Add error handling for amdgpu_sync_wait.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  | 6 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 54f31a420229..3011c191d7dd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -2668,7 +2668,7 @@ static int validate_invalid_user_pages(struct 
amdkfd_process_info *process_info)
 
 unreserve_out:
ttm_eu_backoff_reservation(, _list);
-   amdgpu_sync_wait(, false);
+   ret = amdgpu_sync_wait(, false);
amdgpu_sync_free();
 out_free:
kfree(pd_bo_list_entries);
@@ -2939,8 +2939,11 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, 
struct dma_fence **ef)
}
 
/* Wait for validate and PT updates to finish */
-   amdgpu_sync_wait(_obj, false);
-
+   ret = amdgpu_sync_wait(_obj, false);
+   if (ret) {
+   pr_err("Failed to wait for validate and PT updates to 
finish\n");
+   goto validate_map_fail;
+   }
/* Release old eviction fence and create new one, because fence only
 * goes from unsignaled to signaled, fence cannot be reused.
 * Use context and mm from the old fence.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 70fe3b39c004..a63139277583 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -1153,7 +1153,11 @@ int amdgpu_mes_ctx_map_meta_data(struct amdgpu_device 
*adev,
}
amdgpu_sync_fence(, vm->last_update);
 
-   amdgpu_sync_wait(, false);
+   r = amdgpu_sync_wait(, false);
+   if (r) {
+   DRM_ERROR("failed to wait sync\n");
+   goto error;
+   }
ttm_eu_backoff_reservation(, );
 
amdgpu_sync_free();
-- 
2.36.1



[PATCH 2/2] drm/amdgpu: handle the return for sync wait

2023-10-20 Thread Emily Deng
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c  | 6 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 54f31a420229..3011c191d7dd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -2668,7 +2668,7 @@ static int validate_invalid_user_pages(struct 
amdkfd_process_info *process_info)
 
 unreserve_out:
ttm_eu_backoff_reservation(, _list);
-   amdgpu_sync_wait(, false);
+   ret = amdgpu_sync_wait(, false);
amdgpu_sync_free();
 out_free:
kfree(pd_bo_list_entries);
@@ -2939,8 +2939,11 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, 
struct dma_fence **ef)
}
 
/* Wait for validate and PT updates to finish */
-   amdgpu_sync_wait(_obj, false);
-
+   ret = amdgpu_sync_wait(_obj, false);
+   if (ret) {
+   pr_err("Failed to wait for validate and PT updates to 
finish\n");
+   goto validate_map_fail;
+   }
/* Release old eviction fence and create new one, because fence only
 * goes from unsignaled to signaled, fence cannot be reused.
 * Use context and mm from the old fence.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 70fe3b39c004..a63139277583 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -1153,7 +1153,11 @@ int amdgpu_mes_ctx_map_meta_data(struct amdgpu_device 
*adev,
}
amdgpu_sync_fence(, vm->last_update);
 
-   amdgpu_sync_wait(, false);
+   r = amdgpu_sync_wait(, false);
+   if (r) {
+   DRM_ERROR("failed to wait sync\n");
+   goto error;
+   }
ttm_eu_backoff_reservation(, );
 
amdgpu_sync_free();
-- 
2.36.1



[PATCH 1/2] drm/amdgpu: Add timeout for sync wait

2023-10-20 Thread Emily Deng
Issue: Dead heappen during gpu recover, the call sequence as below:

amdgpu_device_gpu_recover->amdgpu_amdkfd_pre_reset->flush_delayed_work->
amdgpu_amdkfd_gpuvm_restore_process_bos->amdgpu_sync_wait

It is because the amdgpu_sync_wait is waiting for the bad job's fence, and
never return, so the recover couldn't continue.


Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index dcd8c066bc1f..6253d6aab7f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -406,8 +406,15 @@ int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr)
int i, r;
 
hash_for_each_safe(sync->fences, i, tmp, e, node) {
-   r = dma_fence_wait(e->fence, intr);
-   if (r)
+   struct drm_sched_fence *s_fence = to_drm_sched_fence(e->fence);
+   long timeout = msecs_to_jiffies(1);
+
+   if (s_fence)
+   timeout = s_fence->sched->timeout;
+
+   if (r == 0)
+   r = -ETIMEDOUT;
+   if (r < 0)
return r;
 
amdgpu_sync_entry_free(e);
-- 
2.36.1



[PATCH] drm/amdgpu: Add timeout for sync wait

2023-10-19 Thread Emily Deng
Issue: Dead heappen during gpu recover

[56433.829492] amdgpu :04:00.0: amdgpu: GPU reset begin!
[56550.499625] INFO: task kworker/u80:0:10 blocked for more than 120 seconds.
[56550.520215]   Tainted: G   OE  6.2.0-34-generic 
#34~22.04.1-Ubuntu
[56550.542883] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
message.
[56550.566313] task:kworker/u80:0   state:D stack:0 pid:10ppid:2  
flags:0x4000
[56550.591318] Workqueue: kfd_restore_wq restore_process_worker [amdgpu]
[56550.611391] Call Trace:
[56550.618698]  
[56550.624968]  __schedule+0x2b7/0x5f0
[56550.635416]  schedule+0x68/0x110
[56550.645090]  schedule_timeout+0x151/0x160
[56550.657096]  ? amdgpu_vm_bo_update+0x46e/0x660 [amdgpu]
[56550.673245]  dma_fence_default_wait+0x1a2/0x1e0
[56550.686818]  ? __pfx_dma_fence_default_wait_cb+0x10/0x10
[56550.702728]  dma_fence_wait_timeout+0x117/0x140
[56550.716301]  amdgpu_sync_wait+0x62/0xa0 [amdgpu]
[56550.730654]  amdgpu_amdkfd_gpuvm_restore_process_bos+0x59e/0x770 [amdgpu]
[56550.751668]  ? newidle_balance+0x298/0x490
[56550.763936]  restore_process_worker+0x42/0x270 [amdgpu]
[56550.780183]  process_one_work+0x21f/0x440
[56550.792193]  worker_thread+0x50/0x3f0
[56550.803165]  ? __pfx_worker_thread+0x10/0x10
[56550.815934]  kthread+0xee/0x120
[56550.825342]  ? __pfx_kthread+0x10/0x10
[56550.836548]  ret_from_fork+0x2c/0x50
[56550.847262]  
[ 1935.215502] Call Trace:
[ 1935.222827]  
[ 1935.229121]  __schedule+0x23d/0x5a0
[ 1935.239583]  schedule+0x4e/0xc0
[ 1935.248983]  schedule_timeout+0x103/0x140
[ 1935.261002]  __wait_for_common+0xae/0x150
[ 1935.273008]  ? usleep_range_state+0x90/0x90
[ 1935.285546]  wait_for_completion+0x24/0x30
[ 1935.297813]  __flush_work.isra.0+0x175/0x280
[ 1935.310611]  ? worker_detach_from_pool+0xc0/0xc0
[ 1935.324436]  flush_delayed_work+0x31/0x50
[ 1935.336455]  kfd_suspend_all_processes+0x96/0x150 [amdgpu]
[ 1935.353429]  kgd2kfd_suspend+0xb8/0xe0 [amdgpu]
[ 1935.367469]  kgd2kfd_pre_reset+0x81/0xf0 [amdgpu]
[ 1935.382036]  amdgpu_amdkfd_pre_reset+0x1a/0x30 [amdgpu]
[ 1935.398156]  amdgpu_device_gpu_recover.cold+0x210/0xcf2 [amdgpu]
[ 1935.416722]  amdgpu_job_timedout+0x19f/0x1e0 [amdgpu]
[ 1935.432367]  drm_sched_job_timedout+0x6f/0x120 [amd_sched]
[ 1935.448792]  process_one_work+0x22b/0x3d0
[ 1935.460806]  worker_thread+0x53/0x420
[ 1935.471777]  ? process_one_work+0x3d0/0x3d0
[ 1935.484307]  kthread+0x12a/0x150
[ 1935.493993]  ? set_kthread_struct+0x50/0x50
[ 1935.506513]  ret_from_fork+0x22/0x30

It is because the amdgpu_sync_wait is waiting for the bad job's fence, and
never return, so the recover couldn't continue.


Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index dcd8c066bc1f..c922867c5675 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -406,9 +406,19 @@ int amdgpu_sync_wait(struct amdgpu_sync *sync, bool intr)
int i, r;
 
hash_for_each_safe(sync->fences, i, tmp, e, node) {
-   r = dma_fence_wait(e->fence, intr);
-   if (r)
-   return r;
+   struct drm_sched_fence *s_fence = to_drm_sched_fence(e->fence);
+
+   if (s_fence) {
+   r = dma_fence_wait_timeout(e->fence, intr, 
s_fence->sched->timeout);
+   if (r == 0)
+   r = -ETIMEDOUT;
+   if (r < 0)
+   return r;
+   } else {
+   r = dma_fence_wait(e->fence, intr);
+   if (r)
+   return r;
+   }
 
amdgpu_sync_entry_free(e);
}
-- 
2.36.1



[PATCH] drm/amdgpu/irq: Move irq resume to the beginning

2023-08-06 Thread Emily Deng
Need to move irq resume to the beginning of reset sriov, or if
one interrupt occurs before irq resume, then the irq won't work anymore.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1338489b0b2f..8b304fdfe6db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4617,6 +4617,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device 
*adev,
r = amdgpu_virt_reset_gpu(adev);
if (r)
return r;
+   amdgpu_irq_gpu_reset_resume_helper(adev);
 
/* some sw clean up VF needs to do before recover */
amdgpu_virt_post_reset(adev);
@@ -4646,7 +4647,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device 
*adev,
amdgpu_put_xgmi_hive(hive);
 
if (!r) {
-   amdgpu_irq_gpu_reset_resume_helper(adev);
r = amdgpu_ib_ring_tests(adev);
 
amdgpu_amdkfd_post_reset(adev);
-- 
2.36.1



[PATCH] drm/amdgpu/vcn: Need to unpause dpg before stop dpg

2023-06-20 Thread Emily Deng
Need to unpause dpg first, or it will hit follow error during stop dpg:
"[drm] Register(1) [regUVD_POWER_STATUS] failed to reach value 0x0001 != 
0xn"

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index b48bb5212488..259795098173 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -1424,8 +1424,10 @@ static int vcn_v4_0_start_sriov(struct amdgpu_device 
*adev)
  */
 static void vcn_v4_0_stop_dpg_mode(struct amdgpu_device *adev, int inst_idx)
 {
+   struct dpg_pause_state state = {.fw_based = VCN_DPG_STATE__UNPAUSE};
uint32_t tmp;
 
+   vcn_v4_0_pause_dpg_mode(adev, inst_idx, );
/* Wait for power status to be 1 */
SOC15_WAIT_ON_RREG(VCN, inst_idx, regUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
-- 
2.36.1



[PATCH] drm/amdgpu/vcn: Need to pause dpg before stop dpg

2023-06-19 Thread Emily Deng
Need to pause dpg first, or it will hit follow error during stop dpg:
"[drm] Register(1) [regUVD_POWER_STATUS] failed to reach value 0x0001 != 
0xn"

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index b48bb5212488..259795098173 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -1424,8 +1424,10 @@ static int vcn_v4_0_start_sriov(struct amdgpu_device 
*adev)
  */
 static void vcn_v4_0_stop_dpg_mode(struct amdgpu_device *adev, int inst_idx)
 {
+   struct dpg_pause_state state = {.fw_based = VCN_DPG_STATE__UNPAUSE};
uint32_t tmp;
 
+   vcn_v4_0_pause_dpg_mode(adev, inst_idx, );
/* Wait for power status to be 1 */
SOC15_WAIT_ON_RREG(VCN, inst_idx, regUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
-- 
2.36.1



[PATCH] drm/amdgpu/mmsch: Correct the definition for mmsch init header

2023-06-06 Thread Emily Deng
For the header, it is version related, shouldn't use MAX_VCN_INSTANCES.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/mmsch_v3_0.h | 4 +++-
 drivers/gpu/drm/amd/amdgpu/mmsch_v4_0.h | 4 +++-
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c   | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mmsch_v3_0.h 
b/drivers/gpu/drm/amd/amdgpu/mmsch_v3_0.h
index 3e4e858a6965..a773ef61b78c 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmsch_v3_0.h
+++ b/drivers/gpu/drm/amd/amdgpu/mmsch_v3_0.h
@@ -30,6 +30,8 @@
 #define MMSCH_VERSION_MINOR0
 #define MMSCH_VERSION  (MMSCH_VERSION_MAJOR << 16 | MMSCH_VERSION_MINOR)
 
+#define MMSCH_V3_0_VCN_INSTANCES 0x2
+
 enum mmsch_v3_0_command_type {
MMSCH_COMMAND__DIRECT_REG_WRITE = 0,
MMSCH_COMMAND__DIRECT_REG_POLLING = 2,
@@ -47,7 +49,7 @@ struct mmsch_v3_0_table_info {
 struct mmsch_v3_0_init_header {
uint32_t version;
uint32_t total_size;
-   struct mmsch_v3_0_table_info inst[AMDGPU_MAX_VCN_INSTANCES];
+   struct mmsch_v3_0_table_info inst[MMSCH_V3_0_VCN_INSTANCES];
 };
 
 struct mmsch_v3_0_cmd_direct_reg_header {
diff --git a/drivers/gpu/drm/amd/amdgpu/mmsch_v4_0.h 
b/drivers/gpu/drm/amd/amdgpu/mmsch_v4_0.h
index 83653a50a1a2..796d4f8791e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmsch_v4_0.h
+++ b/drivers/gpu/drm/amd/amdgpu/mmsch_v4_0.h
@@ -43,6 +43,8 @@
 #define MMSCH_VF_MAILBOX_RESP__OK 0x1
 #define MMSCH_VF_MAILBOX_RESP__INCOMPLETE 0x2
 
+#define MMSCH_V4_0_VCN_INSTANCES 0x2
+
 enum mmsch_v4_0_command_type {
MMSCH_COMMAND__DIRECT_REG_WRITE = 0,
MMSCH_COMMAND__DIRECT_REG_POLLING = 2,
@@ -60,7 +62,7 @@ struct mmsch_v4_0_table_info {
 struct mmsch_v4_0_init_header {
uint32_t version;
uint32_t total_size;
-   struct mmsch_v4_0_table_info inst[AMDGPU_MAX_VCN_INSTANCES];
+   struct mmsch_v4_0_table_info inst[MMSCH_V4_0_VCN_INSTANCES];
struct mmsch_v4_0_table_info jpegdec;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index 70fefbf26c48..c8f63b3c6f69 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -1313,7 +1313,7 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device 
*adev)
 
header.version = MMSCH_VERSION;
header.total_size = sizeof(struct mmsch_v3_0_init_header) >> 2;
-   for (i = 0; i < AMDGPU_MAX_VCN_INSTANCES; i++) {
+   for (i = 0; i < MMSCH_V3_0_VCN_INSTANCES; i++) {
header.inst[i].init_status = 0;
header.inst[i].table_offset = 0;
header.inst[i].table_size = 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index 60c3fd20e8ce..8d371faaa2b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -1239,7 +1239,7 @@ static int vcn_v4_0_start_sriov(struct amdgpu_device 
*adev)
 
header.version = MMSCH_VERSION;
header.total_size = sizeof(struct mmsch_v4_0_init_header) >> 2;
-   for (i = 0; i < AMDGPU_MAX_VCN_INSTANCES; i++) {
+   for (i = 0; i < MMSCH_V4_0_VCN_INSTANCES; i++) {
header.inst[i].init_status = 0;
header.inst[i].table_offset = 0;
header.inst[i].table_size = 0;
-- 
2.36.1



[PATCH v2] drm/amd/amdgpu: Enable gfx pipe1 and fix related issues

2022-11-06 Thread Emily Deng
Starting from SIENNA CICHLID asic supports two gfx pipes, enabling
two graphics queues for performance concern.

v2: Don't change the entity number of AMDGPU_HW_IP_GFX

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 49d34c7bbf20..bbf18060611e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4606,7 +4606,7 @@ static int gfx_v10_0_sw_init(void *handle)
case IP_VERSION(10, 3, 3):
case IP_VERSION(10, 3, 7):
adev->gfx.me.num_me = 1;
-   adev->gfx.me.num_pipe_per_me = 1;
+   adev->gfx.me.num_pipe_per_me = 2;
adev->gfx.me.num_queue_per_pipe = 1;
adev->gfx.mec.num_mec = 2;
adev->gfx.mec.num_pipe_per_mec = 4;
@@ -6008,6 +6008,24 @@ static int gfx_v10_0_cp_gfx_load_microcode(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int gfx_v10_0_wait_for_idle(void *handle)
+{
+   unsigned i;
+   u32 tmp;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   for (i = 0; i < adev->usec_timeout; i++) {
+   /* read MC_STATUS */
+   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
+   GRBM_STATUS__GUI_ACTIVE_MASK;
+
+   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
+   return 0;
+   udelay(1);
+   }
+   return -ETIMEDOUT;
+}
+
 static int gfx_v10_0_cp_gfx_start(struct amdgpu_device *adev)
 {
struct amdgpu_ring *ring;
@@ -6069,7 +6087,7 @@ static int gfx_v10_0_cp_gfx_start(struct amdgpu_device 
*adev)
amdgpu_ring_write(ring, 0x8000);
 
amdgpu_ring_commit(ring);
-
+   gfx_v10_0_wait_for_idle(adev);
/* submit cs packet to copy state 0 to next available state */
if (adev->gfx.num_gfx_rings > 1) {
/* maximum supported gfx ring is 2 */
@@ -7404,24 +7422,6 @@ static bool gfx_v10_0_is_idle(void *handle)
return true;
 }
 
-static int gfx_v10_0_wait_for_idle(void *handle)
-{
-   unsigned i;
-   u32 tmp;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   for (i = 0; i < adev->usec_timeout; i++) {
-   /* read MC_STATUS */
-   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
-   GRBM_STATUS__GUI_ACTIVE_MASK;
-
-   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
-   return 0;
-   udelay(1);
-   }
-   return -ETIMEDOUT;
-}
-
 static int gfx_v10_0_soft_reset(void *handle)
 {
u32 grbm_soft_reset = 0;
@@ -8466,7 +8466,7 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
}
reg_mem_engine = 0;
} else {
-   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0;
+   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe;
reg_mem_engine = 1; /* pfp */
}
 
-- 
2.36.1



[PATCH] drm/amd/amdgpu: Enable gfx pipe1 and fix related issues

2022-11-04 Thread Emily Deng
Starting from SIENNA CICHLID asic supports two gfx pipes, enabling
two graphics queues for performance concern.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 42 -
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 331aa191910c..0072f36b44d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -33,7 +33,7 @@
container_of((e), struct amdgpu_ctx_entity, entity)
 
 const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
-   [AMDGPU_HW_IP_GFX]  =   1,
+   [AMDGPU_HW_IP_GFX]  =   2,
[AMDGPU_HW_IP_COMPUTE]  =   4,
[AMDGPU_HW_IP_DMA]  =   2,
[AMDGPU_HW_IP_UVD]  =   1,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 49d34c7bbf20..bbf18060611e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4606,7 +4606,7 @@ static int gfx_v10_0_sw_init(void *handle)
case IP_VERSION(10, 3, 3):
case IP_VERSION(10, 3, 7):
adev->gfx.me.num_me = 1;
-   adev->gfx.me.num_pipe_per_me = 1;
+   adev->gfx.me.num_pipe_per_me = 2;
adev->gfx.me.num_queue_per_pipe = 1;
adev->gfx.mec.num_mec = 2;
adev->gfx.mec.num_pipe_per_mec = 4;
@@ -6008,6 +6008,24 @@ static int gfx_v10_0_cp_gfx_load_microcode(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int gfx_v10_0_wait_for_idle(void *handle)
+{
+   unsigned i;
+   u32 tmp;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   for (i = 0; i < adev->usec_timeout; i++) {
+   /* read MC_STATUS */
+   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
+   GRBM_STATUS__GUI_ACTIVE_MASK;
+
+   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
+   return 0;
+   udelay(1);
+   }
+   return -ETIMEDOUT;
+}
+
 static int gfx_v10_0_cp_gfx_start(struct amdgpu_device *adev)
 {
struct amdgpu_ring *ring;
@@ -6069,7 +6087,7 @@ static int gfx_v10_0_cp_gfx_start(struct amdgpu_device 
*adev)
amdgpu_ring_write(ring, 0x8000);
 
amdgpu_ring_commit(ring);
-
+   gfx_v10_0_wait_for_idle(adev);
/* submit cs packet to copy state 0 to next available state */
if (adev->gfx.num_gfx_rings > 1) {
/* maximum supported gfx ring is 2 */
@@ -7404,24 +7422,6 @@ static bool gfx_v10_0_is_idle(void *handle)
return true;
 }
 
-static int gfx_v10_0_wait_for_idle(void *handle)
-{
-   unsigned i;
-   u32 tmp;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   for (i = 0; i < adev->usec_timeout; i++) {
-   /* read MC_STATUS */
-   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
-   GRBM_STATUS__GUI_ACTIVE_MASK;
-
-   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
-   return 0;
-   udelay(1);
-   }
-   return -ETIMEDOUT;
-}
-
 static int gfx_v10_0_soft_reset(void *handle)
 {
u32 grbm_soft_reset = 0;
@@ -8466,7 +8466,7 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
}
reg_mem_engine = 0;
} else {
-   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0;
+   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe;
reg_mem_engine = 1; /* pfp */
}
 
-- 
2.36.1



[PATCH] drm/amd/amdgpu: Enable gfx pipe1 and fix related issues

2022-11-03 Thread Emily Deng
Starting from SIENNA CICHLID asic supports two gfx pipes, enabling
two graphics queues for performance concern.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 43 +
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 331aa191910c..0072f36b44d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -33,7 +33,7 @@
container_of((e), struct amdgpu_ctx_entity, entity)
 
 const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
-   [AMDGPU_HW_IP_GFX]  =   1,
+   [AMDGPU_HW_IP_GFX]  =   2,
[AMDGPU_HW_IP_COMPUTE]  =   4,
[AMDGPU_HW_IP_DMA]  =   2,
[AMDGPU_HW_IP_UVD]  =   1,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index 49d34c7bbf20..9219cd29acd3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -4606,7 +4606,7 @@ static int gfx_v10_0_sw_init(void *handle)
case IP_VERSION(10, 3, 3):
case IP_VERSION(10, 3, 7):
adev->gfx.me.num_me = 1;
-   adev->gfx.me.num_pipe_per_me = 1;
+   adev->gfx.me.num_pipe_per_me = 2;
adev->gfx.me.num_queue_per_pipe = 1;
adev->gfx.mec.num_mec = 2;
adev->gfx.mec.num_pipe_per_mec = 4;
@@ -6008,6 +6008,25 @@ static int gfx_v10_0_cp_gfx_load_microcode(struct 
amdgpu_device *adev)
return 0;
 }
 
+static int gfx_v10_0_wait_for_idle(void *handle)
+{
+   unsigned i;
+   u32 tmp;
+   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+   for (i = 0; i < adev->usec_timeout; i++) {
+   /* read MC_STATUS */
+   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
+   GRBM_STATUS__GUI_ACTIVE_MASK;
+
+   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
+   return 0;
+   udelay(1);
+   }
+   printk("Emily:gfx_v10_0_wait_for_idle\n");
+   return -ETIMEDOUT;
+}
+
 static int gfx_v10_0_cp_gfx_start(struct amdgpu_device *adev)
 {
struct amdgpu_ring *ring;
@@ -6069,7 +6088,7 @@ static int gfx_v10_0_cp_gfx_start(struct amdgpu_device 
*adev)
amdgpu_ring_write(ring, 0x8000);
 
amdgpu_ring_commit(ring);
-
+   gfx_v10_0_wait_for_idle(adev);
/* submit cs packet to copy state 0 to next available state */
if (adev->gfx.num_gfx_rings > 1) {
/* maximum supported gfx ring is 2 */
@@ -7404,24 +7423,6 @@ static bool gfx_v10_0_is_idle(void *handle)
return true;
 }
 
-static int gfx_v10_0_wait_for_idle(void *handle)
-{
-   unsigned i;
-   u32 tmp;
-   struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-
-   for (i = 0; i < adev->usec_timeout; i++) {
-   /* read MC_STATUS */
-   tmp = RREG32_SOC15(GC, 0, mmGRBM_STATUS) &
-   GRBM_STATUS__GUI_ACTIVE_MASK;
-
-   if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
-   return 0;
-   udelay(1);
-   }
-   return -ETIMEDOUT;
-}
-
 static int gfx_v10_0_soft_reset(void *handle)
 {
u32 grbm_soft_reset = 0;
@@ -8466,7 +8467,7 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct 
amdgpu_ring *ring)
}
reg_mem_engine = 0;
} else {
-   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0;
+   ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe;
reg_mem_engine = 1; /* pfp */
}
 
-- 
2.36.1



[PATCH] drm/amdgpu/vcn: Correct the register setting for vcn1

2022-03-21 Thread Emily Deng
Correct the code error for setting register UVD_GFX10_ADDR_CONFIG.
Need to use inst_idx, or it only will set VCN0.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index c87263ed20ec..b16c56aa2d22 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -575,8 +575,8 @@ static void vcn_v3_0_mc_resume_dpg_mode(struct 
amdgpu_device *adev, int inst_idx
AMDGPU_GPU_PAGE_ALIGN(sizeof(struct amdgpu_fw_shared)), 
0, indirect);
 
/* VCN global tiling registers */
-   WREG32_SOC15_DPG_MODE(0, SOC15_DPG_MODE_OFFSET(
-   UVD, 0, mmUVD_GFX10_ADDR_CONFIG), 
adev->gfx.config.gb_addr_config, 0, indirect);
+   WREG32_SOC15_DPG_MODE(inst_idx, SOC15_DPG_MODE_OFFSET(
+   UVD, inst_idx, mmUVD_GFX10_ADDR_CONFIG), 
adev->gfx.config.gb_addr_config, 0, indirect);
 }
 
 static void vcn_v3_0_disable_static_power_gating(struct amdgpu_device *adev, 
int inst)
-- 
2.34.1



[PATCH] drm/amdgpu: Correct the irq numbers for virtual crtc

2021-07-06 Thread Emily Deng
The irq number should be decided by num_crtc, and the num_crtc could change
by parameter.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 33324427b555..7e0d8c092c7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -766,7 +766,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
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 irq numbers for virtual ctrc

2021-07-06 Thread Emily Deng
The irq number should be decided by num_crtc, and the num_crtc could change
by parameter.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 33324427b555..7e0d8c092c7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -766,7 +766,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
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 irq numbers for virtual ctrc

2021-07-01 Thread Emily Deng
Signed-off-by: Emily Deng 
Signed-off-by: Victor 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 33324427b555..7e0d8c092c7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -766,7 +766,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
2.25.1

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


[PATCH] SWDEV-235359 drm/amdgpu: Correct the irq numbers for virtual ctrc

2021-07-01 Thread Emily Deng
Change-Id: I02035f65b71ec52795c3e8ae979fb582c3cce592
Signed-off-by: Emily Deng 
Signed-off-by: Victor 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 33324427b555..7e0d8c092c7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -766,7 +766,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
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: Revert "SWDEV-238407 Add clear vf fw support"

2021-03-31 Thread Emily Deng
As already moved the support to host driver, so revert this
in guest driver.
This reverts commit 8d5e6f45df5f9073760dea0ab94321615cea16ec.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 36 ++---
 drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h |  8 --
 2 files changed, 2 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index c36c8fca1f64..aa2f8fc4aac8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -291,9 +291,8 @@ psp_cmd_submit_buf(struct psp_context *psp,
amdgpu_asic_invalidate_hdp(psp->adev, NULL);
}
 
-   /* We allow TEE_ERROR_NOT_SUPPORTED for VMR command and 
PSP_ERR_UNKNOWN_COMMAND in SRIOV */
-   skip_unsupport = (psp->cmd_buf_mem->resp.status == 
TEE_ERROR_NOT_SUPPORTED ||
-   psp->cmd_buf_mem->resp.status == PSP_ERR_UNKNOWN_COMMAND) && 
amdgpu_sriov_vf(psp->adev);
+   /* We allow TEE_ERROR_NOT_SUPPORTED for VMR command in SRIOV */
+   skip_unsupport = (psp->cmd_buf_mem->resp.status == 0x000a) && 
amdgpu_sriov_vf(psp->adev);
 
memcpy((void*)>resp, (void*)>cmd_buf_mem->resp, sizeof(struct 
psp_gfx_resp));
 
@@ -420,26 +419,6 @@ static int psp_tmr_init(struct psp_context *psp)
return ret;
 }
 
-static int psp_clear_vf_fw(struct psp_context *psp)
-{
-   int ret;
-   struct psp_gfx_cmd_resp *cmd;
-
-   if (!amdgpu_sriov_vf(psp->adev) || psp->adev->asic_type != CHIP_NAVI12)
-   return 0;
-
-   cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
-   if (!cmd)
-   return -ENOMEM;
-
-   cmd->cmd_id = GFX_CMD_ID_CLEAR_VF_FW;
-
-   ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
-   kfree(cmd);
-
-   return ret;
-}
-
 static bool psp_skip_tmr(struct psp_context *psp)
 {
switch (psp->adev->asic_type) {
@@ -1924,12 +1903,6 @@ static int psp_hw_start(struct psp_context *psp)
return ret;
}
 
-   ret = psp_clear_vf_fw(psp);
-   if (ret) {
-   DRM_ERROR("PSP clear vf fw!\n");
-   return ret;
-   }
-
ret = psp_boot_config_set(adev);
if (ret) {
DRM_WARN("PSP set boot config@\n");
@@ -2448,11 +2421,6 @@ static int psp_hw_fini(void *handle)
}
 
psp_asd_unload(psp);
-   ret = psp_clear_vf_fw(psp);
-   if (ret) {
-   DRM_ERROR("PSP clear vf fw!\n");
-   return ret;
-   }
 
psp_tmr_terminate(psp);
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h 
b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
index dd4d65f7e0f0..b5b1feaa259e 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
@@ -97,7 +97,6 @@ enum psp_gfx_cmd_id
 GFX_CMD_ID_SETUP_VMR  = 0x0009,   /* setup VMR region */
 GFX_CMD_ID_DESTROY_VMR= 0x000A,   /* destroy VMR region */
 GFX_CMD_ID_PROG_REG   = 0x000B,   /* program regs */
-GFX_CMD_ID_CLEAR_VF_FW= 0x000D,   /* Clear VF FW, to be used 
on VF shutdown. */
 GFX_CMD_ID_GET_FW_ATTESTATION = 0x000F,   /* Query GPUVA of the Fw 
Attestation DB */
 /* IDs upto 0x1F are reserved for older programs (Raven, Vega 10/12/20) */
 GFX_CMD_ID_LOAD_TOC   = 0x0020,   /* Load TOC and obtain TMR 
size */
@@ -401,11 +400,4 @@ struct psp_gfx_rb_frame
 /* total 64 bytes */
 };
 
-#define PSP_ERR_UNKNOWN_COMMAND 0x0100
-
-enum tee_error_code {
-TEE_SUCCESS = 0x,
-TEE_ERROR_NOT_SUPPORTED = 0x000A,
-};
-
 #endif /* _PSP_TEE_GFX_IF_H_ */
-- 
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: Revert "SWDEV-238407 drm/amdgpu/sriov: Need to clear kiq position"

2021-03-31 Thread Emily Deng
As already moved the implementation to host driver, so remove this from
guest driver.
This reverts commit 96f7d59858ada4a6372fcb249b04805d14482c49.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 --
 1 file changed, 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 b4fd0394cd08..7e012fa1a3f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -7237,7 +7237,6 @@ static int gfx_v10_0_hw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
-   uint32_t tmp;
 
amdgpu_irq_put(adev, >gfx.priv_reg_irq, 0);
amdgpu_irq_put(adev, >gfx.priv_inst_irq, 0);
@@ -7256,11 +7255,6 @@ static int gfx_v10_0_hw_fini(void *handle)
 
if (amdgpu_sriov_vf(adev)) {
gfx_v10_0_cp_gfx_enable(adev, false);
-   /* Program KIQ position of RLC_CP_SCHEDULERS during destroy */
-   tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);
-   tmp &= 0xff00;
-   WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
-
return 0;
}
gfx_v10_0_cp_enable(adev, false);
-- 
2.25.1

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


[PATCH] drm/amdgpu: Toggle msix after FLR for sriov

2021-03-30 Thread Emily Deng
From: "Emily.Deng" 

For vf assigned to guest VM, after FLR, the msix table will be reset.
As the flr is done on host driver. The qemu and vfio driver don't know
this, and the msix is still enable from qemu and vfio driver side.
So if want to  re-setup the msix table, first need to disable and
re-enable the msix from guest VM side or the qemu will do nothing as
it thought the msix is already enabled.

v2:
Change name with amdgpu_irq prefix, remove #ifdef.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 03412543427a..3045f52e613d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -277,6 +277,17 @@ static bool amdgpu_msi_ok(struct amdgpu_device *adev)
return true;
 }
 
+static void amdgpu_irq_restore_msix(struct amdgpu_device *adev)
+{
+   u16 ctrl;
+
+   pci_read_config_word(adev->pdev, adev->pdev->msix_cap + PCI_MSIX_FLAGS, 
);
+   ctrl &= ~PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+   ctrl |= PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+}
+
 /**
  * amdgpu_irq_init - initialize interrupt handling
  *
@@ -558,6 +569,9 @@ void amdgpu_irq_gpu_reset_resume_helper(struct 
amdgpu_device *adev)
 {
int i, j, k;
 
+   if (amdgpu_sriov_vf(adev))
+   amdgpu_irq_restore_msix(adev);
+
for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
if (!adev->irq.client[i].sources)
continue;
-- 
2.25.1

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


[PATCH] drm/amdgpu: Toggle msix after FLR for sriov

2021-03-30 Thread Emily Deng
From: "Emily.Deng" 

After FLR, the msix will be cleared, so need to toggle it for sriov.

v2:
Change name with amdgpu_irq prefix, remove #ifdef.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 03412543427a..3045f52e613d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -277,6 +277,17 @@ static bool amdgpu_msi_ok(struct amdgpu_device *adev)
return true;
 }
 
+static void amdgpu_irq_restore_msix(struct amdgpu_device *adev)
+{
+   u16 ctrl;
+
+   pci_read_config_word(adev->pdev, adev->pdev->msix_cap + PCI_MSIX_FLAGS, 
);
+   ctrl &= ~PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+   ctrl |= PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+}
+
 /**
  * amdgpu_irq_init - initialize interrupt handling
  *
@@ -558,6 +569,9 @@ void amdgpu_irq_gpu_reset_resume_helper(struct 
amdgpu_device *adev)
 {
int i, j, k;
 
+   if (amdgpu_sriov_vf(adev))
+   amdgpu_irq_restore_msix(adev);
+
for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
if (!adev->irq.client[i].sources)
continue;
-- 
2.25.1

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


[PATCH 6/6] drm/amdgpu: Fix driver unload issue

2021-03-29 Thread Emily Deng
During driver unloading, don't need to copy mem, or it will introduce
some call trace, such as when sa_manager is freed, it will introduce warn
call trace in amdgpu_sa_bo_new.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index e00263bcc88b..f0546a489e0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -317,6 +317,9 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
struct dma_fence *fence = NULL;
int r = 0;
 
+   if (adev->shutdown)
+   return 0;
+
if (!adev->mman.buffer_funcs_enabled) {
DRM_ERROR("Trying to move memory with ring turned off.\n");
return -EINVAL;
-- 
2.25.1

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


[PATCH 5/6] drm/amdgpu: Disable RPTR write back for navi12

2021-03-29 Thread Emily Deng
It will hit ramdomly sdma hang, and pending on utcl2
address translation when access the RPTR polling address.

According sdma firmware team mentioned, the RPTR writeback is done by
hardware automatically, and will hit issue when clock gating occurs. So
stop using the rptr write back for sdma5.0.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 920fc6d4a127..63e4a78181b8 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -298,13 +298,19 @@ static void sdma_v5_0_ring_patch_cond_exec(struct 
amdgpu_ring *ring,
  */
 static uint64_t sdma_v5_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
-   u64 *rptr;
+   struct amdgpu_device *adev = ring->adev;
+   u64 rptr;
+   u32 lowbit, highbit;
+
+   lowbit = RREG32(sdma_v5_0_get_reg_offset(adev, ring->me, 
mmSDMA0_GFX_RB_RPTR));
+   highbit = RREG32(sdma_v5_0_get_reg_offset(adev, ring->me, 
mmSDMA0_GFX_RB_RPTR_HI));
 
-   /* XXX check if swapping is necessary on BE */
-   rptr = ((u64 *)>adev->wb.wb[ring->rptr_offs]);
+   rptr = highbit;
+   rptr = rptr << 32;
+   rptr |= lowbit;
 
-   DRM_DEBUG("rptr before shift == 0x%016llx\n", *rptr);
-   return ((*rptr) >> 2);
+   DRM_DEBUG("rptr before shift == 0x%016llx\n", rptr);
+   return (rptr >> 2);
 }
 
 /**
@@ -702,7 +708,7 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
WREG32(sdma_v5_0_get_reg_offset(adev, i, 
mmSDMA0_GFX_RB_RPTR_ADDR_LO),
   lower_32_bits(adev->wb.gpu_addr + wb_offset) & 
0xFFFC);
 
-   rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, 
RPTR_WRITEBACK_ENABLE, 1);
+   rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, 
RPTR_WRITEBACK_ENABLE, 0);
 
WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_BASE), 
ring->gpu_addr >> 8);
WREG32(sdma_v5_0_get_reg_offset(adev, i, 
mmSDMA0_GFX_RB_BASE_HI), ring->gpu_addr >> 40);
-- 
2.25.1

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


[PATCH 4/6] drm/amdgpu: Disable fetch discovery data from vram for navi12 sriov

2021-03-29 Thread Emily Deng
To fix the board disappear issue.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 46d4bbabce75..48dc171bc759 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -693,6 +693,10 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
adev->nbio.funcs = _v2_3_funcs;
adev->nbio.hdp_flush_reg = _v2_3_hdp_flush_reg;
}
+
+   if (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_NAVI12)
+   amdgpu_discovery = 0;
+
adev->hdp.funcs = _v5_0_funcs;
 
if (adev->asic_type >= CHIP_SIENNA_CICHLID)
-- 
2.25.1

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


[PATCH 3/6] drm/amdgpu: Restore msix after FLR

2021-03-29 Thread Emily Deng
From: "Emily.Deng" 

After FLR, the msix will be cleared, so need to re-enable it.

v2:
Change name with amdgpu_irq prefix, remove #ifdef.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 03412543427a..8936589bd7f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -277,6 +277,17 @@ static bool amdgpu_msi_ok(struct amdgpu_device *adev)
return true;
 }
 
+void amdgpu_irq_restore_msix(struct amdgpu_device *adev)
+{
+   u16 ctrl;
+
+   pci_read_config_word(adev->pdev, adev->pdev->msix_cap + PCI_MSIX_FLAGS, 
);
+   ctrl &= ~PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+   ctrl |= PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+}
+
 /**
  * amdgpu_irq_init - initialize interrupt handling
  *
@@ -558,6 +569,7 @@ void amdgpu_irq_gpu_reset_resume_helper(struct 
amdgpu_device *adev)
 {
int i, j, k;
 
+   amdgpu_irq_restore_msix(adev);
for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
if (!adev->irq.client[i].sources)
continue;
-- 
2.25.1

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


[PATCH 1/6] drm/amdgpu: Disable vcn decode ring for sriov navi12

2021-03-29 Thread Emily Deng
Since vcn decoding ring is not required, so just disable it.

Signed-off-by: Frank.Min 
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c |  4 +++-
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c   | 29 -
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8844f650b17f..5d5c41c9d5aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -427,7 +427,9 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
if (adev->uvd.harvest_config & (1 << i))
continue;
 
-   if (adev->vcn.inst[i].ring_dec.sched.ready)
+   if (adev->vcn.inst[i].ring_dec.sched.ready ||
+   (adev->asic_type == CHIP_NAVI12 &&
+   amdgpu_sriov_vf(adev)))
++num_rings;
}
ib_start_alignment = 16;
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index 116b9643d5ba..e4b61f3a45fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
@@ -220,21 +220,20 @@ static int vcn_v2_0_hw_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_ring *ring = >vcn.inst->ring_dec;
-   int i, r;
+   int i, r = -1;
 
adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
 ring->doorbell_index, 0);
 
-   if (amdgpu_sriov_vf(adev))
+   if (amdgpu_sriov_vf(adev)) {
vcn_v2_0_start_sriov(adev);
-
-   r = amdgpu_ring_test_helper(ring);
-   if (r)
-   goto done;
-
-   //Disable vcn decode for sriov
-   if (amdgpu_sriov_vf(adev))
-   ring->sched.ready = false;
+   if (adev->asic_type == CHIP_NAVI12)
+   ring->sched.ready = false;
+   } else {
+   r = amdgpu_ring_test_helper(ring);
+   if (r)
+   goto done;
+   }
 
for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
ring = >vcn.inst->ring_enc[i];
@@ -245,8 +244,11 @@ static int vcn_v2_0_hw_init(void *handle)
 
 done:
if (!r)
-   DRM_INFO("VCN decode and encode initialized successfully(under 
%s).\n",
-   (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)?"DPG 
Mode":"SPG Mode");
+   DRM_INFO("VCN %s encode initialized successfully(under %s).\n",
+   (adev->asic_type == CHIP_NAVI12 &&
+   amdgpu_sriov_vf(adev))?"":"decode and",
+   (adev->pg_flags &
+   AMD_PG_SUPPORT_VCN_DPG)?"DPG Mode":"SPG Mode");
 
return r;
 }
@@ -1719,9 +1721,6 @@ int vcn_v2_0_dec_ring_test_ring(struct amdgpu_ring *ring)
unsigned i;
int r;
 
-   if (amdgpu_sriov_vf(adev))
-   return 0;
-
WREG32(adev->vcn.inst[ring->me].external.scratch9, 0xCAFEDEAD);
r = amdgpu_ring_alloc(ring, 4);
if (r)
-- 
2.25.1

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


[PATCH 2/6] drm/amdgpu: Correct the irq numbers for virtual ctrc

2021-03-29 Thread Emily Deng
Set the num_types equal to the enabled num_crtc.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 5c11144da051..c03a83a2b7cd 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -768,7 +768,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
2.25.1

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


[PATCH v2] drm/amdgpu: Restore msix after FLR

2021-03-29 Thread Emily Deng
From: "Emily.Deng" 

After FLR, the msix will be cleared, so need to re-enable it.

v2:
Change name with amdgpu_irq prefix, remove #ifdef.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 03412543427a..8936589bd7f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -277,6 +277,17 @@ static bool amdgpu_msi_ok(struct amdgpu_device *adev)
return true;
 }
 
+void amdgpu_irq_restore_msix(struct amdgpu_device *adev)
+{
+   u16 ctrl;
+
+   pci_read_config_word(adev->pdev, adev->pdev->msix_cap + PCI_MSIX_FLAGS, 
);
+   ctrl &= ~PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+   ctrl |= PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+}
+
 /**
  * amdgpu_irq_init - initialize interrupt handling
  *
@@ -558,6 +569,7 @@ void amdgpu_irq_gpu_reset_resume_helper(struct 
amdgpu_device *adev)
 {
int i, j, k;
 
+   amdgpu_irq_restore_msix(adev);
for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
if (!adev->irq.client[i].sources)
continue;
-- 
2.25.1

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


[PATCH 6/6] drm/amdgpu: Fix driver unload issue

2021-03-29 Thread Emily Deng
During driver unloading, don't need to copy mem, or it will introduce
some call trace, such as when sa_manager is freed, it will introduce warn
call trace in amdgpu_sa_bo_new.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index e00263bcc88b..f0546a489e0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -317,6 +317,9 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
struct dma_fence *fence = NULL;
int r = 0;
 
+   if (adev->shutdown)
+   return 0;
+
if (!adev->mman.buffer_funcs_enabled) {
DRM_ERROR("Trying to move memory with ring turned off.\n");
return -EINVAL;
-- 
2.25.1

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


[PATCH 5/6] drm/amdgpu: Disable RPTR write back for navi12

2021-03-29 Thread Emily Deng
It will hit ramdomly sdma hang, and pending on utcl2
address translation when access the RPTR polling address.

According sdma firmware team mentioned, the RPTR writeback is done by
hardware automatically, and will hit issue when clock gating occurs. So
stop using the rptr write back for sdma5.0.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 920fc6d4a127..6d268c70857c 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -298,13 +298,19 @@ static void sdma_v5_0_ring_patch_cond_exec(struct 
amdgpu_ring *ring,
  */
 static uint64_t sdma_v5_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
-   u64 *rptr;
+   struct amdgpu_device *adev = ring->adev;
+   u64 rptr;
+   u32 lowbit, highbit;
+
+   lowbit = RREG32_RLC(sdma_v5_0_get_reg_offset(adev, ring->me, 
mmSDMA0_GFX_RB_RPTR));
+   highbit = RREG32_RLC(sdma_v5_0_get_reg_offset(adev, ring->me, 
mmSDMA0_GFX_RB_RPTR_HI));
 
-   /* XXX check if swapping is necessary on BE */
-   rptr = ((u64 *)>adev->wb.wb[ring->rptr_offs]);
+   rptr = highbit;
+   rptr = rptr << 32;
+   rptr |= lowbit;
 
-   DRM_DEBUG("rptr before shift == 0x%016llx\n", *rptr);
-   return ((*rptr) >> 2);
+   DRM_DEBUG("rptr before shift == 0x%016llx\n", rptr);
+   return (rptr >> 2);
 }
 
 /**
@@ -702,7 +708,7 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
WREG32(sdma_v5_0_get_reg_offset(adev, i, 
mmSDMA0_GFX_RB_RPTR_ADDR_LO),
   lower_32_bits(adev->wb.gpu_addr + wb_offset) & 
0xFFFC);
 
-   rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, 
RPTR_WRITEBACK_ENABLE, 1);
+   rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, 
RPTR_WRITEBACK_ENABLE, 0);
 
WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_BASE), 
ring->gpu_addr >> 8);
WREG32(sdma_v5_0_get_reg_offset(adev, i, 
mmSDMA0_GFX_RB_BASE_HI), ring->gpu_addr >> 40);
-- 
2.25.1

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


[PATCH 4/6] drm/amdgpu: Disable fetch discovery data from vram for navi12 sriov

2021-03-29 Thread Emily Deng
To fix the board disappear issue.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/nv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c
index 46d4bbabce75..b9832d31f00d 100644
--- a/drivers/gpu/drm/amd/amdgpu/nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/nv.c
@@ -692,7 +692,10 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
} else {
adev->nbio.funcs = _v2_3_funcs;
adev->nbio.hdp_flush_reg = _v2_3_hdp_flush_reg;
-   }
+
+   if (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_NAVI12)
+   amdgpu_discovery = 0;
+
adev->hdp.funcs = _v5_0_funcs;
 
if (adev->asic_type >= CHIP_SIENNA_CICHLID)
-- 
2.25.1

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


[PATCH 2/6] drm/amdgpu: Correct the irq numbers for virtual ctrc

2021-03-29 Thread Emily Deng
Set the num_types equal to the enabled num_crtc.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 5c11144da051..c03a83a2b7cd 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -768,7 +768,7 @@ static const struct amdgpu_irq_src_funcs 
dce_virtual_crtc_irq_funcs = {
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1;
+   adev->crtc_irq.num_types = adev->mode_info.num_crtc;
adev->crtc_irq.funcs = _virtual_crtc_irq_funcs;
 }
 
-- 
2.25.1

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


[PATCH 3/6] drm/amdgpu: Restore msix after FLR

2021-03-29 Thread Emily Deng
From: "Emily.Deng" 

After FLR, the msix will be cleared, so need to re-enable it.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 03412543427a..f24263120f3a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -277,6 +277,18 @@ static bool amdgpu_msi_ok(struct amdgpu_device *adev)
return true;
 }
 
+void amdgpu_restore_msix(struct amdgpu_device *adev)
+{
+#ifdef PCI_IRQ_MSIX
+   u16 ctrl;
+
+   pci_read_config_word(adev->pdev, adev->pdev->msix_cap + PCI_MSIX_FLAGS, 
);
+   ctrl &= ~PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+   ctrl |= PCI_MSIX_FLAGS_ENABLE;
+   pci_write_config_word(adev->pdev, adev->pdev->msix_cap + 
PCI_MSIX_FLAGS, ctrl);
+#endif
+}
 /**
  * amdgpu_irq_init - initialize interrupt handling
  *
@@ -558,6 +570,7 @@ void amdgpu_irq_gpu_reset_resume_helper(struct 
amdgpu_device *adev)
 {
int i, j, k;
 
+   amdgpu_restore_msix(adev);
for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
if (!adev->irq.client[i].sources)
continue;
-- 
2.25.1

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


[PATCH 1/6] drm/amdgpu: Disable vcn decode ring for sriov navi12

2021-03-29 Thread Emily Deng
Since vcn decoding ring is not required, so just disable it.

Signed-off-by: Frank.Min 
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c |  4 +++-
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c   | 29 -
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 8844f650b17f..5d5c41c9d5aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -427,7 +427,9 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
if (adev->uvd.harvest_config & (1 << i))
continue;
 
-   if (adev->vcn.inst[i].ring_dec.sched.ready)
+   if (adev->vcn.inst[i].ring_dec.sched.ready ||
+   (adev->asic_type == CHIP_NAVI12 &&
+   amdgpu_sriov_vf(adev)))
++num_rings;
}
ib_start_alignment = 16;
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index 116b9643d5ba..e4b61f3a45fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
@@ -220,21 +220,20 @@ static int vcn_v2_0_hw_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_ring *ring = >vcn.inst->ring_dec;
-   int i, r;
+   int i, r = -1;
 
adev->nbio.funcs->vcn_doorbell_range(adev, ring->use_doorbell,
 ring->doorbell_index, 0);
 
-   if (amdgpu_sriov_vf(adev))
+   if (amdgpu_sriov_vf(adev)) {
vcn_v2_0_start_sriov(adev);
-
-   r = amdgpu_ring_test_helper(ring);
-   if (r)
-   goto done;
-
-   //Disable vcn decode for sriov
-   if (amdgpu_sriov_vf(adev))
-   ring->sched.ready = false;
+   if (adev->asic_type == CHIP_NAVI12)
+   ring->sched.ready = false;
+   } else {
+   r = amdgpu_ring_test_helper(ring);
+   if (r)
+   goto done;
+   }
 
for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
ring = >vcn.inst->ring_enc[i];
@@ -245,8 +244,11 @@ static int vcn_v2_0_hw_init(void *handle)
 
 done:
if (!r)
-   DRM_INFO("VCN decode and encode initialized successfully(under 
%s).\n",
-   (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG)?"DPG 
Mode":"SPG Mode");
+   DRM_INFO("VCN %s encode initialized successfully(under %s).\n",
+   (adev->asic_type == CHIP_NAVI12 &&
+   amdgpu_sriov_vf(adev))?"":"decode and",
+   (adev->pg_flags &
+   AMD_PG_SUPPORT_VCN_DPG)?"DPG Mode":"SPG Mode");
 
return r;
 }
@@ -1719,9 +1721,6 @@ int vcn_v2_0_dec_ring_test_ring(struct amdgpu_ring *ring)
unsigned i;
int r;
 
-   if (amdgpu_sriov_vf(adev))
-   return 0;
-
WREG32(adev->vcn.inst[ring->me].external.scratch9, 0xCAFEDEAD);
r = amdgpu_ring_alloc(ring, 4);
if (r)
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix the page fault issue in amdgpu_irq_fini

2021-03-18 Thread Emily Deng
For some source, it will be shared by some client ID and source ID.
To fix the page fault issue, set all those to null.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index af026109421a..623b1ac6231d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -359,7 +359,7 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
  */
 void amdgpu_irq_fini(struct amdgpu_device *adev)
 {
-   unsigned i, j;
+   unsigned i, j, m, n;
 
if (adev->irq.installed) {
drm_irq_uninstall(adev_to_drm(adev));
@@ -380,12 +380,22 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)
if (!src)
continue;
 
-   kfree(src->enabled_types);
+   if (src->enabled_types)
+   kfree(src->enabled_types);
+
src->enabled_types = NULL;
+
if (src->data) {
kfree(src->data);
kfree(src);
-   adev->irq.client[i].sources[j] = NULL;
+   }
+
+   for (m = 0; m < AMDGPU_IRQ_CLIENTID_MAX; ++m) {
+   if (!adev->irq.client[m].sources)
+   continue;
+   for (n = 0; n < AMDGPU_MAX_IRQ_SRC_ID; ++n)
+   if (adev->irq.client[m].sources[n] == 
src)
+   adev->irq.client[m].sources[n] 
= NULL;
}
}
kfree(adev->irq.client[i].sources);
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix some unload driver issues

2021-03-05 Thread Emily Deng
If have memory leak, maybe it will have issue in
ttm_bo_force_list_clean-> ttm_mem_evict_first.

Set adev->gart.ptr to null to avoid to call
amdgpu_gmc_set_pte_pde to cause ptr issue pointer when
calling amdgpu_gart_unbind in amdgpu_bo_fini which is after gart_fini.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index 23823a57374f..f1ede4b43d07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -202,6 +202,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
return;
}
amdgpu_bo_unref(>gart.bo);
+   adev->gart.ptr = NULL;
 }
 
 /*
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix some unload driver issues

2021-03-04 Thread Emily Deng
When unloading driver after killing some applications, it will hit sdma
flush tlb job timeout which is called by ttm_bo_delay_delete. So
to avoid the job submit after fence driver fini, call 
ttm_bo_lock_delayed_workqueue
before fence driver fini. And also put drm_sched_fini before waiting fence.

Set adev->gart.ptr to null to fix null pointer when calling amdgpu_gart_unbind
in amdgpu_bo_fini which is after gart_fini.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c   | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a11760ec3924..de0597d34588 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3594,6 +3594,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 {
dev_info(adev->dev, "amdgpu: finishing device.\n");
flush_delayed_work(>delayed_init_work);
+   ttm_bo_lock_delayed_workqueue(>mman.bdev);
adev->shutdown = true;
 
kfree(adev->pci_state);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 143a14f4866f..6d16f58ac91e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -531,6 +531,8 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
 
if (!ring || !ring->fence_drv.initialized)
continue;
+   if (!ring->no_scheduler)
+   drm_sched_fini(>sched);
r = amdgpu_fence_wait_empty(ring);
if (r) {
/* no need to trigger GPU reset as we are unloading */
@@ -539,8 +541,7 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
if (ring->fence_drv.irq_src)
amdgpu_irq_put(adev, ring->fence_drv.irq_src,
   ring->fence_drv.irq_type);
-   if (!ring->no_scheduler)
-   drm_sched_fini(>sched);
+
del_timer_sync(>fence_drv.fallback_timer);
for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
dma_fence_put(ring->fence_drv.fences[j]);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index 23823a57374f..f1ede4b43d07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -202,6 +202,7 @@ void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
return;
}
amdgpu_bo_unref(>gart.bo);
+   adev->gart.ptr = NULL;
 }
 
 /*
-- 
2.25.1

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


[PATCH v2] drm/amdgpu:Limit the resolution for virtual_display

2021-01-06 Thread Emily Deng
From: "Emily.Deng" 

Limit the resolution not bigger than 16384, which means
dev->mode_info.num_crtc * common_modes[i].w not bigger than 16384.

v2:
  Refine the code

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 2b16c8faca34..fd2b3a6dfd60 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -319,6 +319,7 @@ dce_virtual_encoder(struct drm_connector *connector)
 static int dce_virtual_get_modes(struct drm_connector *connector)
 {
struct drm_device *dev = connector->dev;
+   struct amdgpu_device *adev = dev->dev_private;
struct drm_display_mode *mode = NULL;
unsigned i;
static const struct mode_size {
@@ -350,8 +351,10 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
};
 
for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
-   mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
-   drm_mode_probed_add(connector, mode);
+   if (adev->mode_info.num_crtc * common_modes[i].w <= 16384) {
+   mode = drm_cvt_mode(dev, common_modes[i].w, 
common_modes[i].h, 60, false, false, false);
+   drm_mode_probed_add(connector, mode);
+   }
}
 
return 0;
-- 
2.25.1

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


[PATCH v2] drm/amdgpu: Decrease compute timeout to 10 s for sriov multiple VF

2021-01-06 Thread Emily Deng
From: "Emily.Deng" 

For multiple VF, after engine hang,as host driver will first
encounter FLR, so has no meanning to set compute to 60s.

v2:
   Refine the patch and comment

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5527c549db82..35edf58c825d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3133,7 +3133,10 @@ static int amdgpu_device_get_job_timeout_settings(struct 
amdgpu_device *adev)
 */
adev->gfx_timeout = msecs_to_jiffies(1);
adev->sdma_timeout = adev->video_timeout = adev->gfx_timeout;
-   if (amdgpu_sriov_vf(adev) || amdgpu_passthrough(adev))
+   if (amdgpu_sriov_vf(adev))
+   adev->compute_timeout = amdgpu_sriov_is_pp_one_vf(adev) ?
+   msecs_to_jiffies(6) : 
msecs_to_jiffies(1);
+   else if (amdgpu_passthrough(adev))
adev->compute_timeout =  msecs_to_jiffies(6);
else
adev->compute_timeout = MAX_SCHEDULE_TIMEOUT;
-- 
2.25.1

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


[PATCH] drm/amdgpu: Decrease compute timeout to 10 s for sriov multiple VF

2021-01-06 Thread Emily Deng
From: "Emily.Deng" 

For multiple VF, after engine hang,as host driver will first
encounter FLR, so has no meanning to set compute to 60s.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5527c549db82..ce07b9b975ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3133,7 +3133,10 @@ static int amdgpu_device_get_job_timeout_settings(struct 
amdgpu_device *adev)
 */
adev->gfx_timeout = msecs_to_jiffies(1);
adev->sdma_timeout = adev->video_timeout = adev->gfx_timeout;
-   if (amdgpu_sriov_vf(adev) || amdgpu_passthrough(adev))
+   if (amdgpu_sriov_vf(adev))
+   adev->compute_timeout = amdgpu_sriov_is_pp_one_vf(adev) ?
+   msecs_to_jiffies(6) : 
msecs_to_jiffies(1)
+   else if (amdgpu_passthrough(adev))
adev->compute_timeout =  msecs_to_jiffies(6);
else
adev->compute_timeout = MAX_SCHEDULE_TIMEOUT;
-- 
2.25.1

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


[PATCH] drm/amdgpu: For sriov multiple VF, set compute timeout to 10s

2021-01-06 Thread Emily . Deng
For multiple VF, after engine hang,as host driver will first
encounter FLR, so has no meanning to set compute to 60s.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b69c34074d8d..ed36bf97df29 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3117,8 +3117,10 @@ static int amdgpu_device_get_job_timeout_settings(struct 
amdgpu_device *adev)
 */
adev->gfx_timeout = msecs_to_jiffies(1);
adev->sdma_timeout = adev->video_timeout = adev->gfx_timeout;
-   if (amdgpu_sriov_vf(adev) || amdgpu_passthrough(adev))
+   if ((amdgpu_sriov_vf(adev) && amdgpu_sriov_is_pp_one_vf(adev)) || 
amdgpu_passthrough(adev))
adev->compute_timeout =  msecs_to_jiffies(6);
+   else if (amdgpu_sriov_vf(adev))
+   adev->compute_timeout =  msecs_to_jiffies(1);
else
adev->compute_timeout = MAX_SCHEDULE_TIMEOUT;
 
-- 
2.25.1

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


[PATCH 3/3] drm/amdgpu:Limit the resolution for virtual_display

2021-01-05 Thread Emily . Deng
Limit the resolution not bigger than 16384, which means
dev->mode_info.num_crtc * common_modes[i].w not bigger than 16384.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 9810af712cc0..6fc864cfef61 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -289,6 +289,7 @@ dce_virtual_encoder(struct drm_connector *connector)
 static int dce_virtual_get_modes(struct drm_connector *connector)
 {
struct drm_device *dev = connector->dev;
+   struct amdgpu_device *adev = dev->dev_private;
struct drm_display_mode *mode = NULL;
unsigned i;
static const struct mode_size {
@@ -320,8 +321,10 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
};
 
for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
-   mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
-   drm_mode_probed_add(connector, mode);
+   if (adev->mode_info.num_crtc <= 4 ||  common_modes[i].w <= 
2560) {
+   mode = drm_cvt_mode(dev, common_modes[i].w, 
common_modes[i].h, 60, false, false, false);
+   drm_mode_probed_add(connector, mode);
+   }
}
 
return 0;
-- 
2.25.1

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


[PATCH 3/3] drm/amdgpu:Limit the resolution for virtual_display

2021-01-05 Thread Emily . Deng
Limit the resolution not bigger than 16384, which means
dev->mode_info.num_crtc * common_modes[i].w not bigger than 16384.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 9810af712cc0..6fc864cfef61 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -289,6 +289,7 @@ dce_virtual_encoder(struct drm_connector *connector)
 static int dce_virtual_get_modes(struct drm_connector *connector)
 {
struct drm_device *dev = connector->dev;
+   struct amdgpu_device *adev = dev->dev_private;
struct drm_display_mode *mode = NULL;
unsigned i;
static const struct mode_size {
@@ -320,8 +321,10 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
};
 
for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
-   mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
-   drm_mode_probed_add(connector, mode);
+   if (adev->mode_info.num_crtc <= 4 ||  common_modes[i].w <= 
2560) {
+   mode = drm_cvt_mode(dev, common_modes[i].w, 
common_modes[i].h, 60, false, false, false);
+   drm_mode_probed_add(connector, mode);
+   }
}
 
return 0;
-- 
2.25.1

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


[PATCH 2/3] drm/amdgpu: Correct the read sclk for navi10

2021-01-05 Thread Emily . Deng
According to hw, after navi10,it runs in dfll mode, and should
read sclk from AverageGfxclkFrequency.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index 51e83123f72a..7ebf9588983f 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -1673,7 +1673,7 @@ static int navi10_read_sensor(struct smu_context *smu,
*size = 4;
break;
case AMDGPU_PP_SENSOR_GFX_SCLK:
-   ret = navi10_get_current_clk_freq_by_table(smu, SMU_GFXCLK, 
(uint32_t *)data);
+   ret = navi10_get_smu_metrics_data(smu, METRICS_AVERAGE_GFXCLK, 
(uint32_t *)data);
*(uint32_t *)data *= 100;
*size = 4;
break;
-- 
2.25.1

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


[PATCH 1/3] drm/amdgpu: Add new mode 2560x1440

2021-01-05 Thread Emily . Deng
Add one more 2k resolution which appears frequently in market.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index ffcc64ec6473..9810af712cc0 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -294,7 +294,7 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
static const struct mode_size {
int w;
int h;
-   } common_modes[21] = {
+   } common_modes[] = {
{ 640,  480},
{ 720,  480},
{ 800,  600},
@@ -312,13 +312,14 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
{1600, 1200},
{1920, 1080},
{1920, 1200},
+   {2560, 1440},
{4096, 3112},
{3656, 2664},
{3840, 2160},
{4096, 2160},
};
 
-   for (i = 0; i < 21; i++) {
+   for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
drm_mode_probed_add(connector, mode);
}
-- 
2.25.1

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


[PATCH 3/3] drm/amdgpu:Limit the resolution for virtual_display

2021-01-05 Thread Emily . Deng
Limit the resolution not bigger than 16384, which means
dev->mode_info.num_crtc * common_modes[i].w not bigger than 16384.

Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 2b16c8faca34..c23d37b02fd7 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -319,6 +319,7 @@ dce_virtual_encoder(struct drm_connector *connector)
 static int dce_virtual_get_modes(struct drm_connector *connector)
 {
struct drm_device *dev = connector->dev;
+   struct amdgpu_device *adev = dev->dev_private;
struct drm_display_mode *mode = NULL;
unsigned i;
static const struct mode_size {
@@ -350,8 +351,10 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
};
 
for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
-   mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
-   drm_mode_probed_add(connector, mode);
+   if (adev->mode_info.num_crtc <= 4 ||  common_modes[i].w <= 
2560) {
+   mode = drm_cvt_mode(dev, common_modes[i].w, 
common_modes[i].h, 60, false, false, false);
+   drm_mode_probed_add(connector, mode);
+   }
}
 
return 0;
-- 
2.25.1

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


[PATCH 2/3] drm/amdgpu: Correct the read sclk for navi10

2021-01-05 Thread Emily . Deng
Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index 51e83123f72a..7ebf9588983f 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
@@ -1673,7 +1673,7 @@ static int navi10_read_sensor(struct smu_context *smu,
*size = 4;
break;
case AMDGPU_PP_SENSOR_GFX_SCLK:
-   ret = navi10_get_current_clk_freq_by_table(smu, SMU_GFXCLK, 
(uint32_t *)data);
+   ret = navi10_get_smu_metrics_data(smu, METRICS_AVERAGE_GFXCLK, 
(uint32_t *)data);
*(uint32_t *)data *= 100;
*size = 4;
break;
-- 
2.25.1

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


[PATCH 1/3] drm/amdgpu: Add new mode 2560x1440

2021-01-05 Thread Emily . Deng
Signed-off-by: Emily.Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index bc3dcc262fc2..2b16c8faca34 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -324,7 +324,7 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
static const struct mode_size {
int w;
int h;
-   } common_modes[21] = {
+   } common_modes[] = {
{ 640,  480},
{ 720,  480},
{ 800,  600},
@@ -342,13 +342,14 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
{1600, 1200},
{1920, 1080},
{1920, 1200},
+   {2560, 1440},
{4096, 3112},
{3656, 2664},
{3840, 2160},
{4096, 2160},
};
 
-   for (i = 0; i < 21; i++) {
+   for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
drm_mode_probed_add(connector, mode);
}
-- 
2.25.1

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


[PATCH] drm/amdgpu: Remove warning for virtual_display

2020-10-08 Thread Emily . Deng
Remove the virtual_display warning in drm_crtc_vblank_off when
dev->num_crtcs is null.

Signed-off-by: Emily.Deng 
Change-Id: I755150a32478d8c128eed7ed98a71175d2b3aefc
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 469c05fd43d5..b4d4b76538d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -174,8 +174,10 @@ static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
 static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
 
-   drm_crtc_vblank_off(crtc);
+   if (dev->num_crtcs)
+   drm_crtc_vblank_off(crtc);
 
amdgpu_crtc->enabled = false;
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
-- 
2.25.1

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


[PATCH] drm/amdgpu: Remove warning for virtual_display

2020-10-07 Thread Emily . Deng
Remove the virtual_display warning in drm_crtc_vblank_off when
dev->num_crtcs is null.

Signed-off-by: Emily.Deng 
Change-Id: I755150a32478d8c128eed7ed98a71175d2b3aefc
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 52d40b5e14db..fcf61d94fbc8 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -189,8 +189,10 @@ static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
 static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+   struct drm_device *dev = crtc->dev;
 
-   drm_crtc_vblank_off(crtc);
+   if (!dev->num_crtcs)
+   drm_crtc_vblank_off(crtc);
 
amdgpu_crtc->enabled = false;
amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
-- 
2.25.1

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


[PATCH] drm/amdgpu: Remove some useless code

2020-09-23 Thread Emily . Deng
Signed-off-by: Emily.Deng 
Change-Id: I1a14dcc6f2d5395b2c385f4f290494ce7de108b4
---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c|  5 -
 drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c |  5 -
 drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 13 -
 .../gpu/drm/amd/pm/powerplay/smumgr/smu9_smumgr.c   |  7 ---
 4 files changed, 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
index b882ac59879a..0905d6397972 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
@@ -153,11 +153,6 @@ static void gfxhub_v2_0_init_system_aperture_regs(struct 
amdgpu_device *adev)
uint64_t value;
 
if (!amdgpu_sriov_vf(adev)) {
-   /*
-* the new L1 policy will block SRIOV guest from writing
-* these regs, and they will be programed at host.
-* so skip programing these regs.
-*/
/* Disable AGP. */
WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_BASE, 0);
WREG32_SOC15(GC, 0, mmGCMC_VM_AGP_TOP, 0);
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
index 2d88278c50bf..5241fa991248 100644
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
@@ -201,11 +201,6 @@ static void mmhub_v2_0_init_system_aperture_regs(struct 
amdgpu_device *adev)
WREG32_SOC15(MMHUB, 0, mmMMMC_VM_AGP_BOT, 0x00FF);
 
if (!amdgpu_sriov_vf(adev)) {
-   /*
-* the new L1 policy will block SRIOV guest from writing
-* these regs, and they will be programed at host.
-* so skip programing these regs.
-*/
/* Program the system aperture low logical page number. */
WREG32_SOC15(MMHUB, 0, mmMMMC_VM_SYSTEM_APERTURE_LOW_ADDR,
 adev->gmc.vram_start >> 18);
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h 
b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
index cbc04a5c0fe1..1ef2f5b1d828 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
@@ -83,19 +83,6 @@ struct psp_gfx_ctrl
 */
 #define GFX_FLAG_RESPONSE   0x8000
 
-/* Gbr IH registers ID */
-enum ih_reg_id {
-   IH_RB   = 0,// IH_RB_CNTL
-   IH_RB_RNG1  = 1,// IH_RB_CNTL_RING1
-   IH_RB_RNG2  = 2,// IH_RB_CNTL_RING2
-};
-
-/* Command to setup Gibraltar IH register */
-struct psp_gfx_cmd_gbr_ih_reg {
-   uint32_treg_value;  /* Value to be set to the 
IH_RB_CNTL... register*/
-   enum ih_reg_id  reg_id; /* ID of the register */
-};
-
 /* TEE Gfx Command IDs for the ring buffer interface. */
 enum psp_gfx_cmd_id
 {
diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/smu9_smumgr.c 
b/drivers/gpu/drm/amd/pm/powerplay/smumgr/smu9_smumgr.c
index adfbcbe5d113..8a9aee85043e 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/smu9_smumgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/smu9_smumgr.c
@@ -61,9 +61,6 @@ static uint32_t smu9_wait_for_response(struct pp_hwmgr *hwmgr)
uint32_t reg;
uint32_t ret;
 
-   /* Due to the L1 policy problem under SRIOV, we have to use
-* mmMP1_SMN_C2PMSG_103 as the driver response register
-*/
if (hwmgr->pp_one_vf) {
reg = SOC15_REG_OFFSET(MP1, 0, mmMP1_SMN_C2PMSG_103);
 
@@ -148,10 +145,6 @@ int smu9_send_msg_to_smc_with_parameter(struct pp_hwmgr 
*hwmgr,
 
smu9_wait_for_response(hwmgr);
 
-   /* Due to the L1 policy problem under SRIOV, we have to use
-* mmMP1_SMN_C2PMSG_101 as the driver message register and
-* mmMP1_SMN_C2PMSG_102 as the driver parameter register.
-*/
if (hwmgr->pp_one_vf) {
WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_103, 0);
WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_102, parameter);
-- 
2.25.1

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


[PATCH] drm/amdgpu/sriov: Enable the mcbp parameter for sriov

2020-09-21 Thread Emily . Deng
For debug convenient, reuse mcbp parameter for sriov mcbp

Signed-off-by: Emily.Deng 
Change-Id: If1222b2c050376feefb8fed4be58b4b87d36bd77
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5c2eb46e9b71..fcb6a41594db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3197,15 +3197,18 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
amdgpu_device_get_pcie_info(adev);
 
-   if (amdgpu_mcbp)
-   DRM_INFO("MCBP is enabled\n");
-
if (amdgpu_mes && adev->asic_type >= CHIP_NAVI10)
adev->enable_mes = true;
 
/* detect hw virtualization here */
amdgpu_detect_virtualization(adev);
 
+   if (amdgpu_mcbp == -1)
+   amdgpu_mcbp = amdgpu_sriov_vf(adev) ? 1 : 0;
+
+   if (amdgpu_mcbp)
+   DRM_INFO("MCBP is enabled\n");
+
r = amdgpu_device_get_job_timeout_settings(adev);
if (r) {
dev_err(adev->dev, "invalid lockup_timeout parameter syntax\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 8d658d2a16fe..976d4f8ee2f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -144,7 +144,7 @@ uint amdgpu_smu_memory_pool_size = 0;
 uint amdgpu_dc_feature_mask = 0;
 uint amdgpu_dc_debug_mask = 0;
 int amdgpu_async_gfx_ring = 1;
-int amdgpu_mcbp = 0;
+int amdgpu_mcbp = -1;
 int amdgpu_discovery = -1;
 int amdgpu_mes = 0;
 int amdgpu_noretry;
@@ -575,9 +575,10 @@ module_param_named(async_gfx_ring, amdgpu_async_gfx_ring, 
int, 0444);
  * It is used to enable mid command buffer preemption. (0 = disabled 
(default), 1 = enabled)
  */
 MODULE_PARM_DESC(mcbp,
-   "Enable Mid-command buffer preemption (0 = disabled (default), 1 = 
enabled)");
+   "Enable Mid-command buffer preemption (-1 = auto (default), 0 = 
disabled, 1 = enabled)");
 module_param_named(mcbp, amdgpu_mcbp, int, 0444);
 
+
 /**
  * DOC: discovery (int)
  * Allow driver to discover hardware IP information from IP Discovery table at 
the top of VRAM.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index 2f53fa0ae9a6..cffa45a9481d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -236,7 +236,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned 
num_ibs,
 
for (i = 0; i < num_ibs; ++i) {
ib = [i];
-
+   if (!amdgpu_mcbp)
+   ib->flags &= ~AMDGPU_IB_FLAG_PREEMPT;
/* drop preamble IBs if we don't have a context switch */
if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) &&
skip_preamble &&
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix dead lock issue for vblank

2020-09-18 Thread Emily . Deng
Always start vblank timer, but only calls vblank function
when vblank is enabled.

This is used to fix the dead lock issue.
When drm_crtc_vblank_off want to disable vblank,
it first get event_lock, and then call hrtimer_cancel,
but hrtimer_cancel want to wait timer handler function finished.
Timer handler also want to aquire event_lock in drm_handle_vblank.

Signed-off-by: Emily.Deng 
Change-Id: I7d3cfb1202cd030fdcdec3e7483fcc4c9fa8db70
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 35 
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index cc93577dee03..469c05fd43d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -47,6 +47,9 @@ static void dce_virtual_set_display_funcs(struct 
amdgpu_device *adev);
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
 static int dce_virtual_connector_encoder_init(struct amdgpu_device *adev,
  int index);
+static int dce_virtual_pageflip(struct amdgpu_device *adev,
+   unsigned crtc_id);
+static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer 
*vblank_timer);
 static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device 
*adev,
int crtc,
enum 
amdgpu_interrupt_state state);
@@ -247,6 +250,11 @@ static int dce_virtual_crtc_init(struct amdgpu_device 
*adev, int index)
amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
drm_crtc_helper_add(_crtc->base, _virtual_crtc_helper_funcs);
 
+   hrtimer_init(_crtc->vblank_timer, CLOCK_MONOTONIC, 
HRTIMER_MODE_REL);
+   hrtimer_set_expires(_crtc->vblank_timer, 
DCE_VIRTUAL_VBLANK_PERIOD);
+   amdgpu_crtc->vblank_timer.function = dce_virtual_vblank_timer_handle;
+   hrtimer_start(_crtc->vblank_timer,
+ DCE_VIRTUAL_VBLANK_PERIOD, HRTIMER_MODE_REL);
return 0;
 }
 
@@ -476,7 +484,7 @@ static int dce_virtual_hw_fini(void *handle)
 
for (i = 0; imode_info.num_crtc; i++)
if (adev->mode_info.crtcs[i])
-   dce_virtual_set_crtc_vblank_interrupt_state(adev, i, 
AMDGPU_IRQ_STATE_DISABLE);
+   hrtimer_cancel(>mode_info.crtcs[i]->vblank_timer);
 
return 0;
 }
@@ -698,9 +706,15 @@ static enum hrtimer_restart 
dce_virtual_vblank_timer_handle(struct hrtimer *vbla
   struct amdgpu_crtc, 
vblank_timer);
struct drm_device *ddev = amdgpu_crtc->base.dev;
struct amdgpu_device *adev = drm_to_adev(ddev);
+   struct amdgpu_irq_src *source = 
adev->irq.client[AMDGPU_IRQ_CLIENTID_LEGACY].sources
+   [VISLANDS30_IV_SRCID_SMU_DISP_TIMER2_TRIGGER];
+   int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev,
+   amdgpu_crtc->crtc_id);
 
-   drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
-   dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
+   if (amdgpu_irq_enabled(adev, source, irq_type)) {
+   drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
+   dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
+   }
hrtimer_start(vblank_timer, DCE_VIRTUAL_VBLANK_PERIOD,
  HRTIMER_MODE_REL);
 
@@ -716,21 +730,6 @@ static void 
dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad
return;
}
 
-   if (state && !adev->mode_info.crtcs[crtc]->vsync_timer_enabled) {
-   DRM_DEBUG("Enable software vsync timer\n");
-   hrtimer_init(>mode_info.crtcs[crtc]->vblank_timer,
-CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-   hrtimer_set_expires(>mode_info.crtcs[crtc]->vblank_timer,
-   DCE_VIRTUAL_VBLANK_PERIOD);
-   adev->mode_info.crtcs[crtc]->vblank_timer.function =
-   dce_virtual_vblank_timer_handle;
-   hrtimer_start(>mode_info.crtcs[crtc]->vblank_timer,
- DCE_VIRTUAL_VBLANK_PERIOD, HRTIMER_MODE_REL);
-   } else if (!state && adev->mode_info.crtcs[crtc]->vsync_timer_enabled) {
-   DRM_DEBUG("Disable software vsync timer\n");
-   hrtimer_cancel(>mode_info.crtcs[crtc]->vblank_timer);
-   }
-
adev->mode_info.crtcs[crtc]->vsync_timer_enabled = state;
DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc, state);
 }
-- 
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: Fix dead lock issue for vblank

2020-09-17 Thread Emily . Deng
Always start vblank timer, but only calls vblank function
when vblank is enabled.

This is used to fix the dead lock issue.
When drm_crtc_vblank_off want to disable vblank,
it first get event_lock, and then call hrtimer_cancel,
but hrtimer_cancel want to wait timer handler function finished.
Timer handler also want to aquire event_lock in drm_handle_vblank.

Signed-off-by: Emily.Deng 
Change-Id: I7d3cfb1202cd030fdcdec3e7483fcc4c9fa8db70
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 155 +++
 1 file changed, 77 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index cc93577dee03..8c02ab74c1de 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -226,6 +226,74 @@ static const struct drm_crtc_helper_funcs 
dce_virtual_crtc_helper_funcs = {
.get_scanout_position = amdgpu_crtc_get_scanout_position,
 };
 
+static int dce_virtual_pageflip(struct amdgpu_device *adev,
+   unsigned crtc_id)
+{
+   unsigned long flags;
+   struct amdgpu_crtc *amdgpu_crtc;
+   struct amdgpu_flip_work *works;
+
+   amdgpu_crtc = adev->mode_info.crtcs[crtc_id];
+
+   if (crtc_id >= adev->mode_info.num_crtc) {
+   DRM_ERROR("invalid pageflip crtc %d\n", crtc_id);
+   return -EINVAL;
+   }
+
+   /* IRQ could occur when in initial stage */
+   if (amdgpu_crtc == NULL)
+   return 0;
+
+   spin_lock_irqsave(>ddev->event_lock, flags);
+   works = amdgpu_crtc->pflip_works;
+   if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {
+   DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d != "
+   "AMDGPU_FLIP_SUBMITTED(%d)\n",
+   amdgpu_crtc->pflip_status,
+   AMDGPU_FLIP_SUBMITTED);
+   spin_unlock_irqrestore(>ddev->event_lock, flags);
+   return 0;
+   }
+
+   /* page flip completed. clean up */
+   amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE;
+   amdgpu_crtc->pflip_works = NULL;
+
+   /* wakeup usersapce */
+   if (works->event)
+   drm_crtc_send_vblank_event(_crtc->base, works->event);
+
+   spin_unlock_irqrestore(>ddev->event_lock, flags);
+
+   drm_crtc_vblank_put(_crtc->base);
+   amdgpu_bo_unref(>old_abo);
+   kfree(works->shared);
+   kfree(works);
+
+   return 0;
+}
+
+static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer 
*vblank_timer)
+{
+   struct amdgpu_crtc *amdgpu_crtc = container_of(vblank_timer,
+  struct amdgpu_crtc, 
vblank_timer);
+   struct drm_device *ddev = amdgpu_crtc->base.dev;
+   struct amdgpu_device *adev = ddev->dev_private;
+   struct amdgpu_irq_src *source = 
adev->irq.client[AMDGPU_IRQ_CLIENTID_LEGACY].sources
+   [VISLANDS30_IV_SRCID_SMU_DISP_TIMER2_TRIGGER];
+   int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev,
+   amdgpu_crtc->crtc_id);
+
+   if (amdgpu_irq_enabled(adev, source, irq_type)) {
+   drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
+   dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
+   }
+   hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD),
+ HRTIMER_MODE_REL);
+
+   return HRTIMER_NORESTART;
+}
+
 static int dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
 {
struct amdgpu_crtc *amdgpu_crtc;
@@ -247,6 +315,14 @@ static int dce_virtual_crtc_init(struct amdgpu_device 
*adev, int index)
amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
drm_crtc_helper_add(_crtc->base, _virtual_crtc_helper_funcs);
 
+   hrtimer_init(_crtc->vblank_timer,
+CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+   hrtimer_set_expires(_crtc->vblank_timer,
+   ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD));
+   amdgpu_crtc->vblank_timer.function =
+   dce_virtual_vblank_timer_handle;
+   hrtimer_start(_crtc->vblank_timer,
+ ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), 
HRTIMER_MODE_REL);
return 0;
 }
 
@@ -476,7 +552,7 @@ static int dce_virtual_hw_fini(void *handle)
 
for (i = 0; imode_info.num_crtc; i++)
if (adev->mode_info.crtcs[i])
-   dce_virtual_set_crtc_vblank_interrupt_state(adev, i, 
AMDGPU_IRQ_STATE_DISABLE);
+   hrtimer_cancel(>mode_info.crtcs[i]->vblank_timer);
 
return 0;
 }
@@ -645,68 +721,6 @@ static void dce_virtual_set_display_funcs(struct 
amdgpu_device *adev)
adev->mode_info.funcs = _virtual_display_funcs;
 }
 
-static int dce_virtual_pageflip(struct amdgpu_device *adev,
-   unsigned crtc_id)
-{
-   unsigned long flags;

[PATCH 1/2] drm/amdgpu/sriov: Add one parameter for mcbp debug

2020-09-17 Thread Emily . Deng
For debug convenient, add sriov_mcbp parameter.

Signed-off-by: Emily.Deng 
Change-Id: I84019eb4344e00d85b2ecc853145aabb312412fe
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c  | 3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 13f92dea182a..a255fbf4d370 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -183,6 +183,7 @@ extern uint amdgpu_ras_mask;
 extern int amdgpu_bad_page_threshold;
 extern int amdgpu_async_gfx_ring;
 extern int amdgpu_mcbp;
+extern int amdgpu_sriov_mcbp;
 extern int amdgpu_discovery;
 extern int amdgpu_mes;
 extern int amdgpu_noretry;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 3f07d1475bd2..b0b2f0f7be94 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -145,6 +145,7 @@ uint amdgpu_dc_feature_mask = 0;
 uint amdgpu_dc_debug_mask = 0;
 int amdgpu_async_gfx_ring = 1;
 int amdgpu_mcbp = 0;
+int amdgpu_sriov_mcbp = 1;
 int amdgpu_discovery = -1;
 int amdgpu_mes = 0;
 int amdgpu_noretry;
@@ -578,6 +579,14 @@ MODULE_PARM_DESC(mcbp,
"Enable Mid-command buffer preemption (0 = disabled (default), 1 = 
enabled)");
 module_param_named(mcbp, amdgpu_mcbp, int, 0444);
 
+/**
+ * DOC: sriov_mcbp (int)
+ * It is used to enable mid command buffer preemption. (0 = disabled, 1 = 
enabled(default))
+ */
+MODULE_PARM_DESC(sriov_mcbp,
+   "Enable sriov Mid-command buffer preemption (0 = disabled (default), 1 
= enabled)");
+module_param_named(sriov_mcbp, amdgpu_sriov_mcbp, int, 0444);
+
 /**
  * DOC: discovery (int)
  * Allow driver to discover hardware IP information from IP Discovery table at 
the top of VRAM.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index 2f53fa0ae9a6..ca0e17688bdf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -236,7 +236,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned 
num_ibs,
 
for (i = 0; i < num_ibs; ++i) {
ib = [i];
-
+   if (!amdgpu_sriov_mcbp)
+   ib->flags &= ~AMDGPU_IB_FLAG_PREEMPT;
/* drop preamble IBs if we don't have a context switch */
if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) &&
skip_preamble &&
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index d7f37cb92a97..156e76a5a6e0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -742,7 +742,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void 
*data, struct drm_file
dev_info.ids_flags = 0;
if (adev->flags & AMD_IS_APU)
dev_info.ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
-   if (amdgpu_mcbp || amdgpu_sriov_vf(adev))
+   if (amdgpu_mcbp || (amdgpu_sriov_vf(adev) && amdgpu_sriov_mcbp))
dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
if (amdgpu_is_tmz(adev))
dev_info.ids_flags |= AMDGPU_IDS_FLAGS_TMZ;
-- 
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 repeatly flr issue

2020-08-18 Thread Emily . Deng
From: jqdeng 

Only for no job running test case need to do recover in
flr notification.
For having job in mirror list, then let guest driver to
hit job timeout, and then do recover.

Signed-off-by: jqdeng 
Change-Id: Ic6234fce46fa1655ba81c4149235eeac75e75868
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 28 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c  |  4 ++--
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 1f9d97f61aa5..69115781be05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1136,6 +1136,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter));
 
 /* Common functions */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev);
 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
 int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
  struct amdgpu_job* job);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fe8878761c29..de4bce6d7516 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3925,6 +3925,34 @@ static int amdgpu_device_reset_sriov(struct 
amdgpu_device *adev,
return r;
 }
 
+/**
+ * amdgpu_device_has_job_running - check if there is any job in mirror list
+ *
+ * @adev: amdgpu device pointer
+ *
+ * check if there is any job in mirror list
+ */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev)
+{
+   int i;
+   struct drm_sched_job *job;
+
+   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+   struct amdgpu_ring *ring = adev->rings[i];
+
+   if (!ring || !ring->sched.thread)
+   continue;
+
+   spin_lock(>sched.job_list_lock);
+   job = list_first_entry_or_null(>sched.ring_mirror_list,
+   struct drm_sched_job, node);
+   spin_unlock(>sched.job_list_lock);
+   if (job)
+   return true;
+   }
+   return false;
+}
+
 /**
  * amdgpu_device_should_recover_gpu - check if we should try GPU recovery
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index fe31cbeccfe9..bd4e7c2d0dd1 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -261,7 +261,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct 
*work)
 
/* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev)
-   && adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT)
+   && (amdgpu_device_has_job_running(adev) || adev->sdma_timeout 
== MAX_SCHEDULE_TIMEOUT))
amdgpu_device_gpu_recover(adev, NULL);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
index 6f55172e8337..d5c14745a9d8 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
@@ -281,8 +281,8 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct 
*work)
up_read(>reset_sem);
 
/* Trigger recovery for world switch failure if no TDR */
-   if (amdgpu_device_should_recover_gpu(adev)
-   && (adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
+   if (amdgpu_device_should_recover_gpu(adev) && 
(amdgpu_device_has_job_running(adev) ||
+   adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->compute_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->video_timeout == MAX_SCHEDULE_TIMEOUT))
-- 
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: Limit the error info print rate

2020-08-18 Thread Emily . Deng
From: jqdeng 

Use function printk_ratelimit to limit the print rate.

Signed-off-by: jqdeng 
Change-Id: Ief05debe30d975cbcf88e473c9f486d70b5a202c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index a94b3f862fc2..727b909b4b9e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1296,7 +1296,8 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
 
r = amdgpu_cs_parser_init(, data);
if (r) {
-   DRM_ERROR("Failed to initialize parser %d!\n", r);
+   if (printk_ratelimit())
+   DRM_ERROR("Failed to initialize parser %d!\n", r);
goto out;
}
 
-- 
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 repeatly flr issue

2020-08-18 Thread Emily . Deng
From: jqdeng 

Only for no job running test case need to do recover in
flr notification.
For having job in mirror list, then let guest driver to
hit job timeout, and then do recover.

Signed-off-by: jqdeng 
Change-Id: Ic6234fce46fa1655ba81c4149235eeac75e75868
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c  |  4 +--
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 1f9d97f61aa5..69115781be05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1136,6 +1136,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter));
 
 /* Common functions */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev);
 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
 int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
  struct amdgpu_job* job);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fe8878761c29..e17f632efd07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3925,6 +3925,35 @@ static int amdgpu_device_reset_sriov(struct 
amdgpu_device *adev,
return r;
 }
 
+/**
+ * amdgpu_device_has_job_running - check if whether has job in ring mirror list
+ *
+ * @adev: amdgpu device pointer
+ *
+ * Check whether has job in ring mirror list
+ */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev)
+{
+   int i;
+   struct drm_sched_job *job;
+
+   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+   struct amdgpu_ring *ring = adev->rings[i];
+
+   if (!ring || !ring->sched.thread)
+   continue;
+
+   spin_lock(>sched.job_list_lock);
+   job = list_first_entry_or_null(>sched.ring_mirror_list,
+   struct drm_sched_job, node);
+   spin_unlock(>sched.job_list_lock);
+   if (job) {
+   return true;
+   }
+   }
+   return false;
+}
+
 /**
  * amdgpu_device_should_recover_gpu - check if we should try GPU recovery
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index fe31cbeccfe9..bd4e7c2d0dd1 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -261,7 +261,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct 
*work)
 
/* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev)
-   && adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT)
+   && (amdgpu_device_has_job_running(adev) || adev->sdma_timeout 
== MAX_SCHEDULE_TIMEOUT))
amdgpu_device_gpu_recover(adev, NULL);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
index 6f55172e8337..d5c14745a9d8 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
@@ -281,8 +281,8 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct 
*work)
up_read(>reset_sem);
 
/* Trigger recovery for world switch failure if no TDR */
-   if (amdgpu_device_should_recover_gpu(adev)
-   && (adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
+   if (amdgpu_device_should_recover_gpu(adev) && 
(amdgpu_device_has_job_running(adev) ||
+   adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->compute_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->video_timeout == MAX_SCHEDULE_TIMEOUT))
-- 
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 repeatly flr issue

2020-08-18 Thread Emily . Deng
From: jqdeng 

Only for no job running test case need to do recover in
flr notification.
For having job in mirror list, then let guest driver to
hit job timeout, and then do recover.

Signed-off-by: jqdeng 
Change-Id: Ic6234fce46fa1655ba81c4149235eeac75e75868
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 ++
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c  |  2 +-
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c  |  4 +--
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 1f9d97f61aa5..69115781be05 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1136,6 +1136,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
 #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter));
 
 /* Common functions */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev);
 bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
 int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
  struct amdgpu_job* job);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fe8878761c29..e17f632efd07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3925,6 +3925,35 @@ static int amdgpu_device_reset_sriov(struct 
amdgpu_device *adev,
return r;
 }
 
+/**
+ * amdgpu_device_has_job_running - check if whether has job in ring mirror list
+ *
+ * @adev: amdgpu device pointer
+ *
+ * Check whether has job in ring mirror list
+ */
+bool amdgpu_device_has_job_running(struct amdgpu_device *adev)
+{
+   int i;
+   struct drm_sched_job *job;
+
+   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+   struct amdgpu_ring *ring = adev->rings[i];
+
+   if (!ring || !ring->sched.thread)
+   continue;
+
+   spin_lock(>sched.job_list_lock);
+   job = list_first_entry_or_null(>sched.ring_mirror_list,
+   struct drm_sched_job, node);
+   spin_unlock(>sched.job_list_lock);
+   if (job) {
+   return true;
+   }
+   }
+   return false;
+}
+
 /**
  * amdgpu_device_should_recover_gpu - check if we should try GPU recovery
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index fe31cbeccfe9..bd4e7c2d0dd1 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -261,7 +261,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct 
*work)
 
/* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev)
-   && adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT)
+   && (amdgpu_device_has_job_running(adev) || adev->sdma_timeout 
== MAX_SCHEDULE_TIMEOUT))
amdgpu_device_gpu_recover(adev, NULL);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
index 6f55172e8337..d5c14745a9d8 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
@@ -281,8 +281,8 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct 
*work)
up_read(>reset_sem);
 
/* Trigger recovery for world switch failure if no TDR */
-   if (amdgpu_device_should_recover_gpu(adev)
-   && (adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
+   if (amdgpu_device_should_recover_gpu(adev) && 
(amdgpu_device_has_job_running(adev) ||
+   adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->compute_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->video_timeout == MAX_SCHEDULE_TIMEOUT))
-- 
2.25.1

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


[PATCH] drm/amdgpu: Limit the error info print rate

2020-08-12 Thread Emily . Deng
From: jqdeng 

Use function printk_ratelimit to limit the print rate.

Signed-off-by: jqdeng 
Change-Id: Ief05debe30d975cbcf88e473c9f486d70b5a202c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index a94b3f862fc2..727b909b4b9e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1296,7 +1296,8 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
 
r = amdgpu_cs_parser_init(, data);
if (r) {
-   DRM_ERROR("Failed to initialize parser %d!\n", r);
+   if (printk_ratelimit())
+   DRM_ERROR("Failed to initialize parser %d!\n", r);
goto out;
}
 
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix repeatly flr issue

2020-08-12 Thread Emily . Deng
From: jqdeng 

Only for no job running test case need to do recover in
flr notification.
For having job in mirror list, then let guest driver to
hit job timeout, and then do recover.

Signed-off-by: jqdeng 
Change-Id: Ic6234fce46fa1655ba81c4149235eeac75e75868
---
 drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 20 +++-
 drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 22 --
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
index fe31cbeccfe9..12fe5164aaf3 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c
@@ -238,6 +238,9 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct 
*work)
struct amdgpu_virt *virt = container_of(work, struct amdgpu_virt, 
flr_work);
struct amdgpu_device *adev = container_of(virt, struct amdgpu_device, 
virt);
int timeout = AI_MAILBOX_POLL_FLR_TIMEDOUT;
+   int i;
+   bool need_do_recover = true;
+   struct drm_sched_job *job;
 
/* block amdgpu_gpu_recover till msg FLR COMPLETE received,
 * otherwise the mailbox msg will be ruined/reseted by
@@ -258,10 +261,25 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct 
*work)
 
 flr_done:
up_read(>reset_sem);
+   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+   struct amdgpu_ring *ring = adev->rings[i];
+
+   if (!ring || !ring->sched.thread)
+   continue;
+
+   spin_lock(>sched.job_list_lock);
+   job = list_first_entry_or_null(>sched.ring_mirror_list,
+   struct drm_sched_job, node);
+   spin_unlock(>sched.job_list_lock);
+   if (job) {
+   need_do_recover = false;
+   break;
+   }
+   }
 
/* Trigger recovery for world switch failure if no TDR */
if (amdgpu_device_should_recover_gpu(adev)
-   && adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT)
+   && (need_do_recover || adev->sdma_timeout == 
MAX_SCHEDULE_TIMEOUT))
amdgpu_device_gpu_recover(adev, NULL);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c 
b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
index 6f55172e8337..fc92c494df0b 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c
@@ -259,6 +259,9 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct 
*work)
struct amdgpu_virt *virt = container_of(work, struct amdgpu_virt, 
flr_work);
struct amdgpu_device *adev = container_of(virt, struct amdgpu_device, 
virt);
int timeout = NV_MAILBOX_POLL_FLR_TIMEDOUT;
+   int i;
+   bool need_do_recover = true;
+   struct drm_sched_job *job;
 
/* block amdgpu_gpu_recover till msg FLR COMPLETE received,
 * otherwise the mailbox msg will be ruined/reseted by
@@ -279,10 +282,25 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct 
*work)
 
 flr_done:
up_read(>reset_sem);
+   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+   struct amdgpu_ring *ring = adev->rings[i];
+
+   if (!ring || !ring->sched.thread)
+   continue;
+
+   spin_lock(>sched.job_list_lock);
+   job = list_first_entry_or_null(>sched.ring_mirror_list,
+   struct drm_sched_job, node);
+   spin_unlock(>sched.job_list_lock);
+   if (job) {
+   need_do_recover = false;
+   break;
+   }
+   }
 
/* Trigger recovery for world switch failure if no TDR */
-   if (amdgpu_device_should_recover_gpu(adev)
-   && (adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
+   if (amdgpu_device_should_recover_gpu(adev) && (need_do_recover ||
+   adev->sdma_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->compute_timeout == MAX_SCHEDULE_TIMEOUT ||
adev->video_timeout == MAX_SCHEDULE_TIMEOUT))
-- 
2.25.1

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


[PATCH] drm/amdgpu/sriov: Need to clear kiq position

2020-06-11 Thread Emily Deng
As will clear vf fw during unload driver, to avoid idle fail. Need
to clear KIQ portion also.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index e9045dd..323285e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -6876,6 +6876,7 @@ static int gfx_v10_0_hw_fini(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int r;
+   uint32_t tmp;
 
amdgpu_irq_put(adev, >gfx.priv_reg_irq, 0);
amdgpu_irq_put(adev, >gfx.priv_inst_irq, 0);
@@ -6890,6 +6891,11 @@ static int gfx_v10_0_hw_fini(void *handle)
DRM_ERROR("KCQ disable failed\n");
if (amdgpu_sriov_vf(adev)) {
gfx_v10_0_cp_gfx_enable(adev, false);
+   /* Program KIQ position of RLC_CP_SCHEDULERS during destroy */
+   tmp = RREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS);
+   tmp &= 0xff00;
+   WREG32_SOC15(GC, 0, mmRLC_CP_SCHEDULERS, tmp);
+
return 0;
}
gfx_v10_0_cp_enable(adev, false);
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: Add clear vf fw support

2020-06-10 Thread Emily Deng
Guest VM issue the PSP clear_vf_fw command at 2 points:
1.On VF driver loading, after VF message PSP to setup rings,
the next command is “clear_vf_fw”
2.On VF driver unload before VF message to
destroy rings

Change-Id: Ia31add38a69037d1cbbf9b48ad827fa63b4860f7
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 37 +++--
 drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h |  8 +++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index cdd65b5..6055849 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -270,8 +270,9 @@ psp_cmd_submit_buf(struct psp_context *psp,
amdgpu_asic_invalidate_hdp(psp->adev, NULL);
}
 
-   /* We allow TEE_ERROR_NOT_SUPPORTED for VMR command in SRIOV */
-   skip_unsupport = (psp->cmd_buf_mem->resp.status == 0x000a) && 
amdgpu_sriov_vf(psp->adev);
+   /* We allow TEE_ERROR_NOT_SUPPORTED for VMR command and 
PSP_ERR_UNKNOWN_COMMAND in SRIOV */
+   skip_unsupport = (psp->cmd_buf_mem->resp.status == 
TEE_ERROR_NOT_SUPPORTED ||
+   psp->cmd_buf_mem->resp.status == PSP_ERR_UNKNOWN_COMMAND) && 
amdgpu_sriov_vf(psp->adev);
 
/* In some cases, psp response status is not 0 even there is no
 * problem while the command is submitted. Some version of PSP FW
@@ -389,6 +390,26 @@ static int psp_tmr_init(struct psp_context *psp)
return ret;
 }
 
+static int psp_clear_vf_fw(struct psp_context *psp)
+{
+   int ret;
+   struct psp_gfx_cmd_resp *cmd;
+
+   if (!amdgpu_sriov_vf(psp->adev) || psp->adev->asic_type != CHIP_NAVI12)
+   return 0;
+
+   cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
+   if (!cmd)
+   return -ENOMEM;
+
+   cmd->cmd_id = GFX_CMD_ID_CLEAR_VF_FW;
+
+   ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
+   kfree(cmd);
+
+   return ret;
+}
+
 static int psp_tmr_load(struct psp_context *psp)
 {
int ret;
@@ -1382,6 +1403,12 @@ static int psp_hw_start(struct psp_context *psp)
return ret;
}
 
+   ret = psp_clear_vf_fw(psp);
+   if (ret) {
+   DRM_ERROR("PSP clear vf fw!\n");
+   return ret;
+   }
+
ret = psp_tmr_init(psp);
if (ret) {
DRM_ERROR("PSP tmr init failed!\n");
@@ -1843,6 +1870,7 @@ static int psp_hw_fini(void *handle)
struct psp_context *psp = >psp;
void *tmr_buf;
void **pptr;
+   int ret;
 
if (psp->adev->psp.ta_fw) {
psp_ras_terminate(psp);
@@ -1851,6 +1879,11 @@ static int psp_hw_fini(void *handle)
}
 
psp_asd_unload(psp);
+   ret = psp_clear_vf_fw(psp);
+   if (ret) {
+   DRM_ERROR("PSP clear vf fw!\n");
+   return ret;
+   }
 
psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h 
b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
index a44fd60..cbc04a5 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
+++ b/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h
@@ -110,6 +110,7 @@ enum psp_gfx_cmd_id
 GFX_CMD_ID_SETUP_VMR= 0x0009,   /* setup VMR region */
 GFX_CMD_ID_DESTROY_VMR  = 0x000A,   /* destroy VMR region */
 GFX_CMD_ID_PROG_REG = 0x000B,   /* program regs */
+GFX_CMD_ID_CLEAR_VF_FW  = 0x000D,   /* Clear VF FW, to be used on VF 
shutdown. */
 /* IDs upto 0x1F are reserved for older programs (Raven, Vega 10/12/20) */
 GFX_CMD_ID_LOAD_TOC = 0x0020,   /* Load TOC and obtain TMR size */
 GFX_CMD_ID_AUTOLOAD_RLC = 0x0021,   /* Indicates all graphics fw 
loaded, start RLC autoload */
@@ -365,4 +366,11 @@ struct psp_gfx_rb_frame
 /* total 64 bytes */
 };
 
+#define PSP_ERR_UNKNOWN_COMMAND 0x0100
+
+enum tee_error_code {
+TEE_SUCCESS = 0x,
+TEE_ERROR_NOT_SUPPORTED = 0x000A,
+};
+
 #endif /* _PSP_TEE_GFX_IF_H_ */
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: Disable pm for multiple vf sriov

2020-06-02 Thread Emily Deng
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c 
b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 5294aa7..8ed6c90 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1311,8 +1311,10 @@ static int smu_hw_init(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct smu_context *smu = >smu;
 
-   if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+   if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev)) {
+   smu->pm_enabled = false;
return 0;
+   }
 
ret = smu_start_smc_engine(smu);
if (ret) {
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: Disable pm for multiple vf sriov

2020-06-02 Thread Emily Deng
Change-Id: Ic010440ef625f6f29e91f267a6f284f9b6554e1f
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b6331712..fcbd875 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2004,6 +2004,9 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)
if (amdgpu_sriov_vf(adev))
amdgpu_virt_init_data_exchange(adev);
 
+   if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
+   adev->smu.pm_enabled = 0;
+
r = amdgpu_ib_pool_init(adev);
if (r) {
dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-- 
2.7.4

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


[PATCH 3/4] SWDEV-227979 - Add 4k resolution for virtual display

2020-03-25 Thread Emily Deng
Add 4k resolution for virtual connector.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 3c9f2d2..8656cb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -281,7 +281,7 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
static const struct mode_size {
int w;
int h;
-   } common_modes[17] = {
+   } common_modes[21] = {
{ 640,  480},
{ 720,  480},
{ 800,  600},
@@ -298,10 +298,14 @@ static int dce_virtual_get_modes(struct drm_connector 
*connector)
{1680, 1050},
{1600, 1200},
{1920, 1080},
-   {1920, 1200}
+   {1920, 1200},
+   {4096, 3112},
+   {3656, 2664},
+   {3840, 2160},
+   {4096, 2160},
};
 
-   for (i = 0; i < 17; i++) {
+   for (i = 0; i < 21; i++) {
mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 
60, false, false, false);
drm_mode_probed_add(connector, mode);
}
-- 
2.7.4

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


[PATCH 4/4] SWDEV-226663 - Ignore the not supported error from psp

2020-03-25 Thread Emily Deng
As the VCN firmware will not use
vf vmr now. And new psp policy won't support set tmr
now.
For driver compatible issue, ignore the not support error.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index c2bf2d9..1a46050 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -205,6 +205,7 @@ psp_cmd_submit_buf(struct psp_context *psp,
int index;
int timeout = 2000;
bool ras_intr = false;
+   bool skip_unsupport = false;
 
mutex_lock(>mutex);
 
@@ -236,6 +237,9 @@ psp_cmd_submit_buf(struct psp_context *psp,
amdgpu_asic_invalidate_hdp(psp->adev, NULL);
}
 
+   /* We allow TEE_ERROR_NOT_SUPPORTED for VMR command in SRIOV */
+   skip_unsupport = (psp->cmd_buf_mem->resp.status == 0x000a) && 
amdgpu_sriov_vf(psp->adev);
+
/* In some cases, psp response status is not 0 even there is no
 * problem while the command is submitted. Some version of PSP FW
 * doesn't write 0 to that field.
@@ -243,7 +247,7 @@ psp_cmd_submit_buf(struct psp_context *psp,
 * during psp initialization to avoid breaking hw_init and it doesn't
 * return -EINVAL.
 */
-   if ((psp->cmd_buf_mem->resp.status || !timeout) && !ras_intr) {
+   if (!skip_unsupport && (psp->cmd_buf_mem->resp.status || !timeout) && 
!ras_intr) {
if (ucode)
DRM_WARN("failed to load ucode id (%d) ",
  ucode->ucode_id);
-- 
2.7.4

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


[PATCH 2/4] SWDEV-227334 - No need support vcn decode

2020-03-25 Thread Emily Deng
As no need to support vcn decode feature, so diable the
ring.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
index ec8091a..febd4c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
@@ -223,6 +223,10 @@ static int vcn_v2_0_hw_init(void *handle)
if (r)
goto done;
 
+   //Disable vcn decode for sriov
+   if (amdgpu_sriov_vf(adev))
+   ring->sched.ready = false;
+
for (i = 0; i < adev->vcn.num_enc_rings; ++i) {
ring = >vcn.inst->ring_enc[i];
r = amdgpu_ring_test_helper(ring);
-- 
2.7.4

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


[PATCH 1/4] SWDEV-227605 - Virtual display need to support multiple ctrcs

2020-03-25 Thread Emily Deng
The crtc num is determined by virtual_display parameter.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 43a1ee3..d791bfe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -38,7 +38,8 @@ bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev)
 void amdgpu_virt_init_setting(struct amdgpu_device *adev)
 {
/* enable virtual display */
-   adev->mode_info.num_crtc = 1;
+   if (adev->mode_info.num_crtc == 0)
+   adev->mode_info.num_crtc = 1;
adev->enable_virtual_display = true;
adev->ddev->driver->driver_features &= ~DRIVER_ATOMIC;
adev->cg_flags = 0;
-- 
2.7.4

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


[PATCH v2] drm/amdgpu/sriov: Use kiq to copy the gpu clock

2020-02-26 Thread Emily Deng
For vega10 sriov, the register is blocked, use
copy data command to fix the issue.

v2: Rename amdgpu_kiq_read_clock to gfx_v9_0_kiq_read_clock.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 68 +--
 1 file changed, 58 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index edd5501..5f7336a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3978,6 +3978,63 @@ static int gfx_v9_0_soft_reset(void *handle)
return 0;
 }
 
+static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)
+{
+   signed long r, cnt = 0;
+   unsigned long flags;
+   uint32_t seq;
+   struct amdgpu_kiq *kiq = >gfx.kiq;
+   struct amdgpu_ring *ring = >ring;
+
+   BUG_ON(!ring->funcs->emit_rreg);
+
+   spin_lock_irqsave(>ring_lock, flags);
+   amdgpu_ring_alloc(ring, 32);
+   amdgpu_ring_write(ring, PACKET3(PACKET3_COPY_DATA, 4));
+   amdgpu_ring_write(ring, 9 | /* src: register*/
+   (5 << 8) |  /* dst: memory */
+   (1 << 16) | /* count sel */
+   (1 << 20)); /* write confirm */
+   amdgpu_ring_write(ring, 0);
+   amdgpu_ring_write(ring, 0);
+   amdgpu_ring_write(ring, lower_32_bits(adev->wb.gpu_addr +
+   kiq->reg_val_offs * 4));
+   amdgpu_ring_write(ring, upper_32_bits(adev->wb.gpu_addr +
+   kiq->reg_val_offs * 4));
+   amdgpu_fence_emit_polling(ring, );
+   amdgpu_ring_commit(ring);
+   spin_unlock_irqrestore(>ring_lock, flags);
+
+   r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
+
+   /* don't wait anymore for gpu reset case because this way may
+* block gpu_recover() routine forever, e.g. this virt_kiq_rreg
+* is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
+* never return if we keep waiting in virt_kiq_rreg, which cause
+* gpu_recover() hang there.
+*
+* also don't wait anymore for IRQ context
+* */
+   if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+   goto failed_kiq_read;
+
+   might_sleep();
+   while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
+   msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
+   r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
+   }
+
+   if (cnt > MAX_KIQ_REG_TRY)
+   goto failed_kiq_read;
+
+   return (uint64_t)adev->wb.wb[kiq->reg_val_offs] |
+   (uint64_t)adev->wb.wb[kiq->reg_val_offs + 1 ] << 32ULL;
+
+failed_kiq_read:
+   pr_err("failed to read gpu clock\n");
+   return ~0;
+}
+
 static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
 {
uint64_t clock;
@@ -3985,16 +4042,7 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct 
amdgpu_device *adev)
amdgpu_gfx_off_ctrl(adev, false);
mutex_lock(>gfx.gpu_clock_mutex);
if (adev->asic_type == CHIP_VEGA10 && amdgpu_sriov_runtime(adev)) {
-   uint32_t tmp, lsb, msb, i = 0;
-   do {
-   if (i != 0)
-   udelay(1);
-   tmp = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
-   lsb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_LSB);
-   msb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
-   i++;
-   } while (unlikely(tmp != msb) && (i < adev->usec_timeout));
-   clock = (uint64_t)lsb | ((uint64_t)msb << 32ULL);
+   clock = gfx_v9_0_kiq_read_clock(adev);
} else {
WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
clock = (uint64_t)RREG32_SOC15(GC, 0, 
mmRLC_GPU_CLOCK_COUNT_LSB) |
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: Use kiq to copy the gpu clock

2020-02-25 Thread Emily Deng
For vega10 sriov, the register is blocked, use
copy data command to fix the issue.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 68 +--
 1 file changed, 58 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 1c7a16b..71df0d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3963,6 +3963,63 @@ static int gfx_v9_0_soft_reset(void *handle)
return 0;
 }
 
+static uint64_t amdgpu_kiq_read_clock(struct amdgpu_device *adev)
+{
+   signed long r, cnt = 0;
+   unsigned long flags;
+   uint32_t seq;
+   struct amdgpu_kiq *kiq = >gfx.kiq;
+   struct amdgpu_ring *ring = >ring;
+
+   BUG_ON(!ring->funcs->emit_rreg);
+
+   spin_lock_irqsave(>ring_lock, flags);
+   amdgpu_ring_alloc(ring, 32);
+   amdgpu_ring_write(ring, PACKET3(PACKET3_COPY_DATA, 4));
+   amdgpu_ring_write(ring, 9 | /* src: register*/
+   (5 << 8) |  /* dst: memory */
+   (1 << 16) | /* count sel */
+   (1 << 20)); /* write confirm */
+   amdgpu_ring_write(ring, 0);
+   amdgpu_ring_write(ring, 0);
+   amdgpu_ring_write(ring, lower_32_bits(adev->wb.gpu_addr +
+   kiq->reg_val_offs * 4));
+   amdgpu_ring_write(ring, upper_32_bits(adev->wb.gpu_addr +
+   kiq->reg_val_offs * 4));
+   amdgpu_fence_emit_polling(ring, );
+   amdgpu_ring_commit(ring);
+   spin_unlock_irqrestore(>ring_lock, flags);
+
+   r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
+
+   /* don't wait anymore for gpu reset case because this way may
+* block gpu_recover() routine forever, e.g. this virt_kiq_rreg
+* is triggered in TTM and ttm_bo_lock_delayed_workqueue() will
+* never return if we keep waiting in virt_kiq_rreg, which cause
+* gpu_recover() hang there.
+*
+* also don't wait anymore for IRQ context
+* */
+   if (r < 1 && (adev->in_gpu_reset || in_interrupt()))
+   goto failed_kiq_read;
+
+   might_sleep();
+   while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
+   msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
+   r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
+   }
+
+   if (cnt > MAX_KIQ_REG_TRY)
+   goto failed_kiq_read;
+
+   return (uint64_t)adev->wb.wb[kiq->reg_val_offs] |
+   (uint64_t)adev->wb.wb[kiq->reg_val_offs + 1 ] << 32ULL;
+
+failed_kiq_read:
+   pr_err("failed to read gpu clock\n");
+   return ~0;
+}
+
 static uint64_t gfx_v9_0_get_gpu_clock_counter(struct amdgpu_device *adev)
 {
uint64_t clock;
@@ -3970,16 +4027,7 @@ static uint64_t gfx_v9_0_get_gpu_clock_counter(struct 
amdgpu_device *adev)
amdgpu_gfx_off_ctrl(adev, false);
mutex_lock(>gfx.gpu_clock_mutex);
if (adev->asic_type == CHIP_VEGA10 && amdgpu_sriov_runtime(adev)) {
-   uint32_t tmp, lsb, msb, i = 0;
-   do {
-   if (i != 0)
-   udelay(1);
-   tmp = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
-   lsb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_LSB);
-   msb = RREG32_SOC15(GC, 0, mmRLC_REFCLOCK_TIMESTAMP_MSB);
-   i++;
-   } while (unlikely(tmp != msb) && (i < adev->usec_timeout));
-   clock = (uint64_t)lsb | ((uint64_t)msb << 32ULL);
+   clock = amdgpu_kiq_read_clock(adev);
} else {
WREG32_SOC15(GC, 0, mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
clock = (uint64_t)RREG32_SOC15(GC, 0, 
mmRLC_GPU_CLOCK_COUNT_LSB) |
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: Tonga sriov also need load firmware with smu

2019-12-16 Thread Emily Deng
Fix Tonga sriov load driver fail issue.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 3 ++-
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 3 ---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 26d1a4c..52d3f66 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1818,7 +1818,8 @@ static int amdgpu_device_fw_loading(struct amdgpu_device 
*adev)
}
}
 
-   r = amdgpu_pm_load_smu_firmware(adev, _version);
+   if (!amdgpu_sriov_vf(adev) || adev->asic_type == CHIP_TONGA)
+   r = amdgpu_pm_load_smu_firmware(adev, _version);
 
return r;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 5087d6b..7293763 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -275,9 +275,6 @@ static int pp_dpm_load_fw(void *handle)
 {
struct pp_hwmgr *hwmgr = handle;
 
-   if (!hwmgr->not_vf)
-   return 0;
-
if (!hwmgr || !hwmgr->smumgr_funcs || !hwmgr->smumgr_funcs->start_smu)
return -EINVAL;
 
-- 
2.7.4

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


[PATCH] drm/amdgpu/sriov: No need the event 3 and 4 now

2019-11-30 Thread Emily Deng
As will call unload kms when initialize fail, and the unload kms will
send event 3 and 4, so don't need event 3 and 4 in device init.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d1d573d..0393e35 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3036,8 +3036,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
}
dev_err(adev->dev, "amdgpu_device_ip_init failed\n");
amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 
0);
-   if (amdgpu_virt_request_full_gpu(adev, false))
-   amdgpu_virt_release_full_gpu(adev, false);
goto failed;
}
 
-- 
2.7.4

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

[PATCH] drm/amdgpu: Fix the null pointer issue for tdr

2019-11-07 Thread Emily Deng
When the job is already signaled, the s_fence is freed. Then it will has
null pointer in amdgpu_device_gpu_recover.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 +-
 drivers/gpu/drm/scheduler/sched_main.c | 11 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e6ce949..5a8f08e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4075,7 +4075,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
 *
 * job->base holds a reference to parent fence
 */
-   if (job && job->base.s_fence->parent &&
+   if (job && job->base.s_fence && job->base.s_fence->parent &&
dma_fence_is_signaled(job->base.s_fence->parent))
job_signaled = true;
 
diff --git a/drivers/gpu/drm/scheduler/sched_main.c 
b/drivers/gpu/drm/scheduler/sched_main.c
index 31809ca..56cc10e 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -334,8 +334,8 @@ void drm_sched_increase_karma(struct drm_sched_job *bad)
 
spin_lock(>lock);
list_for_each_entry_safe(entity, tmp, >entities, 
list) {
-   if (bad->s_fence->scheduled.context ==
-   entity->fence_context) {
+   if (bad->s_fence && 
(bad->s_fence->scheduled.context ==
+   entity->fence_context)) {
if (atomic_read(>karma) >
bad->sched->hang_limit)
if (entity->guilty)
@@ -376,7 +376,7 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct 
drm_sched_job *bad)
 * This iteration is thread safe as sched thread is stopped.
 */
list_for_each_entry_safe_reverse(s_job, tmp, >ring_mirror_list, 
node) {
-   if (s_job->s_fence->parent &&
+   if (s_job->s_fence && s_job->s_fence->parent &&
dma_fence_remove_callback(s_job->s_fence->parent,
  _job->cb)) {
atomic_dec(>hw_rq_count);
@@ -395,7 +395,8 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct 
drm_sched_job *bad)
 *
 * Job is still alive so fence refcount at least 1
 */
-   dma_fence_wait(_job->s_fence->finished, false);
+   if (s_job->s_fence)
+   dma_fence_wait(_job->s_fence->finished, 
false);
 
/*
 * We must keep bad job alive for later use during
@@ -438,7 +439,7 @@ void drm_sched_start(struct drm_gpu_scheduler *sched, bool 
full_recovery)
 * GPU recovers can't run in parallel.
 */
list_for_each_entry_safe(s_job, tmp, >ring_mirror_list, node) {
-   struct dma_fence *fence = s_job->s_fence->parent;
+   struct dma_fence *fence = s_job->s_fence ? 
s_job->s_fence->parent : NULL;
 
atomic_inc(>hw_rq_count);
 
-- 
2.7.4

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

[PATCH] drm/amdgpu: Need to disable msix when unloading driver

2019-11-05 Thread Emily Deng
For driver reload test, it will report "can't enable
MSI (MSI-X already enabled)".

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 6f3b03f..30d540d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -311,7 +311,7 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)
drm_irq_uninstall(adev->ddev);
adev->irq.installed = false;
if (adev->irq.msi_enabled)
-   pci_disable_msi(adev->pdev);
+   pci_free_irq_vectors(adev->pdev);
if (!amdgpu_device_has_dc_support(adev))
flush_work(>hotplug_work);
}
-- 
2.7.4

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

[PATCH] drm/amdgpu: Need to disable msix when unloading driver

2019-11-05 Thread Emily Deng
For driver reload test, it will report "can't enable
MSI (MSI-X already enabled)".

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 6040eb3..48d9cf0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -325,7 +325,11 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)
drm_irq_uninstall(adev->ddev);
adev->irq.installed = false;
if (adev->irq.msi_enabled)
+#ifdef PCI_IRQ_MSI
+   pci_free_irq_vectors(adev->pdev);
+#else
pci_disable_msi(adev->pdev);
+#endif
if (!amdgpu_device_has_dc_support(adev))
flush_work(>hotplug_work);
}
-- 
2.7.4

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

[PATCH] drm/amdgpu/discovery: Need to free discovery memory

2019-11-03 Thread Emily Deng
When unloading driver, need to free discovery memory.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 28b09f6..7cbe6d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2106,9 +2106,6 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)
void *stolen_vga_buf;
/* return the VGA stolen memory (if any) back to VRAM */
amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
-
-   /* return the IP Discovery TMR memory back to VRAM */
-   amdgpu_bo_free_kernel(>discovery_memory, NULL, NULL);
 }
 
 /**
@@ -2121,7 +2118,10 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
amdgpu_ttm_debugfs_fini(adev);
amdgpu_ttm_training_reserve_vram_fini(adev);
+   /* return the IP Discovery TMR memory back to VRAM */
+   amdgpu_bo_free_kernel(>discovery_memory, NULL, NULL);
amdgpu_ttm_fw_reserve_vram_fini(adev);
+
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
adev->mman.aper_base_kaddr = NULL;
-- 
2.7.4

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

[PATCH v2] drm/amdgpu: Need to free discovery memory

2019-11-03 Thread Emily Deng
When unloading driver, need to free discovery memory.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 28b09f6..7cbe6d9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2106,9 +2106,6 @@ void amdgpu_ttm_late_init(struct amdgpu_device *adev)
void *stolen_vga_buf;
/* return the VGA stolen memory (if any) back to VRAM */
amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, _vga_buf);
-
-   /* return the IP Discovery TMR memory back to VRAM */
-   amdgpu_bo_free_kernel(>discovery_memory, NULL, NULL);
 }
 
 /**
@@ -2121,7 +2118,10 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
 
amdgpu_ttm_debugfs_fini(adev);
amdgpu_ttm_training_reserve_vram_fini(adev);
+   /* return the IP Discovery TMR memory back to VRAM */
+   amdgpu_bo_free_kernel(>discovery_memory, NULL, NULL);
amdgpu_ttm_fw_reserve_vram_fini(adev);
+
if (adev->mman.aper_base_kaddr)
iounmap(adev->mman.aper_base_kaddr);
adev->mman.aper_base_kaddr = NULL;
-- 
2.7.4

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

[PATCH] drm/amdgpu: Need to free discovery memory

2019-11-01 Thread Emily Deng
When unloading driver, need to free discovery memory.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 9f2a893..50d6ed2 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1091,8 +1091,11 @@ static int gmc_v9_0_sw_fini(void *handle)
amdgpu_gem_force_release(adev);
amdgpu_vm_manager_fini(adev);
 
-   if (gmc_v9_0_keep_stolen_memory(adev))
+   if (gmc_v9_0_keep_stolen_memory(adev)) {
amdgpu_bo_free_kernel(>stolen_vga_memory, NULL, 
_vga_buf);
+   /* return the IP Discovery TMR memory back to VRAM */
+   amdgpu_bo_free_kernel(>discovery_memory, NULL, NULL);
+   }
 
amdgpu_gart_table_vram_free(adev);
amdgpu_bo_fini(adev);
-- 
2.7.4

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

[PATCH] SWDEV-206718 drm/amdgpu: Fix tdr3 could hang with slow compute issue

2019-10-09 Thread Emily Deng
When index is 1, need to set compute ring timeout for sriov and passthrough.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c| 6 --
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 53ce227..2f5a015 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2664,8 +2664,11 @@ static int amdgpu_device_get_job_timeout_settings(struct 
amdgpu_device *adev)
 * There is only one value specified and
 * it should apply to all non-compute jobs.
 */
-   if (index == 1)
+   if (index == 1) {
adev->sdma_timeout = adev->video_timeout = 
adev->gfx_timeout;
+   if (amdgpu_sriov_vf(adev) || amdgpu_passthrough(adev))
+   adev->compute_timeout = adev->gfx_timeout;
+   }
}
 
return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index a88ea74..311abc8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -250,9 +250,11 @@ module_param_named(msi, amdgpu_msi, int, 0444);
  * By default(with no lockup_timeout settings), the timeout for all 
non-compute(GFX, SDMA and Video)
  * jobs is 1. And there is no timeout enforced on compute jobs.
  */
-MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default: 1 for 
non-compute jobs and infinity timeout for compute jobs."
+MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default: for bare 
metal 1 for non-compute jobs and infinity timeout for compute jobs; "
+   "for passthrough or sriov, 1 for all jobs."
" 0: keep default value. negative: infinity timeout), "
-   "format is [Non-Compute] or [GFX,Compute,SDMA,Video]");
+   "format: for bare metal [Non-Compute] or 
[GFX,Compute,SDMA,Video]; "
+   "for passthrough or sriov [all jobs] or 
[GFX,Compute,SDMA,Video].");
 module_param_string(lockup_timeout, amdgpu_lockup_timeout, 
sizeof(amdgpu_lockup_timeout), 0444);
 
 /**
-- 
2.7.4

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

[PATCH] SWDEV-197284 - drm/amdgpu: Only use the peek function in productor side is not correct

2019-08-12 Thread Emily Deng
For spsc queue, use peek function would cause error in productor side.
As for the last element, when the push job is occurring during pop job, the 
peek function
will not be updated in time, and it will return NULL.

So use queue count for double confirming the job queue is empty.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/scheduler/sched_entity.c | 4 ++--
 include/drm/spsc_queue.h | 7 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
b/drivers/gpu/drm/scheduler/sched_entity.c
index 35ddbec..e74894f 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -95,7 +95,7 @@ static bool drm_sched_entity_is_idle(struct drm_sched_entity 
*entity)
rmb(); /* for list_empty to work without lock */
 
if (list_empty(>list) ||
-   spsc_queue_peek(>job_queue) == NULL)
+   ((spsc_queue_peek(>job_queue) == NULL) && 
!spsc_queue_count(>job_queue)))
return true;
 
return false;
@@ -281,7 +281,7 @@ void drm_sched_entity_fini(struct drm_sched_entity *entity)
/* Consumption of existing IBs wasn't completed. Forcefully
 * remove them here.
 */
-   if (spsc_queue_peek(>job_queue)) {
+   if ((spsc_queue_peek(>job_queue) == NULL) && 
!spsc_queue_count(>job_queue)) {
if (sched) {
/* Park the kernel for a moment to make sure it isn't 
processing
 * our enity.
diff --git a/include/drm/spsc_queue.h b/include/drm/spsc_queue.h
index 125f096..78092b9 100644
--- a/include/drm/spsc_queue.h
+++ b/include/drm/spsc_queue.h
@@ -54,9 +54,8 @@ static inline void spsc_queue_init(struct spsc_queue *queue)
 
 static inline struct spsc_node *spsc_queue_peek(struct spsc_queue *queue)
 {
-   return queue->head;
+   return READ_ONCE(queue->head);
 }
-
 static inline int spsc_queue_count(struct spsc_queue *queue)
 {
return atomic_read(>job_count);
@@ -70,9 +69,9 @@ static inline bool spsc_queue_push(struct spsc_queue *queue, 
struct spsc_node *n
 
preempt_disable();
 
+   atomic_inc(>job_count);
tail = (struct spsc_node **)atomic_long_xchg(>tail, 
(long)>next);
WRITE_ONCE(*tail, node);
-   atomic_inc(>job_count);
 
/*
 * In case of first element verify new node will be visible to the 
consumer
@@ -93,6 +92,7 @@ static inline struct spsc_node *spsc_queue_pop(struct 
spsc_queue *queue)
/* Verify reading from memory and not the cache */
smp_rmb();
 
+   atomic_dec(>job_count);
node = READ_ONCE(queue->head);
 
if (!node)
@@ -113,7 +113,6 @@ static inline struct spsc_node *spsc_queue_pop(struct 
spsc_queue *queue)
}
}
 
-   atomic_dec(>job_count);
return node;
 }
 
-- 
2.7.4

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

[PATCH] drm/ttm: Fix the memory delay free issue

2019-07-10 Thread Emily Deng
For vulkan cts allocation test cases, they will create a series of bos, and 
then free
them. As it has lots of alloction test cases with the same vm, as per vm
bo feature enable, all of those bos' resv are the same. But the bo free is 
quite slow,
as they use the same resv object, for every time, free a bo,
it will check the resv whether signal, if it signal, then will free it. But
as the test cases will continue to create bo, and the resv fence is increasing. 
So the
free is more slower than creating. It will cause memory exhausting.

Method:
When the resv signal, release all the bos which are use the same
resv object.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f9a3d4c..57ec59b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -543,6 +543,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
 {
struct ttm_bo_global *glob = bo->bdev->glob;
struct reservation_object *resv;
+   struct ttm_buffer_object *resv_bo, *resv_bo_next;
int ret;
 
if (unlikely(list_empty(>ddestroy)))
@@ -566,10 +567,14 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object 
*bo,
   interruptible,
   30 * HZ);
 
-   if (lret < 0)
+   if (lret < 0) {
+   kref_put(>list_kref, ttm_bo_release_list);
return lret;
-   else if (lret == 0)
+   }
+   else if (lret == 0) {
+   kref_put(>list_kref, ttm_bo_release_list);
return -EBUSY;
+   }
 
spin_lock(>lru_lock);
if (unlock_resv && !kcl_reservation_object_trylock(bo->resv)) {
@@ -582,6 +587,7 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo,
 * here.
 */
spin_unlock(>lru_lock);
+   kref_put(>list_kref, ttm_bo_release_list);
return 0;
}
ret = 0;
@@ -591,15 +597,29 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object 
*bo,
if (unlock_resv)
kcl_reservation_object_unlock(bo->resv);
spin_unlock(>lru_lock);
+   kref_put(>list_kref, ttm_bo_release_list);
return ret;
}
 
ttm_bo_del_from_lru(bo);
list_del_init(>ddestroy);
kref_put(>list_kref, ttm_bo_ref_bug);
-
spin_unlock(>lru_lock);
ttm_bo_cleanup_memtype_use(bo);
+   kref_put(>list_kref, ttm_bo_release_list);
+
+   spin_lock(>lru_lock);
+   list_for_each_entry_safe(resv_bo, resv_bo_next, >bdev->ddestroy, 
ddestroy) {
+   if (resv_bo->resv == bo->resv) {
+   ttm_bo_del_from_lru(resv_bo);
+   list_del_init(_bo->ddestroy);
+   spin_unlock(>lru_lock);
+   ttm_bo_cleanup_memtype_use(resv_bo);
+   kref_put(_bo->list_kref, ttm_bo_release_list);
+   spin_lock(>lru_lock);
+   }
+   }
+   spin_unlock(>lru_lock);
 
if (unlock_resv)
kcl_reservation_object_unlock(bo->resv);
@@ -639,9 +659,8 @@ static bool ttm_bo_delayed_delete(struct ttm_bo_device 
*bdev, bool remove_all)
ttm_bo_cleanup_refs(bo, false, !remove_all, true);
} else {
spin_unlock(>lru_lock);
+   kref_put(>list_kref, ttm_bo_release_list);
}
-
-   kref_put(>list_kref, ttm_bo_release_list);
spin_lock(>lru_lock);
}
list_splice_tail(, >ddestroy);
-- 
2.7.4

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

[PATCH] drm/amdgpu: Fix the null pointer about get vbios

2019-06-17 Thread Emily Deng
Move the get vbios only before SDMA block early init to fix null pointer
about get vbios.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 4a836db..830c4b8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1534,18 +1534,19 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
if (amdgpu_sriov_vf(adev))
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
 
-   /* Read BIOS */
-   if (!amdgpu_get_bios(adev))
-   return -EINVAL;
-
-   r = amdgpu_atombios_init(adev);
-   if (r) {
-   dev_err(adev->dev, "amdgpu_atombios_init failed\n");
-   amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 
0, 0);
-   return r;
-   }
-
for (i = 0; i < adev->num_ip_blocks; i++) {
+   if ( adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SDMA 
) {
+   /* Read BIOS */
+   if (!amdgpu_get_bios(adev))
+   return -EINVAL;
+
+   r = amdgpu_atombios_init(adev);
+   if (r) {
+   dev_err(adev->dev, "amdgpu_atombios_init 
failed\n");
+   amdgpu_vf_error_put(adev, 
AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 0, 0);
+   return r;
+   }
+   }
if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
DRM_ERROR("disabled ip block: %d <%s>\n",
  i, adev->ip_blocks[i].version->funcs->name);
-- 
2.7.4

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

[PATCH] drm/amdgpu/sriov: Correct some register program method

2019-05-31 Thread Emily Deng
For the VF, some registers only could be programmed with RLC.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c| 10 +-
 drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c |  8 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index cc5a382..2e9cac1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1927,17 +1927,17 @@ static void gfx_v9_0_constants_init(struct 
amdgpu_device *adev)
if (i == 0) {
tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
SH_MEM_ALIGNMENT_MODE_UNALIGNED);
-   WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
-   WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0);
+   WREG32_SOC15_RLC(GC, 0, mmSH_MEM_CONFIG, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmSH_MEM_BASES, 0);
} else {
tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
SH_MEM_ALIGNMENT_MODE_UNALIGNED);
-   WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmSH_MEM_CONFIG, tmp);
tmp = REG_SET_FIELD(0, SH_MEM_BASES, PRIVATE_BASE,
(adev->gmc.private_aperture_start >> 48));
tmp = REG_SET_FIELD(tmp, SH_MEM_BASES, SHARED_BASE,
(adev->gmc.shared_aperture_start >> 48));
-   WREG32_SOC15(GC, 0, mmSH_MEM_BASES, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmSH_MEM_BASES, tmp);
}
}
soc15_grbm_select(adev, 0, 0, 0, 0);
@@ -3046,7 +3046,7 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring 
*ring)
(adev->doorbell_index.userqueue_end * 
2) << 2);
}
 
-   WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
+   WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
   mqd->cp_hqd_pq_doorbell_control);
 
/* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
index 0dc8926..9f0f189 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
@@ -146,12 +146,12 @@ static void gfxhub_v1_0_init_cache_regs(struct 
amdgpu_device *adev)
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, PDE_FAULT_CLASSIFICATION, 0);
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, CONTEXT1_IDENTITY_ACCESS_MODE, 1);
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, IDENTITY_MODE_FRAGMENT_SIZE, 0);
-   WREG32_SOC15(GC, 0, mmVM_L2_CNTL, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmVM_L2_CNTL, tmp);
 
tmp = RREG32_SOC15(GC, 0, mmVM_L2_CNTL2);
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS, 1);
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1);
-   WREG32_SOC15(GC, 0, mmVM_L2_CNTL2, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmVM_L2_CNTL2, tmp);
 
tmp = mmVM_L2_CNTL3_DEFAULT;
if (adev->gmc.translate_further) {
@@ -163,12 +163,12 @@ static void gfxhub_v1_0_init_cache_regs(struct 
amdgpu_device *adev)
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
L2_CACHE_BIGK_FRAGMENT_SIZE, 6);
}
-   WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmVM_L2_CNTL3, tmp);
 
tmp = mmVM_L2_CNTL4_DEFAULT;
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PDE_REQUEST_PHYSICAL, 0);
tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PTE_REQUEST_PHYSICAL, 0);
-   WREG32_SOC15(GC, 0, mmVM_L2_CNTL4, tmp);
+   WREG32_SOC15_RLC(GC, 0, mmVM_L2_CNTL4, tmp);
 }
 
 static void gfxhub_v1_0_enable_system_domain(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 v2] drm/amdgpu/display: Fix reload driver error

2019-05-28 Thread Emily Deng
Issue:
Will have follow error when reload driver:
[ 3986.567739] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:07.0/drm_dp_aux_dev'
[ 3986.567743] CPU: 6 PID: 1767 Comm: modprobe Tainted: G   OE 
5.0.0-rc1-custom #1
[ 3986.567745] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
Ubuntu-1.8.2-1ubuntu1 04/01/2014
[ 3986.567746] Call Trace:
..
[ 3986.567808]  drm_dp_aux_register_devnode+0xdc/0x140 [drm_kms_helper]
..
[ 3986.569081] kobject_add_internal failed for drm_dp_aux_dev with -EEXIST, 
don't try to register things with the same name in the same directory.

Reproduce sequences:
1.modprobe amdgpu
2.modprobe -r amdgpu
3.modprobe amdgpu

Root cause:
When unload driver, it doesn't unregister aux.

v2: Don't use has_aux

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 8fe1685..941313b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3760,6 +3760,13 @@ int amdgpu_dm_connector_atomic_get_property(struct 
drm_connector *connector,
return ret;
 }
 
+static void amdgpu_dm_connector_unregister(struct drm_connector *connector)
+{
+   struct amdgpu_dm_connector *amdgpu_dm_connector = 
to_amdgpu_dm_connector(connector);
+
+   drm_dp_aux_unregister(_dm_connector->dm_dp_aux.aux);
+}
+
 static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
 {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
@@ -3788,6 +3795,11 @@ static void amdgpu_dm_connector_destroy(struct 
drm_connector *connector)
drm_dp_cec_unregister_connector(>dm_dp_aux.aux);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
+   if (aconnector->i2c) {
+   i2c_del_adapter(>i2c->base);
+   kfree(aconnector->i2c);
+   }
+
kfree(connector);
 }
 
@@ -3846,7 +3858,8 @@ static const struct drm_connector_funcs 
amdgpu_dm_connector_funcs = {
.atomic_duplicate_state = amdgpu_dm_connector_atomic_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_set_property = amdgpu_dm_connector_atomic_set_property,
-   .atomic_get_property = amdgpu_dm_connector_atomic_get_property
+   .atomic_get_property = amdgpu_dm_connector_atomic_get_property,
+   .early_unregister = amdgpu_dm_connector_unregister
 };
 
 static int get_modes(struct drm_connector *connector)
-- 
2.7.4

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

[PATCH] drm/amdgpu/display: Fix reload driver error

2019-05-28 Thread Emily Deng
Issue:
Will have follow error when reload driver:
[ 3986.567739] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:07.0/drm_dp_aux_dev'
[ 3986.567743] CPU: 6 PID: 1767 Comm: modprobe Tainted: G   OE 
5.0.0-rc1-custom #1
[ 3986.567745] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
Ubuntu-1.8.2-1ubuntu1 04/01/2014
[ 3986.567746] Call Trace:
..
[ 3986.567808]  drm_dp_aux_register_devnode+0xdc/0x140 [drm_kms_helper]
..
[ 3986.569081] kobject_add_internal failed for drm_dp_aux_dev with -EEXIST, 
don't try to register things with the same name in the same directory.

Reproduce sequences:
1.modprobe amdgpu
2.modprobe -r amdgpu
3.modprobe amdgpu

Root cause:
When unload driver, it don't unregister aux.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   |  1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c|  6 +-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index e48fd35..720955b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -525,6 +525,7 @@ enum amdgpu_connector_dither {
 struct amdgpu_dm_dp_aux {
struct drm_dp_aux aux;
struct ddc_service *ddc_service;
+   bool has_aux;
 };
 
 struct amdgpu_i2c_adapter {
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 8fe1685..de369ae 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3760,6 +3760,16 @@ int amdgpu_dm_connector_atomic_get_property(struct 
drm_connector *connector,
return ret;
 }
 
+static void amdgpu_dm_connector_unregister(struct drm_connector *connector)
+{
+   struct amdgpu_dm_connector *amdgpu_dm_connector = 
to_amdgpu_dm_connector(connector);
+
+   if (amdgpu_dm_connector->dm_dp_aux.has_aux) {
+   drm_dp_aux_unregister(_dm_connector->dm_dp_aux.aux);
+   amdgpu_dm_connector->dm_dp_aux.has_aux = false;
+   }
+}
+
 static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
 {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
@@ -3788,6 +3798,11 @@ static void amdgpu_dm_connector_destroy(struct 
drm_connector *connector)
drm_dp_cec_unregister_connector(>dm_dp_aux.aux);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
+   if (aconnector->i2c) {
+   i2c_del_adapter(>i2c->base);
+   kfree(aconnector->i2c);
+   }
+
kfree(connector);
 }
 
@@ -3846,7 +3861,8 @@ static const struct drm_connector_funcs 
amdgpu_dm_connector_funcs = {
.atomic_duplicate_state = amdgpu_dm_connector_atomic_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
.atomic_set_property = amdgpu_dm_connector_atomic_set_property,
-   .atomic_get_property = amdgpu_dm_connector_atomic_get_property
+   .atomic_get_property = amdgpu_dm_connector_atomic_get_property,
+   .early_unregister = amdgpu_dm_connector_unregister
 };
 
 static int get_modes(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 6e205ee..190e92c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -387,12 +387,16 @@ static const struct drm_dp_mst_topology_cbs dm_mst_cbs = {
 void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
   struct amdgpu_dm_connector *aconnector)
 {
+   int ret;
aconnector->dm_dp_aux.aux.name = "dmdc";
aconnector->dm_dp_aux.aux.dev = dm->adev->dev;
aconnector->dm_dp_aux.aux.transfer = dm_dp_aux_transfer;
aconnector->dm_dp_aux.ddc_service = aconnector->dc_link->ddc;
 
-   drm_dp_aux_register(>dm_dp_aux.aux);
+   ret = drm_dp_aux_register(>dm_dp_aux.aux);
+   if (!ret)
+   aconnector->dm_dp_aux.has_aux = true;
+
drm_dp_cec_register_connector(>dm_dp_aux.aux,
  aconnector->base.name, dm->adev->dev);
aconnector->mst_mgr.cbs = _mst_cbs;
-- 
2.7.4

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

[PATCH] drm/amdgpu:Fix the unpin warning about csb buffer

2019-05-28 Thread Emily Deng
As it will destroy clear_state_obj, and also will unpin it in the
gfx_v9_0_sw_fini, so don't need to
call amdgpu_bo_free_kernel in gfx_v9_0_sw_fini, or it will have unpin warning.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index c763733..cc5a382 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1794,9 +1794,7 @@ static int gfx_v9_0_sw_fini(void *handle)
 
gfx_v9_0_mec_fini(adev);
gfx_v9_0_ngg_fini(adev);
-   amdgpu_bo_free_kernel(>gfx.rlc.clear_state_obj,
-   >gfx.rlc.clear_state_gpu_addr,
-   (void **)>gfx.rlc.cs_ptr);
+   amdgpu_bo_unref(>gfx.rlc.clear_state_obj);
if (adev->asic_type == CHIP_RAVEN) {
amdgpu_bo_free_kernel(>gfx.rlc.cp_table_obj,
>gfx.rlc.cp_table_gpu_addr,
-- 
2.7.4

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

[PATCH] drm/amdgpu: Don't need to call csb_vram_unpin

2019-05-27 Thread Emily Deng
As it will destroy clear_state_obj, and also will
unpin it in the gfx_v9_0_sw_fini, so don't need to
call csb_vram unpin in gfx_v9_0_hw_fini, or it will
have unpin warning.

v2: For suspend, still need to do unpin

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

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index 5eb70e8..5b1ff48 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3395,7 +3395,8 @@ static int gfx_v9_0_hw_fini(void *handle)
gfx_v9_0_cp_enable(adev, false);
adev->gfx.rlc.funcs->stop(adev);
 
-   gfx_v9_0_csb_vram_unpin(adev);
+   if (adev->in_suspend)
+   gfx_v9_0_csb_vram_unpin(adev);
 
return 0;
 }
-- 
2.7.4

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

[PATCH] drm/amdgpu: Need to set the baco cap before baco reset

2019-05-27 Thread Emily Deng
For passthrough, after rebooted the VM, driver will do
a baco reset before doing other driver initialization during loading
 driver. For doing the baco reset, it will first
check the baco reset capability. So first need to set the
cap from the vbios information or baco reset won't be
enabled.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 24 ++
 drivers/gpu/drm/amd/amdgpu/soc15.c |  3 ++-
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  4 
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 24 ++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 5 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b6ded84..7a8c220 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1541,6 +1541,17 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
if (amdgpu_sriov_vf(adev))
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
 
+   /* Read BIOS */
+   if (!amdgpu_get_bios(adev))
+   return -EINVAL;
+
+   r = amdgpu_atombios_init(adev);
+   if (r) {
+   dev_err(adev->dev, "amdgpu_atombios_init failed\n");
+   amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 
0, 0);
+   return r;
+   }
+
for (i = 0; i < adev->num_ip_blocks; i++) {
if ((amdgpu_ip_block_mask & (1 << i)) == 0) {
DRM_ERROR("disabled ip block: %d <%s>\n",
@@ -2591,19 +2602,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
goto fence_driver_init;
}
 
-   /* Read BIOS */
-   if (!amdgpu_get_bios(adev)) {
-   r = -EINVAL;
-   goto failed;
-   }
-
-   r = amdgpu_atombios_init(adev);
-   if (r) {
-   dev_err(adev->dev, "amdgpu_atombios_init failed\n");
-   amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 
0, 0);
-   goto failed;
-   }
-
/* detect if we are with an SRIOV vbios */
amdgpu_device_detect_sriov_bios(adev);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 78bd4fc..d9fdd95 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -764,7 +764,8 @@ static bool soc15_need_reset_on_init(struct amdgpu_device 
*adev)
/* Just return false for soc15 GPUs.  Reset does not seem to
 * be necessary.
 */
-   return false;
+   if (!amdgpu_passthrough(adev))
+   return false;
 
if (adev->flags & AMD_IS_APU)
return false;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index ce6aeb5..1d9bb29 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5311,8 +5311,12 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
 
 int vega10_hwmgr_init(struct pp_hwmgr *hwmgr)
 {
+   struct amdgpu_device *adev = hwmgr->adev;
+
hwmgr->hwmgr_func = _hwmgr_funcs;
hwmgr->pptable_func = _pptable_funcs;
+   if (amdgpu_passthrough(adev))
+   return vega10_baco_set_cap(hwmgr);
 
return 0;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index b6767d7..83d22cd 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -1371,3 +1371,27 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr 
*hwmgr,
 
return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+{
+   int result = 0;
+
+   const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+   powerplay_table = get_powerplay_table(hwmgr);
+
+   PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+   "Missing PowerPlay Table!", return -1);
+
+   result = check_powerplay_tables(hwmgr, powerplay_table);
+
+   PP_ASSERT_WITH_CODE((result == 0),
+   "check_powerplay_tables failed", return result);
+
+   set_hw_cap(
+   hwmgr,
+   0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) & 
ATOM_VEGA10_PP_PLATFORM_CAP_BACO),
+   PHM_PlatformCaps_BACO);
+   return result;
+}
+
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h
index d83ed2a..da5fbec 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h
+++ b/drivers/gpu/drm/amd/powerpl

[PATCH] drm/amdgpu: Don't need to call csb_vram_unpin

2019-05-24 Thread Emily Deng
As it will destory clear_state_obj, and also will
unpin it in the gfx_v9_0_sw_fini, so don't need to
call csb_vram unpin in gfx_v9_0_hw_fini, or it will
have unpin warning.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index c763733..231b9e0 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1154,20 +1154,6 @@ static int gfx_v9_0_csb_vram_pin(struct amdgpu_device 
*adev)
return r;
 }
 
-static void gfx_v9_0_csb_vram_unpin(struct amdgpu_device *adev)
-{
-   int r;
-
-   if (!adev->gfx.rlc.clear_state_obj)
-   return;
-
-   r = amdgpu_bo_reserve(adev->gfx.rlc.clear_state_obj, true);
-   if (likely(r == 0)) {
-   amdgpu_bo_unpin(adev->gfx.rlc.clear_state_obj);
-   amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
-   }
-}
-
 static void gfx_v9_0_mec_fini(struct amdgpu_device *adev)
 {
amdgpu_bo_free_kernel(>gfx.mec.hpd_eop_obj, NULL, NULL);
@@ -3385,8 +3371,6 @@ static int gfx_v9_0_hw_fini(void *handle)
gfx_v9_0_cp_enable(adev, false);
adev->gfx.rlc.funcs->stop(adev);
 
-   gfx_v9_0_csb_vram_unpin(adev);
-
return 0;
 }
 
-- 
2.7.4

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

[PATCH] drm/amdgpu: fix unload driver fail

2019-05-24 Thread Emily Deng
dc_destroy should be called amdgpu_cgs_destroy_device,
as it will use cgs context to read or write registers.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index fd04217..f558c9c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -616,6 +616,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 static void amdgpu_dm_fini(struct amdgpu_device *adev)
 {
amdgpu_dm_destroy_drm_device(>dm);
+
+   /* DC Destroy TODO: Replace destroy DAL */
+   if (adev->dm.dc)
+   dc_destroy(>dm.dc);
/*
 * TODO: pageflip, vlank interrupt
 *
@@ -630,9 +634,6 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
mod_freesync_destroy(adev->dm.freesync_module);
adev->dm.freesync_module = NULL;
}
-   /* DC Destroy TODO: Replace destroy DAL */
-   if (adev->dm.dc)
-   dc_destroy(>dm.dc);
 
mutex_destroy(>dm.dc_lock);
 
-- 
2.7.4

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

[PATCH] drm/amdgpu: Need to set the baco cap before baco reset

2019-05-23 Thread Emily Deng
For passthrough, after rebooted the VM, driver will do
a baco reset before doing other driver initialization during loading
 driver. For doing the baco reset, it will first
check the baco reset capability. So first need to set the
cap from the vbios information or baco reset won't be
enabled.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  8 
 drivers/gpu/drm/amd/amdgpu/soc15.c |  3 ++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 16 +++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 24 ++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h  |  1 +
 8 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index bdd1fe73..2dde672 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2611,6 +2611,14 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 *  E.g., driver was not cleanly unloaded previously, etc.
 */
if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+   if (amdgpu_passthrough(adev) && adev->powerplay.pp_funcs && 
adev->powerplay.pp_funcs->set_asic_baco_cap) {
+   r = 
adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+   if (r) {
+   dev_err(adev->dev, "set baco capability 
failed\n");
+   goto failed;
+   }
+   }
+
r = amdgpu_asic_reset(adev);
if (r) {
dev_err(adev->dev, "asic reset on init failed\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 78bd4fc..d9fdd95 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -764,7 +764,8 @@ static bool soc15_need_reset_on_init(struct amdgpu_device 
*adev)
/* Just return false for soc15 GPUs.  Reset does not seem to
 * be necessary.
 */
-   return false;
+   if (!amdgpu_passthrough(adev))
+   return false;
 
if (adev->flags & AMD_IS_APU)
return false;
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h 
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 9f661bf..c6e2a51 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -296,6 +296,7 @@ struct amd_pm_funcs {
int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
int (*get_asic_baco_capability)(void *handle, bool *cap);
+   int (*set_asic_baco_cap)(void *handle);
int (*get_asic_baco_state)(void *handle, int *state);
int (*set_asic_baco_state)(void *handle, int state);
int (*get_ppfeature_status)(void *handle, char *buf);
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bea1587..9856760 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, 
uint32_t count)
return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+   struct pp_hwmgr *hwmgr = handle;
+
+   if (!hwmgr)
+   return -EINVAL;
+
+   if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+   return 0;
+
+   hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+   return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
.set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
.get_asic_baco_capability = pp_get_asic_baco_capability,
+   .set_asic_baco_cap = pp_set_asic_baco_cap,
.get_asic_baco_state = pp_get_asic_baco_state,
.set_asic_baco_state = pp_set_asic_baco_state,
.get_ppfeature_status = pp_get_ppfeature_status,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index ce6aeb5..e5bcbc8 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5302,6 +5302,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
.odn_edit_dpm_table = vega10_odn_edit_dpm_table,
  

[PATCH] Revert "drm/amdgpu: Need to set the baco cap before baco reset"

2019-05-23 Thread Emily Deng
This reverts commit 13f2a375b58918873833cf6859332f960c6cf922.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  1 -
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 16 
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 -
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 --
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 -
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h  |  1 -
 7 files changed, 1 insertion(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 242c38c..bdd1fe73 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2610,15 +2610,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* check if we need to reset the asic
 *  E.g., driver was not cleanly unloaded previously, etc.
 */
-   if (amdgpu_passthrough(adev) && amdgpu_asic_need_reset_on_init(adev)) {
-   if (adev->powerplay.pp_funcs && 
adev->powerplay.pp_funcs->set_asic_baco_cap) {
-   r = 
adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
-   if (r) {
-   dev_err(adev->dev, "set baco capability 
failed\n");
-   goto failed;
-   }
-   }
-
+   if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
r = amdgpu_asic_reset(adev);
if (r) {
dev_err(adev->dev, "asic reset on init failed\n");
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h 
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index c6e2a51..9f661bf 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -296,7 +296,6 @@ struct amd_pm_funcs {
int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
int (*get_asic_baco_capability)(void *handle, bool *cap);
-   int (*set_asic_baco_cap)(void *handle);
int (*get_asic_baco_state)(void *handle, int *state);
int (*set_asic_baco_state)(void *handle, int state);
int (*get_ppfeature_status)(void *handle, char *buf);
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 9856760..bea1587 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1404,21 +1404,6 @@ static int pp_set_active_display_count(void *handle, 
uint32_t count)
return ret;
 }
 
-static int pp_set_asic_baco_cap(void *handle)
-{
-   struct pp_hwmgr *hwmgr = handle;
-
-   if (!hwmgr)
-   return -EINVAL;
-
-   if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
-   return 0;
-
-   hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
-
-   return 0;
-}
-
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
struct pp_hwmgr *hwmgr = handle;
@@ -1561,7 +1546,6 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
.set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
.get_asic_baco_capability = pp_get_asic_baco_capability,
-   .set_asic_baco_cap = pp_set_asic_baco_cap,
.get_asic_baco_state = pp_get_asic_baco_state,
.set_asic_baco_state = pp_set_asic_baco_state,
.get_ppfeature_status = pp_get_ppfeature_status,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index e5bcbc8..ce6aeb5 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5302,7 +5302,6 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
.odn_edit_dpm_table = vega10_odn_edit_dpm_table,
.get_performance_level = vega10_get_performance_level,
.get_asic_baco_capability = smu9_baco_get_capability,
-   .set_asic_baco_cap = vega10_baco_set_cap,
.get_asic_baco_state = smu9_baco_get_state,
.set_asic_baco_state = vega10_baco_set_state,
.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index 8fdeb23..b6767d7 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -1371,25 +1371,3 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr 
*hwmgr,
 
return resu

[PATCH v2] drm/amdgpu: Need to set the baco cap before baco reset

2019-05-22 Thread Emily Deng
Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 16 
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 ++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h  |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d6286ed..5288763 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* check if we need to reset the asic
 *  E.g., driver was not cleanly unloaded previously, etc.
 */
-   if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+   if (amdgpu_passthrough(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+   if (adev->powerplay.pp_funcs && 
adev->powerplay.pp_funcs->set_asic_baco_cap) {
+   r = 
adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+   if (r) {
+   dev_err(adev->dev, "set baco capability 
failed\n");
+   goto failed;
+   }
+   }
+
r = amdgpu_asic_reset(adev);
if (r) {
dev_err(adev->dev, "asic reset on init failed\n");
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h 
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 2b579ba..0dcc18d 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
int (*get_asic_baco_capability)(void *handle, bool *cap);
+   int (*set_asic_baco_cap)(void *handle);
int (*get_asic_baco_state)(void *handle, int *state);
int (*set_asic_baco_state)(void *handle, int state);
int (*get_ppfeature_status)(void *handle, char *buf);
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bea1587..9856760 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, 
uint32_t count)
return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+   struct pp_hwmgr *hwmgr = handle;
+
+   if (!hwmgr)
+   return -EINVAL;
+
+   if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+   return 0;
+
+   hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+   return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
.set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
.get_asic_baco_capability = pp_get_asic_baco_capability,
+   .set_asic_baco_cap = pp_set_asic_baco_cap,
.get_asic_baco_state = pp_get_asic_baco_state,
.set_asic_baco_state = pp_set_asic_baco_state,
.get_ppfeature_status = pp_get_ppfeature_status,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index ed6c638..8dc23eb 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
.odn_edit_dpm_table = vega10_odn_edit_dpm_table,
.get_performance_level = vega10_get_performance_level,
.get_asic_baco_capability = smu9_baco_get_capability,
+   .set_asic_baco_cap = vega10_baco_set_cap,
.get_asic_baco_state = smu9_baco_get_state,
.set_asic_baco_state = vega10_baco_set_state,
.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index b6767d7..8fdeb23 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr 
*hwmgr,
 
return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+

[PATCH] drm/amdgpu: Need to set the baco cap before baco reset

2019-05-22 Thread Emily Deng
For passthrough, after rebooted the VM, driver will do
a baco reset before doing other driver initialization during loading
 driver. For doing the baco reset, it will first
check the baco reset capability. So first need to set the
cap from the vbios information or baco reset won't be
enabled.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  8 
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  | 16 
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 ++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h  |  1 +
 7 files changed, 50 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d6286ed..14415b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2606,6 +2606,14 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 *  E.g., driver was not cleanly unloaded previously, etc.
 */
if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+   if (adev->powerplay.pp_funcs && 
adev->powerplay.pp_funcs->set_asic_baco_cap) {
+   r = 
adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+   if (r) {
+   dev_err(adev->dev, "set baco capability 
failed\n");
+   goto failed;
+   }
+   }
+
r = amdgpu_asic_reset(adev);
if (r) {
dev_err(adev->dev, "asic reset on init failed\n");
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h 
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 2b579ba..0dcc18d 100644
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
int (*get_asic_baco_capability)(void *handle, bool *cap);
+   int (*set_asic_baco_cap)(void *handle);
int (*get_asic_baco_state)(void *handle, int *state);
int (*set_asic_baco_state)(void *handle, int state);
int (*get_ppfeature_status)(void *handle, char *buf);
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c 
b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bea1587..9856760 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, 
uint32_t count)
return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+   struct pp_hwmgr *hwmgr = handle;
+
+   if (!hwmgr)
+   return -EINVAL;
+
+   if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+   return 0;
+
+   hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+   return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
.set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
.get_asic_baco_capability = pp_get_asic_baco_capability,
+   .set_asic_baco_cap = pp_set_asic_baco_cap,
.get_asic_baco_state = pp_get_asic_baco_state,
.set_asic_baco_state = pp_set_asic_baco_state,
.get_ppfeature_status = pp_get_ppfeature_status,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index ed6c638..8dc23eb 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
.odn_edit_dpm_table = vega10_odn_edit_dpm_table,
.get_performance_level = vega10_get_performance_level,
.get_asic_baco_capability = smu9_baco_get_capability,
+   .set_asic_baco_cap = vega10_baco_set_cap,
.get_asic_baco_state = smu9_baco_get_state,
.set_asic_baco_state = vega10_baco_set_state,
.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
index b6767d7..8fdeb23 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
@@ -1371,3 +1371,25 @@ int

[PATCH v2] drm/amdgpu: Correct the irq types' num of sdma

2019-03-27 Thread Emily Deng
Fix the issue about TDR-2 will have "fallback timer expired on ring sdma1".
It is because the wrong number of irq types setting.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h |  7 ++-
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c|  8 
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   |  8 
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   |  8 
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 25 -
 drivers/gpu/drm/amd/amdgpu/si_dma.c  |  8 
 6 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
index c17af30..1ba9ba3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
@@ -28,11 +28,8 @@
 #define AMDGPU_MAX_SDMA_INSTANCES  2
 
 enum amdgpu_sdma_irq {
-   AMDGPU_SDMA_IRQ_TRAP0 = 0,
-   AMDGPU_SDMA_IRQ_TRAP1,
-   AMDGPU_SDMA_IRQ_ECC0,
-   AMDGPU_SDMA_IRQ_ECC1,
-
+   AMDGPU_SDMA_IRQ_INSTANCE0  = 0,
+   AMDGPU_SDMA_IRQ_INSTANCE1,
AMDGPU_SDMA_IRQ_LAST
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 189599b..d42808b 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -977,8 +977,8 @@ static int cik_sdma_sw_init(void *handle)
r = amdgpu_ring_init(adev, ring, 1024,
 >sdma.trap_irq,
 (i == 0) ?
-AMDGPU_SDMA_IRQ_TRAP0 :
-AMDGPU_SDMA_IRQ_TRAP1);
+AMDGPU_SDMA_IRQ_INSTANCE0 :
+AMDGPU_SDMA_IRQ_INSTANCE1);
if (r)
return r;
}
@@ -1114,7 +1114,7 @@ static int cik_sdma_set_trap_irq_state(struct 
amdgpu_device *adev,
u32 sdma_cntl;
 
switch (type) {
-   case AMDGPU_SDMA_IRQ_TRAP0:
+   case AMDGPU_SDMA_IRQ_INSTANCE0:
switch (state) {
case AMDGPU_IRQ_STATE_DISABLE:
sdma_cntl = RREG32(mmSDMA0_CNTL + 
SDMA0_REGISTER_OFFSET);
@@ -1130,7 +1130,7 @@ static int cik_sdma_set_trap_irq_state(struct 
amdgpu_device *adev,
break;
}
break;
-   case AMDGPU_SDMA_IRQ_TRAP1:
+   case AMDGPU_SDMA_IRQ_INSTANCE1:
switch (state) {
case AMDGPU_IRQ_STATE_DISABLE:
sdma_cntl = RREG32(mmSDMA0_CNTL + 
SDMA1_REGISTER_OFFSET);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index cca3552..3619637 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
@@ -870,8 +870,8 @@ static int sdma_v2_4_sw_init(void *handle)
r = amdgpu_ring_init(adev, ring, 1024,
 >sdma.trap_irq,
 (i == 0) ?
-AMDGPU_SDMA_IRQ_TRAP0 :
-AMDGPU_SDMA_IRQ_TRAP1);
+AMDGPU_SDMA_IRQ_INSTANCE0 :
+AMDGPU_SDMA_IRQ_INSTANCE1);
if (r)
return r;
}
@@ -1006,7 +1006,7 @@ static int sdma_v2_4_set_trap_irq_state(struct 
amdgpu_device *adev,
u32 sdma_cntl;
 
switch (type) {
-   case AMDGPU_SDMA_IRQ_TRAP0:
+   case AMDGPU_SDMA_IRQ_INSTANCE0:
switch (state) {
case AMDGPU_IRQ_STATE_DISABLE:
sdma_cntl = RREG32(mmSDMA0_CNTL + 
SDMA0_REGISTER_OFFSET);
@@ -1022,7 +1022,7 @@ static int sdma_v2_4_set_trap_irq_state(struct 
amdgpu_device *adev,
break;
}
break;
-   case AMDGPU_SDMA_IRQ_TRAP1:
+   case AMDGPU_SDMA_IRQ_INSTANCE1:
switch (state) {
case AMDGPU_IRQ_STATE_DISABLE:
sdma_cntl = RREG32(mmSDMA0_CNTL + 
SDMA1_REGISTER_OFFSET);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 0ce8331..6d39544 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -1154,8 +1154,8 @@ static int sdma_v3_0_sw_init(void *handle)
r = amdgpu_ring_init(adev, ring, 1024,
 >sdma.trap_irq,
 (i == 0) ?
-AMDGPU_SDMA_IRQ_TRAP0 :
-AMDGPU_SDMA_IRQ_TRAP1);
+AMDGPU_SDMA_IRQ_INSTANCE0 :
+AMDGPU_SDMA_IRQ_INSTANCE1);
if (r)
return r;
}
@@ -1340,7 +1340,7 @@ static int sdma_v3_0

[PATCH] drm/amdgpu: Correct the irq types' num of sdma

2019-03-27 Thread Emily Deng
Fix the issue about TDR-2 will have "fallback timer expired on ring sdma1".
It is because the wrong number of irq types setting.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index 3ac5abe..72ec51a 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -1908,7 +1908,7 @@ static int sdma_v4_0_set_ecc_irq_state(struct 
amdgpu_device *adev,
 {
u32 sdma_edc_config;
 
-   u32 reg_offset = (type == AMDGPU_SDMA_IRQ_ECC0) ?
+   u32 reg_offset = (type == 0) ?
sdma_v4_0_get_reg_offset(adev, 0, mmSDMA0_EDC_CONFIG) :
sdma_v4_0_get_reg_offset(adev, 1, mmSDMA0_EDC_CONFIG);
 
@@ -2196,10 +2196,10 @@ static const struct amdgpu_irq_src_funcs 
sdma_v4_0_ecc_irq_funcs = {
 
 static void sdma_v4_0_set_irq_funcs(struct amdgpu_device *adev)
 {
-   adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_LAST;
+   adev->sdma.trap_irq.num_types = 2;
adev->sdma.trap_irq.funcs = _v4_0_trap_irq_funcs;
adev->sdma.illegal_inst_irq.funcs = _v4_0_illegal_inst_irq_funcs;
-   adev->sdma.ecc_irq.num_types = AMDGPU_SDMA_IRQ_LAST;
+   adev->sdma.ecc_irq.num_types = 2;
adev->sdma.ecc_irq.funcs = _v4_0_ecc_irq_funcs;
 }
 
-- 
2.7.4

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

[PATCH libdrm] libdrm: Fix issue about differrent domainID but same BDF

2019-02-13 Thread Emily Deng
For multiple GPUs which has the same BDF, but has different domain ID,
the drmOpenByBusid will return the wrong fd when startx.

The reproduce sequence as below:
1. Call drmOpenByBusid to open Card0, then will return the right fd0, and the
fd0 is master privilege;
2. Call drmOpenByBusid to open Card1. In function drmOpenByBusid, it will
open Card0 first, this time, the fd1 for opening Card0 is not master
privilege, and will call drmSetInterfaceVersion to identify the
domain ID feature, as the fd1 is not master privilege, then 
drmSetInterfaceVersion
will fail, and then won't compare domain ID, then return the wrong fd for Card1.

Solution:
First loop search the best match fd about drm 1.4.

Signed-off-by: Emily Deng 
---
 xf86drm.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/xf86drm.c b/xf86drm.c
index 336d64d..b60e029 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -584,11 +584,34 @@ static int drmOpenByBusid(const char *busid, int type)
 if (base < 0)
 return -1;
 
+/* We need to try for 1.4 first for proper PCI domain support */
 drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
 for (i = base; i < base + DRM_MAX_MINOR; i++) {
 fd = drmOpenMinor(i, 1, type);
 drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
 if (fd >= 0) {
+sv.drm_di_major = 1;
+sv.drm_di_minor = 4;
+sv.drm_dd_major = -1;/* Don't care */
+sv.drm_dd_minor = -1;/* Don't care */
+if (!drmSetInterfaceVersion(fd, )) {
+buf = drmGetBusid(fd);
+drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
+if (buf && drmMatchBusID(buf, busid, 1)) {
+drmFreeBusid(buf);
+return fd;
+}
+if (buf)
+drmFreeBusid(buf);
+}
+close(fd);
+}
+}
+
+   for (i = base; i < base + DRM_MAX_MINOR; i++) {
+fd = drmOpenMinor(i, 1, type);
+drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
+if (fd >= 0) {
 /* We need to try for 1.4 first for proper PCI domain support
  * and if that fails, we know the kernel is busted
  */
-- 
2.7.4

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

[PATCH] drm/amdgpu/sriov: For finishing routine send rel event after init failed

2019-01-02 Thread Emily Deng
When init fail, sendsend rel init, req_fini and rel_fini to host for the
finishing routine.

Signed-off-by: Emily Deng 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 3c57ffc..ccd2e83 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1652,7 +1652,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)
if (r) {
DRM_ERROR("sw_init of IP block <%s> failed %d\n",
  adev->ip_blocks[i].version->funcs->name, r);
-   return r;
+   goto init_failed;
}
adev->ip_blocks[i].status.sw = true;
 
@@ -1661,17 +1661,17 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)
r = amdgpu_device_vram_scratch_init(adev);
if (r) {
DRM_ERROR("amdgpu_vram_scratch_init failed 
%d\n", r);
-   return r;
+   goto init_failed;
}
r = adev->ip_blocks[i].version->funcs->hw_init((void 
*)adev);
if (r) {
DRM_ERROR("hw_init %d failed %d\n", i, r);
-   return r;
+   goto init_failed;
}
r = amdgpu_device_wb_init(adev);
if (r) {
DRM_ERROR("amdgpu_device_wb_init failed %d\n", 
r);
-   return r;
+   goto init_failed;
}
adev->ip_blocks[i].status.hw = true;
 
@@ -1682,7 +1682,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)

AMDGPU_CSA_SIZE);
if (r) {
DRM_ERROR("allocate CSA failed %d\n", 
r);
-   return r;
+   goto init_failed;
}
}
}
@@ -1690,30 +1690,32 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)
 
r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init 
complete*/
if (r)
-   return r;
+   goto init_failed;
 
r = amdgpu_device_ip_hw_init_phase1(adev);
if (r)
-   return r;
+   goto init_failed;
 
r = amdgpu_device_fw_loading(adev);
if (r)
-   return r;
+   goto init_failed;
 
r = amdgpu_device_ip_hw_init_phase2(adev);
if (r)
-   return r;
+   goto init_failed;
 
if (adev->gmc.xgmi.num_physical_nodes > 1)
amdgpu_xgmi_add_device(adev);
amdgpu_amdkfd_device_init(adev);
 
+init_failed:
if (amdgpu_sriov_vf(adev)) {
-   amdgpu_virt_init_data_exchange(adev);
+   if (!r)
+   amdgpu_virt_init_data_exchange(adev);
amdgpu_virt_release_full_gpu(adev, true);
}
 
-   return 0;
+   return r;
 }
 
 /**
@@ -2621,6 +2623,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
}
dev_err(adev->dev, "amdgpu_device_ip_init failed\n");
amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 
0);
+   if (amdgpu_virt_request_full_gpu(adev, false))
+   amdgpu_virt_release_full_gpu(adev, false);
goto failed;
}
 
-- 
2.7.4

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


  1   2   3   >