Possible fix for the BBB's vbus vs tps65217-charger interrupt conflict

Hi, I’m an user space dev and uncertain if my fix for the vbus vs tps65217-charger interrupt conflict is correct. Your input would be appreciated.

I needed to re-enable the tps65217-charger driver but got the following error:

genirq: Flags mismatch irq 148. 00002000 (vbus) vs. 00000000 (tps65217-charger)

This is similar to [quote=“RobertCNelson, post:12, topic:33481”]
genirq: Flags mismatch irq 54. 00002000 (vbus) vs. 00000000 (tps65217-charger)
[/quote]

I used the following post as guidance to re-enable the tps65217-charger driver:
https://forum.beagleboard.org/t/enable-ac-power-irq-from-tps65217-on-bbb/33481/1

As a test I disabled to interrupts of tps65217-charger driver (tps65217_charger.c) and forced the use of the polling thread option. This obviously fixed the above irq conflict issue but also ensured that there are no other driver issues.

The potential fix:
I re-enabled the tps65217-charger driver’s interrupts and changed the devm_request_threaded_irq function’s flag from IRQF_ONESHOT to IRQF_SHARED. Did the same for conflicted VBUS driver (musb_dsps.c). Re-compiled and re-deployed…

No errors or conflicts.

cat /proc/interrupts | grep tps
146: 0 INTC 7 Level tps65217-irq
147: 0 tps65217 1 Edge tps65217-charger
148: 0 tps65217 0 Edge vbus, tps65217-charger
149: 0 tps65217 2 Edge tps65217_pwr_but

“sudo systemctl poweroff” shuts down the board (only a visual check).

For TPS65217 PMIC, both the AC and USB interrupts are enabled…

i2cget -f -y 0 0x24 0x2
0x00

Also checked via cat /proc/irq/xyz/spurious.

Additional info:
I used Robert’s scripts to build and modify a kernel, dtbs and modules. Following these steps:
https://forum.digikey.com/t/debian-getting-started-with-the-beaglebone-black/12967

My terse image details:
dogtag:[BeagleBoard.org Debian Buster Console Image 2020-04-06]
bootloader:[U-Boot 2019.04-00002-g07d5700e21]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
kernel:[4.19.94-ti-r74.1]

Awesome @nemith , please post a patch for mainline linux, and i’ll backport it…

I don’t see a real maintainner: kernel/git/torvalds/linux.git - Linux kernel source tree

So just cc linux-omap: MAINTAINERS - kernel/git/torvalds/linux.git - Linux kernel source tree

Regards,

Hi @RobertCNelson

I’ve never created and posted a patch before but keen to do it… could you please check my steps.

clone linux mainline (git clone kernel/git/torvalds/linux.git - Linux kernel source tree)

git describe --tags
v6.5-rc5-55-g22883973244b

Modify and commit drivers/power/supply/tps65217_charger.c & drivers/usb/musb/musb_dsps.c.
Note: I only tested these changes on the BBB kernel:[4.19.94-ti-r74.1], with and without a battery connected.

git format-patch HEAD~2
0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch
0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch

./scripts/checkpatch.pl 0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch
total: 0 errors, 0 warnings, 8 lines checked
./scripts/checkpatch.pl 0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch
total: 0 errors, 0 warnings, 8 lines checked

cat 0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch
From 4b38cb1f0e34c09938ee5a9e02711917abbedfbb Mon Sep 17 00:00:00 2001
From: nemith <...@gmail.com>
Date: Thu, 10 Aug 2023 18:36:36 +0200
Subject: [PATCH 1/2] power: supply: Fix tps65217-charger vs vbus irq conflict

Enabling the tps65217-charger driver/module causes an interrupt conflict
with the vbus driver resulting in a probe failure.
The conflict is resolved by changing both driver's threaded interrupt
request function from IRQF_ONESHOT to IRQF_SHARED.

Signed-off-by: nemth <...@gmail.com>
---
 drivers/power/supply/tps65217_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
index a4bc9f2a10bc..6f68becdbfd0 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -238,7 +238,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
  	for (i = 0; i < NUM_CHARGER_IRQS; i++) {
 		ret = devm_request_threaded_irq(&pdev->dev, irq[i], NULL,
 						tps65217_charger_irq,
-						IRQF_ONESHOT, "tps65217-charger",
+						IRQF_SHARED, "tps65217-charger",
 						charger);
 		if (ret) {
 			dev_err(charger->dev,
-- 
2.34.1
cat 0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch
From a9a04e889e296966abc96f72b9bfcbf535ddb0d4 Mon Sep 17 00:00:00 2001
From: nemth <...@gmail.com>
Date: Thu, 10 Aug 2023 18:40:08 +0200
Subject: [PATCH 2/2] usb: musb: dsps: Fix vbus vs tps65217-charger irq
 conflict

Enabling the tps65217-charger driver/module causes an interrupt conflict
with the vbus driver resulting in a probe failure.
The conflict is resolved by changing both driver's threaded interrupt
request function from IRQF_ONESHOT to IRQF_SHARED.

Signed-off-by: nemith <...@gmail.com>
---
 drivers/usb/musb/musb_dsps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 9119b1d51370..cbb45de5a76f 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -851,7 +851,7 @@ static int dsps_setup_optional_vbus_irq(struct platform_device *pdev,

 	error = devm_request_threaded_irq(glue->dev, glue->vbus_irq,
 					  NULL, dsps_vbus_threaded_irq,
-					  IRQF_ONESHOT,
+					  IRQF_SHARED,

 					  "vbus", glue);
 	if (error) {
 		glue->vbus_irq = 0;
-- 
2.34.1

./scripts/get_maintainer.pl 0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch
Sebastian Reichel sre@kernel.org (maintainer:POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS)
linux-pm@vger.kernel.org (open list:POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS)
linux-kernel@vger.kernel.org (open list)

./scripts/get_maintainer.pl 0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch
Bin Liu b-liu@ti.com (maintainer:MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER)
Greg Kroah-Hartman gregkh@linuxfoundation.org (supporter:USB SUBSYSTEM)
linux-usb@vger.kernel.org (open list:MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER)

I’ve already setup git send-email and will email it to myself first to double check.

git send-email \
–cc-cmd=‘./scripts/get_maintainer.pl --norolestats 0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch’ 0001-power-supply-Fix-tps65217-charger-vs-vbus-irq-conflict.patch
git send-email \
–cc-cmd=‘./scripts/get_maintainer.pl --norolestats 0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch’ 0002-usb-musb-dsps-Fix-vbus-vs-tps65217-charger-irq-conflict.patch

Nemith

That’s an awesome first pass @nemith !

I’d also cc linux-omap@vger.kernel.org to get the omap group and tony@atomide.com as he is the TI omap board maintainer!

Regards,