Skip to contentSkip to conversation

vpci: reduce verboseness of BAR write warnings

PATCH In review Roger Pau Monne 4 participants 6 messages Feb 18, 2019 – Feb 19, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vpci: reduce verboseness of BAR write warnings

Avoid printing a warning message when writing to a BAR register with memory decoding enabled if the value written is the same as the current one.

No functional change.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Juergen Gross <[email protected]>

---
 xen/drivers/vpci/header.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
xen/drivers/vpci/header.c +13 -10
index 106e8af8b2..8583508ee1 100644
@@ -362,16 +362,6 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,
     uint8_t slot = PCI_SLOT(pdev->devfn), func = PCI_FUNC(pdev->devfn);
     bool hi = false;
 
-    if ( pci_conf_read16(pdev->seg, pdev->bus, slot, func, PCI_COMMAND) &
-         PCI_COMMAND_MEMORY )
-    {
-        gprintk(XENLOG_WARNING,
-                "%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n",
-                pdev->seg, pdev->bus, slot, func,
-                bar - pdev->vpci->header.bars);
-        return;
-    }
-
     if ( bar->type == VPCI_BAR_MEM64_HI )
     {
         ASSERT(reg > PCI_BASE_ADDRESS_0);
@@ -381,6 +371,19 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,
     else
         val &= PCI_BASE_ADDRESS_MEM_MASK;
 
+    if ( pci_conf_read16(pdev->seg, pdev->bus, slot, func, PCI_COMMAND) &
+         PCI_COMMAND_MEMORY )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
+            gprintk(XENLOG_WARNING,
+                    "%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n",
+                    pdev->seg, pdev->bus, slot, func,
+                    bar - pdev->vpci->header.bars + (hi ? 1 : 0));
+        return;
+    }
+
+
     /*
      * Update the cached address, so that when memory decoding is enabled
      * Xen can map the BAR into the guest p2m.
Signature · 7 lines
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 18.02.19 at 17:24, <[email protected]> wrote:

Avoid printing a warning message when writing to a BAR register with memory decoding enabled if the value written is the same as the current one.

No functional change.

with one cosmetic question:

xen/drivers/vpci/header.c static void bar_write(const struct pci_dev *pdev, unsigned int reg, · line 382

Quoted 13 lines
xen/drivers/vpci/header.c +9 -0
@@ -381,6 +371,19 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,
     else
         val &= PCI_BASE_ADDRESS_MEM_MASK;
 
+    if ( pci_conf_read16(pdev->seg, pdev->bus, slot, func, PCI_COMMAND) &
+         PCI_COMMAND_MEMORY )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
+            gprintk(XENLOG_WARNING,
+                    "%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n",
+                    pdev->seg, pdev->bus, slot, func,
+                    bar - pdev->vpci->header.bars + (hi ? 1 : 0));

Why the conditional operator? bool converts fine to an integer value of 0 or 1.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 16 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 18.02.19 at 17:24, <[email protected]> wrote:

Avoid printing a warning message when writing to a BAR register with memory decoding enabled if the value written is the same as the current one.

No functional change.

with one cosmetic question:

Quoted 4 lines
xen/drivers/vpci/header.c +0 -0
@@ -381,6 +371,19 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,
     else
         val &= PCI_BASE_ADDRESS_MEM_MASK;
 
Quoted 12 lines

xen/drivers/vpci/header.c static void bar_write(const struct pci_dev *pdev, unsigned int reg, · line 382

Quoted 9 lines
xen/drivers/vpci/header.c +9 -0
+    if ( pci_conf_read16(pdev->seg, pdev->bus, slot, func, PCI_COMMAND) &
+         PCI_COMMAND_MEMORY )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
+            gprintk(XENLOG_WARNING,
+                    "%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n",
+                    pdev->seg, pdev->bus, slot, func,
+                    bar - pdev->vpci->header.bars + (hi ? 1 : 0));

Why the conditional operator? bool converts fine to an integer value of 0 or 1.

Hm, I always forget about this. Would you be willing to fix this at commit if Juergen gives it his RAB?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 18.02.19 at 17:53, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.02.19 at 17:24, <[email protected]> wrote:
xen/drivers/vpci/header.c +0 -0
@@ -381,6 +371,19 @@ static void bar_write(const struct pci_dev *pdev, unsigned int reg,
     else
         val &= PCI_BASE_ADDRESS_MEM_MASK;
 
Quoted 12 lines

xen/drivers/vpci/header.c static void bar_write(const struct pci_dev *pdev, unsigned int reg, · line 382

Quoted 9 lines
xen/drivers/vpci/header.c +9 -0
+    if ( pci_conf_read16(pdev->seg, pdev->bus, slot, func, PCI_COMMAND) &
+         PCI_COMMAND_MEMORY )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
+            gprintk(XENLOG_WARNING,
+                    "%04x:%02x:%02x.%u: ignored BAR %lu write with memory decoding enabled\n",
+                    pdev->seg, pdev->bus, slot, func,
+                    bar - pdev->vpci->header.bars + (hi ? 1 : 0));

Why the conditional operator? bool converts fine to an integer value of 0 or 1.

Quoted 2 lines

Hm, I always forget about this. Would you be willing to fix this at commit if Juergen gives it his RAB?

Sure.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

Avoid printing a warning message when writing to a BAR register with memory decoding enabled if the value written is the same as the current one.

No functional change.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 11 lines · Juergen Gross
Quoted 7 lines · Roger Pau Monne

Avoid printing a warning message when writing to a BAR register with memory decoding enabled if the value written is the same as the current one.

No functional change.

Fixed up per Jan's request and applied.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel