From: Takashi Iwai <tiwai@suse.de>
To: Oliver Neukum <oneukum@suse.de>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Dave Jones <davej@redhat.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
pgynther@google.com, linux-bluetooth@vger.kernel.org
Subject: Re: bluetooth related firmware loader spew on resume.
Date: Thu, 27 Nov 2014 15:43:57 +0100 [thread overview]
Message-ID: <s5h3894zosy.wl-tiwai@suse.de> (raw)
In-Reply-To: <s5hmw7evvg2.wl-tiwai@suse.de>
At Wed, 26 Nov 2014 16:21:49 +0100,
Takashi Iwai wrote:
>
> At Wed, 26 Nov 2014 15:27:57 +0100,
> Oliver Neukum wrote:
> >
> > On Wed, 2014-11-26 at 15:12 +0100, Takashi Iwai wrote:
> > > At Wed, 26 Nov 2014 23:05:20 +0900,
> > > Marcel Holtmann wrote:
> > > >
> > > > Hi Oliver,
> > > >
> > > > >> In order to paper over this, we may also remember the failing firmware
> > > > >> and avoid loading it. This might be an easer way than the endless
> > > > >> fight against UMH race...
> > > > >
> > > > >
> > > > > the full fix would be to implement reset_resume() for btusb.
> > > > > It seems to me that setup() should be split in two methods,
> > > > > one to request the firmware from user space and the second
> > > > > to transfer it to the device. reset_resume() would just need
> > > > > to repeat the second operation.
> > > >
> > > > so when you do hci_register_dev, then hdev->setup is only called once. I really mean only once per lifetime of the hci_dev. So you would need to unregister the hci_dev first before hdev->setup will ever be called again. So I am not sure this is actually the problem here. The problem here is entirely within request_firmware() unless of course we run through the USB probe handlers again. Which I do not see happening here.
> > > >
> > > > And we have hdev->setup this way since normally the Bluetooth devices keep their firmware patches and not forget about them and suspend-resume cycles. If the USB device of course jumps of the bus during it then all bets are off anyway.
> > >
> > > Usually you can avoid unnecessary rebinding when you provide a proper
> > > reset_resume callback. I guess that's what Oliver suggested.
> >
> > Yes, but even in reset_resume() you would need to redo the setup
> > part, as the device lost power. The basic problem of requesting
> > the firmware wouldn't be solved.
>
> Requesting the firmware in the resume path itself is OK. There are
> many drivers doing so. But the primary problem in btusb is that it's
> triggered at the wrong timing. (And the second problem is that the
> firmware loader doesn't cache the non-existing files, so it goes
> through lengthy code paths for reconfirming that the file doesn't
> exist.)
So, below is a quick hack for avoiding the f/w loader activation
during resume. I just compile-tested, so no idea whether it really
works or not.
Takashi
---
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 3d785ebb48d3..e928bde45d7d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -167,6 +167,7 @@ struct fw_name_devm {
#define FW_LOADER_NO_CACHE 0
#define FW_LOADER_START_CACHE 1
+#define FW_LOADER_CACHE_ONLY 2
static int fw_cache_piggyback_on_request(const char *name);
@@ -1112,6 +1113,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
if (ret <= 0) /* error or already assigned */
goto out;
+ if (fw_cache.state == FW_LOADER_CACHE_ONLY) {
+ ret = -ENOENT;
+ goto out;
+ }
+
ret = 0;
timeout = firmware_loading_timeout();
if (opt_flags & FW_OPT_NOWAIT) {
@@ -1633,7 +1639,8 @@ static int fw_pm_notify(struct notifier_block *notify_block,
/* stop caching firmware once syscore_suspend is reached */
static int fw_suspend(void)
{
- fw_cache.state = FW_LOADER_NO_CACHE;
+ /* use only cached firmware until fully resumed */
+ fw_cache.state = FW_LOADER_CACHE_ONLY;
return 0;
}
next prev parent reply other threads:[~2014-11-27 14:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-11 18:12 bluetooth related firmware loader spew on resume Dave Jones
2014-11-25 16:40 ` Takashi Iwai
2014-11-26 5:15 ` Marcel Holtmann
2014-11-26 8:52 ` Takashi Iwai
2014-11-26 10:10 ` Oliver Neukum
2014-11-26 10:31 ` Takashi Iwai
2014-11-26 10:43 ` Oliver Neukum
2014-11-26 10:53 ` Takashi Iwai
2014-11-26 14:08 ` Marcel Holtmann
2014-11-26 14:23 ` Oliver Neukum
2014-11-26 14:31 ` Takashi Iwai
2014-11-26 14:38 ` Oliver Neukum
2014-11-26 14:05 ` Marcel Holtmann
2014-11-26 14:12 ` Takashi Iwai
2014-11-26 14:27 ` Oliver Neukum
2014-11-26 15:21 ` Takashi Iwai
2014-11-27 14:43 ` Takashi Iwai [this message]
2014-11-26 14:16 ` Oliver Neukum
2014-11-26 14:56 ` Mihai Donțu
2014-11-26 15:19 ` Takashi Iwai
2014-11-26 15:26 ` Mihai Donțu
2014-11-26 15:27 ` Takashi Iwai
2014-11-26 17:42 ` Arend van Spriel
2014-11-26 18:13 ` Takashi Iwai
2014-11-27 8:59 ` Arend van Spriel
2014-11-27 9:17 ` Takashi Iwai
2014-11-27 9:29 ` Arend van Spriel
2014-11-27 9:46 ` Arend van Spriel
2014-11-27 10:09 ` 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=s5h3894zosy.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=davej@redhat.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=oneukum@suse.de \
--cc=pgynther@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox