2020-04-27 14:55:28

by Hans de Goede

[permalink] [raw]
Subject: [PATCH] Bluetooth: btbcm: Do not free IRQ on close if we did not request it

When the patch-ram is missing the hci_bcm code does not request the
IRQ, in this case we should not try to free it from bcm_close()

This fixes the following WARN statements + backtraces:
[ 332.670662] WARNING: CPU: 3 PID: 4743 at kernel/irq/devres.c:143 devm_free_irq+0x45/0x50
[ 332.670882] Trying to free already-free IRQ 44
[ 332.670891] WARNING: CPU: 3 PID: 4743 at kernel/irq/manage.c:1718 free_irq+0x1f4/0x390

Signed-off-by: Hans de Goede <[email protected]>
---
drivers/bluetooth/hci_bcm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 0c34b6c57f7d..0fb4b9c1dfc1 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_requested;

#ifdef CONFIG_PM
struct hci_uart *hu;
@@ -333,6 +334,8 @@ static int bcm_request_irq(struct bcm_data *bcm)
goto unlock;
}

+ bdev->irq_requested = true;
+
device_init_wakeup(bdev->dev, true);

pm_runtime_set_autosuspend_delay(bdev->dev,
@@ -514,10 +517,11 @@ static int bcm_close(struct hci_uart *hu)
}

if (bdev) {
- if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) {
+ if (bdev->irq_requested) {
devm_free_irq(bdev->dev, bdev->irq, bdev);
device_init_wakeup(bdev->dev, false);
pm_runtime_disable(bdev->dev);
+ bdev->irq_requested = false;
}

err = bcm_gpio_set_power(bdev, false);
--
2.26.0


2020-04-28 09:41:05

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btbcm: Do not free IRQ on close if we did not request it

Hi Hans,

> When the patch-ram is missing the hci_bcm code does not request the
> IRQ, in this case we should not try to free it from bcm_close()
>
> This fixes the following WARN statements + backtraces:
> [ 332.670662] WARNING: CPU: 3 PID: 4743 at kernel/irq/devres.c:143 devm_free_irq+0x45/0x50
> [ 332.670882] Trying to free already-free IRQ 44
> [ 332.670891] WARNING: CPU: 3 PID: 4743 at kernel/irq/manage.c:1718 free_irq+0x1f4/0x390
>
> Signed-off-by: Hans de Goede <[email protected]>
> ---
> drivers/bluetooth/hci_bcm.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)

the patch doesn’t apply cleanly against bluetooth-next tree. Can you send a revised one. Thanks.

Regards

Marcel

2020-04-28 14:39:41

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btbcm: Do not free IRQ on close if we did not request it

Hi,

On 4/28/20 11:39 AM, Marcel Holtmann wrote:
> Hi Hans,
>
>> When the patch-ram is missing the hci_bcm code does not request the
>> IRQ, in this case we should not try to free it from bcm_close()
>>
>> This fixes the following WARN statements + backtraces:
>> [ 332.670662] WARNING: CPU: 3 PID: 4743 at kernel/irq/devres.c:143 devm_free_irq+0x45/0x50
>> [ 332.670882] Trying to free already-free IRQ 44
>> [ 332.670891] WARNING: CPU: 3 PID: 4743 at kernel/irq/manage.c:1718 free_irq+0x1f4/0x390
>>
>> Signed-off-by: Hans de Goede <[email protected]>
>> ---
>> drivers/bluetooth/hci_bcm.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> the patch doesn’t apply cleanly against bluetooth-next tree. Can you send a revised one. Thanks.

So I looked into rebasing the patch and it did not apply because
another (almost identical) fix for the issue has already landed
in bluetooth-next:

d5d0c62437c0 ("Bluetooth: hci_bcm: fix freeing not-requested IRQ")

So my version of this fix (this patch) can be dropped.

It would be good if this straight forward fix can be send to Linus
for one of the upcoming 5.7-rc# releases.

Regards,

Hans