Skip to contentSkip to conversation

Make staging driver stable for SRIOV VF (1 v2)

PATCH In review Pixel Ding 4 participants 25 messages Oct 17, 2017 – Oct 19, 2017 18 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Pixel Ding

author
#0 lore raw

This is the first patch series to make latest staging driver stable for SRIOV VF on both Tonga and Vega. Patches are merged from SRIOV branches or reimplemented, including bug fixes and small features requested by SRIOV users.

v2: "drm/amdgpu: workaround for VM fault caused by SDMA" is dropped.

Please help reviewing, Thanks.

[PATCH 1/3] drm/amdgpu: always consider virualised device for [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2 [PATCH 3/3] drm/amdgpu: busywait KIQ register accessing v2
_______________________________________________
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): 1508222267-18627-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 1/3 drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
Signature · 6 lines
2.9.5

_______________________________________________
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): 1508222267-18627-2-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org

#4 lore raw

RE: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);

--
2.9.5

_______________________________________________
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): BLUPR12MB04492724C9C66EF3ABA7C295844C0-7LeqcoF/[email protected]

#6 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 59 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -5
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--
Quoted 2 lines

2.9.5

_______________________________________________
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): 77D84CB4-2676-4DBC-AB49-431923E87EAC-5C7GfCeVMHo@public.gmane.org

#8 lore raw

RE: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From the patch itself I still couldn't tell the difference

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev)
96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 59 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -5
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--
Quoted 2 lines

2.9.5

_______________________________________________
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): BLUPR12MB0449C0C378B70A73A44579CC844C0-7LeqcoF/[email protected]

#10 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 89 lines · Monk

From the patch itself I still couldn't tell the difference

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

_______________________________________________
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): BA0191B9-16C3-43D8-9816-BF77301CE5D5-5C7GfCeVMHo@public.gmane.org

#12 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

yeah,

________________________________
From: Ding, Pixel
Sent: Tuesday, October 17, 2017 4:06 PM
To: Liu, Monk; [email protected]; Koenig, Christian
Cc: Li, Bingley; Sun, Gary
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 89 lines · Monk

From the patch itself I still couldn't tell the difference

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {

97    uint8_t __iomem *bios;
98    resource_size_t vram_base;
99    resource_size_t size = 256 * 1024; /* ??? */

100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
      uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
      if (amdgpu_sriov_vf(adev))
              return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
                              return true;
              }
      }
-     return amdgpu_need_post(adev);
+     return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
      amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
      /* Post card if necessary */
-     if (amdgpu_vpost_needed(adev)) {
+     if (amdgpu_need_post(adev)) {
              if (!adev->bios) {
                      dev_err(adev->dev, "no vBIOS found\n");
                      amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

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

#13 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

In reply to a message not in the archive

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

Quoted 103 lines · Pixel

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 89 lines · Monk

From the patch itself I still couldn't tell the difference

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

_______________________________________________
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): 9035FC71-9AB1-406C-9A0B-8B050E51C7F4-5C7GfCeVMHo@public.gmane.org

#15 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post checking. —
Sincerely Yours,
Pixel

Quoted 14 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

Quoted 118 lines
Quoted 116 lines · Pixel

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 89 lines · Monk

From the patch itself I still couldn't tell the difference

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
 * or post is needed if  hw reset is performed.
 * Returns true if need or false if not.
 */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

_______________________________________________
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): 83AE16CE-43F8-44E7-AEF6-6FA581134C7A-5C7GfCeVMHo@public.gmane.org

#17 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

I've already did, but honestly have no idea what you do here.

ASIC post is not something I've every worked on.

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 14 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post checking. —
Sincerely Yours,
Pixel

Quoted 133 lines
Quoted 131 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

Quoted 115 lines · Pixel

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 88 lines · Monk

From the patch itself I still couldn't tell the difference
-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

_______________________________________________
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): b3d8df4b-38f9-2bc2-3340-782069591058-5C7GfCeVMHo@public.gmane.org

#19 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

yeah, this patch is correct

________________________________
From: Koenig, Christian
Sent: Wednesday, October 18, 2017 3:23:04 PM
To: Ding, Pixel; Liu, Monk; [email protected]
Cc: Sun, Gary; Li, Bingley
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

I've already did, but honestly have no idea what you do here.

ASIC post is not something I've every worked on.

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 14 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post checking. —
Sincerely Yours,
Pixel

Quoted 133 lines
Quoted 131 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

Quoted 115 lines · Pixel

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 88 lines · Monk

From the patch itself I still couldn't tell the difference
-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
   uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
   if (amdgpu_sriov_vf(adev))
           return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
                           return true;
           }
   }
- return amdgpu_need_post(adev);
+ return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
   amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
   /* Post card if necessary */
