Skip to content

Commit

Permalink
Merge remote-tracking branch 'brahma/fkuehlin/rocm-rel-3.5' into rocm…
Browse files Browse the repository at this point in the history
…-rel-3.5

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
  • Loading branch information
fxkamd committed May 19, 2020
2 parents bff68b7 + 00592c9 commit 2106eda
Show file tree
Hide file tree
Showing 21 changed files with 520 additions and 122 deletions.
5 changes: 3 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
}

/* Free the BO*/
amdgpu_bo_unref(&mem->bo);
drm_gem_object_put_unlocked(&mem->bo->tbo.base);
mutex_destroy(&mem->lock);
kfree(mem);

Expand Down Expand Up @@ -1895,7 +1895,8 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd,
| KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE
| KFD_IOC_ALLOC_MEM_FLAGS_EXECUTABLE;

(*mem)->bo = amdgpu_bo_ref(bo);
drm_gem_object_get(&bo->tbo.base);
(*mem)->bo = bo;
(*mem)->va = va;
(*mem)->domain = (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) ?
AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ int amdgpu_xgmi_set_pstate(struct amdgpu_device *adev, int pstate)
bool init_low = hive->pstate == AMDGPU_XGMI_PSTATE_UNKNOWN;

/* fw bug so temporarily disable pstate switching */
if (!hive || adev->asic_type == CHIP_VEGA20)
return 0;

if (!hive || adev->asic_type != CHIP_VEGA20)
return 0;

mutex_lock(&hive->hive_lock);
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdkfd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \
$(AMDKFD_PATH)/kfd_int_process_v9.o \
$(AMDKFD_PATH)/kfd_dbgdev.o \
$(AMDKFD_PATH)/kfd_dbgmgr.o \
$(AMDKFD_PATH)/kfd_smi_events.o \
$(AMDKFD_PATH)/kfd_crat.o \
$(AMDKFD_PATH)/kfd_rdma.o \
$(AMDKFD_PATH)/kfd_peerdirect.o \
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/amd/amdkfd/cik_event_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "kfd_events.h"
#include "cik_int.h"
#include "amdgpu_amdkfd.h"
#include "kfd_smi_events.h"

