Skip to contentSkip to conversation

pci: add config space access traces

PATCH Superseded Alexey Kardashevskiy 2 participants 2 messages Aug 16, 2013 – Aug 20, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: add config space access traces

This adds pci_cfg_read and pci_cfg_write traces for config spaces accesses.

---
 hw/pci/pci_host.c | 9 ++++++++-
 trace-events      | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)
hw/pci/pci_host.c +8 -1
index 7dd9b25..f1ba5ae 100644
@@ -20,6 +20,7 @@
 
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
+#include "trace.h"
 
 /* debug PCI */
 //#define DEBUG_PCI
@@ -51,14 +52,20 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
                                   uint32_t limit, uint32_t val, uint32_t len)
 {
     assert(len <= 4);
+    trace_pci_cfg_write(pci_dev->name, addr, val);
     pci_dev->config_write(pci_dev, addr, val, MIN(len, limit - addr));
 }
 
 uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
                                      uint32_t limit, uint32_t len)
 {
+    uint32_t ret;
+
     assert(len <= 4);
-    return pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr));
+    ret = pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr));
+    trace_pci_cfg_read(pci_dev->name, addr, ret);
+
+    return ret;
 }
 
 void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len)
trace-events +4 -0
index 3856b5c..1f0ebf1 100644
@@ -1176,3 +1176,7 @@ object_class_dynamic_cast_assert(const char *type, const char *target, const cha
 # hw/xen/xen_pvdevice.c
 xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space (address %"PRIx64")"
 xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space (address %"PRIx64")"
+
+# hw/pci/pci_host.c
+pci_cfg_read(const char *dev, unsigned offs, unsigned val) "%s @0x%x 0x%x"
+pci_cfg_write(const char *dev, unsigned offs, unsigned val) "%s @0x%x 0x%x"
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 3 lines · Alexey Kardashevskiy

This adds pci_cfg_read and pci_cfg_write traces for config spaces accesses.

Looks good to me.
I think it would be useful to add device and function numbers in trace.
Could you incorporate this please?

Quoted 54 lines
---
 hw/pci/pci_host.c | 9 ++++++++-
 trace-events      | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)
hw/pci/pci_host.c +8 -1
index 7dd9b25..f1ba5ae 100644
@@ -20,6 +20,7 @@
 
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
+#include "trace.h"
 
 /* debug PCI */
 //#define DEBUG_PCI
@@ -51,14 +52,20 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
                                   uint32_t limit, uint32_t val, uint32_t len)
 {
     assert(len <= 4);
+    trace_pci_cfg_write(pci_dev->name, addr, val);
     pci_dev->config_write(pci_dev, addr, val, MIN(len, limit - addr));
 }
 
 uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
                                      uint32_t limit, uint32_t len)
 {
+    uint32_t ret;
+
     assert(len <= 4);
-    return pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr));
+    ret = pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr));
+    trace_pci_cfg_read(pci_dev->name, addr, ret);
+
+    return ret;
 }
 
 void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len)
trace-events +4 -0
index 3856b5c..1f0ebf1 100644
@@ -1176,3 +1176,7 @@ object_class_dynamic_cast_assert(const char *type, const char *target, const cha
 # hw/xen/xen_pvdevice.c
 xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space (address %"PRIx64")"
 xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space (address %"PRIx64")"
+
+# hw/pci/pci_host.c
+pci_cfg_read(const char *dev, unsigned offs, unsigned val) "%s @0x%x 0x%x"
+pci_cfg_write(const char *dev, unsigned offs, unsigned val) "%s @0x%x 0x%x"
Signature · 1 line
1.8.3.2