linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
@ 2019-05-30  0:08 Yrjan Skrimstad
  2019-06-04 20:21 ` Yrjan Skrimstad
  0 siblings, 1 reply; 6+ messages in thread
From: Yrjan Skrimstad @ 2019-05-30  0:08 UTC (permalink / raw)
  To: dri-devel
  Cc: Rex Zhu, Evan Quan, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter, amd-gfx,
	linux-kernel, Yrjan Skrimstad

This driver currently contains a repeated 500ms blocking delay call
which causes frequent major buffer underruns in PulseAudio. This patch
fixes this issue by replacing the blocking delay with a non-blocking
sleep call.

Signed-off-by: Yrjan Skrimstad <yrjan@skrimstad.net>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 048757e8f494..340afdbddc72 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -3494,7 +3494,7 @@ static int smu7_get_gpu_power(struct pp_hwmgr *hwmgr, u32 *query)
 							ixSMU_PM_STATUS_95, 0);
 
 	for (i = 0; i < 10; i++) {
-		mdelay(500);
+		msleep(500);
 		smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PmStatusLogSample);
 		tmp = cgs_read_ind_register(hwmgr->device,
 						CGS_IND_REG__SMC,
-- 
2.20.1


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

* Re: [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
  2019-05-30  0:08 [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking Yrjan Skrimstad
@ 2019-06-04 20:21 ` Yrjan Skrimstad
  2019-06-13 13:57   ` Alex Deucher
  0 siblings, 1 reply; 6+ messages in thread
From: Yrjan Skrimstad @ 2019-06-04 20:21 UTC (permalink / raw)
  To: dri-devel
  Cc: Rex Zhu, Evan Quan, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter, amd-gfx,
	linux-kernel

On Thu, May 30, 2019 at 02:08:21AM +0200, Yrjan Skrimstad wrote:
> This driver currently contains a repeated 500ms blocking delay call
> which causes frequent major buffer underruns in PulseAudio. This patch
> fixes this issue by replacing the blocking delay with a non-blocking
> sleep call.

I see that I have not explained this bug well enough, and I hope that is
the reason for the lack of replies on this patch. I will here attempt to
explain the situation better.

To start with some hardware description I am here using an AMD R9 380
GPU, an AMD Ryzen 7 1700 Eight-Core Processor and an AMD X370 chipset.
If any more hardware or software specifications are necessary, please
ask.

The bug is as follows: When playing audio I will regularly have major
audio issues, similar to that of a skipping CD. This is reported by
PulseAudio as scheduling delays and buffer underruns when running
PulseAudio verbosely and these scheduling delays are always just under
500ms, typically around 490ms. This makes listening to any music quite
the horrible experience as PulseAudio constantly will attempt to rewind
and catch up. It is not a great situation, and seems to me to quite
clearly be a case where regular user space behaviour has been broken.

I want to note that this audio problem was not something I experienced
until recently, it is therefore a new bug.

I have bisected the kernel to find out where the problem originated and
found the following commit:

# first bad commit: [f5742ec36422a39b57f0256e4847f61b3c432f8c] drm/amd/powerplay: correct power reading on fiji

This commit introduces a blocking delay (mdelay) of 500ms, whereas the
old behaviour was a smaller blocking delay of only 1ms. This seems to me
to be very curious as the scheduling delays of PulseAudio are always
almost 500ms. I have therefore with the previous patch replaced the
scheduling delay with a non-blocking sleep (msleep).

The results of the patch seems promising as I have yet to encounter any
of the old <500ms scheduling delays when using it and I have also not
encountered any kernel log messages regarding sleeping in an atomic
context.

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

* Re: [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
  2019-06-04 20:21 ` Yrjan Skrimstad
@ 2019-06-13 13:57   ` Alex Deucher
  2019-06-16 14:43     ` Yrjan Skrimstad
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2019-06-13 13:57 UTC (permalink / raw)
  To: Yrjan Skrimstad
  Cc: Maling list - DRI developers, David Airlie, LKML, amd-gfx list,
	Alex Deucher, Evan Quan, Rex Zhu, Christian König

On Tue, Jun 4, 2019 at 4:22 PM Yrjan Skrimstad <yrjan@skrimstad.net> wrote:
>
> On Thu, May 30, 2019 at 02:08:21AM +0200, Yrjan Skrimstad wrote:
> > This driver currently contains a repeated 500ms blocking delay call
> > which causes frequent major buffer underruns in PulseAudio. This patch
> > fixes this issue by replacing the blocking delay with a non-blocking
> > sleep call.
>
> I see that I have not explained this bug well enough, and I hope that is
> the reason for the lack of replies on this patch. I will here attempt to
> explain the situation better.
>
> To start with some hardware description I am here using an AMD R9 380
> GPU, an AMD Ryzen 7 1700 Eight-Core Processor and an AMD X370 chipset.
> If any more hardware or software specifications are necessary, please
> ask.
>
> The bug is as follows: When playing audio I will regularly have major
> audio issues, similar to that of a skipping CD. This is reported by
> PulseAudio as scheduling delays and buffer underruns when running
> PulseAudio verbosely and these scheduling delays are always just under
> 500ms, typically around 490ms. This makes listening to any music quite
> the horrible experience as PulseAudio constantly will attempt to rewind
> and catch up. It is not a great situation, and seems to me to quite
> clearly be a case where regular user space behaviour has been broken.
>
> I want to note that this audio problem was not something I experienced
> until recently, it is therefore a new bug.
>
> I have bisected the kernel to find out where the problem originated and
> found the following commit:
>
> # first bad commit: [f5742ec36422a39b57f0256e4847f61b3c432f8c] drm/amd/powerplay: correct power reading on fiji
>
> This commit introduces a blocking delay (mdelay) of 500ms, whereas the
> old behaviour was a smaller blocking delay of only 1ms. This seems to me
> to be very curious as the scheduling delays of PulseAudio are always
> almost 500ms. I have therefore with the previous patch replaced the
> scheduling delay with a non-blocking sleep (msleep).
>
> The results of the patch seems promising as I have yet to encounter any
> of the old <500ms scheduling delays when using it and I have also not
> encountered any kernel log messages regarding sleeping in an atomic
> context.

The patch is fine and I can apply it (I don't think there are any
restrictions on sleeping in sysfs), but this code only gets executed
when you actually read the power status from the card (e.g., via sysfs
or debugfs).  Presumably you have something in userspace polling one
of those files on a regular basis?

Alex

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

* Re: [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
  2019-06-13 13:57   ` Alex Deucher
@ 2019-06-16 14:43     ` Yrjan Skrimstad
  2019-07-04 20:15       ` Yrjan Skrimstad
  0 siblings, 1 reply; 6+ messages in thread
From: Yrjan Skrimstad @ 2019-06-16 14:43 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Maling list - DRI developers, David Airlie, LKML, amd-gfx list,
	Alex Deucher, Evan Quan, Rex Zhu, Christian König

On Thu, Jun 13, 2019 at 09:57:24AM -0400, Alex Deucher wrote:
> The patch is fine and I can apply it (I don't think there are any
> restrictions on sleeping in sysfs), but this code only gets executed
> when you actually read the power status from the card (e.g., via sysfs
> or debugfs).  Presumably you have something in userspace polling one
> of those files on a regular basis?
> 
> Alex

That is an interesting observation to me. I am actually running
lm-sensors, although only every 15 seconds. I suppose that this might
be the reason this happens to me.

- Yrjan

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

* Re: [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
  2019-06-16 14:43     ` Yrjan Skrimstad
@ 2019-07-04 20:15       ` Yrjan Skrimstad
  2019-07-05 20:34         ` Alex Deucher
  0 siblings, 1 reply; 6+ messages in thread
From: Yrjan Skrimstad @ 2019-07-04 20:15 UTC (permalink / raw)
  To: Alex Deucher
  Cc: David Airlie, LKML, amd-gfx list, Maling list - DRI developers,
	Alex Deucher, Evan Quan, Rex Zhu, Christian König

On Sun, Jun 16, 2019 at 04:43:10PM +0200, Yrjan Skrimstad wrote:
> That is an interesting observation to me. I am actually running
> lm-sensors, although only every 15 seconds. I suppose that this might
> be the reason this happens to me.

Though I don't think this should reasonably cause problems with the
system, even if it does here. Is there an update on the status of this
patch?

- Yrjan

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

* Re: [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking
  2019-07-04 20:15       ` Yrjan Skrimstad
@ 2019-07-05 20:34         ` Alex Deucher
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2019-07-05 20:34 UTC (permalink / raw)
  To: Yrjan Skrimstad
  Cc: David Airlie, LKML, amd-gfx list, Maling list - DRI developers,
	Alex Deucher, Evan Quan, Rex Zhu, Christian König

On Thu, Jul 4, 2019 at 4:15 PM Yrjan Skrimstad <yrjan@skrimstad.net> wrote:
>
> On Sun, Jun 16, 2019 at 04:43:10PM +0200, Yrjan Skrimstad wrote:
> > That is an interesting observation to me. I am actually running
> > lm-sensors, although only every 15 seconds. I suppose that this might
> > be the reason this happens to me.
>
> Though I don't think this should reasonably cause problems with the
> system, even if it does here. Is there an update on the status of this
> patch?

Applied.  sorry for the delay.

Alex

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

end of thread, other threads:[~2019-07-05 20:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30  0:08 [PATCH] drm/amd/powerplay/smu7_hwmgr: replace blocking delay with non-blocking Yrjan Skrimstad
2019-06-04 20:21 ` Yrjan Skrimstad
2019-06-13 13:57   ` Alex Deucher
2019-06-16 14:43     ` Yrjan Skrimstad
2019-07-04 20:15       ` Yrjan Skrimstad
2019-07-05 20:34         ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).