Skip to contentSkip to conversation

drm/amdgpu: unify the way to judge RAS feature readiness

PATCH In review Evan Quan 2 participants 8 messages Mar 11, 2019 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/2 drm/amdgpu: unify the way to judge RAS feature readiness

Unify the way to judge whether a specific RAS feature is supported.

Change-Id I14bb19db49f06e134de903376b14eb27e0e038c7
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 10 ++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -8
index bf462c59cb76..7f9cbd64cb20 100644
@@ -466,12 +466,6 @@ static struct ras_manager *amdgpu_ras_find_obj(struct amdgpu_device *adev,
 /* obj end */
 
 /* feature ctl begin */
-static int amdgpu_ras_is_feature_allowed(struct amdgpu_device *adev,
-		struct ras_common_if *head)
-{
-	return amdgpu_ras_enable && (amdgpu_ras_mask & BIT(head->block));
-}
-
 static int amdgpu_ras_is_feature_enabled(struct amdgpu_device *adev,
 		struct ras_common_if *head)
 {
@@ -490,7 +484,7 @@ static int __amdgpu_ras_feature_enable(struct amdgpu_device *adev,
 	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 	struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
 
-	if (!amdgpu_ras_is_feature_allowed(adev, head))
+	if (!amdgpu_ras_is_supported(adev, head->block))
 		return 0;
 	if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
 		return 0;
@@ -539,7 +533,7 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
 	}
 
 	/* Do not enable if it is not allowed. */
-	WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev, head));
+	WARN_ON(enable && !amdgpu_ras_is_supported(adev, head->block));
 	/* Are we alerady in that state we are going to set? */
 	if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
 		return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -1
index 02cb9a13ddc5..0ef2b91b8fcd 100644
@@ -163,7 +163,7 @@ struct ras_debug_if {
 
 /* check if ras is supported on block, say, sdma, gfx */
 static inline int amdgpu_ras_is_supported(struct amdgpu_device *adev,
-		unsigned int block)
+		enum amdgpu_ras_block block)
 {
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw

PATCH 2/2 drm/amdgpu: drop unnecessary dereference

It's unnecessary and confusing.

Change-Id I77fe54a108b7ee2031851b3e11d63c4fb74c0d43
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 26 +++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 26 +++++++++++++-------------
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 26 +++++++++++++-------------
 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -13
index 3fb72bf420e0..31996d448817 100644
@@ -3532,7 +3532,7 @@ static int gfx_v9_0_process_ras_data_cb(struct amdgpu_device *adev,
 static int gfx_v9_0_ecc_late_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gfx.ras_if;
+	struct ras_common_if *ras_if = adev->gfx.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gfx_v9_0_process_ras_data_cb,
 	};
@@ -3553,21 +3553,21 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -3587,16 +3587,16 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -13
index 5d1ac53f7ddb..229e614d1b76 100644
@@ -714,7 +714,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)
 static int gmc_v9_0_ecc_late_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gmc.ras_if;
+	struct ras_common_if *ras_if = adev->gmc.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gmc_v9_0_process_ras_data_cb,
 	};
@@ -735,21 +735,21 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -769,16 +769,16 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -13
index 3ac5abe937f4..521218053477 100644
@@ -1501,7 +1501,7 @@ static int sdma_v4_0_process_ras_data_cb(struct amdgpu_device *adev,
 static int sdma_v4_0_late_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->sdma.ras_if;
+	struct ras_common_if *ras_if = adev->sdma.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = sdma_v4_0_process_ras_data_cb,
 	};
@@ -1523,21 +1523,21 @@ static int sdma_v4_0_late_init(void *handle)
 	}
 
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -1563,16 +1563,16 @@ static int sdma_v4_0_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

Well, I think you forgot setting adev->gfx.ras_if = ras_if in the end.

struct ras_common_if **ras_if is pretty simple and easy to use. I prefer to keep the code as it is.

Thanks
xinhui

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

It's unnecessary and confusing.

Change-Id I77fe54a108b7ee2031851b3e11d63c4fb74c0d43
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 26 +++++++++++++-------------  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 26 +++++++++++++-------------  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 26 +++++++++++++-------------
 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -13
