Skip to contentSkip to conversation

drm/amdgpu: Remove repeated calls

PATCH In review yipechai 3 participants 8 messages Jan 19, 2022

Subsystems (2)
lore
Share & tools
lore

yipechai

author
#0 lore raw

PATCH 1/3 drm/amdgpu: Remove repeated calls

Remove repeated calls.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -3
index 7a1d2bac698e..4992bc554c0c 100644
@@ -1704,9 +1704,7 @@ static void amdgpu_ras_log_on_err_counter(struct amdgpu_device *adev)
 static void amdgpu_ras_error_status_query(struct amdgpu_device *adev,
 					  struct ras_query_if *info)
 {
-	struct amdgpu_ras_block_object *block_obj = amdgpu_ras_get_ras_block(adev,
-									info->head.block,
-									info->head.sub_block_index);
+	struct amdgpu_ras_block_object *block_obj;
 	/*
 	 * Only two block need to query read/write
 	 * RspStatus at current state
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/3 drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

Move xgmi ras initialization from .late_init to .early_init, which let xgmi ras be initialized only once.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 -----
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 9 +++++++++
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -5
index 3483a82f5734..d83eee1984c8 100644
@@ -452,11 +452,6 @@ int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev)
 			return r;
 	}
 
-	if (!adev->gmc.xgmi.connected_to_cpu) {
-		adev->gmc.xgmi.ras = &xgmi_ras;
-		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras->ras_block);
-	}
-
 	if (adev->gmc.xgmi.ras && adev->gmc.xgmi.ras->ras_block.ras_late_init) {
 		r = adev->gmc.xgmi.ras->ras_block.ras_late_init(adev, NULL);
 		if (r)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -1
index 4f8d356f8432..5f9f82091000 100644
@@ -716,7 +716,6 @@ static void gmc_v10_0_set_gfxhub_funcs(struct amdgpu_device *adev)
 	}
 }
 
-
 static int gmc_v10_0_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +9 -0
index c76ffd1a70cd..8d1b11368a7b 100644
@@ -1303,6 +1303,14 @@ static void gmc_v9_0_set_hdp_ras_funcs(struct amdgpu_device *adev)
 	amdgpu_ras_register_ras_block(adev, &adev->hdp.ras->ras_block);
 }
 
+static void gmc_v9_0_set_xgmi_ras_funcs(struct amdgpu_device *adev)
+{
+	if (!adev->gmc.xgmi.connected_to_cpu) {
+		adev->gmc.xgmi.ras = &xgmi_ras;
+		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras->ras_block);
+	}
+}
+
 static void gmc_v9_0_set_mca_funcs(struct amdgpu_device *adev)
 {
 	/* is UMC the right IP to check for MCA?  Maybe DF? */
@@ -1339,6 +1347,7 @@ static int gmc_v9_0_early_init(void *handle)
 	gmc_v9_0_set_gfxhub_funcs(adev);
 	gmc_v9_0_set_hdp_ras_funcs(adev);
 	gmc_v9_0_set_mca_funcs(adev);
+	gmc_v9_0_set_xgmi_ras_funcs(adev);
 
 	adev->gmc.shared_aperture_start = 0x2000000000000000ULL;
 	adev->gmc.shared_aperture_end =
Signature · 1 line
2.25.1
#2 lore raw

RE: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

[AMD Official Use Only]

Quoted 46 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 19, 2022 10:56 AM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

Move xgmi ras initialization from .late_init to .early_init, which let xgmi ras be initialized only once.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 -----
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 9 +++++++++
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -5
index 3483a82f5734..d83eee1984c8 100644
@@ -452,11 +452,6 @@ int amdgpu_gmc_ras_late_init(struct amdgpu_device
 *adev)
 			return r;
 	}
 
-	if (!adev->gmc.xgmi.connected_to_cpu) {
-		adev->gmc.xgmi.ras = &xgmi_ras;
-		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras-
 >ras_block);
