提交 98bb9222 编写于 作者: Y Yong Zhao 提交者: Oded Gabbay

drm/amdkfd: Make SDMA engine number an ASIC-dependent variable

On Raven there is only one SDMA engine instead of previously assumed two,
so we need to adapt our code to this new scenario.
Signed-off-by: NYong Zhao <yong.zhao@amd.com>
Reviewed-by: NFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: NFelix Kuehling <Felix.Kuehling@amd.com>
Acked-by: NAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: NOded Gabbay <oded.gabbay@gmail.com>
上级 f3ed5df8
...@@ -52,6 +52,7 @@ static const struct kfd_device_info kaveri_device_info = { ...@@ -52,6 +52,7 @@ static const struct kfd_device_info kaveri_device_info = {
.supports_cwsr = false, .supports_cwsr = false,
.needs_iommu_device = true, .needs_iommu_device = true,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info carrizo_device_info = { static const struct kfd_device_info carrizo_device_info = {
...@@ -67,6 +68,7 @@ static const struct kfd_device_info carrizo_device_info = { ...@@ -67,6 +68,7 @@ static const struct kfd_device_info carrizo_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = true, .needs_iommu_device = true,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
#endif #endif
...@@ -83,6 +85,7 @@ static const struct kfd_device_info hawaii_device_info = { ...@@ -83,6 +85,7 @@ static const struct kfd_device_info hawaii_device_info = {
.supports_cwsr = false, .supports_cwsr = false,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info tonga_device_info = { static const struct kfd_device_info tonga_device_info = {
...@@ -97,6 +100,7 @@ static const struct kfd_device_info tonga_device_info = { ...@@ -97,6 +100,7 @@ static const struct kfd_device_info tonga_device_info = {
.supports_cwsr = false, .supports_cwsr = false,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = true, .needs_pci_atomics = true,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info tonga_vf_device_info = { static const struct kfd_device_info tonga_vf_device_info = {
...@@ -111,6 +115,7 @@ static const struct kfd_device_info tonga_vf_device_info = { ...@@ -111,6 +115,7 @@ static const struct kfd_device_info tonga_vf_device_info = {
.supports_cwsr = false, .supports_cwsr = false,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info fiji_device_info = { static const struct kfd_device_info fiji_device_info = {
...@@ -125,6 +130,7 @@ static const struct kfd_device_info fiji_device_info = { ...@@ -125,6 +130,7 @@ static const struct kfd_device_info fiji_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = true, .needs_pci_atomics = true,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info fiji_vf_device_info = { static const struct kfd_device_info fiji_vf_device_info = {
...@@ -139,6 +145,7 @@ static const struct kfd_device_info fiji_vf_device_info = { ...@@ -139,6 +145,7 @@ static const struct kfd_device_info fiji_vf_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
...@@ -154,6 +161,7 @@ static const struct kfd_device_info polaris10_device_info = { ...@@ -154,6 +161,7 @@ static const struct kfd_device_info polaris10_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = true, .needs_pci_atomics = true,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info polaris10_vf_device_info = { static const struct kfd_device_info polaris10_vf_device_info = {
...@@ -168,6 +176,7 @@ static const struct kfd_device_info polaris10_vf_device_info = { ...@@ -168,6 +176,7 @@ static const struct kfd_device_info polaris10_vf_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info polaris11_device_info = { static const struct kfd_device_info polaris11_device_info = {
...@@ -182,6 +191,7 @@ static const struct kfd_device_info polaris11_device_info = { ...@@ -182,6 +191,7 @@ static const struct kfd_device_info polaris11_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = true, .needs_pci_atomics = true,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info vega10_device_info = { static const struct kfd_device_info vega10_device_info = {
...@@ -196,6 +206,7 @@ static const struct kfd_device_info vega10_device_info = { ...@@ -196,6 +206,7 @@ static const struct kfd_device_info vega10_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
static const struct kfd_device_info vega10_vf_device_info = { static const struct kfd_device_info vega10_vf_device_info = {
...@@ -210,6 +221,7 @@ static const struct kfd_device_info vega10_vf_device_info = { ...@@ -210,6 +221,7 @@ static const struct kfd_device_info vega10_vf_device_info = {
.supports_cwsr = true, .supports_cwsr = true,
.needs_iommu_device = false, .needs_iommu_device = false,
.needs_pci_atomics = false, .needs_pci_atomics = false,
.num_sdma_engines = 2,
}; };
......
...@@ -101,6 +101,17 @@ unsigned int get_pipes_per_mec(struct device_queue_manager *dqm) ...@@ -101,6 +101,17 @@ unsigned int get_pipes_per_mec(struct device_queue_manager *dqm)
return dqm->dev->shared_resources.num_pipe_per_mec; return dqm->dev->shared_resources.num_pipe_per_mec;
} }
static unsigned int get_num_sdma_engines(struct device_queue_manager *dqm)
{
return dqm->dev->device_info->num_sdma_engines;
}
unsigned int get_num_sdma_queues(struct device_queue_manager *dqm)
{
return dqm->dev->device_info->num_sdma_engines
* KFD_SDMA_QUEUES_PER_ENGINE;
}
void program_sh_mem_settings(struct device_queue_manager *dqm, void program_sh_mem_settings(struct device_queue_manager *dqm,
struct qcm_process_device *qpd) struct qcm_process_device *qpd)
{ {
...@@ -855,7 +866,7 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) ...@@ -855,7 +866,7 @@ static int initialize_nocpsch(struct device_queue_manager *dqm)
} }
dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) - 1; dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) - 1;
dqm->sdma_bitmap = (1 << CIK_SDMA_QUEUES) - 1; dqm->sdma_bitmap = (1 << get_num_sdma_queues(dqm)) - 1;
return 0; return 0;
} }
...@@ -903,7 +914,7 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm, ...@@ -903,7 +914,7 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm,
static void deallocate_sdma_queue(struct device_queue_manager *dqm, static void deallocate_sdma_queue(struct device_queue_manager *dqm,
unsigned int sdma_queue_id) unsigned int sdma_queue_id)
{ {
if (sdma_queue_id >= CIK_SDMA_QUEUES) if (sdma_queue_id >= get_num_sdma_queues(dqm))
return; return;
dqm->sdma_bitmap |= (1 << sdma_queue_id); dqm->sdma_bitmap |= (1 << sdma_queue_id);
} }
...@@ -923,8 +934,8 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm, ...@@ -923,8 +934,8 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
if (retval) if (retval)
return retval; return retval;
q->properties.sdma_queue_id = q->sdma_id / CIK_SDMA_QUEUES_PER_ENGINE; q->properties.sdma_queue_id = q->sdma_id / get_num_sdma_engines(dqm);
q->properties.sdma_engine_id = q->sdma_id % CIK_SDMA_QUEUES_PER_ENGINE; q->properties.sdma_engine_id = q->sdma_id % get_num_sdma_engines(dqm);
retval = allocate_doorbell(qpd, q); retval = allocate_doorbell(qpd, q);
if (retval) if (retval)
...@@ -1011,7 +1022,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm) ...@@ -1011,7 +1022,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm)
dqm->queue_count = dqm->processes_count = 0; dqm->queue_count = dqm->processes_count = 0;
dqm->sdma_queue_count = 0; dqm->sdma_queue_count = 0;
dqm->active_runlist = false; dqm->active_runlist = false;
dqm->sdma_bitmap = (1 << CIK_SDMA_QUEUES) - 1; dqm->sdma_bitmap = (1 << get_num_sdma_queues(dqm)) - 1;
INIT_WORK(&dqm->hw_exception_work, kfd_process_hw_exception); INIT_WORK(&dqm->hw_exception_work, kfd_process_hw_exception);
...@@ -1142,9 +1153,9 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, ...@@ -1142,9 +1153,9 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q,
if (retval) if (retval)
goto out_unlock; goto out_unlock;
q->properties.sdma_queue_id = q->properties.sdma_queue_id =
q->sdma_id / CIK_SDMA_QUEUES_PER_ENGINE; q->sdma_id / get_num_sdma_engines(dqm);
q->properties.sdma_engine_id = q->properties.sdma_engine_id =
q->sdma_id % CIK_SDMA_QUEUES_PER_ENGINE; q->sdma_id % get_num_sdma_engines(dqm);
} }
retval = allocate_doorbell(qpd, q); retval = allocate_doorbell(qpd, q);
...@@ -1791,8 +1802,8 @@ int dqm_debugfs_hqds(struct seq_file *m, void *data) ...@@ -1791,8 +1802,8 @@ int dqm_debugfs_hqds(struct seq_file *m, void *data)
} }
} }
for (pipe = 0; pipe < CIK_SDMA_ENGINE_NUM; pipe++) { for (pipe = 0; pipe < get_num_sdma_engines(dqm); pipe++) {
for (queue = 0; queue < CIK_SDMA_QUEUES_PER_ENGINE; queue++) { for (queue = 0; queue < KFD_SDMA_QUEUES_PER_ENGINE; queue++) {
r = dqm->dev->kfd2kgd->hqd_sdma_dump( r = dqm->dev->kfd2kgd->hqd_sdma_dump(
dqm->dev->kgd, pipe, queue, &dump, &n_regs); dqm->dev->kgd, pipe, queue, &dump, &n_regs);
if (r) if (r)
......
...@@ -33,10 +33,7 @@ ...@@ -33,10 +33,7 @@
#define KFD_UNMAP_LATENCY_MS (4000) #define KFD_UNMAP_LATENCY_MS (4000)
#define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000) #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (2 * KFD_UNMAP_LATENCY_MS + 1000)
#define KFD_SDMA_QUEUES_PER_ENGINE (2)
#define CIK_SDMA_QUEUES (4)
#define CIK_SDMA_QUEUES_PER_ENGINE (2)
#define CIK_SDMA_ENGINE_NUM (2)
struct device_process_node { struct device_process_node {
struct qcm_process_device *qpd; struct qcm_process_device *qpd;
...@@ -214,6 +211,7 @@ void program_sh_mem_settings(struct device_queue_manager *dqm, ...@@ -214,6 +211,7 @@ void program_sh_mem_settings(struct device_queue_manager *dqm,
unsigned int get_queues_num(struct device_queue_manager *dqm); unsigned int get_queues_num(struct device_queue_manager *dqm);
unsigned int get_queues_per_pipe(struct device_queue_manager *dqm); unsigned int get_queues_per_pipe(struct device_queue_manager *dqm);
unsigned int get_pipes_per_mec(struct device_queue_manager *dqm); unsigned int get_pipes_per_mec(struct device_queue_manager *dqm);
unsigned int get_num_sdma_queues(struct device_queue_manager *dqm);
static inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd) static inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd)
{ {
......
...@@ -203,6 +203,7 @@ struct kfd_device_info { ...@@ -203,6 +203,7 @@ struct kfd_device_info {
bool supports_cwsr; bool supports_cwsr;
bool needs_iommu_device; bool needs_iommu_device;
bool needs_pci_atomics; bool needs_pci_atomics;
unsigned int num_sdma_engines;
}; };
struct kfd_mem_obj { struct kfd_mem_obj {
......
...@@ -186,8 +186,7 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -186,8 +186,7 @@ int pqm_create_queue(struct process_queue_manager *pqm,
switch (type) { switch (type) {
case KFD_QUEUE_TYPE_SDMA: case KFD_QUEUE_TYPE_SDMA:
if (dev->dqm->queue_count >= if (dev->dqm->queue_count >= get_num_sdma_queues(dev->dqm)) {
CIK_SDMA_QUEUES_PER_ENGINE * CIK_SDMA_ENGINE_NUM) {
pr_err("Over-subscription is not allowed for SDMA.\n"); pr_err("Over-subscription is not allowed for SDMA.\n");
retval = -EPERM; retval = -EPERM;
goto err_create_queue; goto err_create_queue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册