index 3fb72bf420e0..31996d448817 100644
@@ -3532,7 +3532,7 @@ static int gfx_v9_0_process_ras_data_cb(struct amdgpu_device *adev,  static int gfx_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gfx.ras_if;
+	struct ras_common_if *ras_if = adev->gfx.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gfx_v9_0_process_ras_data_cb,
 	};
@@ -3553,21 +3553,21 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -3587,16 +3587,16 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -13
index 5d1ac53f7ddb..229e614d1b76 100644
@@ -714,7 +714,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct amdgpu_device *adev)  static int gmc_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gmc.ras_if;
+	struct ras_common_if *ras_if = adev->gmc.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gmc_v9_0_process_ras_data_cb,
 	};
@@ -735,21 +735,21 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -769,16 +769,16 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -13
index 3ac5abe937f4..521218053477 100644
@@ -1501,7 +1501,7 @@ static int sdma_v4_0_process_ras_data_cb(struct amdgpu_device *adev,  static int sdma_v4_0_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->sdma.ras_if;
+	struct ras_common_if *ras_if = adev->sdma.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = sdma_v4_0_process_ras_data_cb,
 	};
@@ -1523,21 +1523,21 @@ static int sdma_v4_0_late_init(void *handle)
 	}
 
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -1563,16 +1563,16 @@ static int sdma_v4_0_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 

--
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB280003172F75FEECA9BE96D187480-kxOKjb6HO/[email protected]

author
#6 lore raw

RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

I cannot get your point. "ras_if" was already assigned to be same as "adev->gfx.ras_if" at the start of the APIs. //// struct ras_common_if *ras_if = adev->gfx.ras_if; /////
Why there is need to set " adev->gfx.ras_if = ras_if" again?

Regards,
Evan

Quoted 232 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Pan, Xinhui
Sent: 2019年3月11日 13:19
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

Well, I think you forgot setting adev->gfx.ras_if = ras_if in the end.

struct ras_common_if **ras_if is pretty simple and easy to use. I prefer to keep the code as it is.

Thanks
xinhui

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

It's unnecessary and confusing.

Change-Id I77fe54a108b7ee2031851b3e11d63c4fb74c0d43
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 26 +++++++++++++-------------

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 26 +++++++++++++------------

(quoted diff) +0 -2
-  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 26 +++++++++++++---------
----
 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -13
index 3fb72bf420e0..31996d448817 100644
@@ -3532,7 +3532,7 @@ static int gfx_v9_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int gfx_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gfx.ras_if;
+	struct ras_common_if *ras_if = adev->gfx.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gfx_v9_0_process_ras_data_cb,
 	};
@@ -3553,21 +3553,21 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -3587,16 +3587,16 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -13
index 5d1ac53f7ddb..229e614d1b76 100644
@@ -714,7 +714,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct
 amdgpu_device *adev)  static int gmc_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gmc.ras_if;
+	struct ras_common_if *ras_if = adev->gmc.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gmc_v9_0_process_ras_data_cb,
 	};
@@ -735,21 +735,21 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -769,16 +769,16 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -14
index 3ac5abe937f4..521218053477 100644
@@ -1501,7 +1501,7 @@ static int sdma_v4_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int sdma_v4_0_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->sdma.ras_if;
+	struct ras_common_if *ras_if = adev->sdma.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = sdma_v4_0_process_ras_data_cb,
 	};
@@ -1523,21 +1523,21 @@ static int sdma_v4_0_late_init(void *handle)
 	}
 
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -1563,16 +1563,16 @@ static int sdma_v4_0_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
--

2.21.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB3344AFD285AAD5483D92580CE4480-rweVpJHSKToDMgCC8P//[email protected]

#8 lore raw

RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

adev->gfx.ras_if is a pointer and it is NULL at the first time

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: 2019年3月11日 13:41
To: Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

I cannot get your point. "ras_if" was already assigned to be same as "adev->gfx.ras_if" at the start of the APIs. //// struct ras_common_if *ras_if = adev->gfx.ras_if; ///// Why there is need to set " adev->gfx.ras_if = ras_if" again?

