]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dmaengine: ioatdma: Add intr_coalesce sysfs entry
authorUjjal Singh <ujjal.singh@intel.com>
Wed, 23 Aug 2017 00:31:18 +0000 (20:31 -0400)
committerVinod Koul <vinod.koul@intel.com>
Wed, 23 Aug 2017 16:02:21 +0000 (21:32 +0530)
We observed performance increase with DMA copy from memory
to MMIO by changing the interrupt coalescing value to 0.
The previous set value was projected on the C5xxx Xeon
platform and no longer holds true. Removing hard coded
value and providing a tune-able in sysfs in order to allow
user to tune this on a per channel basis. By default this
value will be set to 0.
Example of sysfs variable importing for interrupt coalescing
value from command line:
echo 5> /sys/devices/pci0000:00/0000:00:04.0/dma/dma0chan0/
quickdata/intr_coalesce

Reported-by: Nithin Sujir <nsujir@tintri.com>
Signed-off-by: Ujjal Singh <ujjal.singh@intel.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/ioat/dma.c
drivers/dma/ioat/dma.h
drivers/dma/ioat/sysfs.c

index a371b07a098114518ed3da4d9a164de1b8db1b58..f70cc74032eaa9fd1d8da9b4203839e25befd1f6 100644 (file)
@@ -644,9 +644,13 @@ static void __cleanup(struct ioatdma_chan *ioat_chan, dma_addr_t phys_complete)
                mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
        }
 
-       /* 5 microsecond delay per pending descriptor */
-       writew(min((5 * (active - i)), IOAT_INTRDELAY_MASK),
-              ioat_chan->ioat_dma->reg_base + IOAT_INTRDELAY_OFFSET);
+       /* microsecond delay by sysfs variable  per pending descriptor */
+       if (ioat_chan->intr_coalesce != ioat_chan->prev_intr_coalesce) {
+               writew(min((ioat_chan->intr_coalesce * (active - i)),
+                      IOAT_INTRDELAY_MASK),
+                      ioat_chan->ioat_dma->reg_base + IOAT_INTRDELAY_OFFSET);
+               ioat_chan->prev_intr_coalesce = ioat_chan->intr_coalesce;
+       }
 }
 
 static void ioat_cleanup(struct ioatdma_chan *ioat_chan)
index a9bc1a15b0d1642fd8214d38f04c72661c00a2bd..56200eefcf5eed792137a0ea2b9b4d5c295484ea 100644 (file)
@@ -142,11 +142,14 @@ struct ioatdma_chan {
        spinlock_t prep_lock;
        struct ioat_descs descs[2];
        int desc_chunks;
+       int intr_coalesce;
+       int prev_intr_coalesce;
 };
 
 struct ioat_sysfs_entry {
        struct attribute attr;
        ssize_t (*show)(struct dma_chan *, char *);
+       ssize_t (*store)(struct dma_chan *, const char *, size_t);
 };
 
 /**
index cb4a857ee21b79008bb4200f5e07a0c8cfbb4e64..3ac677f29e8f72680aff2053ad0194953d8340a9 100644 (file)
@@ -64,8 +64,24 @@ ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
        return entry->show(&ioat_chan->dma_chan, page);
 }
 
+static ssize_t
+ioat_attr_store(struct kobject *kobj, struct attribute *attr,
+const char *page, size_t count)
+{
+       struct ioat_sysfs_entry *entry;
+       struct ioatdma_chan *ioat_chan;
+
+       entry = container_of(attr, struct ioat_sysfs_entry, attr);
+       ioat_chan = container_of(kobj, struct ioatdma_chan, kobj);
+
+       if (!entry->store)
+               return -EIO;
+       return entry->store(&ioat_chan->dma_chan, page, count);
+}
+
 const struct sysfs_ops ioat_sysfs_ops = {
        .show   = ioat_attr_show,
+       .store  = ioat_attr_store,
 };
 
 void ioat_kobject_add(struct ioatdma_device *ioat_dma, struct kobj_type *type)
@@ -121,11 +137,37 @@ static ssize_t ring_active_show(struct dma_chan *c, char *page)
 }
 static struct ioat_sysfs_entry ring_active_attr = __ATTR_RO(ring_active);
 
+static ssize_t intr_coalesce_show(struct dma_chan *c, char *page)
+{
+       struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
+
+       return sprintf(page, "%d\n", ioat_chan->intr_coalesce);
+}
+
+static ssize_t intr_coalesce_store(struct dma_chan *c, const char *page,
+size_t count)
+{
+       int intr_coalesce = 0;
+       struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
+
+       if (sscanf(page, "%du", &intr_coalesce) != -1) {
+               if ((intr_coalesce < 0) ||
+                   (intr_coalesce > IOAT_INTRDELAY_MASK))
+                       return -EINVAL;
+               ioat_chan->intr_coalesce = intr_coalesce;
+       }
+
+       return count;
+}
+
+static struct ioat_sysfs_entry intr_coalesce_attr = __ATTR_RW(intr_coalesce);
+
 static struct attribute *ioat_attrs[] = {
        &ring_size_attr.attr,
        &ring_active_attr.attr,
        &ioat_cap_attr.attr,
        &ioat_version_attr.attr,
+       &intr_coalesce_attr.attr,
        NULL,
 };