- if (amdgpu_vpost_needed(adev)) {
+ if (amdgpu_need_post(adev)) {
           if (!adev->bios) {
                   dev_err(adev->dev, "no vBIOS found\n");
                   amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

_______________________________________________
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

#20 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

In reply to a message not in the archive

Sorry for the confusion, while I still believe this is the right way to go.

amdgpu_need_post and amdgpu_vpost_needed both try to check the VBIOS posting, amdgpu_need_post doesn’t consider VF/PT devices. They were both in use.

This patch is to unify these 2 functions to single one and always consider the VF/PT devices.

So the amdgpu_vpost_needed is renamed to amdgpu_need_post, and the previous amdgpu_need_post becomes a static function. —
Sincerely Yours,
Pixel

Quoted 162 lines · amd-gfx on behalf of Christian König

I've already did, but honestly have no idea what you do here.

ASIC post is not something I've every worked on.

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 14 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post checking. —
Sincerely Yours,
Pixel

Quoted 133 lines
Quoted 131 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

Quoted 115 lines · Pixel

you can see the difference of function amdgpu_need_post. Generally speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear? —
Sincerely Yours,
Pixel

Quoted 88 lines · Monk

From the patch itself I still couldn't tell the difference
-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 52 lines · Monk

I don't understand how this patch works??? Looks like just rename vpost_needed to check_post

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -3
index 683965b..ab8f0d6 100644
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc)
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct amdgpu_device *adev)
 
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	amdgpu_device_detect_sriov_bios(adev);
 
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 			amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
--

2.9.5

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

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

#21 lore raw

RE: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

In reply to a message not in the archive
Quoted 9 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Wednesday, October 18, 2017 3:23 AM
To: Ding, Pixel; Liu, Monk; [email protected]
Cc: Sun, Gary; Li, Bingley
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

Quoted 8 lines

I've already did, but honestly have no idea what you do here.

ASIC post is not something I've every worked on.

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

I think we should fix the issue in amdgpu_bios.c or sort out/merge amdgpu_need_post and amdgpu_vpost_needed. This change is really unclear.

Alex

Quoted 173 lines

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 3 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post

checking.

Quoted 28 lines

—
Sincerely Yours,
Pixel

Quoted 15 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

On 17/10/2017, 4:06 PM, "amd-gfx on behalf of Ding, Pixel" <amd-gfx-

Quoted 2 lines · [email protected] on behalf of [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines

you can see the difference of function amdgpu_need_post. Generally

speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear?

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

—
Sincerely Yours,
Pixel

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Monk
Quoted 6 lines

From the patch itself I still couldn't tell the difference -----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected];

Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised

device for checking post

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Monk
Quoted 2 lines

I don't understand how this patch works??? Looks like just rename

vpost_needed to check_post

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk

<[email protected]>; Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>; Ding, Pixel <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device

for checking post

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Review

Quoted 11 lines

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_gart_location(struct

Quoted 4 lines

index 683965b..ab8f0d6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct

amdgpu_device *adev, struct amdgpu_mc *mc)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_need_post(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static bool amdgpu_vpost_needed(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct

amdgpu_device *adev,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct · line 2214

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 
	amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
2.9.5

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

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): BN6PR12MB16521D66D545EE9CF038725AF74D0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#23 lore raw

Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

Hi Alex,

This change only affect virtualization and doesn’t change any code path of baremetal, and I have the virtualization test passed.

As we discussed in the v2 patch, merge 2 bios post checking function. Can I have your review for the v1? Or do you like to keep the amdgpu_vpost_needed() function name?

—
Sincerely Yours,
Pixel

Quoted 13 lines · Alexander
Quoted 13 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Wednesday, October 18, 2017 3:23 AM
To: Ding, Pixel; Liu, Monk; [email protected]
Cc: Sun, Gary; Li, Bingley
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

I've already did, but honestly have no idea what you do here.

ASIC post is not something I've every worked on.

Quoted 186 lines
Quoted 4 lines

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

I think we should fix the issue in amdgpu_bios.c or sort out/merge amdgpu_need_post and amdgpu_vpost_needed. This change is really unclear.

Alex

Quoted 177 lines

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 3 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post

checking.

Quoted 28 lines

—
Sincerely Yours,
Pixel

Quoted 15 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

On 17/10/2017, 4:06 PM, "amd-gfx on behalf of Ding, Pixel" <amd-gfx-

Quoted 2 lines · [email protected] on behalf of [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines

you can see the difference of function amdgpu_need_post. Generally

speaking, there were 2 functions to check VBIOS posting, one considers VF and passthru while the other doesn’t. In fact we should always consider VF and PT for checking, right? For example, this checking here believe VF needs a posting because SCRATCH registers are not the expected value. Is it clear?

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

—
Sincerely Yours,
Pixel

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Monk
Quoted 6 lines

From the patch itself I still couldn't tell the difference -----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; [email protected];

Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised

device for checking post

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Monk
Quoted 2 lines

I don't understand how this patch works??? Looks like just rename

vpost_needed to check_post

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk

<[email protected]>; Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>; Ding, Pixel <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: [PATCH 1/3] drm/amdgpu: always consider virualised device

for checking post

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Review

Quoted 11 lines

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual function.

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_gart_location(struct

Quoted 4 lines

index 683965b..ab8f0d6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct

amdgpu_device *adev, struct amdgpu_mc *mc)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_need_post(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static bool amdgpu_vpost_needed(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct

amdgpu_device *adev,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct · line 2214

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 
	amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
2.9.5

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): 5D15F8FE-DDA7-4AC9-AB1B-2B69ED5C410F-5C7GfCeVMHo@public.gmane.org

#25 lore raw

RE: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

Quoted 9 lines

-----Original Message-----
From: Ding, Pixel
Sent: Wednesday, October 18, 2017 11:23 PM
To: Deucher, Alexander; Koenig, Christian; Liu, Monk; amd- [email protected]
Cc: Sun, Gary; Li, Bingley
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device for checking post

Quoted 8 lines

Hi Alex,

This change only affect virtualization and doesn’t change any code path of baremetal, and I have the virtualization test passed.

As we discussed in the v2 patch, merge 2 bios post checking function. Can I have your review for the v1? Or do you like to keep the amdgpu_vpost_needed() function name?

I don't care what function name we use. Just merge them into one if it's ok for virtualization.

Alex

Quoted 154 lines

—
Sincerely Yours,
Pixel

Quoted 2 lines · Alexander
Quoted 2 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On

Behalf

Quoted 5 lines
Quoted 5 lines

Of Christian König
Sent: Wednesday, October 18, 2017 3:23 AM
To: Ding, Pixel; Liu, Monk; [email protected]
Cc: Sun, Gary; Li, Bingley
Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised device

for

Quoted 4 lines
Quoted 4 lines

checking post

I've already did, but honestly have no idea what you do here.

Quoted 8 lines
Quoted 6 lines

ASIC post is not something I've every worked on.

It looks odd that you add/remove some static keyword here, but I can't judge the technical correctness.

Monk, Alex what do you think of this?

I think we should fix the issue in amdgpu_bios.c or sort out/merge

amdgpu_need_post and amdgpu_vpost_needed. This change is really unclear.

Quoted 41 lines

Alex

Quoted 38 lines

Sorry,
Christian.

Am 18.10.2017 um 09:19 schrieb Ding, Pixel:

Quoted 3 lines

Hi Christian,

Would you please take a look at this change? It’s to unify the VBIOS post

checking.

Quoted 11 lines

—
Sincerely Yours,
Pixel

Quoted 17 lines
Quoted 15 lines · Pixel

Hi all,

Could someone review this patch?

—
Sincerely Yours,
Pixel

On 17/10/2017, 4:06 PM, "amd-gfx on behalf of Ding, Pixel" <amd-gfx-

[email protected] on behalf of [email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

you can see the difference of function amdgpu_need_post.

Generally

Quoted 1 line
Quoted 1 line

speaking, there were 2 functions to check VBIOS posting, one considers

VF

Quoted 1 line
Quoted 1 line

and passthru while the other doesn’t. In fact we should always consider

VF

Quoted 1 line
Quoted 1 line

and PT for checking, right? For example, this checking here believe VF

needs

Quoted 1 line
Quoted 1 line

a posting because SCRATCH registers are not the expected value. Is it

clear?

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

—
Sincerely Yours,
Pixel

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Monk
Quoted 6 lines

From the patch itself I still couldn't tell the difference -----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:54
To: Liu, Monk <[email protected]>; amd-

[email protected];

Quoted 9 lines
Quoted 9 lines

Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: Re: [PATCH 1/3] drm/amdgpu: always consider virualised

device for checking post

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

It fixes a issue hidden in:

95 static bool igp_read_bios_from_vram(struct amdgpu_device

*adev)

Quoted 35 lines
Quoted 35 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

96 {
97 uint8_t __iomem *bios;
98 resource_size_t vram_base;
99 resource_size_t size = 256 * 1024; /* ??? */
100
101 if (!(adev->flags & AMD_IS_APU))
102 if (amdgpu_need_post(adev))
103 return false;

This makes bios reading fallback to SMC INDEX/DATA register case.

—
Sincerely Yours,
Pixel

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Monk
Quoted 2 lines

I don't understand how this patch works??? Looks like just rename

vpost_needed to check_post

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk

<[email protected]>; Koenig, Christian <[email protected]>

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Cc Li, Bingley <[email protected]>; Sun, Gary

<[email protected]>; Ding, Pixel <[email protected]>

Quoted 73 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Subject: [PATCH 1/3] drm/amdgpu: always consider virualised

device

Quoted 5 lines
Quoted 5 lines

for checking post

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

From: pding <[email protected]>

The post checking on scratch registers isn't reliable for virtual

function.

Quoted 65 lines
Quoted 65 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines

---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_gart_location(struct

Quoted 4 lines

index 683965b..ab8f0d6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -669,7 +669,7 @@ void amdgpu_gart_location(struct

amdgpu_device *adev, struct amdgpu_mc *mc)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_need_post(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
  * or post is needed if  hw reset is performed.
  * Returns true if need or false if not.
  */
-bool amdgpu_need_post(struct amdgpu_device *adev)
+static bool amdgpu_check_post(struct amdgpu_device *adev)
 {
 	uint32_t reg;
 
@@ -692,7 +692,7 @@ bool amdgpu_need_post(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static bool amdgpu_vpost_needed(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 }
 
-static bool amdgpu_vpost_needed(struct amdgpu_device *adev)
+bool amdgpu_need_post(struct amdgpu_device *adev)
 {
 	if (amdgpu_sriov_vf(adev))
 		return false;
@@ -716,7 +716,7 @@ static bool amdgpu_vpost_needed(struct

amdgpu_device *adev)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 				return true;
 		}
 	}
-	return amdgpu_need_post(adev);
+	return amdgpu_check_post(adev);
 }
 
 /**
@@ -2208,7 +2208,7 @@ int amdgpu_device_init(struct

amdgpu_device *adev,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct · line 2214

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 	amdgpu_device_detect_sriov_bios(adev);
 
 	/* Post card if necessary */
-	if (amdgpu_vpost_needed(adev)) {
+	if (amdgpu_need_post(adev)) {
 		if (!adev->bios) {
 			dev_err(adev->dev, "no vBIOS found\n");
 
	amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
2.9.5

_______________________________________________
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

author
#26 lore raw

PATCH 2/3 drm/amdgpu: report more amdgpu_fence_info v2

In reply to a message not in the archive

From: pding <[email protected]>

Only for GFX ring. This can help checking MCBP feature.

v2: report more fence offs.

The fence at the end of the frame will indicate the completion status. If the frame completed normally, the fence is written to the address given in the EVENT_WRITE_EOP packet. If preemption occurred in the previous IB the address is adjusted by 2 DWs. If work submitted in the frame was reset before completion, the fence address is adjusted by four DWs. In the case that preemption occurred, and before preemption completed a reset was initiated, the address will be adjusted with six DWs

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13 -0
index 09d5a5c..688740e 100644
@@ -645,6 +645,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
 			   atomic_read(&ring->fence_drv.last_seq));
 		seq_printf(m, "Last emitted        0x%08x\n",
 			   ring->fence_drv.sync_seq);
+
+		if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
+			continue;
+
+		/* set in CP_VMID_PREEMPT and preemption occurred */
+		seq_printf(m, "Last preempted      0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
+		/* set in CP_VMID_RESET and reset occurred */
+		seq_printf(m, "Last reset          0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
+		/* Both preemption and reset occurred */
+		seq_printf(m, "Last both           0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
 	}
 	return 0;
 }
Signature · 6 lines
2.9.5

_______________________________________________
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): 1508222267-18627-3-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#28 lore raw

Re: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

Am 17.10.2017 um 08:37 schrieb Pixel Ding:

Quoted 15 lines

From: pding <[email protected]>

Only for GFX ring. This can help checking MCBP feature.

v2: report more fence offs.

The fence at the end of the frame will indicate the completion status. If the frame completed normally, the fence is written to the address given in the EVENT_WRITE_EOP packet. If preemption occurred in the previous IB the address is adjusted by 2 DWs. If work submitted in the frame was reset before completion, the fence address is adjusted by four DWs. In the case that preemption occurred, and before preemption completed a reset was initiated, the address will be adjusted with six DWs

Quoted 1 line
Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +6 -0
index 09d5a5c..688740e 100644
@@ -645,6 +645,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
  			   atomic_read(&ring->fence_drv.last_seq));
  		seq_printf(m, "Last emitted        0x%08x\n",
  			   ring->fence_drv.sync_seq);
+
+		if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
+			continue;
+
+		/* set in CP_VMID_PREEMPT and preemption occurred */
+		seq_printf(m, "Last preempted      0x%08x\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data) · line 663

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +7 -0
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
+		/* set in CP_VMID_RESET and reset occurred */
+		seq_printf(m, "Last reset          0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
+		/* Both preemption and reset occurred */
+		seq_printf(m, "Last both           0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
  	}
  	return 0;
  }

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

#29 lore raw

RE: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

In reply to a message not in the archive

Please use if (amdgpu_sriov_vf())
To protect your added part

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

From: pding <[email protected]>

Only for GFX ring. This can help checking MCBP feature.

v2: report more fence offs.

The fence at the end of the frame will indicate the completion status.
If the frame completed normally, the fence is written to the address given in the EVENT_WRITE_EOP packet. If preemption occurred in the previous IB the address is adjusted by 2 DWs. If work submitted in the frame was reset before completion, the fence address is adjusted by four DWs. In the case that preemption occurred, and before preemption completed a reset was initiated, the address will be adjusted with six DWs

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13 -0
index 09d5a5c..688740e 100644
@@ -645,6 +645,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
 			   atomic_read(&ring->fence_drv.last_seq));
 		seq_printf(m, "Last emitted        0x%08x\n",
 			   ring->fence_drv.sync_seq);
+
+		if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
+			continue;
+
+		/* set in CP_VMID_PREEMPT and preemption occurred */
+		seq_printf(m, "Last preempted      0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
+		/* set in CP_VMID_RESET and reset occurred */
+		seq_printf(m, "Last reset          0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
+		/* Both preemption and reset occurred */
+		seq_printf(m, "Last both           0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
 	}
 	return 0;
 }

--
2.9.5

_______________________________________________
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): BLUPR12MB0449B223F1C69AE2587EE9F5844C0-7LeqcoF/[email protected]

#31 lore raw

Re: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

Why? The fence WB is always 8 DW.
—
Sincerely Yours,
Pixel

Quoted 49 lines · Monk

Please use if (amdgpu_sriov_vf())
To protect your added part

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

From: pding <[email protected]>

Only for GFX ring. This can help checking MCBP feature.

v2: report more fence offs.

The fence at the end of the frame will indicate the completion status.
If the frame completed normally, the fence is written to the address given in the EVENT_WRITE_EOP packet. If preemption occurred in the previous IB the address is adjusted by 2 DWs. If work submitted in the frame was reset before completion, the fence address is adjusted by four DWs. In the case that preemption occurred, and before preemption completed a reset was initiated, the address will be adjusted with six DWs

---
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 13 +++++++++++++

1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13 -1
index 09d5a5c..688740e 100644
@@ -645,6 +645,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
 			   atomic_read(&ring->fence_drv.last_seq));
 		seq_printf(m, "Last emitted        0x%08x\n",
 			   ring->fence_drv.sync_seq);
+
+		if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
+			continue;
+
+		/* set in CP_VMID_PREEMPT and preemption occurred */
+		seq_printf(m, "Last preempted      0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
+		/* set in CP_VMID_RESET and reset occurred */
+		seq_printf(m, "Last reset          0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
+		/* Both preemption and reset occurred */
+		seq_printf(m, "Last both           0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
 	}
 	return 0;
 }
--
Quoted 2 lines

2.9.5

_______________________________________________
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): AE86FEF5-92C5-4F1B-B302-5A9289C42CD8-5C7GfCeVMHo@public.gmane.org

Reviewed-by Monk Liu
#33 lore raw

RE: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

Okay leave it, we may need OS preemption in future so it still can be used for that purpose

-----Original Message-----
From: Ding, Pixel
Sent: 2017年10月17日 15:56
To: Liu, Monk <[email protected]>; [email protected]; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>
Subject: Re: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

Why? The fence WB is always 8 DW.
—
Sincerely Yours,
Pixel

Quoted 49 lines · Monk

Please use if (amdgpu_sriov_vf())
To protect your added part

-----Original Message-----
From: Pixel Ding [mailto:[email protected]]
Sent: 2017年10月17日 14:38
To: [email protected]; Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>
Cc: Li, Bingley <[email protected]>; Sun, Gary <[email protected]>; Ding, Pixel <[email protected]>
Subject: [PATCH 2/3] drm/amdgpu: report more amdgpu_fence_info v2

From: pding <[email protected]>

Only for GFX ring. This can help checking MCBP feature.

v2: report more fence offs.

The fence at the end of the frame will indicate the completion status.
If the frame completed normally, the fence is written to the address given in the EVENT_WRITE_EOP packet. If preemption occurred in the previous IB the address is adjusted by 2 DWs. If work submitted in the frame was reset before completion, the fence address is adjusted by four DWs. In the case that preemption occurred, and before preemption completed a reset was initiated, the address will be adjusted with six DWs

---
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 13 +++++++++++++

1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13 -1
index 09d5a5c..688740e 100644
@@ -645,6 +645,19 @@ static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
 			   atomic_read(&ring->fence_drv.last_seq));
 		seq_printf(m, "Last emitted        0x%08x\n",
 			   ring->fence_drv.sync_seq);
+
+		if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
+			continue;
+
+		/* set in CP_VMID_PREEMPT and preemption occurred */
+		seq_printf(m, "Last preempted      0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 2)));
+		/* set in CP_VMID_RESET and reset occurred */
+		seq_printf(m, "Last reset          0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 4)));
+		/* Both preemption and reset occurred */
+		seq_printf(m, "Last both           0x%08x\n",
+			   le32_to_cpu(*(ring->fence_drv.cpu_addr + 6)));
 	}
 	return 0;
 }
--
Quoted 2 lines

2.9.5

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

author
#34 lore raw

PATCH 3/3 drm/amdgpu: busywait KIQ register accessing v2

In reply to a message not in the archive

From: pding <[email protected]>

Register accessing is performed when IRQ is disabled. Never sleep in this function.

Known issue: dead sleep in many use cases of index/data registers.

v2: wrap polling fence functions. don't trigger IRQ for polling in case of wrongly fence signal.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  8 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c         | 53 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c           |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h          |  4 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c          | 30 ++++++-------
 8 files changed, 78 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index ca212ef..cc06e62 100644
@@ -885,7 +885,7 @@ struct amdgpu_mec {
 struct amdgpu_kiq {
 	u64			eop_gpu_addr;
 	struct amdgpu_bo	*eop_obj;
-	struct mutex		ring_mutex;
+	spinlock_t              ring_lock;
 	struct amdgpu_ring	ring;
 	struct amdgpu_irq_src	irq;
 };
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 -2
index 9d9965d..6d83573 100644
@@ -788,7 +788,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
 	struct dma_fence *f;
 	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
 	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
 	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
 	amdgpu_ring_write(ring,
@@ -796,7 +796,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
 			PACKET3_INVALIDATE_TLBS_PASID(pasid));
 	amdgpu_fence_emit(ring, &f);
 	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
 	r = dma_fence_wait(f, false);
 	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +2 -2
index edbae19..c92217f 100644
@@ -973,7 +973,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
 	struct dma_fence *f;
 	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
 	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
 	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
 	amdgpu_ring_write(ring,
@@ -983,7 +983,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
 			PACKET3_INVALIDATE_TLBS_FLUSH_TYPE(2));
 	amdgpu_fence_emit(ring, &f);
 	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
 	r = dma_fence_wait(f, false);
 	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -6
index ab8f0d6..1197274 100644
@@ -109,10 +109,8 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg,
 {
 	uint32_t ret;
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
 		return amdgpu_virt_kiq_rreg(adev, reg);
-	}
 
 	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
 		ret = readl(((void __iomem *)adev->rmmio) + (reg * 4));
@@ -137,10 +135,8 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
 		adev->last_mm_index = v;
 	}
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
 		return amdgpu_virt_kiq_wreg(adev, reg, v);
-	}
 
 	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
 		writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +53 -0

65 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
index 4f6c68f..e5a9077 100644
@@ -185,7 +185,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 	int r = 0;
 
-	mutex_init(&kiq->ring_mutex);
+	spin_lock_init(&kiq->ring_lock);
 
 	r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs);
 	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +4 -0
index af8e544..9de89ea 100644
@@ -89,8 +89,12 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
 void amdgpu_fence_driver_suspend(struct amdgpu_device *adev);
 void amdgpu_fence_driver_resume(struct amdgpu_device *adev);
 int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence);
+int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s);
 void amdgpu_fence_process(struct amdgpu_ring *ring);
 int amdgpu_fence_wait_empty(struct amdgpu_ring *ring);
+signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
+				      uint32_t wait_seq,
+				      signed long timeout);
 unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);
 
 /*
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +13 -17
index ab05121..177fe10 100644
@@ -22,7 +22,7 @@
  */
 
 #include "amdgpu.h"
-#define MAX_KIQ_REG_WAIT	100000
+#define MAX_KIQ_REG_WAIT	100000000 /* in usecs */
 
 int amdgpu_allocate_static_csa(struct amdgpu_device *adev)
 {
@@ -114,27 +114,24 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
 uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 {
 	signed long r;
-	uint32_t val;
-	struct dma_fence *f;
+	uint32_t val, seq;
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 	struct amdgpu_ring *ring = &kiq->ring;
 
 	BUG_ON(!ring->funcs->emit_rreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
 	amdgpu_ring_alloc(ring, 32);
 	amdgpu_ring_emit_rreg(ring, reg);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
 	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
-	dma_fence_put(f);
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	if (r < 1) {
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
 		return ~0;
 	}
-
 	val = adev->wb.wb[adev->virt.reg_val_offs];
 
 	return val;
@@ -143,23 +140,22 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
 void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
 {
 	signed long r;
-	struct dma_fence *f;
+	uint32_t seq;
 	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
 	struct amdgpu_ring *ring = &kiq->ring;
 
 	BUG_ON(!ring->funcs->emit_wreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
 	amdgpu_ring_alloc(ring, 32);
 	amdgpu_ring_emit_wreg(ring, reg, v);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
 	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	if (r < 1)
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
-	dma_fence_put(f);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
 }
 
 /**
Signature · 6 lines
2.9.5

_______________________________________________
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): 1508222267-18627-4-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org

#36 lore raw

Re: [PATCH 3/3] drm/amdgpu: busywait KIQ register accessing v2

Am 17.10.2017 um 08:37 schrieb Pixel Ding:

Quoted 145 lines

From: pding <[email protected]>

Register accessing is performed when IRQ is disabled. Never sleep in this function.

Known issue: dead sleep in many use cases of index/data registers.

v2: wrap polling fence functions. don't trigger IRQ for polling in case of wrongly fence signal.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c |  4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c |  4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  8 +---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c         | 53 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c           |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h          |  4 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c          | 30 ++++++-------
  8 files changed, 78 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index ca212ef..cc06e62 100644
@@ -885,7 +885,7 @@ struct amdgpu_mec {
  struct amdgpu_kiq {
  	u64			eop_gpu_addr;
  	struct amdgpu_bo	*eop_obj;
-	struct mutex		ring_mutex;
+	spinlock_t              ring_lock;
  	struct amdgpu_ring	ring;
  	struct amdgpu_irq_src	irq;
  };
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 -2
index 9d9965d..6d83573 100644
@@ -788,7 +788,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  	struct dma_fence *f;
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
  	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
  	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
  	amdgpu_ring_write(ring,
@@ -796,7 +796,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  			PACKET3_INVALIDATE_TLBS_PASID(pasid));
  	amdgpu_fence_emit(ring, &f);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
  	r = dma_fence_wait(f, false);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +2 -2
index edbae19..c92217f 100644
@@ -973,7 +973,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  	struct dma_fence *f;
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
  	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
  	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
  	amdgpu_ring_write(ring,
@@ -983,7 +983,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  			PACKET3_INVALIDATE_TLBS_FLUSH_TYPE(2));
  	amdgpu_fence_emit(ring, &f);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
  	r = dma_fence_wait(f, false);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -6
index ab8f0d6..1197274 100644
@@ -109,10 +109,8 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg,
  {
  	uint32_t ret;
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
  		return amdgpu_virt_kiq_rreg(adev, reg);
-	}
 
  	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
  		ret = readl(((void __iomem *)adev->rmmio) + (reg * 4));
@@ -137,10 +135,8 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
  		adev->last_mm_index = v;
  	}
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
  		return amdgpu_virt_kiq_wreg(adev, reg, v);
-	}
 
  	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
  		writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +26 -0
index 688740e..68a5e90 100644
@@ -169,6 +169,32 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
  }
 
  /**
+ * amdgpu_fence_emit_polling - emit a fence on the requeste ring
+ *
+ * @ring: ring the fence is associated with
+ * @s: resulting sequence number
+ *
+ * Emits a fence command on the requested ring (all asics).
+ * Used For polling fence.
+ * Returns 0 on success, -ENOMEM on failure.
+ */
+int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s)
+{
+	uint32_t seq;
+
+	if (!s)
+		return -EINVAL;
+
+	seq = ++ring->fence_drv.sync_seq;
+	amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
+			       seq, AMDGPU_FENCE_FLAG_INT);
+
+	*s = seq;
+
+	return 0;
+}
+
+/**
   * amdgpu_fence_schedule_fallback - schedule fallback check
   *
   * @ring: pointer to struct amdgpu_ring

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 309

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0 -0
@@ -281,6 +307,33 @@ int amdgpu_fence_wait_empty(struct amdgpu_ring *ring)
  	return r;
  }
 

Please add some documentation here that timeout is in usec.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4 -0
+signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
+				      uint32_t wait_seq,
+				      signed long timeout)
+{

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 323

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +10 -0
+	uint32_t seq, last_seq;
+	struct amdgpu_fence_driver *drv = &ring->fence_drv;
+
+	last_seq = atomic_read(&ring->fence_drv.last_seq);
+
+	do {
+		seq = amdgpu_fence_read(ring);
+
+		if (unlikely(seq == last_seq))
+			break;

That doesn't look correct to me, it will abort the busy wait as soon as we see the last value we have seen.

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 328

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +5 -0
+		if (seq >= wait_seq && wait_seq >= last_seq)
+			break;
+		if (seq <= last_seq &&
+		    (wait_seq <= seq || wait_seq >= last_seq))
+			break;

Why not just "(int32_t)(wait_seq - seq) > 0" ? IIRC that should be sufficient for a wrap around test.

Regards,
Christian.

Quoted 108 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +8 -0
+		udelay(5);
+		timeout -= 5;
+	} while (timeout > 0);
+
+	atomic_cmpxchg(&drv->last_seq, last_seq, wait_seq);
+
+	return timeout;
+}
  /**
   * amdgpu_fence_count_emitted - get the count of emitted fences
   *
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
index 4f6c68f..e5a9077 100644
@@ -185,7 +185,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	int r = 0;
 
-	mutex_init(&kiq->ring_mutex);
+	spin_lock_init(&kiq->ring_lock);
 
  	r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +4 -0
index af8e544..9de89ea 100644
@@ -89,8 +89,12 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
  void amdgpu_fence_driver_suspend(struct amdgpu_device *adev);
  void amdgpu_fence_driver_resume(struct amdgpu_device *adev);
  int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence);
+int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s);
  void amdgpu_fence_process(struct amdgpu_ring *ring);
  int amdgpu_fence_wait_empty(struct amdgpu_ring *ring);
+signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
+				      uint32_t wait_seq,
+				      signed long timeout);
  unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);
 
  /*
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +11 -14
index ab05121..177fe10 100644
@@ -22,7 +22,7 @@
   */
 
  #include "amdgpu.h"
-#define MAX_KIQ_REG_WAIT	100000
+#define MAX_KIQ_REG_WAIT	100000000 /* in usecs */
 
  int amdgpu_allocate_static_csa(struct amdgpu_device *adev)
  {
@@ -114,27 +114,24 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
  uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
  {
  	signed long r;
-	uint32_t val;
-	struct dma_fence *f;
+	uint32_t val, seq;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	struct amdgpu_ring *ring = &kiq->ring;
 
  	BUG_ON(!ring->funcs->emit_rreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
  	amdgpu_ring_alloc(ring, 32);
  	amdgpu_ring_emit_rreg(ring, reg);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
-	dma_fence_put(f);
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
  	if (r < 1) {
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
  		return ~0;
  	}
-
  	val = adev->wb.wb[adev->virt.reg_val_offs];
 
  	return val;
@@ -143,23 +140,22 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
  void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
  {
  	signed long r;
-	struct dma_fence *f;
+	uint32_t seq;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	struct amdgpu_ring *ring = &kiq->ring;
 
  	BUG_ON(!ring->funcs->emit_wreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
  	amdgpu_ring_alloc(ring, 32);
  	amdgpu_ring_emit_wreg(ring, reg, v);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg) · line 161

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -3
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
  	if (r < 1)
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
-	dma_fence_put(f);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
  }
 
  /**

_______________________________________________
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): 7f22595c-ae6d-f859-3ba6-42fe30a24707-5C7GfCeVMHo@public.gmane.org

#38 lore raw

Re: [PATCH 3/3] drm/amdgpu: busywait KIQ register accessing v2

Quoted 143 lines · Christian

Am 17.10.2017 um 08:37 schrieb Pixel Ding:

Quoted 142 lines

From: pding <[email protected]>

Register accessing is performed when IRQ is disabled. Never sleep in this function.

Known issue: dead sleep in many use cases of index/data registers.

v2: wrap polling fence functions. don't trigger IRQ for polling in case of wrongly fence signal.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h               |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c |  4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c |  4 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  8 +---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c         | 53 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c           |  2 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h          |  4 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c          | 30 ++++++-------
  8 files changed, 78 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index ca212ef..cc06e62 100644
@@ -885,7 +885,7 @@ struct amdgpu_mec {
  struct amdgpu_kiq {
  	u64			eop_gpu_addr;
  	struct amdgpu_bo	*eop_obj;
-	struct mutex		ring_mutex;
+	spinlock_t              ring_lock;
  	struct amdgpu_ring	ring;
  	struct amdgpu_irq_src	irq;
  };
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 -2
index 9d9965d..6d83573 100644
@@ -788,7 +788,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  	struct dma_fence *f;
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
  	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
  	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
  	amdgpu_ring_write(ring,
@@ -796,7 +796,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  			PACKET3_INVALIDATE_TLBS_PASID(pasid));
  	amdgpu_fence_emit(ring, &f);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
  	r = dma_fence_wait(f, false);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +2 -2
index edbae19..c92217f 100644
@@ -973,7 +973,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  	struct dma_fence *f;
  	struct amdgpu_ring *ring = &adev->gfx.kiq.ring;
 
-	mutex_lock(&adev->gfx.kiq.ring_mutex);
+	spin_lock(&adev->gfx.kiq.ring_lock);
  	amdgpu_ring_alloc(ring, 12); /* fence + invalidate_tlbs package*/
  	amdgpu_ring_write(ring, PACKET3(PACKET3_INVALIDATE_TLBS, 0));
  	amdgpu_ring_write(ring,
@@ -983,7 +983,7 @@ static int invalidate_tlbs_with_kiq(struct amdgpu_device *adev, uint16_t pasid)
  			PACKET3_INVALIDATE_TLBS_FLUSH_TYPE(2));
  	amdgpu_fence_emit(ring, &f);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&adev->gfx.kiq.ring_mutex);
+	spin_unlock(&adev->gfx.kiq.ring_lock);
 
  	r = dma_fence_wait(f, false);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -6
index ab8f0d6..1197274 100644
@@ -109,10 +109,8 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg,
  {
  	uint32_t ret;
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
  		return amdgpu_virt_kiq_rreg(adev, reg);
-	}
 
  	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
  		ret = readl(((void __iomem *)adev->rmmio) + (reg * 4));
@@ -137,10 +135,8 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v,
  		adev->last_mm_index = v;
  	}
 
-	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) {
-		BUG_ON(in_interrupt());
+	if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
  		return amdgpu_virt_kiq_wreg(adev, reg, v);
-	}
 
  	if ((reg * 4) < adev->rmmio_size && !(acc_flags & AMDGPU_REGS_IDX))
  		writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +26 -0
index 688740e..68a5e90 100644
@@ -169,6 +169,32 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f)
  }
 
  /**
+ * amdgpu_fence_emit_polling - emit a fence on the requeste ring
+ *
+ * @ring: ring the fence is associated with
+ * @s: resulting sequence number
+ *
+ * Emits a fence command on the requested ring (all asics).
+ * Used For polling fence.
+ * Returns 0 on success, -ENOMEM on failure.
+ */
+int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s)
+{
+	uint32_t seq;
+
+	if (!s)
+		return -EINVAL;
+
+	seq = ++ring->fence_drv.sync_seq;
+	amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
+			       seq, AMDGPU_FENCE_FLAG_INT);
+
+	*s = seq;
+
+	return 0;
+}
+
+/**
   * amdgpu_fence_schedule_fallback - schedule fallback check
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 309

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0 -0
   *
   * @ring: pointer to struct amdgpu_ring
@@ -281,6 +307,33 @@ int amdgpu_fence_wait_empty(struct amdgpu_ring *ring)
  	return r;
  }
 

Please add some documentation here that timeout is in usec.

[Pixel] sure.

Quoted 19 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4 -0
+signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
+				      uint32_t wait_seq,
+				      signed long timeout)
+{

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 323

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +10 -0
+	uint32_t seq, last_seq;
+	struct amdgpu_fence_driver *drv = &ring->fence_drv;
+
+	last_seq = atomic_read(&ring->fence_drv.last_seq);
+
+	do {
+		seq = amdgpu_fence_read(ring);
+
+		if (unlikely(seq == last_seq))
+			break;

That doesn't look correct to me, it will abort the busy wait as soon as
we see the last value we have seen.
[pixel]you’re right. My intention is to use the “seq" as latest submitted one(sync_seq), then it means all submitted seqs are notified. This condition could be removed.

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 328

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +5 -0
+		if (seq >= wait_seq && wait_seq >= last_seq)
+			break;
+		if (seq <= last_seq &&
+		    (wait_seq <= seq || wait_seq >= last_seq))
+			break;

Why not just "(int32_t)(wait_seq - seq) > 0" ? IIRC that should be
sufficient for a wrap around test.
[pixel] seq could be larger (executed) or smaller (not yet) than wait_seq even without a wrap round, I think you mean "(int32_t)(last_seq - seq) > 0”
it actually can know there’s a wrap around, but it still doesn't know if the waited seq is in the range between or not, we still need other conditions. Code here is to identify cases to break as:

===last_seq=====wait_seq====seq===
===wait_seq==seq========last_seq==
==seq==========last_seq==wait_seq=

Does it make sense?

Regards.
Pixel

Quoted 118 lines
Quoted 118 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +8 -0
+		udelay(5);
+		timeout -= 5;
+	} while (timeout > 0);
+
+	atomic_cmpxchg(&drv->last_seq, last_seq, wait_seq);
+
+	return timeout;
+}
  /**
   * amdgpu_fence_count_emitted - get the count of emitted fences
   *
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1 -1
index 4f6c68f..e5a9077 100644
@@ -185,7 +185,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	int r = 0;
 
-	mutex_init(&kiq->ring_mutex);
+	spin_lock_init(&kiq->ring_lock);
 
  	r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs);
  	if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +4 -0
index af8e544..9de89ea 100644
@@ -89,8 +89,12 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
  void amdgpu_fence_driver_suspend(struct amdgpu_device *adev);
  void amdgpu_fence_driver_resume(struct amdgpu_device *adev);
  int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **fence);
+int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s);
  void amdgpu_fence_process(struct amdgpu_ring *ring);
  int amdgpu_fence_wait_empty(struct amdgpu_ring *ring);
+signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
+				      uint32_t wait_seq,
+				      signed long timeout);
  unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);
 
  /*
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +13 -17
index ab05121..177fe10 100644
@@ -22,7 +22,7 @@
   */
 
  #include "amdgpu.h"
-#define MAX_KIQ_REG_WAIT	100000
+#define MAX_KIQ_REG_WAIT	100000000 /* in usecs */
 
  int amdgpu_allocate_static_csa(struct amdgpu_device *adev)
  {
@@ -114,27 +114,24 @@ void amdgpu_virt_init_setting(struct amdgpu_device *adev)
  uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
  {
  	signed long r;
-	uint32_t val;
-	struct dma_fence *f;
+	uint32_t val, seq;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	struct amdgpu_ring *ring = &kiq->ring;
 
  	BUG_ON(!ring->funcs->emit_rreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
  	amdgpu_ring_alloc(ring, 32);
  	amdgpu_ring_emit_rreg(ring, reg);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
-	dma_fence_put(f);
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
  	if (r < 1) {
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
  		return ~0;
  	}
-
  	val = adev->wb.wb[adev->virt.reg_val_offs];
 
  	return val;
@@ -143,23 +140,22 @@ uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)
  void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
  {
  	signed long r;
-	struct dma_fence *f;
+	uint32_t seq;
  	struct amdgpu_kiq *kiq = &adev->gfx.kiq;
  	struct amdgpu_ring *ring = &kiq->ring;
 
  	BUG_ON(!ring->funcs->emit_wreg);
 
-	mutex_lock(&kiq->ring_mutex);
+	spin_lock(&kiq->ring_lock);
  	amdgpu_ring_alloc(ring, 32);
  	amdgpu_ring_emit_wreg(ring, reg, v);
-	amdgpu_fence_emit(ring, &f);
+	amdgpu_fence_emit_polling(ring, &seq);
  	amdgpu_ring_commit(ring);
-	mutex_unlock(&kiq->ring_mutex);
+	spin_unlock(&kiq->ring_lock);
 
-	r = dma_fence_wait_timeout(f, false, msecs_to_jiffies(MAX_KIQ_REG_WAIT));
+	r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
  	if (r < 1)
-		DRM_ERROR("wait for kiq fence error: %ld.\n", r);
-	dma_fence_put(f);
+		DRM_ERROR("wait for kiq fence error: %ld\n", r);
  }
 
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg) · line 161

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +0 -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): E8EDC6D0-8756-4E09-8C0F-187CE061A470-5C7GfCeVMHo@public.gmane.org

#40 lore raw

Re: [PATCH 3/3] drm/amdgpu: busywait KIQ register accessing v2

Am 17.10.2017 um 10:38 schrieb Ding, Pixel:

Quoted 10 lines

[SNIP]

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_wait_empty(struct amdgpu_ring *ring) · line 328

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +5 -0
+		if (seq >= wait_seq && wait_seq >= last_seq)
+			break;
+		if (seq <= last_seq &&
+		    (wait_seq <= seq || wait_seq >= last_seq))
+			break;

Why not just "(int32_t)(wait_seq - seq) > 0" ? IIRC that should be
sufficient for a wrap around test.
[pixel] seq could be larger (executed) or smaller (not yet) than wait_seq even without a wrap round, I think you mean "(int32_t)(last_seq - seq) > 0”
it actually can know there’s a wrap around, but it still doesn't know if the waited seq is in the range between or not, we still need other conditions. Code here is to identify cases to break as:

Quoted 5 lines

===last_seq=====wait_seq====seq===
===wait_seq==seq========last_seq==
==seq==========last_seq==wait_seq=

Does it make sense?

No, let me explain a bit more. The full code I had in mind is this:

do {
seq = amdgpu_fence_read(ring)
} while ((int32_t)(wait_seq - seq) > 0);

This should handle the following cases:
1. wait_seq is larger than seq, in this case we still need to wait.

(wait_seq - seq) is larger than zero and the loop continues.

2. wait_seq is smaller than seq, in this case the we can stop waiting.

(wait_seq -seq) is smaller or equal to zero and the loop stops.

3. wait_seq is much smaller than seq because of a wrap around, in this case we still need to wait.

(wait_seq - seq) is larger than zero because the substraction wraps around the numeric range as well and the look will continue.

4. wait_seq is much larger than seq because of a wrap around, in this case we can stop waiting.

(wait_seq - seq) is smaller than zero because the cast to a signed number makes it negative and the loop stops.

This is rather common code for wrap around testing and you don't need to fiddle with last_seq at all here.

If you want you can also use the __dma_fence_is_later() helper function which implements exactly that test as well.

Regards,
Christian.
_______________________________________________
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): b6506918-3acf-6480-2f90-6b4bbc09eada-5C7GfCeVMHo@public.gmane.org

#42 lore raw

Re: [PATCH 3/3] drm/amdgpu: busywait KIQ register accessing v2

Thanks. In logically, it can’t handle the extreme case that the seq almost catches up with wait_seq in wrap round where we can’t use this trick, however I understand it can’t happen in reality.

I will test and modify.

—
Sincerely Yours,
Pixel

Quoted 44 lines · Christian

Am 17.10.2017 um 10:38 schrieb Ding, Pixel:

