dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] amdkfd fixes (sparse and some more)
@ 2014-11-21  8:38 Oded Gabbay
  2014-11-21  8:43 ` [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c Oded Gabbay
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:38 UTC (permalink / raw)
  To: dri-devel

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(-)

-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c
  2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
@ 2014-11-21  8:43 ` Oded Gabbay
  2014-11-21  8:43   ` [PATCH 02/12] amdkfd: Fix sparse warnings in kfd_topology.c Oded Gabbay
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:43 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 64c73ba..3b3fce7 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -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;
 	}
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/12] amdkfd: Fix sparse warnings in kfd_topology.c
  2014-11-21  8:43 ` [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c Oded Gabbay
@ 2014-11-21  8:43   ` Oded Gabbay
  0 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:43 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 40 +++++++++++++++----------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 77cd7d5..5733e28 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/12] amdkfd: test_kq() can be static
  2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
  2014-11-21  8:43 ` [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c Oded Gabbay
@ 2014-11-21  8:47 ` Oded Gabbay
  2014-11-21  8:47   ` [PATCH 04/12] amdkfd: pqm_get_kernel_queue() " Oded Gabbay
                     ` (4 more replies)
  2014-11-21  8:49 ` [PATCH 09/12] amdkfd: Fix memory leak on process deregistration Oded Gabbay
                   ` (2 subsequent siblings)
  4 siblings, 5 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel; +Cc: kbuild test robot

From: kbuild test robot <fengguang.wu@intel.com>

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index 555af45..424ddcc 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/12] amdkfd: pqm_get_kernel_queue() can be static
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
@ 2014-11-21  8:47   ` Oded Gabbay
  2014-11-21  8:47   ` [PATCH 05/12] amdkfd: Fix sparse warnings in kfd_flat_memory.c Oded Gabbay
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel; +Cc: kbuild test robot

From: kbuild test robot <fengguang.wu@intel.com>

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
index c7859fc..de2c163 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 05/12] amdkfd: Fix sparse warnings in kfd_flat_memory.c
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
  2014-11-21  8:47   ` [PATCH 04/12] amdkfd: pqm_get_kernel_queue() " Oded Gabbay
@ 2014-11-21  8:47   ` Oded Gabbay
  2014-11-21  8:47   ` [PATCH 06/12] amdkfd: is_occupied() can be static Oded Gabbay
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 2dfc4c0..66df4da 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -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)
 {
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 06/12] amdkfd: is_occupied() can be static
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
  2014-11-21  8:47   ` [PATCH 04/12] amdkfd: pqm_get_kernel_queue() " Oded Gabbay
  2014-11-21  8:47   ` [PATCH 05/12] amdkfd: Fix sparse warnings in kfd_flat_memory.c Oded Gabbay
@ 2014-11-21  8:47   ` Oded Gabbay
  2014-11-21  8:47   ` [PATCH 07/12] amdkfd: fence_wait_timeout() " Oded Gabbay
  2014-11-21  8:47   ` [PATCH 08/12] amdkfd: add __iomem attribute to doorbell_ptr Oded Gabbay
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
index 59d2407..adc3147 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
@@ -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,
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/12] amdkfd: fence_wait_timeout() can be static
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
                     ` (2 preceding siblings ...)
  2014-11-21  8:47   ` [PATCH 06/12] amdkfd: is_occupied() can be static Oded Gabbay
@ 2014-11-21  8:47   ` Oded Gabbay
  2014-11-21  8:47   ` [PATCH 08/12] amdkfd: add __iomem attribute to doorbell_ptr Oded Gabbay
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 8c40d04..718f50e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 08/12] amdkfd: add __iomem attribute to doorbell_ptr
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
                     ` (3 preceding siblings ...)
  2014-11-21  8:47   ` [PATCH 07/12] amdkfd: fence_wait_timeout() " Oded Gabbay
@ 2014-11-21  8:47   ` Oded Gabbay
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:47 UTC (permalink / raw)
  To: dri-devel

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.

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index 424ddcc..5055fc9 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -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);
 }
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 41e608d..d0bcafc 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/12] amdkfd: Fix memory leak on process deregistration
  2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
  2014-11-21  8:43 ` [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c Oded Gabbay
  2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
@ 2014-11-21  8:49 ` Oded Gabbay
  2014-11-21  8:51 ` [PATCH 10/12] amdkfd: use schedule() in sync_with_hw Oded Gabbay
  2014-11-21 15:06 ` [PATCH 00/12] amdkfd fixes (sparse and some more) Alex Deucher
  4 siblings, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:49 UTC (permalink / raw)
  To: dri-devel; +Cc: Jay Cornwall

