From: Luis Chamberlain <mcgrof@kernel.org>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Lukas Middendorf <kernel@tuxforce.de>,
linux-media@vger.kernel.org, Antti Palosaari <crope@iki.fi>
Subject: Re: [PATCH 1/2] media: si2168: request caching of firmware to make it available on resume
Date: Fri, 9 Apr 2021 16:58:02 +0000 [thread overview]
Message-ID: <20210409165802.GG4332@42.do-not-panic.com> (raw)
In-Reply-To: <20210409132957.08d7c7bf@coco.lan>
On Fri, Apr 09, 2021 at 01:29:57PM +0200, Mauro Carvalho Chehab wrote:
> Em Thu, 1 Apr 2021 16:42:26 +0200
> Lukas Middendorf <kernel@tuxforce.de> escreveu:
>
> > Hi,
> >
> > I see this (or a similar fix) has not yet been included in 5.12-rc5.
> > Any further problems or comments regarding this patch? It still applies
> > cleanly to current git master and the problem is still relevant.
>
> Well, I fail to see why si2168 is so special that it would require it...
>
> on a quick check, it sounds that there's just a single driver using this
> kAPI:
>
> drivers/net/wireless/mediatek/mt7601u/mcu.c: return firmware_request_cache(dev->dev, MT7601U_FIRMWARE);
>
> while there are several drivers on media that require firmware.
>
> Btw, IMHO, the better would be to reload the firmware at resume
> time, instead of caching it, just like other media drivers.
Mauro,
Here is the thing. If we have a race to a filesystem (it calls
submit_bio()) after resume but before thaw you can end up in
a situation where async read waits forever as the read never
hit hardware.
Fixing this is part of the work I had tried long ago by removing
the kthread freezer from filesystems [0] which allow proper
filesystem freeze/thaw during suspend / resume. I am picking
this work up in the meantime.
The firmware cache resolves these races by caching firmware
in case its needed on resume. However, if a driver never
actually had called request_firmware() upon bootup, then
the firmware was never cached and the call to request_firmware()
on resume will actually trigger a submit_bio().
In my tests the race does trigger a forever wait on XFS and btrfs, but
not on ext4. But in any case, I can put a stop gap to these issues
by issuing a try lock on the usermode helper lock prior to a direct
fs read, however that's just a hack, and preference is to just resolve
this by getting drivers to properly call request_firmware() before
thaw. The commit log for the one user you mentioned explains well why
that driver needed it, commit d723522b0be4 ("mt7601u: use
firmware_request_cache() to address cache on reboot") was added
since the device may sometimes retain the firmware on the hardware
device upon reboot, and in such case not trigger a request_firmware()
call on reboot on the driver side.
If such cases happen on other drivers, they can use that.
Its not clear to me from looking at the media APIs whether or not
all drivers are always properly calling the request_firmware() API
on suspend, prior to resume. If not that needs to be fixed.
Luis
next prev parent reply other threads:[~2021-04-09 16:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 21:45 [PATCH 1/2] media: si2168: request caching of firmware to make it available on resume Lukas Middendorf
2020-08-13 21:45 ` [PATCH 2/2] media: si2168: also cache Si2168 B40 fallback firmware Lukas Middendorf
2020-08-13 21:55 ` Luis Chamberlain
2021-04-01 14:46 ` Lukas Middendorf
2020-08-13 21:54 ` [PATCH 1/2] media: si2168: request caching of firmware to make it available on resume Luis Chamberlain
2021-04-01 14:42 ` Lukas Middendorf
2021-04-02 18:04 ` Luis Chamberlain
2021-04-09 11:29 ` Mauro Carvalho Chehab
2021-04-09 16:58 ` Luis Chamberlain [this message]
2021-04-09 22:02 ` Lukas Middendorf
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=20210409165802.GG4332@42.do-not-panic.com \
--to=mcgrof@kernel.org \
--cc=crope@iki.fi \
--cc=kernel@tuxforce.de \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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