Regards,
Evan

Quoted 234 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Pan, Xinhui
Sent: 2019年3月11日 13:19
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

Well, I think you forgot setting adev->gfx.ras_if = ras_if in the end.

struct ras_common_if **ras_if is pretty simple and easy to use. I prefer to keep the code as it is.

Thanks
xinhui

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

It's unnecessary and confusing.

Change-Id I77fe54a108b7ee2031851b3e11d63c4fb74c0d43
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 26 

+++++++++++++------------- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 26
+++++++++++++------------

(quoted diff) +0 -2
-  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 26 +++++++++++++---------
----
 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -13
index 3fb72bf420e0..31996d448817 100644
@@ -3532,7 +3532,7 @@ static int gfx_v9_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int gfx_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gfx.ras_if;
+	struct ras_common_if *ras_if = adev->gfx.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gfx_v9_0_process_ras_data_cb,
 	};
@@ -3553,21 +3553,21 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -3587,16 +3587,16 @@ static int gfx_v9_0_ecc_late_init(void 
 *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -13
index 5d1ac53f7ddb..229e614d1b76 100644
@@ -714,7 +714,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct
 amdgpu_device *adev)  static int gmc_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gmc.ras_if;
+	struct ras_common_if *ras_if = adev->gmc.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gmc_v9_0_process_ras_data_cb,
 	};
@@ -735,21 +735,21 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -769,16 +769,16 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -14
index 3ac5abe937f4..521218053477 100644
@@ -1501,7 +1501,7 @@ static int sdma_v4_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int sdma_v4_0_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->sdma.ras_if;
+	struct ras_common_if *ras_if = adev->sdma.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = sdma_v4_0_process_ras_data_cb,
 	};
@@ -1523,21 +1523,21 @@ static int sdma_v4_0_late_init(void *handle)
 	}
 
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -1563,16 +1563,16 @@ static int sdma_v4_0_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
--

2.21.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB28008BD6E89295354485D56B87480-kxOKjb6HO/[email protected]

author
#10 lore raw

RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

OK, i see. Yes, adev->gfx.ras_if needs to point to the new alloced buffer as it was NULL. I still think drop one level dereference can make code clean and better understandable. Anyway, it's fine with me to keep old code.

Regards,
Evan

Quoted 260 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Pan, Xinhui
Sent: 2019年3月11日 13:45
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

adev->gfx.ras_if is a pointer and it is NULL at the first time

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: 2019年3月11日 13:41
To: Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

I cannot get your point. "ras_if" was already assigned to be same as "adev-

Quoted 1 line

gfx.ras_if" at the start of the APIs.

//// struct ras_common_if *ras_if = adev->gfx.ras_if; ///// Why there is need to set " adev->gfx.ras_if = ras_if" again?

Regards,
Evan

Quoted 26 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Pan, Xinhui
Sent: 2019年3月11日 13:19
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

Well, I think you forgot setting adev->gfx.ras_if = ras_if in the end.

struct ras_common_if **ras_if is pretty simple and easy to use. I prefer to keep the code as it is.

Thanks
xinhui

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: drop unnecessary dereference

Quoted 7 lines

It's unnecessary and confusing.

Change-Id I77fe54a108b7ee2031851b3e11d63c4fb74c0d43
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 26

+++++++++++++------------- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |

26

Quoted 2 lines

+++++++++++++------------
- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 26 +++++++++++++-------

--

Quoted 199 lines

----

 3 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -13
index 3fb72bf420e0..31996d448817 100644
@@ -3532,7 +3532,7 @@ static int gfx_v9_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int gfx_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gfx.ras_if;
+	struct ras_common_if *ras_if = adev->gfx.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gfx_v9_0_process_ras_data_cb,
 	};