static bool cik_event_interrupt_isr(struct kfd_dev *dev,
const uint32_t *ih_ring_entry,
Expand Down Expand Up @@ -107,6 +108,7 @@ static void cik_event_interrupt_wq(struct kfd_dev *dev,
ihre->source_id == CIK_INTSRC_GFX_MEM_PROT_FAULT) {
struct kfd_vm_fault_info info;

kfd_smi_event_update_vmfault(dev, pasid);
kfd_process_vm_fault(dev->dqm, pasid);

memset(&info, 0, sizeof(info));
Expand Down
42 changes: 33 additions & 9 deletions drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "kfd_trace.h"

#include "amdgpu_amdkfd.h"
#include "kfd_smi_events.h"

static long kfd_ioctl(struct file *, unsigned int, unsigned long);
static int kfd_open(struct inode *, struct file *);
Expand Down Expand Up @@ -2681,7 +2682,7 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
target = need_proc_create ?
kfd_create_process(thread) : kfd_lookup_process_by_pid(pid);
if (!target) {
pr_err("Cannot find process info info for %i\n",
pr_debug("Cannot find process info for %i\n",
args->pid);
r = -ESRCH;
goto out;
Expand Down Expand Up @@ -2832,17 +2833,27 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
data3, /* Grace Period */
data1, /* Flags */
queue_id_array); /* array of queue ids */
if (r)

if (copy_to_user((void __user *)args->ptr, queue_id_array,
sizeof(uint32_t) * data2)) {
r = -EFAULT;
goto unlock_out;
}

break;

case KFD_IOC_DBG_TRAP_NODE_RESUME:
r = resume_queues(target,
data2, /* Number of queues */
data1, /* Flags */
queue_id_array); /* array of queue ids */
if (r)

if (copy_to_user((void __user *)args->ptr, queue_id_array,
sizeof(uint32_t) * data2)) {
r = -EFAULT;
goto unlock_out;
}

break;
case KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT:
r = kfd_dbg_ev_query_debug_event(pdd, &args->data1,
Expand Down Expand Up @@ -2896,6 +2907,20 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
return r;
}

/* Handle requests for watching SMI events */
static int kfd_ioctl_smi_events(struct file *filep,
struct kfd_process *p, void *data)
{
struct kfd_ioctl_smi_events_args *args = data;
struct kfd_dev *dev;

dev = kfd_device_by_id(args->gpuid);
if (!dev)
return -EINVAL;

return kfd_smi_event_open(dev, &args->anon_fd);
}

#define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
[_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, \
.cmd_drv = 0, .name = #ioctl}
Expand Down Expand Up @@ -2992,6 +3017,9 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
AMDKFD_IOCTL_DEF(AMDKFD_IOC_ALLOC_QUEUE_GWS,
kfd_ioctl_alloc_queue_gws, 0),

AMDKFD_IOCTL_DEF(AMDKFD_IOC_SMI_EVENTS,
kfd_ioctl_smi_events, 0),

AMDKFD_IOCTL_DEF(AMDKFD_IOC_IPC_IMPORT_HANDLE,
kfd_ioctl_ipc_import_handle, 0),

Expand All @@ -3005,8 +3033,6 @@ static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
kfd_ioctl_dbg_set_debug_trap, 0),
};

#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls)

static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
struct kfd_process *process;
Expand All @@ -3018,10 +3044,8 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
unsigned int usize, asize;
int retcode = -EINVAL;

if (nr >= AMDKFD_CORE_IOCTL_COUNT)
goto err_i1;

if ((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) {
if (((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) ||
((nr >= AMDKFD_COMMAND_START_2) && (nr < AMDKFD_COMMAND_END_2))) {
u32 amdkfd_size;

ioctl = &amdkfd_ioctls[nr];
Expand Down
17 changes: 10 additions & 7 deletions drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ uint32_t kfd_dbg_get_queue_status_word(struct queue *q, int flags)
if (flags & KFD_DBG_EV_FLAG_CLEAR_STATUS)
WRITE_ONCE(q->properties.debug_event_type, 0);

q->properties.is_new = false;

return queue_status_word;
}

Expand Down Expand Up @@ -153,17 +151,22 @@ int kfd_dbg_ev_query_debug_event(struct kfd_process_device *pdd,
}

*event_status = kfd_dbg_get_queue_status_word(q, flags);

q->properties.is_new = false;
goto out;
}

list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
unsigned int tmp_status =
kfd_dbg_get_queue_status_word(pqn->q, flags);
if (pqn->q && (tmp_status & (KFD_DBG_EV_STATUS_TRAP |
KFD_DBG_EV_STATUS_VMFAULT))) {
unsigned int tmp_status;

if (!pqn->q)
continue;

tmp_status = kfd_dbg_get_queue_status_word(pqn->q, flags);
if (tmp_status & (KFD_DBG_EV_STATUS_TRAP |
KFD_DBG_EV_STATUS_VMFAULT)) {
*queue_id = pqn->q->properties.queue_id;
*event_status = tmp_status;
pqn->q->properties.is_new = false;
goto out;
}
}
Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/amd/amdkfd/kfd_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ static int kfd_gws_init(struct kfd_dev *kfd)
return ret;
}

static void kfd_smi_init(struct kfd_dev *dev) {
INIT_LIST_HEAD(&dev->smi_clients);
spin_lock_init(&dev->smi_lock);
}

bool kgd2kfd_device_init(struct kfd_dev *kfd,
struct drm_device *ddev,
const struct kgd2kfd_shared_resources *gpu_resources)
Expand Down Expand Up @@ -700,6 +705,8 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
goto kfd_topology_add_device_error;
}

kfd_smi_init(kfd);

kfd->init_complete = true;
dev_info(kfd_device, "added device %x:%x\n", kfd->pdev->vendor,
kfd->pdev->device);
Expand Down
Loading

0 comments on commit 2106eda

Please sign in to comment.