Skip to contentSkip to conversation

ipmi: bt-bmc: Propagate errors from IRQ configuration

PATCH In review [email protected] 2 participants 13 messages Aug 17 – Aug 19 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ipmi: bt-bmc: Propagate errors from IRQ configuration

From: bui duc phuc <[email protected]>

Check and propagate the return value of bt_bmc_config_irq() instead of ignoring errors during probe.

---
 drivers/char/ipmi/bt-bmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +3 -1
index a179d4797011..7d3944bda8db 100644
@@ -436,7 +436,9 @@ static int bt_bmc_probe(struct platform_device *pdev)
 		return rc;
 	}
 
-	bt_bmc_config_irq(bt_bmc, pdev);
+	rc = bt_bmc_config_irq(bt_bmc, pdev);
+	if (rc)
+		return rc;
 
 	if (bt_bmc->irq >= 0) {
 		dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/4 ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

From: bui duc phuc <[email protected]>

platform_get_irq_optional() can return -ENXIO when no IRQ resource is available, as well as other negative error codes.

The probe path supports running without an IRQ by falling back to the timer. Treat -ENXIO as the no-IRQ case while propagating other errors to the caller.

---
 drivers/char/ipmi/bt-bmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +1 -1
index 7d3944bda8db..4c5457c88503 100644
@@ -380,7 +380,7 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
 	u32 reg;
 
 	bt_bmc->irq = platform_get_irq_optional(pdev, 0);
-	if (bt_bmc->irq < 0)
+	if (bt_bmc->irq < 0 && bt_bmc->irq != -ENXIO)
 		return bt_bmc->irq;
 
 	rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
Signature · 1 line
2.43.0
#9 lore raw

PATCH 3/4 ipmi: bt-bmc: Request IRQ only when available

In reply to [email protected]

From: bui duc phuc <[email protected]>

Only call devm_request_irq() when a valid positive IRQ number is available.

Remove the redundant warning since devm_request_irq() already reports the error. There is also no need to store the error in bt_bmc->irq, as errors other than -ENXIO are returned to the caller instead of being handled as the no-IRQ case.

---
 drivers/char/ipmi/bt-bmc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/char/ipmi/bt-bmc.c +5 -6
index 4c5457c88503..99b38300f9e1 100644
@@ -383,12 +383,11 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
 	if (bt_bmc->irq < 0 && bt_bmc->irq != -ENXIO)
 		return bt_bmc->irq;
 
-	rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
-			      DEVICE_NAME, bt_bmc);
-	if (rc < 0) {
-		dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
-		bt_bmc->irq = rc;
-		return rc;
+	if (bt_bmc->irq > 0) {
+		rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq,
+				      IRQF_SHARED, DEVICE_NAME, bt_bmc);
+		if (rc < 0)
+			return rc;
 	}
 
 	/*
Signature · 1 line
2.43.0
#10 lore raw

PATCH 4/4 ipmi: bt-bmc: Check IRQ number correctly

In reply to [email protected]

From: bui duc phuc <[email protected]>

bt_bmc->irq does not have a value of zero, so check for a positive IRQ number when selecting between IRQ and timer-based handling.

---
 drivers/char/ipmi/bt-bmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +1 -1
index 99b38300f9e1..68bf34715387 100644
@@ -439,7 +439,7 @@ static int bt_bmc_probe(struct platform_device *pdev)
 	if (rc)
 		return rc;
 
-	if (bt_bmc->irq >= 0) {
+	if (bt_bmc->irq > 0) {
 		dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
 	} else {
 		dev_info(dev, "No IRQ; using timer\n");
Signature · 1 line
2.43.0
maintainer
#11 lore raw
In reply to [email protected]
Quoted 15 lines · On Mon, Aug 17, 2026 at 05:50:38PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

Check and propagate the return value of bt_bmc_config_irq() instead of ignoring errors during probe.

---
 drivers/char/ipmi/bt-bmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +0 -0
index a179d4797011..7d3944bda8db 100644

drivers/char/ipmi/bt-bmc.c static int bt_bmc_probe(struct platform_device *pdev) · line 441

Quoted 7 lines
drivers/char/ipmi/bt-bmc.c +3 -1
@@ -436,7 +436,9 @@ static int bt_bmc_probe(struct platform_device *pdev)
 		return rc;
 	}
 
-	bt_bmc_config_irq(bt_bmc, pdev);
+	rc = bt_bmc_config_irq(bt_bmc, pdev);
+	if (rc)
+		return rc;

No, this will break the driver if the interrupt is not available. That function is badly written (it should return the irq and the irq should be set here) but if it encounters an error, it should use the timer.

-corey

Quoted 6 lines
drivers/char/ipmi/bt-bmc.c +0 -0
 	if (bt_bmc->irq >= 0) {
 		dev_info(dev, "Using IRQ %d\n", bt_bmc->irq);
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

In reply to [email protected]
Quoted 8 lines · On Mon, Aug 17, 2026 at 05:50:39PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() can return -ENXIO when no IRQ resource is available, as well as other negative error codes.

The probe path supports running without an IRQ by falling back to the timer. Treat -ENXIO as the no-IRQ case while propagating other errors to the caller.

This is obviously wrong, it will pass -ENXIO into devm_request_irq() if returned.

-corey

Quoted 22 lines
---
 drivers/char/ipmi/bt-bmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ipmi/bt-bmc.c +1 -1
index 7d3944bda8db..4c5457c88503 100644
@@ -380,7 +380,7 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
 	u32 reg;
 
 	bt_bmc->irq = platform_get_irq_optional(pdev, 0);
-	if (bt_bmc->irq < 0)
+	if (bt_bmc->irq < 0 && bt_bmc->irq != -ENXIO)
 		return bt_bmc->irq;
 
 	rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
Signature · 1 line
2.43.0
#12 lore raw
In reply to Corey Minyard

Hi Corey,

Thank you for your review .

Quoted 5 lines

No, this will break the driver if the interrupt is not available. That function is badly written (it should return the irq and the irq should be set here) but if it encounters an error, it should use the timer.

Yes, that's why I created the follow-up patches.

Best regards,
Phuc

#3 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

In reply to Corey Minyard
Quoted 7 lines · Corey Minyard
Quoted 5 lines · On Mon, Aug 17, 2026 at 05:50:39PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() can return -ENXIO when no IRQ resource is available, as well as other negative error codes.

Quoted 7 lines
Quoted 3 lines

The probe path supports running without an IRQ by falling back to the timer. Treat -ENXIO as the no-IRQ case while propagating other errors to the caller.

This is obviously wrong, it will pass -ENXIO into devm_request_irq() if returned.

No. This is addressed in the following patch:
[PATCH 3/4] ipmi: bt-bmc: Request IRQ only when available

https://lore.kernel.org/all/[email protected]/

Please take a look at the subsequent patches in the series as well.

Best regards,
Phuc

maintainer
#4 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

Quoted 17 lines · Bui Duc Phuc
Quoted 7 lines · Corey Minyard
Quoted 5 lines · On Mon, Aug 17, 2026 at 05:50:39PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() can return -ENXIO when no IRQ resource is available, as well as other negative error codes.

Quoted 7 lines
Quoted 3 lines

The probe path supports running without an IRQ by falling back to the timer. Treat -ENXIO as the no-IRQ case while propagating other errors to the caller.

This is obviously wrong, it will pass -ENXIO into devm_request_irq() if returned.

Quoted 6 lines

No. This is addressed in the following patch:
[PATCH 3/4] ipmi: bt-bmc: Request IRQ only when available

https://lore.kernel.org/all/[email protected]/

Please take a look at the subsequent patches in the series as well.

You cannot add patches that introduce bugs then fix them later. Occassionally it might be necessary, but it should be avoided if possible, and it's certainly possible here.

And as I said earlier, this function should return an error/interrupt, not set the value inside the function. The function has issues, and you are right to work on it, but it needs to be consistent with everything else in the kernel.

This would also be better as a single patch. There's no reason to split it up to this fine a level of detail, it makes it hard to follow.

And it must work if no interrupt is available for any reason.

-corey

Quoted 3 lines

Best regards,
Phuc

#5 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

Hi Corey,

Thanks for your feedback.

Quoted 11 lines
Quoted 6 lines

No. This is addressed in the following patch:
[PATCH 3/4] ipmi: bt-bmc: Request IRQ only when available

https://lore.kernel.org/all/[email protected]/

Please take a look at the subsequent patches in the series as well.

You cannot add patches that introduce bugs then fix them later. Occassionally it might be necessary, but it should be avoided if possible, and it's certainly possible here.

This patch does not introduce a new bug. It fixes the incorrect handling of platform_get_irq_optional() .
The only issue is that, as you pointed out, the patches are not ordered appropriately.
Perhaps it would be better to make this patch look like this:

- if (bt_bmc->irq < 0)
+ if (bt_bmc->irq < 0 && bt_bmc->irq != -ENXIO)

                return bt_bmc->irq;

- rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED,
- DEVICE_NAME, bt_bmc);
- if (rc < 0) {

-               dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
-               bt_bmc->irq = rc;
-               return rc;

+ if (bt_bmc->irq > 0) {
+ rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq,
+ IRQF_SHARED, DEVICE_NAME, bt_bmc);
+ if (rc < 0) {
+ dev_warn(dev, "Unable to request IRQ %d\n",
bt_bmc->irq);
+ bt_bmc->irq = rc;

+                       return rc;
        }

Then the next patch would remove the error log:

       if (rc < 0) {
-               dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
-               bt_bmc->irq = rc;
               return rc;
Quoted 2 lines

And as I said earlier, this function should return an error/interrupt, not set the value inside the function.

I agree. This is reasonable and can be refactored to make the code clearer.

Quoted 4 lines

The function has issues,
and you are right to work on it, but it needs to be consistent with everything else in the kernel.

Yes, I agree.
I found that quite a few places in the kernel handle the error values from platform_get_irq_optional()
correctly. However, there are still some places where they are not handled correctly.

Regarding the incorrect error handling of platform_get_irq_optional(), I have submitted several patches to address such cases. Some places have agreed with my approach of propagating all error values except -ENXIO, while some other places have so far only agreed with propagating -EPROBE_DEFER.

I think that when we do not fully understand the semantics of an API, we may end up with incorrect error handling. But once the issue has been identified,
I think we should fix it rather than continue to maintain the incorrect behavior.

If, with other APIs, callers also unintentionally or intentionally hide meaningful errors
instead of propagating them upwards, just imagine what the kernel would become.

Quoted 3 lines

This would also be better as a single patch. There's no reason to split it up to this fine a level of detail, it makes it hard to follow.

If the issue is fixed, having it as a single patch would not be a problem.

Quoted 2 lines

And it must work if no interrupt is available for any reason.

As I understand it, you mean keeping the current behavior of ignoring all errors and
continuing to run, in order to ensure that existing systems can still work? Since the current code already ignores all errors, is that correct?

Best regards,
Phuc

maintainer
#6 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

Quoted 4 lines · Bui Duc Phuc

Hi Corey,

Thanks for your feedback.

snip...

Quoted 8 lines
Quoted 3 lines

And it must work if no interrupt is available for any reason.

As I understand it, you mean keeping the current behavior of ignoring all errors and
continuing to run, in order to ensure that existing systems can still work? Since the current code already ignores all errors, is that correct?

Yes, ignoring errors is the right thing to do in this case. Printing a warning log about incorrect configuration is ok, but breaking systems that have incorrect configuration is not ok.

It is common for these systems to not have interrupts. I think it's a bad idea, but I didn't design the hardware or the specifciations. And it's common for configuration to have issues :-(

Anyway, I think you have the parameters now, looking forward to the next patch.

-corey

#7 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

Hi Corey,

Thank you for your feedback.

Quoted 4 lines

Yes, ignoring errors is the right thing to do in this case. Printing a warning log about incorrect configuration is ok, but breaking systems that have incorrect configuration is not ok.

If that's the case, then perhaps platform_get_irq() would be a better fit than platform_get_irq_optional(). platform_get_irq() already prints an error message internally and only requires the caller to distinguish between success and failure.
This seems to match the behavior you are looking for.

Quoted 4 lines

It is common for these systems to not have interrupts. I think it's a bad idea, but I didn't design the hardware or the specifciations. And it's common for configuration to have issues :-(

Hardware configuration is handled by software, so if the software configures the hardware incorrectly but ignores the error, the problem may go undetected. Could this allow the same driver bug to persist when the driver is used with newer generations of chips?

Also, if software silently ignores errors, it can hide a problem in the hardware or
in how the hardware is being used. This can make the problem harder to detect and potentially allow it to persist when the design is reused in subsequent chip generations.

Quoted 2 lines

Anyway, I think you have the parameters now, looking forward to the next patch.

My goal is to ensure that the correct error code is returned to the caller. Although I could implement it by ignoring the errors as you suggested, I will not do so because that goes against the goal of this series.

Best regards,
Phuc

maintainer
#8 lore raw

Re: [PATCH 2/4] ipmi: bt-bmc: Handle -ENXIO from optional IRQ lookup

Quoted 9 lines · Bui Duc Phuc

Hi Corey,

Thank you for your feedback.

Quoted 4 lines

Yes, ignoring errors is the right thing to do in this case. Printing a warning log about incorrect configuration is ok, but breaking systems that have incorrect configuration is not ok.

Quoted 5 lines

If that's the case, then perhaps platform_get_irq() would be a better fit than platform_get_irq_optional(). platform_get_irq() already prints an error message internally and only requires the caller to distinguish between success and failure.
This seems to match the behavior you are looking for.

No, it is optional. Some systems don't have interrupts. But they may be misconfigured in this case. For instance, they may put "0" for the interrupt if they don't support it. These things can't always be easily fixed. The big thing is we can't change behaviour without a really compelling reasons.

Quoted 12 lines
Quoted 5 lines

It is common for these systems to not have interrupts. I think it's a bad idea, but I didn't design the hardware or the specifciations. And it's common for configuration to have issues :-(

Hardware configuration is handled by software, so if the software configures the hardware incorrectly but ignores the error, the problem may go undetected. Could this allow the same driver bug to persist when the driver is used with newer generations of chips?

Quoted 5 lines

Also, if software silently ignores errors, it can hide a problem in the hardware or
in how the hardware is being used. This can make the problem harder to detect and potentially allow it to persist when the design is reused in subsequent chip generations.

I'm not going to argue with any of this. But I also have to live inside the parameters of the real world.

It doesn't have to be silent, you can print a warning. But it can't return an error in this case.

Quoted 7 lines
Quoted 3 lines

Anyway, I think you have the parameters now, looking forward to the next patch.

My goal is to ensure that the correct error code is returned to the caller. Although I could implement it by ignoring the errors as you suggested, I will not do so because that goes against the goal of this series.

Ok, that's fine. This isn't critical.

Thanks,

-corey

Quoted 3 lines

Best regards,
Phuc