@@ -3553,21 +3553,21 @@ static int gfx_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -3587,16 +3587,16 @@ static int gfx_v9_0_ecc_late_init(void
 *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -13
index 5d1ac53f7ddb..229e614d1b76 100644
@@ -714,7 +714,7 @@ static int gmc_v9_0_allocate_vm_inv_eng(struct
 amdgpu_device *adev)  static int gmc_v9_0_ecc_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->gmc.ras_if;
+	struct ras_common_if *ras_if = adev->gmc.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = gmc_v9_0_process_ras_data_cb,
 	};
@@ -735,21 +735,21 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 		return 0;
 	}
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -769,16 +769,16 @@ static int gmc_v9_0_ecc_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +13 -14
index 3ac5abe937f4..521218053477 100644
@@ -1501,7 +1501,7 @@ static int sdma_v4_0_process_ras_data_cb(struct
 amdgpu_device *adev,  static int sdma_v4_0_late_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	struct ras_common_if **ras_if = &adev->sdma.ras_if;
+	struct ras_common_if *ras_if = adev->sdma.ras_if;
 	struct ras_ih_if ih_info = {
 		.cb = sdma_v4_0_process_ras_data_cb,
 	};
@@ -1523,21 +1523,21 @@ static int sdma_v4_0_late_init(void *handle)
 	}
 
 	/* handle resume path. */
-	if (*ras_if)
+	if (ras_if)
 		goto resume;
 
-	*ras_if = kmalloc(sizeof(**ras_if), GFP_KERNEL);
-	if (!*ras_if)
+	ras_if = kmalloc(sizeof(*ras_if), GFP_KERNEL);
+	if (!ras_if)
 		return -ENOMEM;
 
-	**ras_if = ras_block;
+	*ras_if = ras_block;
 
-	r = amdgpu_ras_feature_enable(adev, *ras_if, 1);
+	r = amdgpu_ras_feature_enable(adev, ras_if, 1);
 	if (r)
 		goto feature;
 
-	ih_info.head = **ras_if;
-	fs_info.head = **ras_if;
+	ih_info.head = *ras_if;
+	fs_info.head = *ras_if;
 
 	r = amdgpu_ras_interrupt_add_handler(adev, &ih_info);
 	if (r)
@@ -1563,16 +1563,16 @@ static int sdma_v4_0_late_init(void *handle)
 
 	return 0;
 irq:
-	amdgpu_ras_sysfs_remove(adev, *ras_if);
+	amdgpu_ras_sysfs_remove(adev, ras_if);
 sysfs:
-	amdgpu_ras_debugfs_remove(adev, *ras_if);
+	amdgpu_ras_debugfs_remove(adev, ras_if);
 debugfs:
 	amdgpu_ras_interrupt_remove_handler(adev, &ih_info);
 interrupt:
-	amdgpu_ras_feature_enable(adev, *ras_if, 0);
+	amdgpu_ras_feature_enable(adev, ras_if, 0);
 feature:
-	kfree(*ras_if);
-	*ras_if = NULL;
+	kfree(ras_if);
+	ras_if = NULL;
 	return -EINVAL;
 }
 
--

2.21.0

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw
In reply to a message not in the archive

Inline.

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: unify the way to judge RAS feature readiness

Unify the way to judge whether a specific RAS feature is supported.

