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.

Signed-off-by: Roger Pau Monné <roger....@citrix.com>
---
Cc: Andrew Cooper <andrew.coop...@citrix.com>
Cc: George Dunlap <george.dun...@eu.citrix.com>
Cc: Ian Jackson <ian.jack...@eu.citrix.com>
Cc: Jan Beulich <jbeul...@suse.com>
Cc: Julien Grall <julien.gr...@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.w...@oracle.com>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Tim Deegan <t...@xen.org>
Cc: Wei Liu <wei.l...@citrix.com>
Cc: Juergen Gross <jgr...@suse.com>
---
 xen/drivers/vpci/header.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 106e8af8b2..8583508ee1 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -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.
-- 
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to