linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Middendorf <kernel@tuxforce.de>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: linux-btrfs@vger.kernel.org, Antti Palosaari <crope@iki.fi>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>,
	dsterba@suse.cz, Lukas Middendorf <kernel@tuxforce.de>
Subject: Re: Is request_firmware() really safe to call in resume callback when /usr/lib/firmware is on btrfs?
Date: Sun, 4 Apr 2021 02:50:18 +0200	[thread overview]
Message-ID: <e57f9f01-c620-0d72-98de-d0831395bb7e@tuxforce.de> (raw)
In-Reply-To: <20210403202538.GW4332@42.do-not-panic.com>


Great to hear that you now succeeded in reproducing the problem.

On 03/04/2021 22:25, Luis Chamberlain wrote:
> On Sat, Apr 03, 2021 at 12:24:07PM +0200, Lukas Middendorf wrote:
>> One further thing I noticed which might be problematic in rare cases:
>> According to the kernel debug messages, the firmware-loader does not attempt
>> to cache the firmware during suspend,
> 
> Correct, the goal with this test was to purposely *not* call for the
> firmware prior to suspend, and instead *race* (do the wrong thing) at
> resume. It shouldn't really stall... fail yes, but stall, that seems
> fishy.

I understood that.
>> if the previous call to
>> request_firmware() has failed (file not present; call made during previous
>> resume). In my opinion it should attempt to cache the firmware on suspend
>> even in this case
> 
> Yes, that is the *proper* way to do use the firmware API, but we want to
> reproduce the stall, and so we have to recreate the issue you reported
> by doing something bad.

Should firmware_request_cache() always be called, or only instead of 
request_firmware() ? In case request_firmware is called on its own, and 
the firmware file is not present, it might still race on the next resume.
request_firmware seems to be meant to include the cache request for the 
next suspend, but it apparently *does not* if firmware loading fails due 
to a missing file. I think this is something that should either be 
changed or properly documented in the API documentation.


>> Did you also try to create a random test-firmware.bin (I used 1M from
>> /dev/urandom) instead of an empty /lib/firmware ?
> 
> No, right now I want to to just focus on fixing the stall you saw.

This is a second nuance of the stall I saw: The firmware file (in this 
case test-firmware.bin) is present but not in cache.

If you run

ls -lR /lib/firmware > /dev/null

before

systemctl suspend

your reproduction steps will very likely not stall.
If you in addition run

dd if=/dev/urandom of=/lib/firmware/test-firmware.bin bs=1K count=64

during the preparation of /lib/firmware (in addition to or instead of 
your for loop), then it will always stall (as long as the file content 
is not read before suspend).

One stall is happening while the directory content is being listed (to 
find that the file is not present), the second stall is happening while 
actually trying to read the file. Those two stalls likely have the same 
root cause, but it might be different. I just want to make sure you have 
covered all cases.


>>> You might be better off just reposting your
>>> patches with the respective Reviewed-by tags and pestering your
>>> maintainer.
>>
>> I will try to be a little bit more insistent this time. Is "just repost" the
>> usual way to handle if patches are ignored?
> 
> You can repost, v2 just add my reviewed-by. Those patches are indeed
> correct as they are calling for the firmware prior to resume. Maybe
> clarify that.

OK, will do.

> But indeed there is also another issue which you reported which needs to
> be fixed, and for that thanks so much for you patience! I'll be looking
> into this!

Also thank you for your effort.

Lukas




  parent reply	other threads:[~2021-04-04  0:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-09 18:51 Is request_firmware() really safe to call in resume callback when /usr/lib/firmware is on btrfs? Lukas Middendorf
2020-08-13 16:37 ` Luis Chamberlain
2020-08-13 21:53   ` Lukas Middendorf
2020-08-13 22:13     ` Luis Chamberlain
2020-08-14 11:38       ` Lukas Middendorf
2020-08-14 16:37         ` Luis Chamberlain
2020-08-14 21:59           ` Lukas Middendorf
2020-08-17 15:20             ` Luis Chamberlain
2020-08-17 22:04               ` Lukas Middendorf
2020-08-18 14:37                 ` Luis Chamberlain
2021-04-01 14:59                   ` Lukas Middendorf
2021-04-02 18:02                     ` Luis Chamberlain
2021-04-02 22:19                       ` Luis Chamberlain
2021-04-02 22:58                         ` Luis Chamberlain
2021-04-03 10:24                           ` Lukas Middendorf
2021-04-03 16:07                             ` Lukas Middendorf
2021-04-03 20:25                             ` Luis Chamberlain
2021-04-03 21:04                               ` Luis Chamberlain
2021-04-05  9:52                                 ` Lukas Middendorf
2021-04-04  0:50                               ` Lukas Middendorf [this message]
2021-04-08 18:02                               ` Luis Chamberlain
2021-04-16 23:17                                 ` Luis Chamberlain

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=e57f9f01-c620-0d72-98de-d0831395bb7e@tuxforce.de \
    --to=kernel@tuxforce.de \
    --cc=crope@iki.fi \
    --cc=dsterba@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mcgrof@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;
as well as URLs for NNTP newsgroup(s).