Skip to contentSkip to conversation

PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

PATCH Applied Josef Johansson 3 participants 6 messages Feb 14, 2022 – Aug 26, 2022 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

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()")

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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
Quoted 39 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

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()")

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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);
  		}
 
--
Quoted 2 lines

2.31.1

Hi,

I'm sending a ping such that this patch will not get forgotten in the oblivion.

Regards
Josef

Reviewed-by
#2 lore raw
Quoted 23 lines · Josef Johansson
Quoted 22 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc() 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()")

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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

Quoted 13 lines

drivers/pci/msi/msi.c static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base, · line 532

Quoted 13 lines
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);
  		}
 

Bjorn, please take it?

Jason

#3 lore raw
Quoted 40 lines · Jason Gunthorpe
Quoted 23 lines · Josef Johansson
Quoted 22 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc() 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()")

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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

Quoted 13 lines

drivers/pci/msi/msi.c static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base, · line 532

Quoted 13 lines
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);
  		}
 
Quoted 1 line

Bjorn, please take it?

Thanks for the ping. Since 71020a3c0dff4 is by Thomas, and he merged that along with a whole series of MSI work, I think I probably expected him to take care of this.

This looks like a simple typo, so I think the commit log should be reworded along that line, e.g., something like:

71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") inadvertently reversed the sense of "msi_attrib.can_mask" in one use:

- if (entry->pci.msi_attrib.can_mask) {
- addr = pci_msix_desc_addr(entry);
- entry->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
+ if (!desc.pci.msi_attrib.can_mask) {
+ addr = pci_msix_desc_addr(&desc);
+ desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);

Restore the original test.

Thomas, do you want to take this? I'm happy to merge it, but would like your reviewed-by or ack first.

Bjorn

#4 lore raw
Quoted 60 lines · Bjorn Helgaas
Quoted 40 lines · Jason Gunthorpe
Quoted 23 lines · Josef Johansson
Quoted 22 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc() 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()")

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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

Quoted 13 lines

drivers/pci/msi/msi.c static int msix_setup_msi_descs(struct pci_dev *dev, void __iomem *base, · line 532

Quoted 13 lines
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);
  		}
 
Quoted 1 line

Bjorn, please take it?

Thanks for the ping. Since 71020a3c0dff4 is by Thomas, and he merged that along with a whole series of MSI work, I think I probably expected him to take care of this.

This looks like a simple typo, so I think the commit log should be reworded along that line, e.g., something like:

71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") inadvertently reversed the sense of "msi_attrib.can_mask" in one use:

- if (entry->pci.msi_attrib.can_mask) {
- addr = pci_msix_desc_addr(entry);
- entry->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
+ if (!desc.pci.msi_attrib.can_mask) {
+ addr = pci_msix_desc_addr(&desc);
+ desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);

Quoted 4 lines

Restore the original test.

Thomas, do you want to take this? I'm happy to merge it, but would like your reviewed-by or ack first.

At this point I think you should take it Bjorn..

Jason

#5 lore raw
In reply to Josef Johansson
Quoted 11 lines · Josef Johansson

From: Josef Johansson <[email protected]>

PCI/MSI: Correct use of can_mask in msi_add_msi_desc()

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()")

Applied to pci/misc for v6.1 with commit log below, thanks!

PCI/MSI: Correct 'can_mask' test in msi_add_msi_desc()

71020a3c0dff4 ("PCI/MSI: Use msi_add_msi_desc()") inadvertently reversed the sense of "msi_attrib.can_mask" in one use:

- if (entry->pci.msi_attrib.can_mask) {
- addr = pci_msix_desc_addr(entry);
- entry->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
+ if (!desc.pci.msi_attrib.can_mask) {
+ addr = pci_msix_desc_addr(&desc);
+ desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);

Restore the original test.

Quoted 30 lines

---
v2: Changing subject line to fit earlier commits.

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, and it did not break anything correcting the logic.

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