From: Takashi Iwai <tiwai@suse.de>
To: Curtis Malainey <cujomalainey@google.com>
Cc: cujomalainey@chromium.org, alsa-devel@alsa-project.org,
Doug Anderson <dianders@chromium.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Zheyu Ma <zheyuma97@gmail.com>, Dan Carpenter <error27@gmail.com>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
Clement Lecigne <clecigne@google.com>,
Ivan Orlov <ivan.orlov0322@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] sound: core: fix device ownership model in card and pcm
Date: Sun, 06 Aug 2023 20:32:06 +0200 [thread overview]
Message-ID: <87msz4f2e1.wl-tiwai@suse.de> (raw)
In-Reply-To: <87o7jloqp5.wl-tiwai@suse.de>
On Sat, 05 Aug 2023 10:09:58 +0200,
Takashi Iwai wrote:
>
> On Fri, 04 Aug 2023 21:17:56 +0200,
> Curtis Malainey wrote:
> >
> > On Fri, Aug 4, 2023 at 1:58 AM Takashi Iwai <tiwai@suse.de> wrote:
> > >
> > > Now I've been reconsidering the problem, and thought of another
> > > possible workaround. We may add the card's refcount control for the
> > > device init and release, so that we delay the actual resource free.
> > > The basic idea is to take card->card_ref at the device init and unref
> > > it at the actual device release callback. Then the snd_card_free()
> > > call is held until all those refcounted devices are released.
> > >
> > > Below is a PoC patch (yes, this can be split, too ;)
> > > A quick test on VM seems OK, but needs more reviews and tests.
> > >
> > > It contains somewhat ugly conditional put_device() at the dev_free
> > > ops. We can make those a bit saner with some helpers later, too.
> > >
> > > BTW, this approach may avoid another potential problem by the delayed
> > > release; if we finish the driver remove without waiting for the actual
> > > device releases, it may hit a code (the piece of the device release
> > > callback) of the already removed module, and it's not guaranteed to be
> > > present.
> > > I'm not sure whether this really happens, but it's another thing to be
> > > considered.
> > >
> > >
> > > thanks,
> > >
> > > Takashi
> > >
> > > ---
> > > diff --git a/include/sound/core.h b/include/sound/core.h
> > > index f6e0dd648b80..00c514a80a4a 100644
> > > --- a/include/sound/core.h
> > > +++ b/include/sound/core.h
> >
> > Unfortunately it doesn't hold up in my testing, hit the devm vs device
> > race bug after a little over 30min of hammering snd-dummy (on top of
> > your for-next branch)
> (snip)
> > I was talking with Stephen Boyd about this bug and his recommendation
> > was to keep snd_card always out of devm and just allocate a pointer in
> > devm to snd_card to puppet it as if it was managed via devm and just
> > reference count rather than release the card so that its always
> > handled through device->release. What do you think? This would go
> > alongside the current patch proposed.
>
> Indeed, that's another issue about devres vs delayed kobj release.
> A quick fix would be something like below, I suppose.
> (note: totally untested)
Scratch it. It's still obviously broken.
Will cook more proper patches later.
Takashi
next prev parent reply other threads:[~2023-08-06 18:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 17:18 [PATCH] sound: core: fix device ownership model in card and pcm cujomalainey
2023-08-02 3:29 ` kernel test robot
2023-08-02 3:51 ` kernel test robot
2023-08-02 6:42 ` Takashi Iwai
2023-08-02 17:06 ` Curtis Malainey
2023-08-02 17:43 ` [PATCH v2] " cujomalainey
2023-08-03 6:49 ` Greg Kroah-Hartman
2023-08-03 9:46 ` Dan Carpenter
2023-08-03 9:49 ` [PATCH] " Dan Carpenter
2023-08-03 13:06 ` Takashi Iwai
2023-08-03 15:35 ` Takashi Iwai
2023-08-03 23:39 ` Curtis Malainey
2023-08-04 8:58 ` Takashi Iwai
2023-08-04 19:17 ` Curtis Malainey
2023-08-05 8:09 ` Takashi Iwai
2023-08-06 18:32 ` Takashi Iwai [this message]
2023-08-07 13:43 ` Takashi Iwai
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=87msz4f2e1.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=clecigne@google.com \
--cc=cujomalainey@chromium.org \
--cc=cujomalainey@google.com \
--cc=dianders@chromium.org \
--cc=error27@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ivan.orlov0322@gmail.com \
--cc=maciej.szmigiero@oracle.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=zheyuma97@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.