Change-Id I14bb19db49f06e134de903376b14eb27e0e038c7
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 10 ++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -7
index bf462c59cb76..7f9cbd64cb20 100644
@@ -466,12 +466,6 @@ static struct ras_manager *amdgpu_ras_find_obj(struct amdgpu_device *adev,
 /* obj end */
 
 /* feature ctl begin */
-static int amdgpu_ras_is_feature_allowed(struct amdgpu_device *adev,
-		struct ras_common_if *head)
-{
-	return amdgpu_ras_enable && (amdgpu_ras_mask & BIT(head->block));
-}
-
 static int amdgpu_ras_is_feature_enabled(struct amdgpu_device *adev,
 		struct ras_common_if *head)
 {
@@ -490,7 +484,7 @@ static int __amdgpu_ras_feature_enable(struct amdgpu_device *adev,
 	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 	struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
 
-	if (!amdgpu_ras_is_feature_allowed(adev, head))
+	if (!amdgpu_ras_is_supported(adev, head->block))
 		return 0;
 

[XH] I am thinking of splitting supported to hw_supported and sw_supported. The code become a little clearer now.
For hw_supported case, we need allow IP disable ras.
For sw_suppporeted case, we need allow IP disable/enable/inject/query, etc .

if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
return 0;
@@ -539,7 +533,7 @@ int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
}

/* Do not enable if it is not allowed. */
- WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev, head));
+ WARN_ON(enable && !amdgpu_ras_is_supported(adev, head->block));
/* Are we alerady in that state we are going to set? */ if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -2
index 02cb9a13ddc5..0ef2b91b8fcd 100644
@@ -163,7 +163,7 @@ struct ras_debug_if {
 
 /* check if ras is supported on block, say, sdma, gfx */  static inline int amdgpu_ras_is_supported(struct amdgpu_device *adev,
-		unsigned int block)
+		enum amdgpu_ras_block block)
 {
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
--

2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB28007A2E394FFDC0A570959A87480-kxOKjb6HO/[email protected]

author
#13 lore raw
Quoted 61 lines

-----Original Message-----
From: Pan, Xinhui
Sent: 2019年3月11日 13:08
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu: unify the way to judge RAS feature readiness

Inline.

-----Original Message-----
From: Evan Quan <[email protected]>
Sent: 2019年3月11日 12:31
To: [email protected]
Cc: Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: unify the way to judge RAS feature readiness

Unify the way to judge whether a specific RAS feature is supported.

Change-Id I14bb19db49f06e134de903376b14eb27e0e038c7
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 10 ++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h |  2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -6
index bf462c59cb76..7f9cbd64cb20 100644
@@ -466,12 +466,6 @@ static struct ras_manager
 *amdgpu_ras_find_obj(struct amdgpu_device *adev,
 /* obj end */
 
 /* feature ctl begin */
-static int amdgpu_ras_is_feature_allowed(struct amdgpu_device *adev,
-		struct ras_common_if *head)
-{
-	return amdgpu_ras_enable && (amdgpu_ras_mask & BIT(head-
 >block));
-}
-
 static int amdgpu_ras_is_feature_enabled(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
 		struct ras_common_if *head)
 {
@@ -490,7 +484,7 @@ static int __amdgpu_ras_feature_enable(struct
 amdgpu_device *adev,
 	struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
 	struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
 
-	if (!amdgpu_ras_is_feature_allowed(adev, head))
+	if (!amdgpu_ras_is_supported(adev, head->block))
 		return 0;
 
Quoted 6 lines

[XH] I am thinking of splitting supported to hw_supported and sw_supported. The code become a little clearer now.
For hw_supported case, we need allow IP disable ras.
For sw_suppporeted case, we need allow IP disable/enable/inject/query, etc .

[Quan, Evan] "sw_supported" here means amdgpu_ras_enable/mask module parameters. Right?
[Quan, Evan] And do you mean even with "sw_supported" disabled(ras_enable/mask = 0), there will be still RAS disable functionality as long as hardware supports it? Not quite sure, that sounds a little confusing.
Anyway, I think you can add one more flag to existing amdgpu_ras_is_supported() to support this. Maintaining two APIs which do almost the same thing is error-prone.

Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
 	if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
 		return 0;
@@ -539,7 +533,7 @@ int amdgpu_ras_feature_enable(struct
 amdgpu_device *adev,
 	}
 
 	/* Do not enable if it is not allowed. */
-	WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev,
 head));
+	WARN_ON(enable && !amdgpu_ras_is_supported(adev, head-
 >block));
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
 	/* Are we alerady in that state we are going to set? */
 	if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
 		return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h +1 -2
index 02cb9a13ddc5..0ef2b91b8fcd 100644
@@ -163,7 +163,7 @@ struct ras_debug_if {
 
 /* check if ras is supported on block, say, sdma, gfx */  static inline int
 amdgpu_ras_is_supported(struct amdgpu_device *adev,
-		unsigned int block)
+		enum amdgpu_ras_block block)
 {
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
--
Quoted 1 line

2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx