Skip to contentSkip to conversation

xen-pciback: Use pci_enable_msix_range() instead of pci_enable_msix()

PATCH Superseded Alexander Gordeev 3 participants 14 messages Feb 19, 2014 – Feb 25, 2014

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

PATCH 1/1 xen-pciback: Use pci_enable_msix_range() instead of pci_enable_msix()

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() and pci_enable_msix_range() interfaces.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/xen-pciback/pciback_ops.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/xen/xen-pciback/pciback_ops.c +10 -6
index 64eb0cd..f5b4c3e 100644
@@ -213,9 +213,15 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
 		entries[i].vector = op->msix_entries[i].vector;
 	}
 
-	result = pci_enable_msix(dev, entries, op->value);
+	result = pci_enable_msix_range(dev, entries, op->value, op->value);
+	if (result < op->value) {
+		if (result > 0)
+			pci_disable_msix(dev);
 
-	if (result == 0) {
+		pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",
+				    pci_name(dev), pdev->xdev->otherend_id,
+				    result);
+	} else {
 		for (i = 0; i < op->value; i++) {
 			op->msix_entries[i].entry = entries[i].entry;
 			if (entries[i].vector)
@@ -227,10 +233,8 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
 						pci_name(dev), i,
 						op->msix_entries[i].vector);
 		}
-	} else
-		pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",
-				    pci_name(dev), pdev->xdev->otherend_id,
-				    result);
+	}
+
 	kfree(entries);
 
 	op->value = result;
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 20 lines · Alexander Gordeev

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() and pci_enable_msix_range() interfaces.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
  drivers/xen/xen-pciback/pciback_ops.c |   16 ++++++++++------
  1 files changed, 10 insertions(+), 6 deletions(-)
drivers/xen/xen-pciback/pciback_ops.c +0 -0
index 64eb0cd..f5b4c3e 100644

drivers/xen/xen-pciback/pciback_ops.c int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev, · line 217

Quoted 6 lines
drivers/xen/xen-pciback/pciback_ops.c +2 -1
@@ -213,9 +213,15 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
  		entries[i].vector = op->msix_entries[i].vector;
  	}
 
-	result = pci_enable_msix(dev, entries, op->value);
+	result = pci_enable_msix_range(dev, entries, op->value, op->value);
+	if (result < op->value) {

I think it would be better to have 'if (result != op->value)', in case op->value is negative (which presumably it should never be).

-boris

Quoted 24 lines
drivers/xen/xen-pciback/pciback_ops.c +8 -5
+		if (result > 0)
+			pci_disable_msix(dev);
 
-	if (result == 0) {
+		pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",
+				    pci_name(dev), pdev->xdev->otherend_id,
+				    result);
+	} else {
  		for (i = 0; i < op->value; i++) {
  			op->msix_entries[i].entry = entries[i].entry;
  			if (entries[i].vector)
@@ -227,10 +233,8 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
  						pci_name(dev), i,
  						op->msix_entries[i].vector);
  		}
-	} else
-		pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n",
-				    pci_name(dev), pdev->xdev->otherend_id,
-				    result);
+	}
+
  	kfree(entries);
 
  	op->value = result;
#2 lore raw
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines · Alexander Gordeev

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() and pci_enable_msix_range() interfaces.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
  drivers/xen/xen-pciback/pciback_ops.c |   16 ++++++++++------
  1 files changed, 10 insertions(+), 6 deletions(-)
Quoted 14 lines

drivers/xen/xen-pciback/pciback_ops.c int xen_pcibk_enable_msix(struct · line 218

Quoted 11 lines
drivers/xen/xen-pciback/pciback_ops.c +2 -0
index 64eb0cd..f5b4c3e 100644
@@ -213,9 +213,15 @@ int xen_pcibk_enable_msix(struct 
 xen_pcibk_device *pdev,
          entries[i].vector = op->msix_entries[i].vector;
      }
  -    result = pci_enable_msix(dev, entries, op->value);
+    result = pci_enable_msix_range(dev, entries, op->value, op->value);
+    if (result < op->value) {

I think it would be better to have 'if (result != op->value)', in case op->value is negative (which presumably it should never be).

Better yet, at the top of the routine we check 'if (op->value > SH_INFO_MAX_VEC)'. If you add '|| op->value < 0' we'd be all set.

-boris

Quoted 31 lines

-boris

Quoted 25 lines
drivers/xen/xen-pciback/pciback_ops.c +8 -4
+        if (result > 0)
+            pci_disable_msix(dev);
  -    if (result == 0) {
+        pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: 
 err %d!\n",
+                    pci_name(dev), pdev->xdev->otherend_id,
+                    result);
+    } else {
          for (i = 0; i < op->value; i++) {
              op->msix_entries[i].entry = entries[i].entry;
              if (entries[i].vector)
@@ -227,10 +233,8 @@ int xen_pcibk_enable_msix(struct 
 xen_pcibk_device *pdev,
                          pci_name(dev), i,
                          op->msix_entries[i].vector);
          }
-    } else
-        pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: 
 err %d!\n",
-                    pci_name(dev), pdev->xdev->otherend_id,
-                    result);
+    }
+
      kfree(entries);
        op->value = result;
#3 lore raw
Quoted 18 lines · Boris Ostrovsky
Quoted 8 lines
Quoted 8 lines
drivers/xen/xen-pciback/pciback_ops.c +0 -0
index 64eb0cd..f5b4c3e 100644
@@ -213,9 +213,15 @@ int xen_pcibk_enable_msix(struct
 xen_pcibk_device *pdev,
         entries[i].vector = op->msix_entries[i].vector;
Quoted 8 lines

drivers/xen/xen-pciback/pciback_ops.c int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev, · line 217

Quoted 4 lines
drivers/xen/xen-pciback/pciback_ops.c +2 -0
     }
 -    result = pci_enable_msix(dev, entries, op->value);
+    result = pci_enable_msix_range(dev, entries, op->value, op->value);
+    if (result < op->value) {

I think it would be better to have 'if (result != op->value)', in case op->value is negative (which presumably it should never be).

Quoted 2 lines

Better yet, at the top of the routine we check 'if (op->value > SH_INFO_MAX_VEC)'. If you add '|| op->value < 0' we'd be all set.

xen_pci_op::value is uint32_t

Quoted 1 line

-boris

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
Reviewed-by
#4 lore raw
Quoted 17 lines · Alexander Gordeev
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines

drivers/xen/xen-pciback/pciback_ops.c int xen_pcibk_enable_msix(struct · line 218

Quoted 12 lines
drivers/xen/xen-pciback/pciback_ops.c +2 -0
index 64eb0cd..f5b4c3e 100644
@@ -213,9 +213,15 @@ int xen_pcibk_enable_msix(struct
 xen_pcibk_device *pdev,
          entries[i].vector = op->msix_entries[i].vector;
      }
  -    result = pci_enable_msix(dev, entries, op->value);
+    result = pci_enable_msix_range(dev, entries, op->value, op->value);
+    if (result < op->value) {

I think it would be better to have 'if (result != op->value)', in case op->value is negative (which presumably it should never be).

Quoted 3 lines
Quoted 2 lines

Better yet, at the top of the routine we check 'if (op->value > SH_INFO_MAX_VEC)'. If you add '|| op->value < 0' we'd be all set.

xen_pci_op::value is uint32_t

Ah, OK --- then 'if (op->value > SH_INFO_MAX_VEC)' alone will catch this (hopefully its' not in billions).

#5 lore raw

On Wed, Feb 19, 2014 at 11:24:29AM -0500, Boris Ostrovsky wrote:

Hi Boris et al,

Based on recently accepted to the mainline pci_enable_msix_exact() function, I am sending an updated version of the patch.

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
#6 lore raw

PATCH v2 1/1 xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/xen-pciback/pciback_ops.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/xen/xen-pciback/pciback_ops.c +1 -2
index 64eb0cd..929dd46 100644
@@ -213,8 +213,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
 		entries[i].vector = op->msix_entries[i].vector;
 	}
 
-	result = pci_enable_msix(dev, entries, op->value);
-
+	result = pci_enable_msix_exact(dev, entries, op->value);
 	if (result == 0) {
 		for (i = 0; i < op->value; i++) {
 			op->msix_entries[i].entry = entries[i].entry;
Signature · 6 lines
1.7.7.6

-- 
Regards,
Alexander Gordeev
[email protected]
#7 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

Hi Boris et al,

Based on recently accepted to the mainline pci_enable_msix_exact() function, I am sending a updated version of the patch. Please, let me know if it does not work for you and you need and incremental update from the previous version.

Thanks!

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]
Reviewed-by on v2 1/1
#8 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

In reply to Alexander Gordeev
Quoted 7 lines · Alexander Gordeev

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces.

Quoted 5 lines
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 18 lines
---
  drivers/xen/xen-pciback/pciback_ops.c |    3 +--
  1 files changed, 1 insertions(+), 2 deletions(-)
drivers/xen/xen-pciback/pciback_ops.c +1 -2
index 64eb0cd..929dd46 100644
@@ -213,8 +213,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
  		entries[i].vector = op->msix_entries[i].vector;
  	}
 
-	result = pci_enable_msix(dev, entries, op->value);
-
+	result = pci_enable_msix_exact(dev, entries, op->value);
  	if (result == 0) {
  		for (i = 0; i < op->value; i++) {
  			op->msix_entries[i].entry = entries[i].entry;
#10 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

Quoted 5 lines · Alexander Gordeev
Quoted 1 line · Boris Ostrovsky

Thank you, Boris!
Whom should I ask this patch for inclusion?

This should go into the Xen tree. Konrad is usually the one putting together pull requests for Linus.

I don't think this needs to go in right away so presumably this will be queued for the next merge window (unless Konrad has other things for next RCs and decides to tack this onto other patches).

-boris

#11 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

Quoted 7 lines · Boris Ostrovsky
Quoted 5 lines · Alexander Gordeev
Quoted 1 line · Boris Ostrovsky

Thank you, Boris!
Whom should I ask this patch for inclusion?

Quoted 6 lines

This should go into the Xen tree. Konrad is usually the one putting together pull requests for Linus.

I don't think this needs to go in right away so presumably this will be queued for the next merge window (unless Konrad has other things for next RCs and decides to tack this onto other patches).

I was thinking for next one. Will have a branch ready on Monday.

Quoted 3 lines

-boris

#12 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

In reply to Alexander Gordeev
Quoted 6 lines · Alexander Gordeev

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces.

What is this based on? Thanks.

Quoted 31 lines
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc David Vrabel <[email protected]>
---
 drivers/xen/xen-pciback/pciback_ops.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/xen/xen-pciback/pciback_ops.c +1 -2
index 64eb0cd..929dd46 100644
@@ -213,8 +213,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
 		entries[i].vector = op->msix_entries[i].vector;
 	}
 
-	result = pci_enable_msix(dev, entries, op->value);
-
+	result = pci_enable_msix_exact(dev, entries, op->value);
 	if (result == 0) {
 		for (i = 0; i < op->value; i++) {
 			op->msix_entries[i].entry = entries[i].entry;
Signature · 6 lines
1.7.7.6

-- 
Regards,
Alexander Gordeev
[email protected]
#13 lore raw

Re: [PATCH v2] xen-pciback: Use pci_enable_msix_exact() instead of pci_enable_msix()

Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Alexander Gordeev

As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces.

What is this based on? Thanks.

3.14-rc4

Signature · 3 lines
Regards,
Alexander Gordeev
[email protected]