-	}
-
 	if (adev->gmc.xgmi.ras && adev->gmc.xgmi.ras->ras_block.ras_late_init)

{

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
 		r = adev->gmc.xgmi.ras->ras_block.ras_late_init(adev, NULL);
 		if (r)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
index 4f8d356f8432..5f9f82091000 100644

drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_set_gfxhub_funcs(struct · line 720

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -1
@@ -716,7 +716,6 @@ static void gmc_v10_0_set_gfxhub_funcs(struct
 amdgpu_device *adev)
 	}
 }
 
-

[Tao]: Please don't introduce irrelevant change.

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -0
 static int gmc_v10_0_early_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle; diff --git

a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index c76ffd1a70cd..8d1b11368a7b 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static void gmc_v9_0_set_hdp_ras_funcs(struct · line 1312

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -0
@@ -1303,6 +1303,14 @@ static void gmc_v9_0_set_hdp_ras_funcs(struct
 amdgpu_device *adev)
 	amdgpu_ras_register_ras_block(adev, &adev->hdp.ras->ras_block);  }
 
+static void gmc_v9_0_set_xgmi_ras_funcs(struct amdgpu_device *adev) {
+	if (!adev->gmc.xgmi.connected_to_cpu) {
+		adev->gmc.xgmi.ras = &xgmi_ras;
+		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras-
 >ras_block);
+	}
+}

[Tao]: Since the initialization of xgmi.ras is common for all versions of IP, I recommend to create a generic ras_early_init func for it. BTW, I think we can remove the check for block_obj's existence in register_ras_block now.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -0
+
 static void gmc_v9_0_set_mca_funcs(struct amdgpu_device *adev)  {
 	/* is UMC the right IP to check for MCA?  Maybe DF? */ @@ -1339,6
+1347,7 @@ static int gmc_v9_0_early_init(void *handle)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
 	gmc_v9_0_set_gfxhub_funcs(adev);
 	gmc_v9_0_set_hdp_ras_funcs(adev);
 	gmc_v9_0_set_mca_funcs(adev);
+	gmc_v9_0_set_xgmi_ras_funcs(adev);
 
 	adev->gmc.shared_aperture_start = 0x2000000000000000ULL;
 	adev->gmc.shared_aperture_end =
--

2.25.1

#3 lore raw

RE: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

-----Original Message-----
From: Zhou1, Tao <[email protected]>
Sent: Wednesday, January 19, 2022 2:11 PM
To: Chai, Thomas <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>; Clements, John <[email protected]>
Subject: RE: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

[AMD Official Use Only]

Quoted 52 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 19, 2022 10:56 AM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

Move xgmi ras initialization from .late_init to .early_init, which let xgmi ras be initialized only once.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 ----- 
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 9 +++++++++
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -5
index 3483a82f5734..d83eee1984c8 100644
@@ -452,11 +452,6 @@ int amdgpu_gmc_ras_late_init(struct amdgpu_device
 *adev)
 			return r;
 	}
 
-	if (!adev->gmc.xgmi.connected_to_cpu) {
-		adev->gmc.xgmi.ras = &xgmi_ras;
-		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras-
 >ras_block);
-	}
-
 	if (adev->gmc.xgmi.ras && 

adev->gmc.xgmi.ras->ras_block.ras_late_init)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
 		r = adev->gmc.xgmi.ras->ras_block.ras_late_init(adev, NULL);
 		if (r)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -1
index 4f8d356f8432..5f9f82091000 100644
@@ -716,7 +716,6 @@ static void gmc_v10_0_set_gfxhub_funcs(struct 
 amdgpu_device *adev)
 	}
 }
 
-
Quoted 1 line

[Tao]: Please don't introduce irrelevant change.

[Thomas] OK

Quoted 18 lines

