Skip to contentSkip to conversation

PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

PATCH In review Josef Johansson 3 participants 5 messages Jan 22, 2022 – Feb 11, 2022 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

From: Josef Johansson <[email protected]>

PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

Commit 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") modifies the logic of checking msi_attrib.can_mask, without any reason.

This commits restores that logic.

Fixes 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()")

---
Trying to fix a NULL BUG in the NVMe MSIX implementation I stumbled upon this code, which ironically was what my last MSI patch resulted into.

I don't see any reason why this logic was change, nor do I have the possibility to see if anything works with my patch or without, since the kernel crashes in other places.

As such this is still untested, but as far as I can tell it should restore functionality.

Re-sending since it was rejected by [email protected] due to HTML contents. Sorry about that.

CC xen-devel since it very much relates to Xen kernel (via pci_msi_ignore_mask).
---

drivers/pci/msi/msi.c +1 -1
index c19c7ca58186..146e7b9a01cc 100644
@@ -526,7 +526,7 @@ static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base,
 		desc.pci.msi_attrib.can_mask = !pci_msi_ignore_mask &&
 					       !desc.pci.msi_attrib.is_virtual;
 
-		if (!desc.pci.msi_attrib.can_mask) {
+		if (desc.pci.msi_attrib.can_mask) {
 			addr = pci_msix_desc_addr(&desc);
 			desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
 		}

--
2.31.1

#1 lore raw

[+cc Jason, since you reviewed the original commit]

Quoted 3 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

Please match the form and style of previous subject lines (in particular, omit "msix_setup_msi_descs:").

Quoted 4 lines

Commit 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") modifies the logic of checking msi_attrib.can_mask, without any reason.

This commits restores that logic.

I agree, this looks like a typo in 71020a3c0dff4, but I might be missing something, so Thomas should take a look, and I added Jason since he reviewed it.

Since it was merged by Thomas, I'll let him take care of this, too. If it *is* a typo, the fix looks like v5.17 material.

Before: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/msi/msi.c?id=71020a3c0dff4%5E#n522
After:  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/msi/msi.c?id=71020a3c0dff4#n520
Quoted 37 lines
Fixes 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()")

---
Trying to fix a NULL BUG in the NVMe MSIX implementation I stumbled upon this code, which ironically was what my last MSI patch resulted into.

I don't see any reason why this logic was change, nor do I have the possibility to see if anything works with my patch or without, since the kernel crashes in other places.

As such this is still untested, but as far as I can tell it should restore functionality.

Re-sending since it was rejected by [email protected] due to HTML contents. Sorry about that.

CC xen-devel since it very much relates to Xen kernel (via pci_msi_ignore_mask).
---

drivers/pci/msi/msi.c +1 -2
index c19c7ca58186..146e7b9a01cc 100644
@@ -526,7 +526,7 @@ static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base,
 		desc.pci.msi_attrib.can_mask = !pci_msi_ignore_mask &&
 					       !desc.pci.msi_attrib.is_virtual;
 
-		if (!desc.pci.msi_attrib.can_mask) {
+		if (desc.pci.msi_attrib.can_mask) {
 			addr = pci_msix_desc_addr(&desc);
 			desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
 		}
 
--

2.31.1

#2 lore raw
Quoted 8 lines · Bjorn Helgaas

[+cc Jason, since you reviewed the original commit]

Quoted 3 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

Please match the form and style of previous subject lines (in particular, omit "msix_setup_msi_descs:").

Would this subject suffice?
PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

Quoted 8 lines
Quoted 4 lines

Commit 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") modifies the logic of checking msi_attrib.can_mask, without any reason.

This commits restores that logic.

I agree, this looks like a typo in 71020a3c0dff4, but I might be missing something, so Thomas should take a look, and I added Jason since he reviewed it.

Quoted 5 lines

Since it was merged by Thomas, I'll let him take care of this, too. If it *is* a typo, the fix looks like v5.17 material.

Before: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/msi/msi.c?id=71020a3c0dff4%5E#n522
After:  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/msi/msi.c?id=71020a3c0dff4#n520

It should be noted that I successfully ran the kernel with this patch.

Quoted 37 lines
Quoted 37 lines
Fixes 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()")

---
Trying to fix a NULL BUG in the NVMe MSIX implementation I stumbled upon this code, which ironically was what my last MSI patch resulted into.

I don't see any reason why this logic was change, nor do I have the possibility to see if anything works with my patch or without, since the kernel crashes in other places.

As such this is still untested, but as far as I can tell it should restore functionality.

Re-sending since it was rejected by [email protected] due to HTML contents. Sorry about that.

CC xen-devel since it very much relates to Xen kernel (via pci_msi_ignore_mask).
---

drivers/pci/msi/msi.c +1 -2
index c19c7ca58186..146e7b9a01cc 100644
@@ -526,7 +526,7 @@ static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base,
 		desc.pci.msi_attrib.can_mask = !pci_msi_ignore_mask &&
 					       !desc.pci.msi_attrib.is_virtual;
 
-		if (!desc.pci.msi_attrib.can_mask) {
+		if (desc.pci.msi_attrib.can_mask) {
 			addr = pci_msix_desc_addr(&desc);
 			desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
 		}
 
--

2.31.1

#3 lore raw
Quoted 9 lines · Josef Johansson
Quoted 6 lines · Bjorn Helgaas
Quoted 3 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: msix_setup_msi_descs: Restore logic for msi_attrib.can_mask

Please match the form and style of previous subject lines (in particular, omit "msix_setup_msi_descs:").

Would this subject suffice?
PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

Looks good to me!

Bjorn

#4 lore raw
In reply to Bjorn Helgaas
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines

Commit 71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") modifies the logic of checking msi_attrib.can_mask, without any reason.

This commits restores that logic.

I agree, this looks like a typo in 71020a3c0dff4, but I might be missing something, so Thomas should take a look, and I added Jason since he reviewed it.

I concur

Jason