Skip to contentSkip to conversation

x86/of: Return consistent error type from x86_of_pci_irq_enable()

PATCH Applied Ilpo Järvinen 5 participants 12 messages May 27, 2024 – Jun 24, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 x86/of: Return consistent error type from x86_of_pci_irq_enable()

x86_of_pci_irq_enable() returns PCIBIOS_* code received from pci_read_config_byte() directly and also -EINVAL which are not compatible error types. x86_of_pci_irq_enable() is used as (*pcibios_enable_irq) function which should not return PCIBIOS_* codes.

Convert the PCIBIOS_* return code from pci_read_config_byte() into normal errno using pcibios_err_to_errno().

Fixes 96e0a0797eba ("x86: dtb: Add support for PCI devices backed by dtb nodes")
---
 arch/x86/kernel/devicetree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/devicetree.c +1 -1
index 8e3c53b4d070..64280879c68c 100644
@@ -83,7 +83,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev)
 
 	ret = pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
 	if (ret)
-		return ret;
+		return pcibios_err_to_errno(ret);
 	if (!pin)
 		return 0;
 
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/4 x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling

intel_mid_pci_irq_enable() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

intel_mid_pci_irq_enable() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 5b395e2be6c4 ("x86/platform/intel-mid: Make IRQ allocation a bit more flexible")
---
 arch/x86/pci/intel_mid_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/intel_mid_pci.c +2 -2
index 8edd62206604..722a33be08a1 100644
@@ -233,9 +233,9 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 		return 0;
 
 	ret = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
