Commit 093c7d8c authored by Alexey Skidanov's avatar Alexey Skidanov Committed by Oded Gabbay
Browse files

drm/amdkfd: Process-device data creation and lookup split



This patch splits the current kfd_get_process_device_data() to two
functions, one that specifically creates a pdd and another one which
just do lookup.

This is done to enhance the readability and maintainability of the code.

Signed-off-by: default avatarAlexey Skidanov <Alexey.Skidanov@amd.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@amd.com>
parent f7c826ad
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd)
	nybble = (pdd->lds_base >> 60) & 0x0E;

	return nybble;

}

static inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd)
+0 −4
Original line number Diff line number Diff line
@@ -137,10 +137,6 @@ int kfd_doorbell_mmap(struct kfd_process *process, struct vm_area_struct *vma)
	if (dev == NULL)
		return -EINVAL;

	/* Find if pdd exists for combination of process and gpu id */
	if (!kfd_get_process_device_data(dev, process, 0))
		return -EINVAL;

	/* Calculate physical address of doorbell */
	address = kfd_get_process_doorbells(dev, process);

+4 −3
Original line number Diff line number Diff line
@@ -303,10 +303,11 @@ int kfd_init_apertures(struct kfd_process *process)
	while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL &&
		id < NUM_OF_SUPPORTED_GPUS) {

		pdd = kfd_get_process_device_data(dev, process, 1);
		if (!pdd)
		pdd = kfd_create_process_device_data(dev, process);
		if (pdd == NULL) {
			pr_err("Failed to create process device data\n");
			return -1;

		}
		/*
		 * For 64 bit process aperture will be statically reserved in
		 * the x86_64 non canonical process address space
+3 −2
Original line number Diff line number Diff line
@@ -473,8 +473,9 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
							struct kfd_process *p);
void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid);
struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
							struct kfd_process *p,
							int create_pdd);
							struct kfd_process *p);
struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
							struct kfd_process *p);

/* Process device data iterator */
struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p);
+24 −16
Original line number Diff line number Diff line
@@ -311,16 +311,22 @@ err_alloc_process:
}

struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
							struct kfd_process *p,
							int create_pdd)
							struct kfd_process *p)
{
	struct kfd_process_device *pdd = NULL;

	list_for_each_entry(pdd, &p->per_device_data, per_device_list)
		if (pdd->dev == dev)
			break;

	return pdd;
}

struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
							struct kfd_process *p)
{
	struct kfd_process_device *pdd = NULL;

	if (create_pdd) {
	pdd = kzalloc(sizeof(*pdd), GFP_KERNEL);
	if (pdd != NULL) {
		pdd->dev = dev;
@@ -329,7 +335,6 @@ struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
		pdd->qpd.dqm = dev->dqm;
		list_add(&pdd->per_device_list, &p->per_device_data);
	}
	}

	return pdd;
}
@@ -344,11 +349,14 @@ struct kfd_process_device *kfd_get_process_device_data(struct kfd_dev *dev,
struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev,
							struct kfd_process *p)
{
	struct kfd_process_device *pdd = kfd_get_process_device_data(dev, p, 1);
	struct kfd_process_device *pdd;
	int err;

	if (pdd == NULL)
	pdd = kfd_get_process_device_data(dev, p);
	if (!pdd) {
		pr_err("Process device data doesn't exist\n");
		return ERR_PTR(-ENOMEM);
	}

	if (pdd->bound)
		return pdd;
@@ -384,7 +392,7 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)

	pqm_uninit(&p->pqm);

	pdd = kfd_get_process_device_data(dev, p, 0);
	pdd = kfd_get_process_device_data(dev, p);

	/*
	 * Just mark pdd as unbound, because we still need it to call
Loading