mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown
@ 2026-09-30  7:44 Runyu Xiao
  2026-10-02 16:40 ` patchwork-bot+bluetooth
  2026-10-05  4:14 ` Ravindra
  0 siblings, 2 replies; 6+ messages in thread
From: Runyu Xiao @ 2026-09-30  7:44 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Luiz Augusto von Dentz, Tedd Ho-Jeong An, Kiran K,
	linux-bluetooth, linux-kernel, stable, Runyu Xiao, Jianhao Xu

The PCIe driver registers its MSI-X handlers with
devm_request_threaded_irq(), but remove() uses free_irq() directly. The
devres actions then retain registrations and attempt to release them again
during device cleanup.

Use devm_free_irq() for the remove path and for already registered vectors
when a later setup request fails. This removes the managed resource at the
same time as the IRQ is released and keeps MSI-X vector teardown ordered
after IRQ ownership is gone.

Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
 drivers/bluetooth/btintel_pcie.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 005c77a4f..f8901df7c 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -1750,7 +1750,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
 static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
 {
 	int err;
-	int num_irqs, i;
+	int num_irqs, i, j;
 
 	for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++)
 		data->msix_entries[i].entry = i;
@@ -1779,6 +1779,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
 						KBUILD_MODNAME,
 						msix_entry);
 		if (err) {
+			for (j = 0; j < i; j++)
+				devm_free_irq(&data->pdev->dev,
+					      data->msix_entries[j].vector,
+					      &data->msix_entries[j]);
 			pci_free_irq_vectors(data->pdev);
 			data->alloc_vecs = 0;
 			return err;
@@ -3101,7 +3105,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
 		struct msix_entry *msix_entry;
 
 		msix_entry = &data->msix_entries[i];
-		free_irq(msix_entry->vector, msix_entry);
+		devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry);
 	}
 
 	pci_free_irq_vectors(pdev);
-- 
2.34.1

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

