linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
	Emma Anholt <emma@anholt.net>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Regression with mainline kernel on rpi4
Date: Fri, 24 Sep 2021 15:30:22 +0200	[thread overview]
Message-ID: <20210924133022.waqgtr5xjjxigong@gilmour> (raw)
In-Reply-To: <CAHk-=whASMriPYRdH8kxC_UwObBtwHbPvf7rb58sUEZZyaFxJg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2548 bytes --]

On Wed, Sep 22, 2021 at 01:25:21PM -0700, Linus Torvalds wrote:
> On Wed, Sep 22, 2021 at 1:19 PM Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> >
> > I added some debugs to print the addresses, and I am getting:
> > [   38.813809] sudip crtc 0000000000000000
> >
> > This is from struct drm_crtc *crtc = connector->state->crtc;
> 
> Yeah, that was my personal suspicion, because while the line number
> implied "crtc->state" being NULL, the drm data structure documentation
> and other drivers both imply that "crtc" was the more likely one.
> 
> I suspect a simple
> 
>         if (!crtc)
>                 return;
> 
> in vc4_hdmi_set_n_cts() is at least part of the fix for this all, but
> I didn't check if there is possibly something else that needs to be
> done too.

Thanks for the decode_stacktrace.sh and the follow-up

Yeah, it looks like we have several things wrong here:

  * we only check that connector->state is set, and not
    connector->state->crtc indeed.

  * We also check only in startup(), so at open() and not later on when
    the sound streaming actually start. This has been there for a while,
    so I guess it's never really been causing a practical issue before.

I'm still not entirely sure how we can end up in that situation though.
The only case I could think of is that:

  * The firmware enables the HDMI controller, then boots Linux

  * The driver starts, registers its audio card. connector->state is
    NULL then, and if the HDMI monitor is actually an HDMI monitor (vs a
    DVI monitor), the VC4_HDMI_RAM_PACKET_ENABLE bit that we test in
    startup will be set.

  * The driver will create the connector->state (through a call to
    drm_mode_config_reset in vc4_kms_load), connector->state isn't NULL
    anymore, VC4_HDMI_RAM_PACKET_ENABLE is still set.

  * The driver then disables the HDMI controller (in
    vc4_crtc_disable_at_boot) but never clears the
    VC4_HDMI_RAM_PACKET_ENABLE bit.

  * Pulseaudio opens the audio device, startup succeeds because both
    conditions we test succeed.

  * However, since we either never enabled the HDMI connector (or if it
    was disabled at some point), connector->state->crtc is NULL and we
    get our NULL pointer dereference.

    The Ubuntu configuration has the framebuffer emulation and the
    framebuffer console enabled, so it's likely to be enabled and
    something (X.org?) comes along and disables the connector right when
    pulseaudio calls prepare().

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2021-09-24 13:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02  9:08 Regression with mainline kernel on rpi4 Sudip Mukherjee
2021-09-03 16:03 ` Maxime Ripard
2021-09-03 20:09   ` Sudip Mukherjee
2021-09-04  9:10     ` Maxime Ripard
2021-09-04  9:40       ` Sudip Mukherjee
2021-09-20 14:47         ` Maxime Ripard
2021-09-20 15:43           ` Maxime Ripard
2021-09-20 15:53             ` Maxime Ripard
2021-09-20 16:35               ` Sudip Mukherjee
2021-09-20 17:10                 ` Maxime Ripard
2021-09-20 17:21                   ` Sudip Mukherjee
2021-09-22  9:57                     ` Maxime Ripard
2021-09-22 10:10                       ` Sudip Mukherjee
2021-09-22 11:28                         ` Maxime Ripard
2021-09-22 17:18                           ` Sudip Mukherjee
2021-09-22 15:22                         ` Linus Torvalds
2021-09-22 17:02                           ` Sudip Mukherjee
2021-09-22 18:23                             ` Linus Torvalds
2021-09-22 20:19                               ` Sudip Mukherjee
2021-09-22 20:25                                 ` Linus Torvalds
2021-09-24 13:30                                   ` Maxime Ripard [this message]
2021-09-24 22:50                                     ` Daniel Vetter
2021-09-28  8:34                                       ` Maxime Ripard
2021-09-30  9:19                                         ` Daniel Vetter
2021-10-13 15:01                                           ` Maxime Ripard
2021-10-14 13:15                                             ` Daniel Vetter
2021-10-25 14:15                                               ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210924133022.waqgtr5xjjxigong@gilmour \
    --to=maxime@cerno.tech \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).