Skip to contentSkip to conversation

amdkfd fixes (sparse and some more)

PATCH In review Oded Gabbay 2 participants 14 messages Nov 21, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover amdkfd fixes (sparse and some more)

Hi,
This patch-set contains mostly fixes for sparse warnings.
In addition, there is a fix for a memory leak, for suspend operation and a patch that prevents the blocking of IOMMU PPR handling while waiting to sync with hw

Oded

Alexey Skidanov (1):
amdkfd: Instead of using get function, use container_of

Jay Cornwall (1):
amdkfd: Fix memory leak on process deregistration

Oded Gabbay (8):
amdkfd: Fix sparse warnings in kfd_chardev.c
amdkfd: Fix sparse warnings in kfd_topology.c
amdkfd: Fix sparse warnings in kfd_flat_memory.c
amdkfd: is_occupied() can be static
amdkfd: fence_wait_timeout() can be static
amdkfd: add __iomem attribute to doorbell_ptr
amdkfd: use schedule() in sync_with_hw
amdkfd: Clear ctx cb before suspend

kbuild test robot (2):
amdkfd: test_kq() can be static
amdkfd: pqm_get_kernel_queue() can be static

 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 16 ++++++---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            |  1 +
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 27 +++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       | 11 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 14 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c       |  6 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  4 ++-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          | 40 +++++++++++-----------
 9 files changed, 67 insertions(+), 55 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/12 amdkfd: Fix sparse warnings in kfd_chardev.c

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +12 -4
index 64c73ba..3b3fce7 100644
@@ -149,7 +149,9 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 	}
 
 	if ((args->ring_base_address) &&
-		(!access_ok(VERIFY_WRITE, args->ring_base_address, sizeof(uint64_t)))) {
+		(!access_ok(VERIFY_WRITE,
+			(const void __user *) args->ring_base_address,
+			sizeof(uint64_t)))) {
 		pr_err("kfd: can't access ring base address\n");
 		return -EFAULT;
 	}
@@ -159,12 +161,16 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
 		return -EINVAL;
 	}
 
-	if (!access_ok(VERIFY_WRITE, args->read_pointer_address, sizeof(uint32_t))) {
+	if (!access_ok(VERIFY_WRITE,
+			(const void __user *) args->read_pointer_address,
+			sizeof(uint32_t))) {
 		pr_err("kfd: can't access read pointer\n");
 		return -EFAULT;
 	}
 
-	if (!access_ok(VERIFY_WRITE, args->write_pointer_address, sizeof(uint32_t))) {
+	if (!access_ok(VERIFY_WRITE,
+			(const void __user *) args->write_pointer_address,
+			sizeof(uint32_t))) {
 		pr_err("kfd: can't access write pointer\n");
 		return -EFAULT;
 	}
@@ -325,7 +331,9 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,
 	}
 
 	if ((args.ring_base_address) &&
-		(!access_ok(VERIFY_WRITE, args.ring_base_address, sizeof(uint64_t)))) {
+		(!access_ok(VERIFY_WRITE,
+			(const void __user *) args.ring_base_address,
+			sizeof(uint64_t)))) {
 		pr_err("kfd: can't access ring base address\n");
 		return -EFAULT;
 	}
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/12 amdkfd: Fix sparse warnings in kfd_topology.c

---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 40 +++++++++++++++----------------
 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +20 -20
index 77cd7d5..5733e28 100644
@@ -96,7 +96,7 @@ static int kfd_topology_get_crat_acpi(void *crat_image, size_t *size)
 		return -EINVAL;
 	}
 
-	if (*size >= crat_table->length && crat_image != 0)
+	if (*size >= crat_table->length && crat_image != NULL)
 		memcpy(crat_image, crat_table, crat_table->length);
 
 	*size = crat_table->length;
