Skip to content

Commit

Permalink
amdkfd: Add process queue manager module
Browse files Browse the repository at this point in the history
The queue scheduler divides into two sections, one section is process bounded
and the other section is device bounded.
The process bounded section is handled by this module. The PQM handles usermode
queue setup, updates and tear-down.

v3:

Used kernel parameter to limit queues per process instead of define
Added use of doorbell address from user

v4:

Modified pqm_create_queue so that only when creating usermode queues the
driver should return the queue properties to the userspace.

Added an info message print when no more queues can be opened because of the
queue per process limitation

v5:

Move amdkfd from drm/radeon/ to drm/amd/
Various fixes

Signed-off-by: Ben Goz <ben.goz@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
  • Loading branch information
Ben Goz authored and Oded Gabbay committed Jul 16, 2014
1 parent 241f24f commit 4510204
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpu/drm/amd/amdkfd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amd/include/
amdkfd-y := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
kfd_pasid.o kfd_doorbell.o kfd_flat_memory.o \
kfd_process.o kfd_queue.o kfd_mqd_manager.o \
kfd_kernel_queue.o kfd_packet_manager.o
kfd_kernel_queue.o kfd_packet_manager.o \
kfd_process_queue_manager.o

obj-$(CONFIG_HSA_AMD) += amdkfd.o
26 changes: 26 additions & 0 deletions drivers/gpu/drm/amd/amdkfd/kfd_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ struct kfd_process_device {
struct kfd_dev *dev;


/* per-process-per device QCM data structure */
struct qcm_process_device qpd;

/*Apertures*/
uint64_t lds_base;
uint64_t lds_limit;
Expand Down Expand Up @@ -432,6 +435,8 @@ struct kfd_process {
*/
struct list_head per_device_data;

struct process_queue_manager pqm;

/* The process's queues. */
size_t queue_array_size;

Expand Down Expand Up @@ -501,12 +506,33 @@ inline uint32_t upper_32(uint64_t x);

int init_queue(struct queue **q, struct queue_properties properties);
void uninit_queue(struct queue *q);
void print_queue_properties(struct queue_properties *q);
void print_queue(struct queue *q);

struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
enum kfd_queue_type type);
void kernel_queue_uninit(struct kernel_queue *kq);

/* Process Queue Manager */
struct process_queue_node {
struct queue *q;
struct kernel_queue *kq;
struct list_head process_queue_list;
};

int pqm_init(struct process_queue_manager *pqm, struct kfd_process *p);
void pqm_uninit(struct process_queue_manager *pqm);
int pqm_create_queue(struct process_queue_manager *pqm,
struct kfd_dev *dev,
struct file *f,
struct queue_properties *properties,
unsigned int flags,
enum kfd_queue_type type,
unsigned int *qid);
int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid);
int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
struct queue_properties *p);

/* Packet Manager */

#define KFD_HIQ_TIMEOUT (500)
Expand Down
20 changes: 20 additions & 0 deletions drivers/gpu/drm/amd/amdkfd/kfd_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
mutex_unlock(&kfd_processes_mutex);
synchronize_srcu(&kfd_processes_srcu);

mutex_lock(&p->mutex);

/* In case our notifier is called before IOMMU notifier */
pqm_uninit(&p->pqm);

mutex_unlock(&p->mutex);

/*
* Because we drop mm_count inside kfd_process_destroy_delayed
* and because the mmu_notifier_unregister function also drop
Expand Down Expand Up @@ -274,8 +281,16 @@ static struct kfd_process *create_process(const struct task_struct *thread)

INIT_LIST_HEAD(&process->per_device_data);

err = pqm_init(&process->pqm, process);
if (err != 0)
goto err_process_pqm_init;

return process;

err_process_pqm_init:
hash_del_rcu(&process->kfd_processes);
synchronize_rcu();
mmu_notifier_unregister_no_release(&process->mmu_notifier, process->mm);
err_mmu_notifier:
kfd_pasid_free(process->pasid);
err_alloc_pasid:
Expand All @@ -300,6 +315,9 @@ struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
pdd = kzalloc(sizeof(*pdd), GFP_KERNEL);
if (pdd != NULL) {
pdd->dev = dev;
INIT_LIST_HEAD(&pdd->qpd.queues_list);
INIT_LIST_HEAD(&pdd->qpd.priv_queue_list);
pdd->qpd.dqm = dev->dqm;
list_add(&pdd->per_device_list, &p->per_device_data);
}
}
Expand Down Expand Up @@ -360,6 +378,8 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)

mutex_lock(&p->mutex);

pqm_uninit(&p->pqm);

pdd = kfd_get_process_device_data(dev, p, 0);

/*
Expand Down
Loading

0 comments on commit 4510204

Please sign in to comment.