* Re: [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown
  2026-09-30  7:44 [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown Runyu Xiao
@ 2026-10-02 16:40 ` patchwork-bot+bluetooth
  2026-10-05  4:14 ` Ravindra
  1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2026-10-02 16:40 UTC (permalink / raw)
  To: Runyu Xiao
  Cc: marcel, luiz.dentz, tedd.an, kiran.k, linux-bluetooth,
	linux-kernel, stable, jianhao.xu

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 30 Sep 2026 15:44:53 +0800 you wrote:
> The PCIe driver registers its MSI-X handlers with
> devm_request_threaded_irq(), but remove() uses free_irq() directly. The
> devres actions then retain registrations and attempt to release them again
> during device cleanup.
> 
> Use devm_free_irq() for the remove path and for already registered vectors
> when a later setup request fails. This removes the managed resource at the
> same time as the IRQ is released and keeps MSI-X vector teardown ordered
> after IRQ ownership is gone.
> 
> [...]

Here is the summary with links:
  - Bluetooth: btintel_pcie: use managed IRQ teardown
    https://git.kernel.org/bluetooth/bluetooth-next/c/25016fe8c1ed

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown
  2026-09-30  7:44 [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown Runyu Xiao
  2026-10-02 16:40 ` patchwork-bot+bluetooth
@ 2026-10-05  4:14 ` Ravindra
  2026-10-06  9:56   ` Runyu Xiao
  2026-10-06  9:56   ` [PATCH v2] " Runyu Xiao
  1 sibling, 2 replies; 6+ messages in thread
From: Ravindra @ 2026-10-05  4:14 UTC (permalink / raw)
  To: runyu.xiao
  Cc: jianhao.xu, kiran.k, linux-bluetooth, linux-kernel, luiz.dentz,
	marcel, stable, tedd.an, Ravindra

Hi Runyu,

Thanks for the fix.

I have tested this patch with repeated Bluetooth load/unload cycles on
an Intel PCIe Bluetooth device and did not observe any kernel warnings
or issues with the patch applied.

Tested-by: Ravindra <ravindra@intel.com>

Could you please send a v2 including the above Tested-by tag?

Thanks,
Ravindra

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

* Re: [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown
  2026-10-05  4:14 ` Ravindra
@ 2026-10-06  9:56   ` Runyu Xiao
  2026-10-06  9:56   ` [PATCH v2] " Runyu Xiao
  1 sibling, 0 replies; 6+ messages in thread
From: Runyu Xiao @ 2026-10-06  9:56 UTC (permalink / raw)
  To: Ravindra
  Cc: Jianhao Xu, Kiran K, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, Marcel Holtmann, stable,
	Tedd Ho-Jeong An

On Mon, 5 Oct 2026 09:44:57 +0530, Ravindra wrote:
> I have tested this patch with repeated Bluetooth load/unload cycles on
> an Intel PCIe Bluetooth device and did not observe any kernel warnings
> or issues with the patch applied.
>
> Tested-by: Ravindra <ravindra@intel.com>
>
> Could you please send a v2 including the above Tested-by tag?

Thanks for testing this patch. I'll send a v2 shortly with your
Tested-by tag.

Thanks,
Runyu

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

* [PATCH v2] Bluetooth: btintel_pcie: use managed IRQ teardown
  2026-10-05  4:14 ` Ravindra
  2026-10-06  9:56   ` Runyu Xiao
@ 2026-10-06  9:56   ` Runyu Xiao
  2026-10-06 13:56     ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 6+ messages in thread
From: Runyu Xiao @ 2026-10-06  9:56 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Luiz Augusto von Dentz, Tedd Ho-Jeong An, Kiran K,
	linux-bluetooth, linux-kernel, stable, Ravindra, Runyu Xiao,
	Jianhao Xu

The PCIe driver registers its MSI-X handlers with
devm_request_threaded_irq(), but remove() uses free_irq() directly. The
devres actions then retain registrations and attempt to release them again
during device cleanup.

Use devm_free_irq() for the remove path and for already registered vectors
when a later setup request fails. This removes the managed resource at the
same time as the IRQ is released and keeps MSI-X vector teardown ordered
after IRQ ownership is gone.

Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Cc: stable@vger.kernel.org
Tested-by: Ravindra <ravindra@intel.com>
Assisted-by: LLM
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
Changes in v2:
- Add Ravindra's Tested-by tag.

 drivers/bluetooth/btintel_pcie.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 005c77a4f..f8901df7c 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -1750,7 +1750,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
 static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
 {
 	int err;
-	int num_irqs, i;
+	int num_irqs, i, j;
 
 	for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++)
 		data->msix_entries[i].entry = i;
@@ -1779,6 +1779,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
 						KBUILD_MODNAME,
 						msix_entry);
 		if (err) {
+			for (j = 0; j < i; j++)
+				devm_free_irq(&data->pdev->dev,
+					      data->msix_entries[j].vector,
+					      &data->msix_entries[j]);
 			pci_free_irq_vectors(data->pdev);
 			data->alloc_vecs = 0;
 			return err;
@@ -3101,7 +3105,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
 		struct msix_entry *msix_entry;
 
 		msix_entry = &data->msix_entries[i];
-		free_irq(msix_entry->vector, msix_entry);
+		devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry);
 	}
 
 	pci_free_irq_vectors(pdev);
-- 
2.34.1

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

* Re: [PATCH v2] Bluetooth: btintel_pcie: use managed IRQ teardown
  2026-10-06  9:56   ` [PATCH v2] " Runyu Xiao
@ 2026-10-06 13:56     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-10-06 13:56 UTC (permalink / raw)
  To: Runyu Xiao
  Cc: Marcel Holtmann, Tedd Ho-Jeong An, Kiran K, linux-bluetooth,
	linux-kernel, stable, Ravindra, Jianhao Xu

Hi Runyu,

On Tue, Oct 6, 2026 at 5:56 AM Runyu Xiao <runyu.xiao@seu.edu.cn> wrote:
>
> The PCIe driver registers its MSI-X handlers with
> devm_request_threaded_irq(), but remove() uses free_irq() directly. The
> devres actions then retain registrations and attempt to release them again
> during device cleanup.
>
> Use devm_free_irq() for the remove path and for already registered vectors
> when a later setup request fails. This removes the managed resource at the
> same time as the IRQ is released and keeps MSI-X vector teardown ordered
> after IRQ ownership is gone.
>
> Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
> Cc: stable@vger.kernel.org
> Tested-by: Ravindra <ravindra@intel.com>
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> Changes in v2:
> - Add Ravindra's Tested-by tag.

v1 has already been applied.

>
>  drivers/bluetooth/btintel_pcie.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
> index 005c77a4f..f8901df7c 100644
> --- a/drivers/bluetooth/btintel_pcie.c
> +++ b/drivers/bluetooth/btintel_pcie.c
> @@ -1750,7 +1750,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
>  static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
>  {
>         int err;
> -       int num_irqs, i;
> +       int num_irqs, i, j;
>
>         for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++)
>                 data->msix_entries[i].entry = i;
> @@ -1779,6 +1779,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
>                                                 KBUILD_MODNAME,
>                                                 msix_entry);
>                 if (err) {
> +                       for (j = 0; j < i; j++)
> +                               devm_free_irq(&data->pdev->dev,
> +                                             data->msix_entries[j].vector,
> +                                             &data->msix_entries[j]);
>                         pci_free_irq_vectors(data->pdev);
>                         data->alloc_vecs = 0;
>                         return err;
> @@ -3101,7 +3105,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
>                 struct msix_entry *msix_entry;
>
>                 msix_entry = &data->msix_entries[i];
> -               free_irq(msix_entry->vector, msix_entry);
> +               devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry);
>         }
>
>         pci_free_irq_vectors(pdev);
> --
> 2.34.1



-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2026-10-06 13:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30  7:44 [PATCH] Bluetooth: btintel_pcie: use managed IRQ teardown Runyu Xiao
2026-10-02 16:40 ` patchwork-bot+bluetooth
2026-10-05  4:14 ` Ravindra
2026-10-06  9:56   ` Runyu Xiao
2026-10-06  9:56   ` [PATCH v2] " Runyu Xiao
2026-10-06 13:56     ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®