@@ -183,7 +183,7 @@ static int kfd_parse_subtype_mem(struct crat_subtype_memory *mem)
 	list_for_each_entry(dev, &topology_device_list, list) {
 		if (mem->promixity_domain == i) {
 			props = kfd_alloc_struct(props);
-			if (props == 0)
+			if (props == NULL)
 				return -ENOMEM;
 
 			if (dev->node_props.cpu_cores_count == 0)
@@ -231,7 +231,7 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache)
 		if (id == dev->node_props.cpu_core_id_base ||
 		    id == dev->node_props.simd_id_base) {
 			props = kfd_alloc_struct(props);
-			if (props == 0)
+			if (props == NULL)
 				return -ENOMEM;
 
 			props->processor_id_low = id;
@@ -282,7 +282,7 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink)
 	list_for_each_entry(dev, &topology_device_list, list) {
 		if (id_from == i) {
 			props = kfd_alloc_struct(props);
-			if (props == 0)
+			if (props == NULL)
 				return -ENOMEM;
 
 			props->node_from = id_from;
@@ -415,9 +415,9 @@ static struct kfd_topology_device *kfd_create_topology_device(void)
 	struct kfd_topology_device *dev;
 
 	dev = kfd_alloc_struct(dev);
-	if (dev == 0) {
+	if (dev == NULL) {
 		pr_err("No memory to allocate a topology device");
-		return 0;
+		return NULL;
 	}
 
 	INIT_LIST_HEAD(&dev->mem_props);
@@ -428,7 +428,7 @@ static struct kfd_topology_device *kfd_create_topology_device(void)
 	sys_props.num_devices++;
 
 	return dev;
-	}
+}
 
 static int kfd_parse_crat_table(void *crat_image)
 {
@@ -752,11 +752,11 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
 			if (iolink->kobj) {
 				kfd_remove_sysfs_file(iolink->kobj,
 							&iolink->attr);
-				iolink->kobj = 0;
+				iolink->kobj = NULL;
 			}
 		kobject_del(dev->kobj_iolink);
 		kobject_put(dev->kobj_iolink);
-		dev->kobj_iolink = 0;
+		dev->kobj_iolink = NULL;
 	}
 
 	if (dev->kobj_cache) {
@@ -764,22 +764,22 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
 			if (cache->kobj) {
 				kfd_remove_sysfs_file(cache->kobj,
 							&cache->attr);
-				cache->kobj = 0;
+				cache->kobj = NULL;
 			}
 		kobject_del(dev->kobj_cache);
 		kobject_put(dev->kobj_cache);
-		dev->kobj_cache = 0;
+		dev->kobj_cache = NULL;
 	}
 
 	if (dev->kobj_mem) {
 		list_for_each_entry(mem, &dev->mem_props, list)
 			if (mem->kobj) {
 				kfd_remove_sysfs_file(mem->kobj, &mem->attr);
-				mem->kobj = 0;
+				mem->kobj = NULL;
 			}
 		kobject_del(dev->kobj_mem);
 		kobject_put(dev->kobj_mem);
-		dev->kobj_mem = 0;
+		dev->kobj_mem = NULL;
 	}
 
 	if (dev->kobj_node) {
@@ -788,7 +788,7 @@ static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
 		sysfs_remove_file(dev->kobj_node, &dev->attr_props);
 		kobject_del(dev->kobj_node);
 		kobject_put(dev->kobj_node);
-		dev->kobj_node = 0;
+		dev->kobj_node = NULL;
 	}
 }
 
@@ -939,7 +939,7 @@ static int kfd_topology_update_sysfs(void)
 	int ret;
 
 	pr_info("Creating topology SYSFS entries\n");
-	if (sys_props.kobj_topology == 0) {
+	if (sys_props.kobj_topology == NULL) {
 		sys_props.kobj_topology =
 				kfd_alloc_struct(sys_props.kobj_topology);
 		if (!sys_props.kobj_topology)
@@ -989,17 +989,17 @@ static void kfd_topology_release_sysfs(void)
 		if (sys_props.kobj_nodes) {
 			kobject_del(sys_props.kobj_nodes);
 			kobject_put(sys_props.kobj_nodes);
-			sys_props.kobj_nodes = 0;
+			sys_props.kobj_nodes = NULL;
 		}
 		kobject_del(sys_props.kobj_topology);
 		kobject_put(sys_props.kobj_topology);
-		sys_props.kobj_topology = 0;
+		sys_props.kobj_topology = NULL;
 	}
 }
 
 int kfd_topology_init(void)
 {
-	void *crat_image = 0;
+	void *crat_image = NULL;
 	size_t image_size = 0;
 	int ret;
 
@@ -1094,12 +1094,12 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
 static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
 {
 	struct kfd_topology_device *dev;
-	struct kfd_topology_device *out_dev = 0;
+	struct kfd_topology_device *out_dev = NULL;
 
 	BUG_ON(!gpu);
 
 	list_for_each_entry(dev, &topology_device_list, list)
-		if (dev->gpu == 0 && dev->node_props.simd_count > 0) {
+		if (dev->gpu == NULL && dev->node_props.simd_count > 0) {
 			dev->gpu = gpu;
 			out_dev = dev;
 			break;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/12 amdkfd: test_kq() can be static

In reply to Oded Gabbay

From: kbuild test robot <[email protected]>

---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +1 -1
index 555af45..424ddcc 100644
@@ -321,7 +321,7 @@ void kernel_queue_uninit(struct kernel_queue *kq)
 	kfree(kq);
 }
 
-void test_kq(struct kfd_dev *dev)
+static __attribute__((unused)) void test_kq(struct kfd_dev *dev)
 {
 	struct kernel_queue *kq;
 	uint32_t *buffer, i;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH 4/12 amdkfd: pqm_get_kernel_queue() can be static

From: kbuild test robot <[email protected]>

---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -1
index c7859fc..de2c163 100644
@@ -325,7 +325,8 @@ int pqm_update_queue(struct process_queue_manager *pqm, unsigned int qid,
 	return 0;
 }
 
-struct kernel_queue *pqm_get_kernel_queue(struct process_queue_manager *pqm,
+static __attribute__((unused)) struct kernel_queue *pqm_get_kernel_queue(
+					struct process_queue_manager *pqm,
 					unsigned int qid)
 {
 	struct process_queue_node *pqn;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH 5/12 amdkfd: Fix sparse warnings in kfd_flat_memory.c

In reply to Oded Gabbay
---
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +6 -5
index 2dfc4c0..66df4da 100644
@@ -276,21 +276,22 @@
  */
 
 #define MAKE_GPUVM_APP_BASE(gpu_num) \
-	(((uint64_t)(gpu_num) << 61) + 0x1000000000000)
+	(((uint64_t)(gpu_num) << 61) + 0x1000000000000L)
 
 #define MAKE_GPUVM_APP_LIMIT(base) \
-	(((uint64_t)(base) & 0xFFFFFF0000000000) | 0xFFFFFFFFFF)
+	(((uint64_t)(base) & \
+		0xFFFFFF0000000000UL) | 0xFFFFFFFFFFL)
 
 #define MAKE_SCRATCH_APP_BASE(gpu_num) \
-	(((uint64_t)(gpu_num) << 61) + 0x100000000)
+	(((uint64_t)(gpu_num) << 61) + 0x100000000L)
 
 #define MAKE_SCRATCH_APP_LIMIT(base) \
-	(((uint64_t)base & 0xFFFFFFFF00000000) | 0xFFFFFFFF)
+	(((uint64_t)base & 0xFFFFFFFF00000000UL) | 0xFFFFFFFF)
 
 #define MAKE_LDS_APP_BASE(gpu_num) \
 	(((uint64_t)(gpu_num) << 61) + 0x0)
 #define MAKE_LDS_APP_LIMIT(base) \
-	(((uint64_t)(base) & 0xFFFFFFFF00000000) | 0xFFFFFFFF)
+	(((uint64_t)(base) & 0xFFFFFFFF00000000UL) | 0xFFFFFFFF)
 
 int kfd_init_apertures(struct kfd_process *process)
 {
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

PATCH 6/12 amdkfd: is_occupied() can be static

In reply to Oded Gabbay
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +3 -3
index 59d2407..adc3147 100644
@@ -179,9 +179,9 @@ static int destroy_mqd(struct mqd_manager *mm, void *mqd,
 					pipe_id, queue_id);
 }
 
-bool is_occupied(struct mqd_manager *mm, void *mqd,
-		uint64_t queue_address,	uint32_t pipe_id,
-		uint32_t queue_id)
+static bool is_occupied(struct mqd_manager *mm, void *mqd,
+			uint64_t queue_address,	uint32_t pipe_id,
+			uint32_t queue_id)
 {
 
 	return kfd2kgd->hqd_is_occupies(mm->dev->kgd, queue_address,
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 7/12 amdkfd: fence_wait_timeout() can be static

In reply to Oded Gabbay
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -2
index 8c40d04..718f50e 100644
@@ -789,8 +789,9 @@ out:
 	return retval;
 }
 
-int fence_wait_timeout(unsigned int *fence_addr, unsigned int fence_value,
-			unsigned long timeout)
+static int fence_wait_timeout(unsigned int *fence_addr,
+				unsigned int fence_value,
+				unsigned long timeout)
 {
 	BUG_ON(!fence_addr);
 	timeout += jiffies;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH 8/12 amdkfd: add __iomem attribute to doorbell_ptr

In reply to Oded Gabbay

This patch was done due to sparse warning. It changes the definition of doorbell_ptr in queue_properties to be with __iomem attribute, so it would match the type which the doorbell module functions are returning.

---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 9 ++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h         | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +4 -5
index 424ddcc..5055fc9 100644
@@ -66,8 +66,7 @@ static bool initialize(struct kernel_queue *kq, struct kfd_dev *dev,
 	if (kq->mqd == NULL)
 		return false;
 
-	prop.doorbell_ptr =
-		(uint32_t *)kfd_get_kernel_doorbell(dev, &prop.doorbell_off);
+	prop.doorbell_ptr = kfd_get_kernel_doorbell(dev, &prop.doorbell_off);
 
 	if (prop.doorbell_ptr == NULL)
 		goto err_get_kernel_doorbell;
@@ -172,7 +171,7 @@ err_rptr_allocate_vidmem:
 	kfd2kgd->free_mem(dev->kgd, (struct kgd_mem *) kq->pq);
 err_pq_allocate_vidmem:
 	pr_err("kfd: error init pq\n");
-	kfd_release_kernel_doorbell(dev, (u32 *)prop.doorbell_ptr);
+	kfd_release_kernel_doorbell(dev, prop.doorbell_ptr);
 err_get_kernel_doorbell:
 	pr_err("kfd: error init doorbell");
 	return false;
@@ -195,7 +194,7 @@ static void uninitialize(struct kernel_queue *kq)
 	kfd2kgd->free_mem(kq->dev->kgd, (struct kgd_mem *) kq->wptr_mem);
 	kfd2kgd->free_mem(kq->dev->kgd, (struct kgd_mem *) kq->pq);
 	kfd_release_kernel_doorbell(kq->dev,
-				(u32 *)kq->queue->properties.doorbell_ptr);
+					kq->queue->properties.doorbell_ptr);
 	uninit_queue(kq->queue);
 }
 
@@ -255,7 +254,7 @@ static void submit_packet(struct kernel_queue *kq)
 #endif
 
 	*kq->wptr_kernel = kq->pending_wptr;
-	write_kernel_doorbell((u32 *)kq->queue->properties.doorbell_ptr,
+	write_kernel_doorbell(kq->queue->properties.doorbell_ptr,
 				kq->pending_wptr);
 }
 
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
index 41e608d..d0bcafc 100644
@@ -279,7 +279,7 @@ struct queue_properties {
 	uint32_t queue_percent;
 	uint32_t *read_ptr;
 	uint32_t *write_ptr;
-	uint32_t *doorbell_ptr;
+	uint32_t __iomem *doorbell_ptr;
 	uint32_t doorbell_off;
 	bool is_interop;
 	bool is_active;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH 9/12 amdkfd: Fix memory leak on process deregistration

In reply to Oded Gabbay

From: Jay Cornwall <[email protected]>

struct device_process_node was allocated during process registration but not released at process deregistration.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -0
index 718f50e..bc8961c3 100644
@@ -409,6 +409,7 @@ static int unregister_process_nocpsch(struct device_queue_manager *dqm,
 	list_for_each_entry_safe(cur, next, &dqm->queues, list) {
 		if (qpd == cur->qpd) {
 			list_del(&cur->list);
+			kfree(cur);
 			dqm->processes_count--;
 			goto out;
 		}
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH 10/12 amdkfd: use schedule() in sync_with_hw

In reply to Oded Gabbay

amdkfd uses cpu_relax() in its sync_with_hw() function. Because cpu_relax() is defined as 'REP; NOP' on x86_64, it will block the CPU from servicing IOMMU PPR requests.

This may cause a deadlock, because sync_with_hw() won't be completed until the PPR request has been served.

Therefore, we need to use schedule() instead of cpu_relax() as it is the minimum requirement to allow other threads to execute.

---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +2 -1
index 5055fc9..9abac48 100644
@@ -25,6 +25,7 @@
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/printk.h>
+#include <linux/sched.h>
 #include "kfd_kernel_queue.h"
 #include "kfd_priv.h"
 #include "kfd_device_queue_manager.h"
@@ -274,7 +275,7 @@ static int sync_with_hw(struct kernel_queue *kq, unsigned long timeout_ms)
 				*kq->wptr_kernel, *kq->rptr_kernel);
 			return -ETIME;
 		}
-		cpu_relax();
+		schedule();
 	}
 
 	return 0;
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 11/12 amdkfd: Instead of using get function, use container_of

From: Alexey Skidanov <[email protected]>

---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c   | 21 +++++++++------------
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h               |  2 ++
 2 files changed, 11 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +9 -12
index bc8961c3..904eb38 100644
@@ -67,26 +67,21 @@ static inline unsigned int get_pipes_num_cpsch(void)
 	return PIPE_PER_ME_CP_SCHEDULING;
 }
 
-static unsigned int get_sh_mem_bases_nybble_64(struct kfd_process *process,
-						struct kfd_dev *dev)
+static inline unsigned int
+get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd)
 {
-	struct kfd_process_device *pdd;
 	uint32_t nybble;
 
-	pdd = kfd_get_process_device_data(dev, process, 1);
 	nybble = (pdd->lds_base >> 60) & 0x0E;
 
 	return nybble;
 
 }
 
-static unsigned int get_sh_mem_bases_32(struct kfd_process *process,
-					struct kfd_dev *dev)
+static inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd)
 {
-	struct kfd_process_device *pdd;
 	unsigned int shared_base;
 
-	pdd = kfd_get_process_device_data(dev, process, 1);
 	shared_base = (pdd->lds_base >> 16) & 0xFF;
 
 	return shared_base;
@@ -96,10 +91,13 @@ static uint32_t compute_sh_mem_bases_64bit(unsigned int top_address_nybble);
 static void init_process_memory(struct device_queue_manager *dqm,
 				struct qcm_process_device *qpd)
 {
+	struct kfd_process_device *pdd;
 	unsigned int temp;
 
 	BUG_ON(!dqm || !qpd);
 
+	pdd = qpd_to_pdd(qpd);
+
 	/* check if sh_mem_config register already configured */
 	if (qpd->sh_mem_config == 0) {
 		qpd->sh_mem_config =
@@ -111,11 +109,11 @@ static void init_process_memory(struct device_queue_manager *dqm,
 	}
 
 	if (qpd->pqm->process->is_32bit_user_mode) {
-		temp = get_sh_mem_bases_32(qpd->pqm->process, dqm->dev);
+		temp = get_sh_mem_bases_32(pdd);
 		qpd->sh_mem_bases = SHARED_BASE(temp);
 		qpd->sh_mem_config |= PTR32;
 	} else {
-		temp = get_sh_mem_bases_nybble_64(qpd->pqm->process, dqm->dev);
+		temp = get_sh_mem_bases_nybble_64(pdd);
 		qpd->sh_mem_bases = compute_sh_mem_bases_64bit(temp);
 	}
 
@@ -707,8 +705,7 @@ static int stop_cpsch(struct device_queue_manager *dqm)
 	destroy_queues_cpsch(dqm, true);
 
 	list_for_each_entry(node, &dqm->queues, list) {
-		pdd = kfd_get_process_device_data(dqm->dev,
-						node->qpd->pqm->process, 1);
+		pdd = qpd_to_pdd(node->qpd);
 		pdd->bound = false;
 	}
 	kfd2kgd->free_mem(dqm->dev->kgd,
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -0
index d0bcafc..f9fb81e 100644
@@ -414,6 +414,8 @@ struct kfd_process_device {
 	bool bound;
 };
 
+#define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd)
+
 /* Process data */
 struct kfd_process {
 	/*
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 12/12 amdkfd: Clear ctx cb before suspend

In reply to Oded Gabbay
---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -0
index 9beb6f7..43884eb 100644
@@ -267,6 +267,7 @@ void kgd2kfd_suspend(struct kfd_dev *kfd)
 
 	if (kfd->init_complete) {
 		kfd->dqm->stop(kfd->dqm);
+		amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL);
 		amd_iommu_free_device(kfd->pdev);
 	}
 }
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on the v1 series
#13 lore raw
In reply to Oded Gabbay
Quoted 5 lines · Oded Gabbay

Hi,
This patch-set contains mostly fixes for sparse warnings.
In addition, there is a fix for a memory leak, for suspend operation and a patch that prevents the blocking of IOMMU PPR handling while waiting to sync with hw

Series is:

Quoted 34 lines

Oded

Alexey Skidanov (1):
amdkfd: Instead of using get function, use container_of

Jay Cornwall (1):
amdkfd: Fix memory leak on process deregistration

Oded Gabbay (8):
amdkfd: Fix sparse warnings in kfd_chardev.c
amdkfd: Fix sparse warnings in kfd_topology.c
amdkfd: Fix sparse warnings in kfd_flat_memory.c
amdkfd: is_occupied() can be static
amdkfd: fence_wait_timeout() can be static
amdkfd: add __iomem attribute to doorbell_ptr
amdkfd: use schedule() in sync_with_hw
amdkfd: Clear ctx cb before suspend

kbuild test robot (2):
amdkfd: test_kq() can be static
amdkfd: pqm_get_kernel_queue() can be static

 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           | 16 ++++++---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c            |  1 +
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  | 27 +++++++--------
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c       | 11 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c      | 14 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c       |  6 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |  4 ++-
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c          | 40 +++++++++++-----------
 9 files changed, 67 insertions(+), 55 deletions(-)
Quoted 7 lines

--
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel