[2/2] drm/amdgpu: export test ring debugfs interface

Submitted by Huang, Ray on May 11, 2017, 2:29 a.m.

Details

Message ID 1494469757-25784-2-git-send-email-ray.huang@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Huang, Ray May 11, 2017, 2:29 a.m.
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 ++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7becf11..3637396 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3625,14 +3625,54 @@  static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
 	return 0;
 }
 
+static int amdgpu_ring_tests(struct amdgpu_device *adev)
+{
+	unsigned i;
+	int r = 0;
+
+	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+		struct amdgpu_ring *ring = adev->rings[i];
+
+		if (!ring || !ring->ready)
+			continue;
+
+		r = amdgpu_ring_test_ring(ring);
+		if (r) {
+			ring->ready = false;
+			DRM_ERROR("amdgpu: failed to test ring %d (%d).\n",
+				  i, r);
+		}
+	}
+
+	return r;
+}
+
+static int amdgpu_debugfs_test_ring(struct seq_file *m, void *data)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct amdgpu_device *adev = dev->dev_private;
+	int r = 0;
+
+	seq_printf(m, "run ring test:\n");
+	r = amdgpu_ring_tests(adev);
+	if (r)
+		seq_printf(m, "ring tests failed (%d).\n", r);
+	else
+		seq_printf(m, "ring tests passed.\n");
+
+	return 0;
+}
+
 static const struct drm_info_list amdgpu_debugfs_test_ib_ring_list[] = {
-	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib}
+	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
+	{"amdgpu_test_ring", &amdgpu_debugfs_test_ring}
 };
 
 static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev)
 {
 	return amdgpu_debugfs_add_files(adev,
-					amdgpu_debugfs_test_ib_ring_list, 1);
+					amdgpu_debugfs_test_ib_ring_list, 2);
 }
 
 int amdgpu_debugfs_init(struct drm_minor *minor)

Comments

> -----Original Message-----
> From: Huang Rui [mailto:ray.huang@amd.com]
> Sent: Wednesday, May 10, 2017 10:29 PM
> To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian
> Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> 
> Signed-off-by: Huang Rui <ray.huang@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44
> ++++++++++++++++++++++++++++--
>  1 file changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 7becf11..3637396 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3625,14 +3625,54 @@ static int amdgpu_debugfs_test_ib(struct
> seq_file *m, void *data)
>  	return 0;
>  }
> 
> +static int amdgpu_ring_tests(struct amdgpu_device *adev)
> +{
> +	unsigned i;
> +	int r = 0;
> +
> +	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
> +		struct amdgpu_ring *ring = adev->rings[i];
> +
> +		if (!ring || !ring->ready)
> +			continue;
> +
> +		r = amdgpu_ring_test_ring(ring);
> +		if (r) {
> +			ring->ready = false;
> +			DRM_ERROR("amdgpu: failed to test ring %d
> (%d).\n",
> +				  i, r);
> +		}
> +	}
> +
> +	return r;
> +}
> +
> +static int amdgpu_debugfs_test_ring(struct seq_file *m, void *data)
> +{
> +	struct drm_info_node *node = (struct drm_info_node *) m-
> >private;
> +	struct drm_device *dev = node->minor->dev;
> +	struct amdgpu_device *adev = dev->dev_private;
> +	int r = 0;
> +
> +	seq_printf(m, "run ring test:\n");
> +	r = amdgpu_ring_tests(adev);
> +	if (r)
> +		seq_printf(m, "ring tests failed (%d).\n", r);
> +	else
> +		seq_printf(m, "ring tests passed.\n");
> +
> +	return 0;
> +}
> +
>  static const struct drm_info_list amdgpu_debugfs_test_ib_ring_list[] = {
> -	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib}
> +	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
> +	{"amdgpu_test_ring", &amdgpu_debugfs_test_ring}
>  };
> 
>  static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev)
>  {
>  	return amdgpu_debugfs_add_files(adev,
> -					amdgpu_debugfs_test_ib_ring_list,
> 1);
> +					amdgpu_debugfs_test_ib_ring_list,
> 2);
>  }
> 
>  int amdgpu_debugfs_init(struct drm_minor *minor)
> --
> 2.7.4
> -----Original Message-----
> From: Deucher, Alexander
> Sent: Wednesday, May 10, 2017 10:38 PM
> To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
> Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> 
> > -----Original Message-----
> > From: Huang Rui [mailto:ray.huang@amd.com]
> > Sent: Wednesday, May 10, 2017 10:29 PM
> > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian
> > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> >
> > Signed-off-by: Huang Rui <ray.huang@amd.com>
> 
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Not sure if it's important for this since it's debugfs, but we don't have any sort of ring locks anymore (since everything should go through the scheduler once it's started) so we could theoretically get collisions if there are active apps using the GPU and you run these tests.

Alex

> 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44
> > ++++++++++++++++++++++++++++--
> >  1 file changed, 42 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 7becf11..3637396 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -3625,14 +3625,54 @@ static int amdgpu_debugfs_test_ib(struct
> > seq_file *m, void *data)
> >  	return 0;
> >  }
> >
> > +static int amdgpu_ring_tests(struct amdgpu_device *adev)
> > +{
> > +	unsigned i;
> > +	int r = 0;
> > +
> > +	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
> > +		struct amdgpu_ring *ring = adev->rings[i];
> > +
> > +		if (!ring || !ring->ready)
> > +			continue;
> > +
> > +		r = amdgpu_ring_test_ring(ring);
> > +		if (r) {
> > +			ring->ready = false;
> > +			DRM_ERROR("amdgpu: failed to test ring %d
> > (%d).\n",
> > +				  i, r);
> > +		}
> > +	}
> > +
> > +	return r;
> > +}
> > +
> > +static int amdgpu_debugfs_test_ring(struct seq_file *m, void *data)
> > +{
> > +	struct drm_info_node *node = (struct drm_info_node *) m-
> > >private;
> > +	struct drm_device *dev = node->minor->dev;
> > +	struct amdgpu_device *adev = dev->dev_private;
> > +	int r = 0;
> > +
> > +	seq_printf(m, "run ring test:\n");
> > +	r = amdgpu_ring_tests(adev);
> > +	if (r)
> > +		seq_printf(m, "ring tests failed (%d).\n", r);
> > +	else
> > +		seq_printf(m, "ring tests passed.\n");
> > +
> > +	return 0;
> > +}
> > +
> >  static const struct drm_info_list amdgpu_debugfs_test_ib_ring_list[] = {
> > -	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib}
> > +	{"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
> > +	{"amdgpu_test_ring", &amdgpu_debugfs_test_ring}
> >  };
> >
> >  static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device
> *adev)
> >  {
> >  	return amdgpu_debugfs_add_files(adev,
> > -					amdgpu_debugfs_test_ib_ring_list,
> > 1);
> > +					amdgpu_debugfs_test_ib_ring_list,
> > 2);
> >  }
> >
> >  int amdgpu_debugfs_init(struct drm_minor *minor)
> > --
> > 2.7.4
On 2017年05月11日 10:41, Deucher, Alexander wrote:
> > -----Original Message-----
> > From: Deucher, Alexander
> > Sent: Wednesday, May 10, 2017 10:38 PM
> > To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
> > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> > Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> >
> > > -----Original Message-----
> > > From: Huang Rui [mailto:ray.huang@amd.com]
> > > Sent: Wednesday, May 10, 2017 10:29 PM
> > > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, 
> Christian
> > > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> > > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> > >
> > > Signed-off-by: Huang Rui <ray.huang@amd.com>
> >
> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>
> Not sure if it's important for this since it's debugfs, but we don't 
> have any sort of ring locks anymore (since everything should go 
> through the scheduler once it's started) so we could theoretically get 
> collisions if there are active apps using the GPU and you run these tests.
Yes, agree. So patch#1 for ib test should use scheduler, but which could 
be a big change and Christian doesn't like to use scheduler for ib test 
case, consider this is only for test case, the problem isn't big:).

btw: I think patch#2 isn't need if patch#1 is landed, since when you use 
this sys interface, the amdgpu driver must be loaded successfully, ring 
test is meaningless.

Regards,
David Zhou
>
> Alex
>
> >
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44
> > > ++++++++++++++++++++++++++++--
> > >  1 file changed, 42 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > index 7becf11..3637396 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > > @@ -3625,14 +3625,54 @@ static int amdgpu_debugfs_test_ib(struct
> > > seq_file *m, void *data)
> > >      return 0;
> > >  }
> > >
> > > +static int amdgpu_ring_tests(struct amdgpu_device *adev)
> > > +{
> > > +   unsigned i;
> > > +   int r = 0;
> > > +
> > > +   for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
> > > +           struct amdgpu_ring *ring = adev->rings[i];
> > > +
> > > +           if (!ring || !ring->ready)
> > > +                   continue;
> > > +
> > > +           r = amdgpu_ring_test_ring(ring);
> > > +           if (r) {
> > > +                   ring->ready = false;
> > > +                   DRM_ERROR("amdgpu: failed to test ring %d
> > > (%d).\n",
> > > +                             i, r);
> > > +           }
> > > +   }
> > > +
> > > +   return r;
> > > +}
> > > +
> > > +static int amdgpu_debugfs_test_ring(struct seq_file *m, void *data)
> > > +{
> > > +   struct drm_info_node *node = (struct drm_info_node *) m-
> > > >private;
> > > +   struct drm_device *dev = node->minor->dev;
> > > +   struct amdgpu_device *adev = dev->dev_private;
> > > +   int r = 0;
> > > +
> > > +   seq_printf(m, "run ring test:\n");
> > > +   r = amdgpu_ring_tests(adev);
> > > +   if (r)
> > > +           seq_printf(m, "ring tests failed (%d).\n", r);
> > > +   else
> > > +           seq_printf(m, "ring tests passed.\n");
> > > +
> > > +   return 0;
> > > +}
> > > +
> > >  static const struct drm_info_list 
> amdgpu_debugfs_test_ib_ring_list[] = {
> > > -   {"amdgpu_test_ib", &amdgpu_debugfs_test_ib}
> > > +   {"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
> > > +   {"amdgpu_test_ring", &amdgpu_debugfs_test_ring}
> > >  };
> > >
> > >  static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device
> > *adev)
> > >  {
> > >      return amdgpu_debugfs_add_files(adev,
> > > - amdgpu_debugfs_test_ib_ring_list,
> > > 1);
> > > + amdgpu_debugfs_test_ib_ring_list,
> > > 2);
> > >  }
> > >
> > >  int amdgpu_debugfs_init(struct drm_minor *minor)
> > > --
> > > 2.7.4
>
On Thu, May 11, 2017 at 10:41:42AM +0800, Deucher, Alexander wrote:
> > -----Original Message-----
> > From: Deucher, Alexander
> > Sent: Wednesday, May 10, 2017 10:38 PM
> > To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
> > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> > Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> >
> > > -----Original Message-----
> > > From: Huang Rui [mailto:ray.huang@amd.com]
> > > Sent: Wednesday, May 10, 2017 10:29 PM
> > > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian
> > > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
> > > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
> > >
> > > Signed-off-by: Huang Rui <ray.huang@amd.com>
> >
> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
> Not sure if it's important for this since it's debugfs, but we don't have any
> sort of ring locks anymore (since everything should go through the scheduler
> once it's started) so we could theoretically get collisions if there are active
> apps using the GPU and you run these tests.
> 

Right. Any idea to hold on scheduler when I try to run this test?

Thanks,
Rui
On Wed, May 10, 2017 at 10:56 PM, Huang Rui <ray.huang@amd.com> wrote:
> On Thu, May 11, 2017 at 10:41:42AM +0800, Deucher, Alexander wrote:
>> > -----Original Message-----
>> > From: Deucher, Alexander
>> > Sent: Wednesday, May 10, 2017 10:38 PM
>> > To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
>> > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>> > Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>> >
>> > > -----Original Message-----
>> > > From: Huang Rui [mailto:ray.huang@amd.com]
>> > > Sent: Wednesday, May 10, 2017 10:29 PM
>> > > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian
>> > > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>> > > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>> > >
>> > > Signed-off-by: Huang Rui <ray.huang@amd.com>
>> >
>> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>
>> Not sure if it's important for this since it's debugfs, but we don't have any
>> sort of ring locks anymore (since everything should go through the scheduler
>> once it's started) so we could theoretically get collisions if there are active
>> apps using the GPU and you run these tests.
>>
>
> Right. Any idea to hold on scheduler when I try to run this test?

Park the scheduler thread for each ring like we do for GPU reset?
That said, I think the expectation is that you should only run these
tests when the GPU is idle.

Alex
On 2017年05月11日 11:03, Huang Rui wrote:
> On Thu, May 11, 2017 at 10:50:17AM +0800, Zhou, David(ChunMing) wrote:
>>
>> On 2017年05月11日 10:41, Deucher, Alexander wrote:
>>
>>      > -----Original Message-----
>>      > From: Deucher, Alexander
>>      > Sent: Wednesday, May 10, 2017 10:38 PM
>>      > To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
>>      > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>>      > Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>>      >
>>      > > -----Original Message-----
>>      > > From: Huang Rui [mailto:ray.huang@amd.com]
>>      > > Sent: Wednesday, May 10, 2017 10:29 PM
>>      > > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig,
>>      Christian
>>      > > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>>      > > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>>      > >
>>      > > Signed-off-by: Huang Rui <ray.huang@amd.com>
>>      >
>>      > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>
>>      Not sure if it's important for this since it's debugfs, but we don't have
>>      any sort of ring locks anymore (since everything should go through the
>>      scheduler once it's started) so we could theoretically get collisions if
>>      there are active apps using the GPU and you run these tests.
>>
>> Yes, agree. So patch#1 for ib test should use scheduler, but which could be a
>> big change and Christian doesn't like to use scheduler for ib test case,
>> consider this is only for test case, the problem isn't big:).
> Do you know any method to hold on the scheduler?
like Alex suggested, park scheduler, and then do your things.

Regards,
David Zhou
>
>> btw: I think patch#2 isn't need if patch#1 is landed, since when you use this
>> sys interface, the amdgpu driver must be loaded successfully, ring test is
>> meaningless.
>>
> In normal case, ring tests&ib tests must be passed during boot&resume&reset
> phase. Is there anything that will break the ring test at runtime?
>
> Thanks,
> Rui
On Thu, May 11, 2017 at 10:50:17AM +0800, Zhou, David(ChunMing) wrote:
> 
> 
> On 2017年05月11日 10:41, Deucher, Alexander wrote:
> 
>     > -----Original Message-----
>     > From: Deucher, Alexander
>     > Sent: Wednesday, May 10, 2017 10:38 PM
>     > To: Huang, Ray; amd-gfx@lists.freedesktop.org; Koenig, Christian
>     > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>     > Subject: RE: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>     >
>     > > -----Original Message-----
>     > > From: Huang Rui [mailto:ray.huang@amd.com]
>     > > Sent: Wednesday, May 10, 2017 10:29 PM
>     > > To: amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig,
>     Christian
>     > > Cc: Zhou, David(ChunMing); Wang, Ken; Huan, Alvin; Huang, Ray
>     > > Subject: [PATCH 2/2] drm/amdgpu: export test ring debugfs interface
>     > >
>     > > Signed-off-by: Huang Rui <ray.huang@amd.com>
>     >
>     > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
>     Not sure if it's important for this since it's debugfs, but we don't have
>     any sort of ring locks anymore (since everything should go through the
>     scheduler once it's started) so we could theoretically get collisions if
>     there are active apps using the GPU and you run these tests.
> 
> Yes, agree. So patch#1 for ib test should use scheduler, but which could be a
> big change and Christian doesn't like to use scheduler for ib test case,
> consider this is only for test case, the problem isn't big:).

Do you know any method to hold on the scheduler?

> 
> btw: I think patch#2 isn't need if patch#1 is landed, since when you use this
> sys interface, the amdgpu driver must be loaded successfully, ring test is
> meaningless.
> 

In normal case, ring tests&ib tests must be passed during boot&resume&reset
phase. Is there anything that will break the ring test at runtime?

Thanks,
Rui