s390/pci: Fix reset of IOMMU software counters
authorNiklas Schnelle <schnelle@linux.ibm.com>
Wed, 4 Oct 2023 08:56:12 +0000 (10:56 +0200)
committerJoerg Roedel <jroedel@suse.de>
Thu, 5 Oct 2023 11:00:57 +0000 (13:00 +0200)
Together with enabling the Function Measurement Block
zpci_fmb_enable_device() also resets the software counters. This allows
to use "echo 0 > /sys/kernel/debug/pci/<dev>/statistics" followed by
echo "1 > /../statistics" to reset all counters. In commit c76c067e488c
("s390/pci: Use dma-iommu layer") this use of the now obsolete counters
in struct zpci_device was missed as was their removal. Fix this by
resetting the new counters and removing the old ones.

Fixes: c76c067e488c ("s390/pci: Use dma-iommu layer")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/20231004-dma_iommu_fix-v1-1-129777cd8232@linux.ibm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c

index 3f74f1cf37dfda0ef2a3c1efbbdbd222c2485366..e91cd6bbc330d960996eb0b0f9148e0a818ba3ef 100644 (file)
@@ -173,10 +173,6 @@ struct zpci_dev {
        struct zpci_fmb *fmb;
        u16             fmb_update;     /* update interval */
        u16             fmb_length;
-       /* software counters */
-       atomic64_t allocated_pages;
-       atomic64_t mapped_pages;
-       atomic64_t unmapped_pages;
 
        u8              version;
        enum pci_bus_speed max_bus_speed;
index 563cb72d9ed0f4a5cc9ef4fcd03e2fc8f4555316..63fd9e1d9f22c57f5a3f72177aea0752d93dfa58 100644 (file)
@@ -157,6 +157,7 @@ int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas)
 int zpci_fmb_enable_device(struct zpci_dev *zdev)
 {
        u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE);
+       struct zpci_iommu_ctrs *ctrs;
        struct zpci_fib fib = {0};
        u8 cc, status;
 
@@ -169,9 +170,15 @@ int zpci_fmb_enable_device(struct zpci_dev *zdev)
        WARN_ON((u64) zdev->fmb & 0xf);
 
        /* reset software counters */
-       atomic64_set(&zdev->allocated_pages, 0);
-       atomic64_set(&zdev->mapped_pages, 0);
-       atomic64_set(&zdev->unmapped_pages, 0);
+       ctrs = zpci_get_iommu_ctrs(zdev);
+       if (ctrs) {
+               atomic64_set(&ctrs->mapped_pages, 0);
+               atomic64_set(&ctrs->unmapped_pages, 0);
+               atomic64_set(&ctrs->global_rpcits, 0);
+               atomic64_set(&ctrs->sync_map_rpcits, 0);
+               atomic64_set(&ctrs->sync_rpcits, 0);
+       }
+
 
        fib.fmb_addr = virt_to_phys(zdev->fmb);
        fib.gd = zdev->gisa;