From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Daniel Drake <drake@endlessm.com>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Linux Bluetooth mailing list <linux-bluetooth@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Subject: Re: [PATCH 3/3] Bluetooth: btrtl: Skip initialization if firmware is already loaded
Date: Sat, 26 Jan 2019 01:46:01 +0800 [thread overview]
Message-ID: <5D6AFF40-BBE2-4B42-91D2-C89C52ED06A0@canonical.com> (raw)
In-Reply-To: <CAD8Lp47YpoVeDheK3pi0CcSJTdh2jSVcM8V9T_zmu=7deXszOw@mail.gmail.com>
> On Jan 25, 2019, at 08:55, Daniel Drake <drake@endlessm.com> wrote:
>
> On Thu, Jan 24, 2019 at 11:23 PM Kai-Heng Feng
> <kai.heng.feng@canonical.com> wrote:
>> Realtek bluetooth may not work after reboot:
>> [ 12.446130] Bluetooth: hci0: RTL: rtl: unknown IC info, lmp subver a99e, hci rev 826c, hci ver 0008
>>
>> The power is not cut during system reboot, so the firmware is kept in
>> Bluetooth controller.
>>
>> Realtek bluetooth doesn't have the ability to check firmware loading
>> status. but the version queried by HCI_OP_READ_LOCAL_VERSION will be
>> different if firmware is already loaded. Realtek's own fork, rtk_btusb
>> also use this method to detect the loading status.
>>
>> So let's assume the firmware is already loaded when we can't find
>> matching IC info.
>
> This logic was already present in the driver - but it looks like this
> regressed at this point:
>
> commit 26503ad25de8c7c93a2037f919c2e49a62cf65f1
> Author: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Date: Thu Aug 2 16:57:13 2018 +0200
>
> Bluetooth: btrtl: split the device initialization into smaller parts
Thanks, didn’t find out it’s a regression.
>
> After your patch it is effectively there in two places now, since it
> is also in btrtl_download_firmware() (although not really effective
> after the above commit). I wonder if that can be cleaned up to avoid
> duplication.
Put the additional check to btrtl_download_firmware() should be sufficient.
>
> Regarding the other patches that move away from the style of returning
> either a useful value or an error, is this purely a stylistic thing or
> is it needed for your 3rd patch? I don't have strong feelings either
> way but I have the impression that the currently implemented approach
> is a common style within kernel code and I don't see benefit in
> splitting off a separate out parameter.
Ok. I’ll send a v2 without the refactoring part.
Kai-Heng
>
> Daniel
>
>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201921
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/bluetooth/btrtl.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
>> index c36f500d8313..e2f89d57dd14 100644
>> --- a/drivers/bluetooth/btrtl.c
>> +++ b/drivers/bluetooth/btrtl.c
>> @@ -546,9 +546,10 @@ int btrtl_initialize(struct hci_dev *hdev,
>> hdev->bus);
>>
>> if (!btrtl_dev->ic_info) {
>> - rtl_dev_err(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
>> - lmp_subver, hci_rev, hci_ver);
>> - return -EINVAL;
>> + rtl_dev_info(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
>> + lmp_subver, hci_rev, hci_ver);
>> + rtl_dev_info(hdev, "rtl: firmware may be already loaded, or it's an unsupported IC.");
>> + return 0;
>> }
>>
>> if (btrtl_dev->ic_info->has_rom_version) {
>> @@ -621,7 +622,8 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
>> if (ret)
>> return ret;
>>
>> - ret = btrtl_download_firmware(hdev, &btrtl_dev);
>> + if (btrtl_dev.ic_info)
>> + ret = btrtl_download_firmware(hdev, &btrtl_dev);
>>
>> return ret;
>> }
>> --
>> 2.17.1
>>
prev parent reply other threads:[~2019-01-25 17:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 15:23 [PATCH 1/3] Bluetooth: btrtl: Let rtl_load_file() always return error code Kai-Heng Feng
2019-01-24 15:23 ` [PATCH 2/3] Bluetooth: btrtl: Let btrtl_initialize() " Kai-Heng Feng
2019-01-24 15:23 ` [PATCH 3/3] Bluetooth: btrtl: Skip initialization if firmware is already loaded Kai-Heng Feng
2019-01-25 0:55 ` Daniel Drake
2019-01-25 17:46 ` Kai-Heng Feng [this message]
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=5D6AFF40-BBE2-4B42-91D2-C89C52ED06A0@canonical.com \
--to=kai.heng.feng@canonical.com \
--cc=drake@endlessm.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=martin.blumenstingl@googlemail.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;
as well as URLs for NNTP newsgroup(s).