-	if (ret < 0) {
+	if (ret) {
 		dev_warn(&dev->dev, "Failed to read interrupt line: %d\n", ret);
-		return ret;
+		return pcibios_err_to_errno(ret);
 	}
 
 	id = x86_match_cpu(intel_mid_cpu_ids);
Signature · 1 line
2.39.2
Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling

Quoted 11 lines · Ilpo Järvinen

intel_mid_pci_irq_enable() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

intel_mid_pci_irq_enable() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
merge bot Applied
#3 lore raw

[tip: x86/misc] x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling

In reply to Ilpo Järvinen
The following commit has been merged into the x86/misc branch of tip:

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     724852059e97c48557151b3aa4af424614819752
Gitweb:        https://git.kernel.org/tip/724852059e97c48557151b3aa4af424614819752
Author:        Ilpo Järvinen <[email protected]>
AuthorDate:    Mon, 27 May 2024 15:55:36 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 24 Jun 2024 19:19:55 +02:00

x86/pci/intel_mid_pci: Fix PCIBIOS_* return code handling

intel_mid_pci_irq_enable() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

intel_mid_pci_irq_enable() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 5b395e2be6c4 ("x86/platform/intel-mid: Make IRQ allocation a bit more flexible")
---
 arch/x86/pci/intel_mid_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/intel_mid_pci.c +2 -2
index 8edd622..722a33b 100644
@@ -233,9 +233,9 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 		return 0;
 
 	ret = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
-	if (ret < 0) {
+	if (ret) {
 		dev_warn(&dev->dev, "Failed to read interrupt line: %d\n", ret);
-		return ret;
+		return pcibios_err_to_errno(ret);
 	}
 
 	id = x86_match_cpu(intel_mid_cpu_ids);
#4 lore raw

PATCH 3/4 x86/pci/xen: Fix PCIBIOS_* return code handling

In reply to Ilpo Järvinen

xen_pcifront_enable_irq() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

xen_pcifront_enable_irq() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 3f2a230caf21 ("xen: handled remapped IRQs when enabling a pcifront PCI device.")
---
 arch/x86/pci/xen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/xen.c +2 -2
index 652cd53e77f6..0f2fe524f60d 100644
@@ -38,10 +38,10 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
 	u8 gsi;
 
 	rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
-	if (rc < 0) {
+	if (rc) {
 		dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n",
 			 rc);
-		return rc;
+		return pcibios_err_to_errno(rc);
 	}
 	/* In PV DomU the Xen PCI backend puts the PIRQ in the interrupt line.*/
 	pirq = gsi;
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 3/4
#5 lore raw

Re: [PATCH 3/4] x86/pci/xen: Fix PCIBIOS_* return code handling

Quoted 8 lines · Ilpo Järvinen

xen_pcifront_enable_irq() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

xen_pcifront_enable_irq() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Quoted 7 lines

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 3f2a230caf21 ("xen: handled remapped IRQs when enabling a pcifront PCI device.")

Juergen

merge bot Applied
#6 lore raw

[tip: x86/misc] x86/pci/xen: Fix PCIBIOS_* return code handling

In reply to Ilpo Järvinen
The following commit has been merged into the x86/misc branch of tip:

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     e9d7b435dfaec58432f4106aaa632bf39f52ce9f
Gitweb:        https://git.kernel.org/tip/e9d7b435dfaec58432f4106aaa632bf39f52ce9f
Author:        Ilpo Järvinen <[email protected]>
AuthorDate:    Mon, 27 May 2024 15:55:37 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 24 Jun 2024 19:21:25 +02:00

x86/pci/xen: Fix PCIBIOS_* return code handling

xen_pcifront_enable_irq() uses pci_read_config_byte() that returns PCIBIOS_* codes. The error handling, however, assumes the codes are normal errnos because it checks for < 0.

xen_pcifront_enable_irq() also returns the PCIBIOS_* code back to the caller but the function is used as the (*pcibios_enable_irq) function which should return normal errnos.

Convert the error check to plain non-zero check which works for PCIBIOS_* return codes and convert the PCIBIOS_* return code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 3f2a230caf21 ("xen: handled remapped IRQs when enabling a pcifront PCI device.")
---
 arch/x86/pci/xen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/pci/xen.c +2 -2
index 652cd53..0f2fe52 100644
@@ -38,10 +38,10 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
 	u8 gsi;
 
 	rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
-	if (rc < 0) {
+	if (rc) {
 		dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n",
 			 rc);
-		return rc;
+		return pcibios_err_to_errno(rc);
 	}
 	/* In PV DomU the Xen PCI backend puts the PIRQ in the interrupt line.*/
 	pirq = gsi;
#7 lore raw

PATCH 4/4 x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos

In reply to Ilpo Järvinen

iosf_mbi_pci_{read,write}_mdr() use pci_{read,write}_config_dword() that return PCIBIOS_* codes but functions also return -ENODEV which are not compatible error codes. As neither of the functions are related to PCI read/write functions, they should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 46184415368a ("arch: x86: New MailBox support driver for Intel SOC's")
---
 arch/x86/platform/intel/iosf_mbi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/platform/intel/iosf_mbi.c +2 -2
index fdd49d70b437..c81cea208c2c 100644
@@ -62,7 +62,7 @@ static int iosf_mbi_pci_read_mdr(u32 mcrx, u32 mcr, u32 *mdr)
 
 fail_read:
 	dev_err(&mbi_pdev->dev, "PCI config access failed with %d\n", result);
-	return result;
+	return pcibios_err_to_errno(result);
 }
 
 static int iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
@@ -91,7 +91,7 @@ static int iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
 
 fail_write:
 	dev_err(&mbi_pdev->dev, "PCI config access failed with %d\n", result);
-	return result;
+	return pcibios_err_to_errno(result);
 }
 
 int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
Signature · 1 line
2.39.2
merge bot Applied
#8 lore raw

[tip: x86/misc] x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos

The following commit has been merged into the x86/misc branch of tip:

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     7821fa101eab529521aa4b724bf708149d70820c
Gitweb:        https://git.kernel.org/tip/7821fa101eab529521aa4b724bf708149d70820c
Author:        Ilpo Järvinen <[email protected]>
AuthorDate:    Mon, 27 May 2024 15:55:38 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 24 Jun 2024 19:28:18 +02:00

x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos

iosf_mbi_pci_{read,write}_mdr() use pci_{read,write}_config_dword() that return PCIBIOS_* codes but functions also return -ENODEV which are not compatible error codes. As neither of the functions are related to PCI read/write functions, they should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.