static int gmc_v10_0_early_init(void *handle) {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; diff
--git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index c76ffd1a70cd..8d1b11368a7b 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -0
@@ -1303,6 +1303,14 @@ static void gmc_v9_0_set_hdp_ras_funcs(struct 
 amdgpu_device *adev)
 	amdgpu_ras_register_ras_block(adev, &adev->hdp.ras->ras_block);  }
 
+static void gmc_v9_0_set_xgmi_ras_funcs(struct amdgpu_device *adev) {
+	if (!adev->gmc.xgmi.connected_to_cpu) {
+		adev->gmc.xgmi.ras = &xgmi_ras;
+		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras-
 >ras_block);
+	}
+}
Quoted 2 lines

[Tao]: Since the initialization of xgmi.ras is common for all versions of IP, I recommend to create a generic ras_early_init func for it. BTW, I think we can remove the check for block_obj's existence in register_ras_block now.

[Thomas] I will update the patch.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -1
+
 static void gmc_v9_0_set_mca_funcs(struct amdgpu_device *adev)  {
 	/* is UMC the right IP to check for MCA?  Maybe DF? */ @@ -1339,6
+1347,7 @@ static int gmc_v9_0_early_init(void *handle)
 	gmc_v9_0_set_gfxhub_funcs(adev);
 	gmc_v9_0_set_hdp_ras_funcs(adev);
 	gmc_v9_0_set_mca_funcs(adev);
+	gmc_v9_0_set_xgmi_ras_funcs(adev);
 
 	adev->gmc.shared_aperture_start = 0x2000000000000000ULL;
 	adev->gmc.shared_aperture_end =
--

2.25.1

Reviewed-by on v1 2/3
#4 lore raw

RE: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

In reply to yipechai

[AMD Official Use Only]

Patch is

Regards,
Hawking
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 19, 2022 10:56
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: Move xgmi ras initialization from .late_init to .early_init

Move xgmi ras initialization from .late_init to .early_init, which let xgmi ras be initialized only once.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 -----  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 9 +++++++++
 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -5
index 3483a82f5734..d83eee1984c8 100644
@@ -452,11 +452,6 @@ int amdgpu_gmc_ras_late_init(struct amdgpu_device *adev)
 			return r;
 	}
 
-	if (!adev->gmc.xgmi.connected_to_cpu) {
-		adev->gmc.xgmi.ras = &xgmi_ras;
-		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras->ras_block);
-	}
-
 	if (adev->gmc.xgmi.ras && adev->gmc.xgmi.ras->ras_block.ras_late_init) {
 		r = adev->gmc.xgmi.ras->ras_block.ras_late_init(adev, NULL);
 		if (r)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -1
index 4f8d356f8432..5f9f82091000 100644
@@ -716,7 +716,6 @@ static void gmc_v10_0_set_gfxhub_funcs(struct amdgpu_device *adev)
 	}
 }
 
-
 static int gmc_v10_0_early_init(void *handle)  {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index c76ffd1a70cd..8d1b11368a7b 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7 -0
@@ -1303,6 +1303,14 @@ static void gmc_v9_0_set_hdp_ras_funcs(struct amdgpu_device *adev)
 	amdgpu_ras_register_ras_block(adev, &adev->hdp.ras->ras_block);  }
 
