linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND] [PATCH 1/3] Bluetooth: btintel: Add firmware lock function
@ 2018-10-03  7:35 Kai-Heng Feng
  2018-10-03  7:35 ` [RESEND] [PATCH 2/3] Bluetooth: btusb: Load firmware exclusively for Intel BT Kai-Heng Feng
       [not found] ` <20181003073556.28154-3-kai.heng.feng@canonical.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2018-10-03  7:35 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg
  Cc: Kai-Heng Feng, linux-kernel, linux-bluetooth

When Intel 8260 starts to load Bluetooth firmware and WiFi firmware, by
calling btintel_download_firmware() and iwl_pcie_load_given_ucode_8000()
respectively, the Bluetooth btintel_download_firmware() aborts half way:
[   11.950216] Bluetooth: hci0: Failed to send firmware data (-38)

Let btusb and iwlwifi load firmwares exclusively can avoid the issue, so
introduce a lock to use in btusb and iwlwifi.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/bluetooth/btintel.c   | 14 ++++++++++++++
 drivers/bluetooth/btintel.h   | 10 ++++++++++
 include/linux/intel-wifi-bt.h |  8 ++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 include/linux/intel-wifi-bt.h

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 5270d5513201..2d2a983a6641 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -35,6 +35,8 @@
 
 #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}})
 
+static DEFINE_MUTEX(firmware_lock);
+
 int btintel_check_bdaddr(struct hci_dev *hdev)
 {
 	struct hci_rp_read_bd_addr *bda;
@@ -724,6 +726,18 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw,
 }
 EXPORT_SYMBOL_GPL(btintel_download_firmware);
 
+void btintel_firmware_lock(void)
+{
+	mutex_lock(&firmware_lock);
+}
+EXPORT_SYMBOL_GPL(btintel_firmware_lock);
+
+void btintel_firmware_unlock(void)
+{
+	mutex_unlock(&firmware_lock);
+}
+EXPORT_SYMBOL_GPL(btintel_firmware_unlock);
+
 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
 MODULE_VERSION(VERSION);
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index 41c642cc523f..1373ffc2b575 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -102,6 +102,8 @@ int btintel_read_boot_params(struct hci_dev *hdev,
 			     struct intel_boot_params *params);
 int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
 			      u32 *boot_param);
+void btintel_firmware_lock(void);
+void btintel_firmware_unlock(void);
 #else
 
 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
@@ -196,4 +198,12 @@ static inline int btintel_download_firmware(struct hci_dev *dev,
 {
 	return -EOPNOTSUPP;
 }
+
+static inline void btintel_firmware_lock(void)
+{
+}
+
+static inline void btintel_firmware_unlock(void)
+{
+}
 #endif
diff --git a/include/linux/intel-wifi-bt.h b/include/linux/intel-wifi-bt.h
new file mode 100644
index 000000000000..260ed628d19b
--- /dev/null
+++ b/include/linux/intel-wifi-bt.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __INTEL_WIFI_BT_H__
+#define __INTEL_WIFI_BT_H__
+
+void btintel_firmware_lock(void);
+void btintel_firmware_unlock(void);
+
+#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RESEND] [PATCH 2/3] Bluetooth: btusb: Load firmware exclusively for Intel BT
  2018-10-03  7:35 [RESEND] [PATCH 1/3] Bluetooth: btintel: Add firmware lock function Kai-Heng Feng
@ 2018-10-03  7:35 ` Kai-Heng Feng
       [not found] ` <20181003073556.28154-3-kai.heng.feng@canonical.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2018-10-03  7:35 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg
  Cc: Kai-Heng Feng, linux-bluetooth, linux-kernel

To avoid the firmware loading race between Bluetooth and WiFi on Intel
8260, load firmware exclusively when IWLWIFI is enabled.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/bluetooth/btusb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 61cde1a7ec1b..060e3c6482f4 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2251,8 +2251,16 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 
 	set_bit(BTUSB_DOWNLOADING, &data->flags);
 
+#if IS_ENABLED(CONFIG_IWLWIFI)
+	btintel_firmware_lock();
+#endif
+
 	/* Start firmware downloading and get boot parameter */
 	err = btintel_download_firmware(hdev, fw, &boot_param);
+
+#if IS_ENABLED(CONFIG_IWLWIFI)
+	btintel_firmware_unlock();
+#endif
 	if (err < 0)
 		goto done;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND] [PATCH 3/3] iwlwifi: Load firmware exclusively for Intel WiFi
       [not found]       ` <87tvm3id0f.fsf@kamboji.qca.qualcomm.com>
@ 2018-10-03  9:47         ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-10-03  9:47 UTC (permalink / raw)
  To: Kai Heng Feng
  Cc: LKML, Johannes Berg, Emmanuel Grumbach, Luca Coelho,
	Intel Linux Wireless, David S. Miller, linux-wireless, netdev,
	linux-bluetooth

Kalle Valo <kvalo@codeaurora.org> writes:

> Kai Heng Feng <kai.heng.feng@canonical.com> writes:
>
>>> On Oct 3, 2018, at 5:10 PM, Kalle Valo <kvalo@codeaurora.org> wrote:
>>> 
>>> Kai-Heng Feng <kai.heng.feng@canonical.com> writes:
>>> 
>>>> To avoid the firmware loading race between Bluetooth and WiFi on Intel
>>>> 8260, load firmware exclusively when BT_INTEL is enabled.
>>>> 
>>>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>>> 
>>> Still the commit log tells nothing about the actual problem which makes
>>> review impossible.
>>
>> Sorry for that. The first two patches [1] only sends to linux-bluetooth and LMKL.
>
> For a patchset like this you should CC linux-wireless for all patches,
> otherwise people just get confused. And even more so as patch 3 seems to
> depend on the other patches.
>
>> I don’t know what really happened at hardware/firmware level, but
>> making btusb and iwlwifi load firmware sequentially can workaround the
>> issue.
>
> We don't apply ugly workarounds without understanding the issue.
>
>> Matt Chen may be able to explain this issue with more detail.
>
> Then you need to work with Matt so that the issue is properly explained
> in the commit log.

linux-bluetooth was not CCed, adding that.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND] [PATCH 3/3] iwlwifi: Load firmware exclusively for Intel WiFi
       [not found]       ` <0BA3FCBA62E2DC44AF3030971E174FB301336D868D@HASMSX111.ger.corp.intel.com>