Fixes 46184415368a ("arch: x86: New MailBox support driver for Intel SOC's")
---
 arch/x86/platform/intel/iosf_mbi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/platform/intel/iosf_mbi.c +2 -2
index fdd49d7..c81cea2 100644
@@ -62,7 +62,7 @@ static int iosf_mbi_pci_read_mdr(u32 mcrx, u32 mcr, u32 *mdr)
 
 fail_read:
 	dev_err(&mbi_pdev->dev, "PCI config access failed with %d\n", result);
-	return result;
+	return pcibios_err_to_errno(result);
 }
 
 static int iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
@@ -91,7 +91,7 @@ static int iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
 
 fail_write:
 	dev_err(&mbi_pdev->dev, "PCI config access failed with %d\n", result);
-	return result;
+	return pcibios_err_to_errno(result);
 }
 
 int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
maintainer
#9 lore raw
In reply to Ilpo Järvinen
Quoted 11 lines · Ilpo Järvinen

x86_of_pci_irq_enable() returns PCIBIOS_* code received from pci_read_config_byte() directly and also -EINVAL which are not compatible error types. x86_of_pci_irq_enable() is used as (*pcibios_enable_irq) function which should not return PCIBIOS_* codes.

Convert the PCIBIOS_* return code from pci_read_config_byte() into normal errno using pcibios_err_to_errno().

Fixes 96e0a0797eba ("x86: dtb: Add support for PCI devices backed by dtb nodes")

Any particular reason why this is CC:stable?

I'd say unless you're fixing a specific failure, this should go the normal route to 6.11...

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#10 lore raw
Quoted 9 lines · Borislav Petkov
Quoted 8 lines · Ilpo Järvinen

x86_of_pci_irq_enable() returns PCIBIOS_* code received from pci_read_config_byte() directly and also -EINVAL which are not compatible error types. x86_of_pci_irq_enable() is used as (*pcibios_enable_irq) function which should not return PCIBIOS_* codes.

Convert the PCIBIOS_* return code from pci_read_config_byte() into normal errno using pcibios_err_to_errno().

Quoted 8 lines
Quoted 3 lines
Fixes 96e0a0797eba ("x86: dtb: Add support for PCI devices backed by dtb nodes")

Any particular reason why this is CC:stable?

I'd say unless you're fixing a specific failure, this should go the normal route to 6.11...

It can go the normal route. And feel free to drop Cc stable too but I don't think it matters much as stable folks will autoselect things regardless of cc being there or not.

Signature · 1 line
 i.
merge bot Applied
#11 lore raw
In reply to Ilpo Järvinen
The following commit has been merged into the x86/misc branch of tip:

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     ec0b4c4d45cf7cf9a6c9626a494a89cb1ae7c645
Gitweb:        https://git.kernel.org/tip/ec0b4c4d45cf7cf9a6c9626a494a89cb1ae7c645
Author:        Ilpo Järvinen <[email protected]>
AuthorDate:    Mon, 27 May 2024 15:55:35 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 24 Jun 2024 19:11:31 +02:00

x86/of: Return consistent error type from x86_of_pci_irq_enable()

x86_of_pci_irq_enable() returns PCIBIOS_* code received from pci_read_config_byte() directly and also -EINVAL which are not compatible error types. x86_of_pci_irq_enable() is used as (*pcibios_enable_irq) function which should not return PCIBIOS_* codes.

Convert the PCIBIOS_* return code from pci_read_config_byte() into normal errno using pcibios_err_to_errno().

Fixes 96e0a0797eba ("x86: dtb: Add support for PCI devices backed by dtb nodes")
---
 arch/x86/kernel/devicetree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/devicetree.c +1 -1
index 8e3c53b..6428087 100644
@@ -83,7 +83,7 @@ static int x86_of_pci_irq_enable(struct pci_dev *dev)
 
 	ret = pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
 	if (ret)
-		return ret;
+		return pcibios_err_to_errno(ret);
 	if (!pin)
 		return 0;