]> git.itanic.dy.fi Git - linux-stable/commitdiff
s390/pci: extract software counters from fmb
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Fri, 10 Apr 2015 12:33:08 +0000 (14:33 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 18 Apr 2016 12:49:30 +0000 (08:49 -0400)
[ Upstream commit 6001018ae8c659e624351d2e73b1272bacd68d6a ]

The software counters are not a part of the function measurement
block. Also we do not check for zdev->fmb != NULL when using these
counters (function measurement can be toggled at runtime). Just move
the software counters to struct zpci_dev.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c
arch/s390/pci/pci_debug.c
arch/s390/pci/pci_dma.c

index c030900320e0baf62a3e9eb0b879c300620ab4ae..7672152a93acd5c986f6a7c555dd2e164e6e23bd 100644 (file)
@@ -44,10 +44,6 @@ struct zpci_fmb {
        u64 rpcit_ops;
        u64 dma_rbytes;
        u64 dma_wbytes;
-       /* software counters */
-       atomic64_t allocated_pages;
-       atomic64_t mapped_pages;
-       atomic64_t unmapped_pages;
 } __packed __aligned(16);
 
 #define ZPCI_MSI_VEC_BITS      11
@@ -114,6 +110,10 @@ struct zpci_dev {
        /* Function measurement block */
        struct zpci_fmb *fmb;
        u16             fmb_update;     /* update interval */
+       /* software counters */
+       atomic64_t allocated_pages;
+       atomic64_t mapped_pages;
+       atomic64_t unmapped_pages;
 
        enum pci_bus_speed max_bus_speed;
 
index 2fa7b14b9c08dee648afcdbe7ae75744ba73cb22..1902ce7cb71d7c11b4df8264b8a88f863e9ab202 100644 (file)
@@ -190,6 +190,11 @@ int zpci_fmb_enable_device(struct zpci_dev *zdev)
                return -ENOMEM;
        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);
+
        args.fmb_addr = virt_to_phys(zdev->fmb);
        return mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args);
 }
index eec598c5939f9b173e36801122c30b13d3bf5e2a..8eeccd7d7f793fa7c696acd45ec7e0644b4275cb 100644 (file)
@@ -31,12 +31,25 @@ static char *pci_perf_names[] = {
        "Refresh operations",
        "DMA read bytes",
        "DMA write bytes",
-       /* software counters */
+};
+
+static char *pci_sw_names[] = {
        "Allocated pages",
        "Mapped pages",
        "Unmapped pages",
 };
 
+static void pci_sw_counter_show(struct seq_file *m)
+{
+       struct zpci_dev *zdev = m->private;
+       atomic64_t *counter = &zdev->allocated_pages;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(pci_sw_names); i++, counter++)
+               seq_printf(m, "%26s:\t%llu\n", pci_sw_names[i],
+                          atomic64_read(counter));
+}
+
 static int pci_perf_show(struct seq_file *m, void *v)
 {
        struct zpci_dev *zdev = m->private;
@@ -63,12 +76,8 @@ static int pci_perf_show(struct seq_file *m, void *v)
                for (i = 4; i < 6; i++)
                        seq_printf(m, "%26s:\t%llu\n",
                                   pci_perf_names[i], *(stat + i));
-       /* software counters */
-       for (i = 6; i < ARRAY_SIZE(pci_perf_names); i++)
-               seq_printf(m, "%26s:\t%llu\n",
-                          pci_perf_names[i],
-                          atomic64_read((atomic64_t *) (stat + i)));
 
+       pci_sw_counter_show(m);
        return 0;
 }
 
index 4cbb29a4d6152238c771d5f1936b9d9d15b94e68..6fd8d583613807904eac33ab9ce5030709545f73 100644 (file)
@@ -300,7 +300,7 @@ static dma_addr_t s390_dma_map_pages(struct device *dev, struct page *page,
                flags |= ZPCI_TABLE_PROTECTED;
 
        if (!dma_update_trans(zdev, pa, dma_addr, size, flags)) {
-               atomic64_add(nr_pages, &zdev->fmb->mapped_pages);
+               atomic64_add(nr_pages, &zdev->mapped_pages);
                return dma_addr + (offset & ~PAGE_MASK);
        }
 
@@ -328,7 +328,7 @@ static void s390_dma_unmap_pages(struct device *dev, dma_addr_t dma_addr,
                zpci_err_hex(&dma_addr, sizeof(dma_addr));
        }
 
-       atomic64_add(npages, &zdev->fmb->unmapped_pages);
+       atomic64_add(npages, &zdev->unmapped_pages);
        iommu_page_index = (dma_addr - zdev->start_dma) >> PAGE_SHIFT;
        dma_free_iommu(zdev, iommu_page_index, npages);
 }
@@ -357,7 +357,7 @@ static void *s390_dma_alloc(struct device *dev, size_t size,
                return NULL;
        }
 
-       atomic64_add(size / PAGE_SIZE, &zdev->fmb->allocated_pages);
+       atomic64_add(size / PAGE_SIZE, &zdev->allocated_pages);
        if (dma_handle)
                *dma_handle = map;
        return (void *) pa;
@@ -370,7 +370,7 @@ static void s390_dma_free(struct device *dev, size_t size,
        struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
 
        size = PAGE_ALIGN(size);
-       atomic64_sub(size / PAGE_SIZE, &zdev->fmb->allocated_pages);
+       atomic64_sub(size / PAGE_SIZE, &zdev->allocated_pages);
        s390_dma_unmap_pages(dev, dma_handle, size, DMA_BIDIRECTIONAL, NULL);
        free_pages((unsigned long) pa, get_order(size));
 }