Quoted 10 lines

[SNIP]

Quoted 9 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+		if (seq >= wait_seq && wait_seq >= last_seq)
+			break;
+		if (seq <= last_seq &&
+		    (wait_seq <= seq || wait_seq >= last_seq))
+			break;

Why not just "(int32_t)(wait_seq - seq) > 0" ? IIRC that should be
sufficient for a wrap around test.
[pixel] seq could be larger (executed) or smaller (not yet) than wait_seq even without a wrap round, I think you mean "(int32_t)(last_seq - seq) > 0”
it actually can know there’s a wrap around, but it still doesn't know if the waited seq is in the range between or not, we still need other conditions. Code here is to identify cases to break as:

Quoted 5 lines

===last_seq=====wait_seq====seq===
===wait_seq==seq========last_seq==
==seq==========last_seq==wait_seq=

Does it make sense?

No, let me explain a bit more. The full code I had in mind is this:

do {
seq = amdgpu_fence_read(ring)
} while ((int32_t)(wait_seq - seq) > 0);

This should handle the following cases:
1. wait_seq is larger than seq, in this case we still need to wait.

(wait_seq - seq) is larger than zero and the loop continues.

2. wait_seq is smaller than seq, in this case the we can stop waiting.

(wait_seq -seq) is smaller or equal to zero and the loop stops.

3. wait_seq is much smaller than seq because of a wrap around, in this case we still need to wait.

(wait_seq - seq) is larger than zero because the substraction wraps around the numeric range as well and the look will continue.

4. wait_seq is much larger than seq because of a wrap around, in this case we can stop waiting.

(wait_seq - seq) is smaller than zero because the cast to a signed number makes it negative and the loop stops.

Quoted 8 lines

This is rather common code for wrap around testing and you don't need to fiddle with last_seq at all here.

If you want you can also use the __dma_fence_is_later() helper function which implements exactly that test as well.

Regards,
Christian.

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