linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT
@ 2020-04-02 12:55 Michał Mirosław
  2020-04-02 12:55 ` [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ Michał Mirosław
  2020-04-03  6:40 ` [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Marcel Holtmann
  0 siblings, 2 replies; 4+ messages in thread
From: Michał Mirosław @ 2020-04-02 12:55 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Guillaume La Roque, Kevin Hilman,
	Frederic Danis
  Cc: linux-bluetooth, linux-kernel

The IRQ polarity is be configured in bcm_setup_sleep(). Make the
configured value match what is in the DeviceTree.

Cc: stable@vger.kernel.org
Fixes: f25a96c8eb46 ("Bluetooth: hci_bcm: enable IRQ capability from devicetree")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/bluetooth/hci_bcm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index b236cb11c0dc..36b7f0d00c4b 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -1153,7 +1153,8 @@ static int bcm_of_probe(struct bcm_device *bdev)
 	device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
 				      bdev->pcm_int_params, 5);
 	bdev->irq = of_irq_get_byname(bdev->dev->of_node, "host-wakeup");
-
+	bdev->irq_active_low = irq_get_trigger_type(bdev->irq)
+			     & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW);
 	return 0;
 }
 
-- 
2.20.1


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

* [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ
  2020-04-02 12:55 [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Michał Mirosław
@ 2020-04-02 12:55 ` Michał Mirosław
  2020-04-03  6:41   ` Marcel Holtmann
  2020-04-03  6:40 ` [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Marcel Holtmann
  1 sibling, 1 reply; 4+ messages in thread
From: Michał Mirosław @ 2020-04-02 12:55 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Frederic Danis,
	Guillaume La Roque, Kevin Hilman
  Cc: linux-bluetooth, linux-kernel

When BT module can't be initialized, but it has an IRQ, unloading
the driver WARNs when trying to free not-yet-requested IRQ. Fix it by
noting whether the IRQ was requested.

WARNING: CPU: 2 PID: 214 at kernel/irq/devres.c:144 devm_free_irq+0x49/0x4ca
[...]
WARNING: CPU: 2 PID: 214 at kernel/irq/manage.c:1746 __free_irq+0x8b/0x27c
Trying to free already-free IRQ 264
Modules linked in: hci_uart(-) btbcm bluetooth ecdh_generic ecc libaes
CPU: 2 PID: 214 Comm: rmmod Tainted: G        W         5.6.1mq-00044-ga5f9ea098318-dirty #928
[...]
[<b016aefb>] (devm_free_irq) from [<af8ba1ff>] (bcm_close+0x97/0x118 [hci_uart])
[<af8ba1ff>] (bcm_close [hci_uart]) from [<af8b736f>] (hci_uart_unregister_device+0x33/0x3c [hci_uart])
[<af8b736f>] (hci_uart_unregister_device [hci_uart]) from [<b035930b>] (serdev_drv_remove+0x13/0x20)
[<b035930b>] (serdev_drv_remove) from [<b037093b>] (device_release_driver_internal+0x97/0x118)
[<b037093b>] (device_release_driver_internal) from [<b0370a0b>] (driver_detach+0x2f/0x58)
[<b0370a0b>] (driver_detach) from [<b036f855>] (bus_remove_driver+0x41/0x94)
[<b036f855>] (bus_remove_driver) from [<af8ba8db>] (bcm_deinit+0x1b/0x740 [hci_uart])
[<af8ba8db>] (bcm_deinit [hci_uart]) from [<af8ba86f>] (hci_uart_exit+0x13/0x30 [hci_uart])
[<af8ba86f>] (hci_uart_exit [hci_uart]) from [<b01900bd>] (sys_delete_module+0x109/0x1d0)
[<b01900bd>] (sys_delete_module) from [<b0101001>] (ret_fast_syscall+0x1/0x5a)
[...]

Cc: stable@vger.kernel.org
Fixes: 6cc4396c8829 ("Bluetooth: hci_bcm: Add wake-up capability")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/bluetooth/hci_bcm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 36b7f0d00c4b..19e4587f366c 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -118,6 +118,7 @@ struct bcm_device {
 	u32			oper_speed;
 	int			irq;
 	bool			irq_active_low;
+	bool			irq_acquired;
 
 #ifdef CONFIG_PM
 	struct hci_uart		*hu;
@@ -333,6 +334,8 @@ static int bcm_request_irq(struct bcm_data *bcm)
 		goto unlock;
 	}
 
+	bdev->irq_acquired = true;
+
 	device_init_wakeup(bdev->dev, true);
 
 	pm_runtime_set_autosuspend_delay(bdev->dev,
@@ -514,7 +517,7 @@ static int bcm_close(struct hci_uart *hu)
 	}
 
 	if (bdev) {
-		if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) {
+		if (IS_ENABLED(CONFIG_PM) && bdev->irq_acquired) {
 			devm_free_irq(bdev->dev, bdev->irq, bdev);
 			device_init_wakeup(bdev->dev, false);
 			pm_runtime_disable(bdev->dev);
-- 
2.20.1


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

* Re: [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT
  2020-04-02 12:55 [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Michał Mirosław
  2020-04-02 12:55 ` [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ Michał Mirosław
@ 2020-04-03  6:40 ` Marcel Holtmann
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-04-03  6:40 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Johan Hedberg, Guillaume La Roque, Kevin Hilman, Frederic Danis,
	Bluetooth Kernel Mailing List, linux-kernel

Hi Michal,

> The IRQ polarity is be configured in bcm_setup_sleep(). Make the
> configured value match what is in the DeviceTree.
> 
> Cc: stable@vger.kernel.org
> Fixes: f25a96c8eb46 ("Bluetooth: hci_bcm: enable IRQ capability from devicetree")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> drivers/bluetooth/hci_bcm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ
  2020-04-02 12:55 ` [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ Michał Mirosław
@ 2020-04-03  6:41   ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-04-03  6:41 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Johan Hedberg, Frederic Danis, Guillaume La Roque, Kevin Hilman,
	linux-bluetooth, linux-kernel

Hi Michal,

> When BT module can't be initialized, but it has an IRQ, unloading
> the driver WARNs when trying to free not-yet-requested IRQ. Fix it by
> noting whether the IRQ was requested.
> 
> WARNING: CPU: 2 PID: 214 at kernel/irq/devres.c:144 devm_free_irq+0x49/0x4ca
> [...]
> WARNING: CPU: 2 PID: 214 at kernel/irq/manage.c:1746 __free_irq+0x8b/0x27c
> Trying to free already-free IRQ 264
> Modules linked in: hci_uart(-) btbcm bluetooth ecdh_generic ecc libaes
> CPU: 2 PID: 214 Comm: rmmod Tainted: G        W         5.6.1mq-00044-ga5f9ea098318-dirty #928
> [...]
> [<b016aefb>] (devm_free_irq) from [<af8ba1ff>] (bcm_close+0x97/0x118 [hci_uart])
> [<af8ba1ff>] (bcm_close [hci_uart]) from [<af8b736f>] (hci_uart_unregister_device+0x33/0x3c [hci_uart])
> [<af8b736f>] (hci_uart_unregister_device [hci_uart]) from [<b035930b>] (serdev_drv_remove+0x13/0x20)
> [<b035930b>] (serdev_drv_remove) from [<b037093b>] (device_release_driver_internal+0x97/0x118)
> [<b037093b>] (device_release_driver_internal) from [<b0370a0b>] (driver_detach+0x2f/0x58)
> [<b0370a0b>] (driver_detach) from [<b036f855>] (bus_remove_driver+0x41/0x94)
> [<b036f855>] (bus_remove_driver) from [<af8ba8db>] (bcm_deinit+0x1b/0x740 [hci_uart])
> [<af8ba8db>] (bcm_deinit [hci_uart]) from [<af8ba86f>] (hci_uart_exit+0x13/0x30 [hci_uart])
> [<af8ba86f>] (hci_uart_exit [hci_uart]) from [<b01900bd>] (sys_delete_module+0x109/0x1d0)
> [<b01900bd>] (sys_delete_module) from [<b0101001>] (ret_fast_syscall+0x1/0x5a)
> [...]
> 
> Cc: stable@vger.kernel.org
> Fixes: 6cc4396c8829 ("Bluetooth: hci_bcm: Add wake-up capability")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> drivers/bluetooth/hci_bcm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2020-04-03  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 12:55 [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Michał Mirosław
2020-04-02 12:55 ` [PATCH 2/2] bluetooth: hci_bcm: fix freeing not-requested IRQ Michał Mirosław
2020-04-03  6:41   ` Marcel Holtmann
2020-04-03  6:40 ` [PATCH 1/2] bluetooth: hci_bcm: respect IRQ polarity from DT Marcel Holtmann

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