@ 2018-10-03  9:57         ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-10-03  9:57 UTC (permalink / raw)
  To: Grumbach, Emmanuel
  Cc: Kai Heng Feng, LKML, Berg, Johannes, Coelho, Luciano, linuxwifi,
	David S. Miller, linux-wireless, netdev, linux-bluetooth

+ linux-bluetooth

"Grumbach, Emmanuel" <emmanuel.grumbach@intel.com> writes:

>> 
>> > On Oct 3, 2018, at 5:10 PM, Kalle Valo <kvalo@codeaurora.org> wrote:
>> >
>> > Kai-Heng Feng <kai.heng.feng@canonical.com> writes:
>> >
>> >> To avoid the firmware loading race between Bluetooth and WiFi on
>> >> Intel 8260, load firmware exclusively when BT_INTEL is enabled.
>> >>
>> >> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> >
>> > Still the commit log tells nothing about the actual problem which
>> > makes review impossible.
>> 
>> Sorry for that. The first two patches [1] only sends to linux-bluetooth and
>> LMKL.
>> 
>> I don’t know what really happened at hardware/firmware level, but making
>> btusb and iwlwifi load firmware sequentially can workaround the issue.
>> 
>> Matt Chen may be able to explain this issue with more detail.
>> 
>> [1] https://lkml.org/lkml/2018/10/3/322
>>
>
> I just read the code of this patch and I don't quite understand.
> You have a function that is declared as a non-inline function in two different header files?
> btintel_firmware_lock is declared here:
>
> --- /dev/null
> +++ b/include/linux/intel-wifi-bt.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __INTEL_WIFI_BT_H__
> +#define __INTEL_WIFI_BT_H__
> +
> +void btintel_firmware_lock(void);
>
> And ...
>
> diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
> index 41c642cc523f..1373ffc2b575 100644
> --- a/drivers/bluetooth/btintel.h
> +++ b/drivers/bluetooth/btintel.h
> @@ -102,6 +102,8 @@ int btintel_read_boot_params(struct hci_dev *hdev,
>  			     struct intel_boot_params *params);
>  int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
>  			      u32 *boot_param);
> +void btintel_firmware_lock(void);
>
>
> This can't be right.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-03  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03  7:35 [RESEND] [PATCH 1/3] Bluetooth: btintel: Add firmware lock function Kai-Heng Feng
2018-10-03  7:35 ` [RESEND] [PATCH 2/3] Bluetooth: btusb: Load firmware exclusively for Intel BT Kai-Heng Feng
     [not found] ` <20181003073556.28154-3-kai.heng.feng@canonical.com>
     [not found]   ` <87y3bfiees.fsf@kamboji.qca.qualcomm.com>
     [not found]     ` <265BAF93-4BFF-4850-92F7-80AC39496473@canonical.com>
     [not found]       ` <87tvm3id0f.fsf@kamboji.qca.qualcomm.com>
2018-10-03  9:47         ` [RESEND] [PATCH 3/3] iwlwifi: Load firmware exclusively for Intel WiFi Kalle Valo
     [not found]       ` <0BA3FCBA62E2DC44AF3030971E174FB301336D868D@HASMSX111.ger.corp.intel.com>
2018-10-03  9:57         ` Kalle Valo

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).