mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN
@ 2022-11-14 22:20 Lyude Paul
  2022-11-17 21:40 ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Lyude Paul @ 2022-11-14 22:20 UTC (permalink / raw)
  To: amd-gfx
  Cc: stable, Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
	Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
	Alan Liu, Aurabindo Pillai, open list:DRM DRIVERS, open list

There's been a very long running bug that seems to have been neglected for
a while, where amdgpu consistently triggers a KASAN error at start:

  BUG: KASAN: global-out-of-bounds in read_indirect_azalia_reg+0x1d4/0x2a0 [amdgpu]
  Read of size 4 at addr ffffffffc2274b28 by task modprobe/1889

After digging through amd's rather creative method for accessing registers,
I eventually discovered the problem likely has to do with the fact that on
my dce120 GPU there are supposedly 7 sets of audio registers. But we only
define a register mapping for 6 sets.

So, fix this and fix the KASAN warning finally.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: stable@vger.kernel.org
---
Sending this one separately from the rest of my fixes since:

* It's definitely completely unrelated to the Gitlab 2171 issue
* I'm not sure if this is the correct fix since it's in DC

 drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
index 1b70b78e2fa15..af631085e88c5 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -359,7 +359,8 @@ static const struct dce_audio_registers audio_regs[] = {
 	audio_regs(2),
 	audio_regs(3),
 	audio_regs(4),
-	audio_regs(5)
+	audio_regs(5),
+	audio_regs(6),
 };
 
 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
-- 
2.37.3


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

* Re: [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN
  2022-11-14 22:20 [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN Lyude Paul
@ 2022-11-17 21:40 ` Alex Deucher
  2022-11-18 20:25   ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2022-11-17 21:40 UTC (permalink / raw)
  To: Lyude Paul, Wentland, Harry
  Cc: amd-gfx, Alan Liu, Leo Li, David Airlie, Pan, Xinhui,
	Rodrigo Siqueira, open list, stable, Aurabindo Pillai,
	open list:DRM DRIVERS, Daniel Vetter, Alex Deucher,
	Christian König

On Mon, Nov 14, 2022 at 5:21 PM Lyude Paul <lyude@redhat.com> wrote:
>
> There's been a very long running bug that seems to have been neglected for
> a while, where amdgpu consistently triggers a KASAN error at start:
>
>   BUG: KASAN: global-out-of-bounds in read_indirect_azalia_reg+0x1d4/0x2a0 [amdgpu]
>   Read of size 4 at addr ffffffffc2274b28 by task modprobe/1889
>
> After digging through amd's rather creative method for accessing registers,
> I eventually discovered the problem likely has to do with the fact that on
> my dce120 GPU there are supposedly 7 sets of audio registers. But we only
> define a register mapping for 6 sets.
>
> So, fix this and fix the KASAN warning finally.
>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> Cc: stable@vger.kernel.org

This is the correct fix for asics having 7 audio instances.  It looks
correct to me, assuming DCE12 actually has 7 audio instances.
@Wentland, Harry Do you know off hand?  If you can confirm that, the
patch is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


> ---
> Sending this one separately from the rest of my fixes since:
>
> * It's definitely completely unrelated to the Gitlab 2171 issue
> * I'm not sure if this is the correct fix since it's in DC
>
>  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> index 1b70b78e2fa15..af631085e88c5 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> @@ -359,7 +359,8 @@ static const struct dce_audio_registers audio_regs[] = {
>         audio_regs(2),
>         audio_regs(3),
>         audio_regs(4),
> -       audio_regs(5)
> +       audio_regs(5),
> +       audio_regs(6),
>  };
>
>  #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
> --
> 2.37.3
>

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

* Re: [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN
  2022-11-17 21:40 ` Alex Deucher
@ 2022-11-18 20:25   ` Alex Deucher
  2022-11-18 21:05     ` Harry Wentland
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2022-11-18 20:25 UTC (permalink / raw)
  To: Lyude Paul, Wentland, Harry
  Cc: amd-gfx, Alan Liu, Leo Li, David Airlie, Pan, Xinhui,
	Rodrigo Siqueira, open list, stable, Aurabindo Pillai,
	open list:DRM DRIVERS, Daniel Vetter, Alex Deucher,
	Christian König

On Thu, Nov 17, 2022 at 4:40 PM Alex Deucher <alexdeucher@gmail.com> wrote:
>
> On Mon, Nov 14, 2022 at 5:21 PM Lyude Paul <lyude@redhat.com> wrote:
> >
> > There's been a very long running bug that seems to have been neglected for
> > a while, where amdgpu consistently triggers a KASAN error at start:
> >
> >   BUG: KASAN: global-out-of-bounds in read_indirect_azalia_reg+0x1d4/0x2a0 [amdgpu]
> >   Read of size 4 at addr ffffffffc2274b28 by task modprobe/1889
> >
> > After digging through amd's rather creative method for accessing registers,
> > I eventually discovered the problem likely has to do with the fact that on
> > my dce120 GPU there are supposedly 7 sets of audio registers. But we only
> > define a register mapping for 6 sets.
> >
> > So, fix this and fix the KASAN warning finally.
> >
> > Signed-off-by: Lyude Paul <lyude@redhat.com>
> > Cc: stable@vger.kernel.org
>
> This is the correct fix for asics having 7 audio instances.  It looks
> correct to me, assuming DCE12 actually has 7 audio instances.
> @Wentland, Harry Do you know off hand?  If you can confirm that, the
> patch is:
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

The driver currently defines 7 audio instances, whether or not it
actually has 7 remains to be seen but the code as is is broken, so
I'll apply this.  If it turns out there are only 6 instances we can
fix the count later.  Applied.  Thanks!

Alex

>
>
> > ---
> > Sending this one separately from the rest of my fixes since:
> >
> > * It's definitely completely unrelated to the Gitlab 2171 issue
> > * I'm not sure if this is the correct fix since it's in DC
> >
> >  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > index 1b70b78e2fa15..af631085e88c5 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
> > @@ -359,7 +359,8 @@ static const struct dce_audio_registers audio_regs[] = {
> >         audio_regs(2),
> >         audio_regs(3),
> >         audio_regs(4),
> > -       audio_regs(5)
> > +       audio_regs(5),
> > +       audio_regs(6),
> >  };
> >
> >  #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
> > --
> > 2.37.3
> >

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

* Re: [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN
  2022-11-18 20:25   ` Alex Deucher
@ 2022-11-18 21:05     ` Harry Wentland
  0 siblings, 0 replies; 4+ messages in thread
From: Harry Wentland @ 2022-11-18 21:05 UTC (permalink / raw)
  To: Alex Deucher, Lyude Paul
  Cc: amd-gfx, Alan Liu, Leo Li, David Airlie, Pan, Xinhui,
	Rodrigo Siqueira, open list, stable, Aurabindo Pillai,
	open list:DRM DRIVERS, Daniel Vetter, Alex Deucher,
	Christian König



On 11/18/22 15:25, Alex Deucher wrote:
> On Thu, Nov 17, 2022 at 4:40 PM Alex Deucher <alexdeucher@gmail.com> wrote:
>>
>> On Mon, Nov 14, 2022 at 5:21 PM Lyude Paul <lyude@redhat.com> wrote:
>>>
>>> There's been a very long running bug that seems to have been neglected for
>>> a while, where amdgpu consistently triggers a KASAN error at start:
>>>
>>>   BUG: KASAN: global-out-of-bounds in read_indirect_azalia_reg+0x1d4/0x2a0 [amdgpu]
>>>   Read of size 4 at addr ffffffffc2274b28 by task modprobe/1889
>>>
>>> After digging through amd's rather creative method for accessing registers,
>>> I eventually discovered the problem likely has to do with the fact that on
>>> my dce120 GPU there are supposedly 7 sets of audio registers. But we only
>>> define a register mapping for 6 sets.
>>>
>>> So, fix this and fix the KASAN warning finally.
>>>
>>> Signed-off-by: Lyude Paul <lyude@redhat.com>
>>> Cc: stable@vger.kernel.org
>>
>> This is the correct fix for asics having 7 audio instances.  It looks
>> correct to me, assuming DCE12 actually has 7 audio instances.
>> @Wentland, Harry Do you know off hand?  If you can confirm that, the
>> patch is:
>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
> The driver currently defines 7 audio instances, whether or not it
> actually has 7 remains to be seen but the code as is is broken, so
> I'll apply this.  If it turns out there are only 6 instances we can
> fix the count later.  Applied.  Thanks!
> 

Good catch. I seem to recall some DCE generations had an extra audio
device and if DCE12 defines 7 audio instances then this is the correct
fix.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> Alex
> 
>>
>>
>>> ---
>>> Sending this one separately from the rest of my fixes since:
>>>
>>> * It's definitely completely unrelated to the Gitlab 2171 issue
>>> * I'm not sure if this is the correct fix since it's in DC
>>>
>>>  drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
>>> index 1b70b78e2fa15..af631085e88c5 100644
>>> --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
>>> +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
>>> @@ -359,7 +359,8 @@ static const struct dce_audio_registers audio_regs[] = {
>>>         audio_regs(2),
>>>         audio_regs(3),
>>>         audio_regs(4),
>>> -       audio_regs(5)
>>> +       audio_regs(5),
>>> +       audio_regs(6),
>>>  };
>>>
>>>  #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
>>> --
>>> 2.37.3
>>>


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

end of thread, other threads:[~2022-11-18 21:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 22:20 [PATCH] drm/amd/dc/dce120: Fix audio register mapping, stop triggering KASAN Lyude Paul
2022-11-17 21:40 ` Alex Deucher
2022-11-18 20:25   ` Alex Deucher
2022-11-18 21:05     ` Harry Wentland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®