+static void gmc_v9_0_set_xgmi_ras_funcs(struct amdgpu_device *adev) {
+	if (!adev->gmc.xgmi.connected_to_cpu) {
+		adev->gmc.xgmi.ras = &xgmi_ras;
+		amdgpu_ras_register_ras_block(adev, &adev->gmc.xgmi.ras->ras_block);
+	}
+}
+
 static void gmc_v9_0_set_mca_funcs(struct amdgpu_device *adev)  {
 	/* is UMC the right IP to check for MCA?  Maybe DF? */ @@ -1339,6 +1347,7 @@ static int gmc_v9_0_early_init(void *handle)
 	gmc_v9_0_set_gfxhub_funcs(adev);
 	gmc_v9_0_set_hdp_ras_funcs(adev);

gmc_v9_0_set_mca_funcs(adev);
+ gmc_v9_0_set_xgmi_ras_funcs(adev);

adev->gmc.shared_aperture_start = 0x2000000000000000ULL; adev->gmc.shared_aperture_end =
--
2.25.1

author
#5 lore raw

PATCH 3/3 drm/amdgpu: Remove redundant code in gmc v10

In reply to yipechai

Gmc v10 doesn't support ras function, remove redundant code in it.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 19 -------------------
 1 file changed, 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0 -19
index 5f9f82091000..a833ef130495 100644
@@ -664,25 +664,10 @@ static void gmc_v10_0_set_umc_funcs(struct amdgpu_device *adev)
 		adev->umc.umc_inst_num = UMC_V8_7_UMC_INSTANCE_NUM;
 		adev->umc.channel_offs = UMC_V8_7_PER_CHANNEL_OFFSET_SIENNA;
 		adev->umc.channel_idx_tbl = &umc_v8_7_channel_idx_tbl[0][0];
-		adev->umc.ras = &umc_v8_7_ras;
 		break;
 	default:
 		break;
 	}
-	if (adev->umc.ras) {
-		amdgpu_ras_register_ras_block(adev, &adev->umc.ras->ras_block);
-
-		strcpy(adev->umc.ras->ras_block.name, "umc");
-		adev->umc.ras->ras_block.block = AMDGPU_RAS_BLOCK__UMC;
-
-		/* If don't define special ras_late_init function, use default ras_late_init */
-		if (!adev->umc.ras->ras_block.ras_late_init)
-				adev->umc.ras->ras_block.ras_late_init = amdgpu_umc_ras_late_init;
-
-		/* If don't define special ras_fini function, use default ras_fini */
-		if (!adev->umc.ras->ras_block.ras_fini)
-				adev->umc.ras->ras_block.ras_fini = amdgpu_umc_ras_fini;
-	}
 }
 
 
@@ -745,10 +730,6 @@ static int gmc_v10_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_gmc_ras_late_init(adev);
-	if (r)
-		return r;
-
 	return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/3
#6 lore raw
In reply to yipechai

[AMD Official Use Only]

Regards,
Hawking
-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 19, 2022 10:56
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Remove repeated calls

Remove repeated calls.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -4
index 7a1d2bac698e..4992bc554c0c 100644
@@ -1704,9 +1704,7 @@ static void amdgpu_ras_log_on_err_counter(struct amdgpu_device *adev)  static void amdgpu_ras_error_status_query(struct amdgpu_device *adev,
 					  struct ras_query_if *info)
 {
-	struct amdgpu_ras_block_object *block_obj = amdgpu_ras_get_ras_block(adev,
-									info->head.block,
-									info->head.sub_block_index);
+	struct amdgpu_ras_block_object *block_obj;
 	/*
 	 * Only two block need to query read/write
 	 * RspStatus at current state
--

2.25.1

Reviewed-by on v1 1/3
#7 lore raw
In reply to yipechai

[AMD Official Use Only]

Quoted 38 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Wednesday, January 19, 2022 10:56 AM
To: [email protected]
Cc: Chai, Thomas <[email protected]>; Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Clements, John <[email protected]>; Chai, Thomas <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: Remove repeated calls

Remove repeated calls.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 7a1d2bac698e..4992bc554c0c 100644
@@ -1704,9 +1704,7 @@ static void amdgpu_ras_log_on_err_counter(struct

amdgpu_device *adev) static void amdgpu_ras_error_status_query(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
 					  struct ras_query_if *info)
 {
-	struct amdgpu_ras_block_object *block_obj =

amdgpu_ras_get_ras_block(adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-									info-
Quoted 1 line

head.block,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -1
-									info-
Quoted 1 line

head.sub_block_index);

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
+	struct amdgpu_ras_block_object *block_obj;
 	/*
 	 * Only two block need to query read/write
 	 * RspStatus at current state
--

2.25.1