From: Jay Cornwall <jay.cornwall@amd.com>

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

Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 718f50e..bc8961c3 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -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;
 		}
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/12] amdkfd: use schedule() in sync_with_hw
  2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
                   ` (2 preceding siblings ...)
  2014-11-21  8:49 ` [PATCH 09/12] amdkfd: Fix memory leak on process deregistration Oded Gabbay
@ 2014-11-21  8:51 ` Oded Gabbay
  2014-11-21  8:51   ` [PATCH 11/12] amdkfd: Instead of using get function, use container_of Oded Gabbay
  2014-11-21  8:52   ` [PATCH 12/12] amdkfd: Clear ctx cb before suspend Oded Gabbay
  2014-11-21 15:06 ` [PATCH 00/12] amdkfd fixes (sparse and some more) Alex Deucher
  4 siblings, 2 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:51 UTC (permalink / raw)
  To: dri-devel

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.

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index 5055fc9..9abac48 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -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;
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 11/12] amdkfd: Instead of using get function, use container_of
  2014-11-21  8:51 ` [PATCH 10/12] amdkfd: use schedule() in sync_with_hw Oded Gabbay
@ 2014-11-21  8:51   ` Oded Gabbay
  2014-11-21  8:52   ` [PATCH 12/12] amdkfd: Clear ctx cb before suspend Oded Gabbay
  1 sibling, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:51 UTC (permalink / raw)
  To: dri-devel

From: Alexey Skidanov <Alexey.Skidanov@amd.com>

Signed-off-by: Alexey Skidanov <Alexey.Skidanov@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 .../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(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index bc8961c3..904eb38 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -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,
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index d0bcafc..f9fb81e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -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 {
 	/*
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 12/12] amdkfd: Clear ctx cb before suspend
  2014-11-21  8:51 ` [PATCH 10/12] amdkfd: use schedule() in sync_with_hw Oded Gabbay
  2014-11-21  8:51   ` [PATCH 11/12] amdkfd: Instead of using get function, use container_of Oded Gabbay
@ 2014-11-21  8:52   ` Oded Gabbay
  1 sibling, 0 replies; 14+ messages in thread
From: Oded Gabbay @ 2014-11-21  8:52 UTC (permalink / raw)
  To: dri-devel

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index 9beb6f7..43884eb 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -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);
 	}
 }
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 00/12] amdkfd fixes (sparse and some more)
  2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
                   ` (3 preceding siblings ...)
  2014-11-21  8:51 ` [PATCH 10/12] amdkfd: use schedule() in sync_with_hw Oded Gabbay
@ 2014-11-21 15:06 ` Alex Deucher
  4 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2014-11-21 15:06 UTC (permalink / raw)
  To: Oded Gabbay; +Cc: Maling list - DRI developers

On Fri, Nov 21, 2014 at 3:38 AM, Oded Gabbay <oded.gabbay@amd.com> wrote:
> 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:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>
> 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(-)
>
> --
> 2.1.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-11-21 15:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-21  8:38 [PATCH 00/12] amdkfd fixes (sparse and some more) Oded Gabbay
2014-11-21  8:43 ` [PATCH 01/12] amdkfd: Fix sparse warnings in kfd_chardev.c Oded Gabbay
2014-11-21  8:43   ` [PATCH 02/12] amdkfd: Fix sparse warnings in kfd_topology.c Oded Gabbay
2014-11-21  8:47 ` [PATCH 03/12] amdkfd: test_kq() can be static Oded Gabbay
2014-11-21  8:47   ` [PATCH 04/12] amdkfd: pqm_get_kernel_queue() " Oded Gabbay
2014-11-21  8:47   ` [PATCH 05/12] amdkfd: Fix sparse warnings in kfd_flat_memory.c Oded Gabbay
2014-11-21  8:47   ` [PATCH 06/12] amdkfd: is_occupied() can be static Oded Gabbay
2014-11-21  8:47   ` [PATCH 07/12] amdkfd: fence_wait_timeout() " Oded Gabbay
2014-11-21  8:47   ` [PATCH 08/12] amdkfd: add __iomem attribute to doorbell_ptr Oded Gabbay
2014-11-21  8:49 ` [PATCH 09/12] amdkfd: Fix memory leak on process deregistration Oded Gabbay
2014-11-21  8:51 ` [PATCH 10/12] amdkfd: use schedule() in sync_with_hw Oded Gabbay
2014-11-21  8:51   ` [PATCH 11/12] amdkfd: Instead of using get function, use container_of Oded Gabbay
2014-11-21  8:52   ` [PATCH 12/12] amdkfd: Clear ctx cb before suspend Oded Gabbay
2014-11-21 15:06 ` [PATCH 00/12] amdkfd fixes (sparse and some more) Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox