aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2015-08-11 11:48:38 -0400
committerVinod Koul <vinod.koul@intel.com>2015-08-17 04:07:30 -0400
commit80b1973659949fbdcbfe9e086e2370313a9f1288 (patch)
tree0751831df9b67d80dbbac52ec5f91f4a67c782ba
parent885b201056e942f7deb66496b5c501d2a35d6c04 (diff)
dmaengine: ioatdma: move all sysfs related code
Move and fixup all sysfs related bits to sysfs.c file. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/ioat/Makefile2
-rw-r--r--drivers/dma/ioat/dma.c108
-rw-r--r--drivers/dma/ioat/sysfs.c135
3 files changed, 136 insertions, 109 deletions
diff --git a/drivers/dma/ioat/Makefile b/drivers/dma/ioat/Makefile
index 655df9188387..d2555f4881d7 100644
--- a/drivers/dma/ioat/Makefile
+++ b/drivers/dma/ioat/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o 1obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
2ioatdma-y := pci.o dma.o dma_v3.o dca.o 2ioatdma-y := pci.o dma.o dma_v3.o dca.o sysfs.o
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 02b5c04dea8a..1746f7b4c3b4 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -491,84 +491,6 @@ int ioat_register(struct ioatdma_device *ioat_dma)
491 return err; 491 return err;
492} 492}
493 493
494static ssize_t cap_show(struct dma_chan *c, char *page)
495{
496 struct dma_device *dma = c->device;
497
498 return sprintf(page, "copy%s%s%s%s%s\n",
499 dma_has_cap(DMA_PQ, dma->cap_mask) ? " pq" : "",
500 dma_has_cap(DMA_PQ_VAL, dma->cap_mask) ? " pq_val" : "",
501 dma_has_cap(DMA_XOR, dma->cap_mask) ? " xor" : "",
502 dma_has_cap(DMA_XOR_VAL, dma->cap_mask) ? " xor_val" : "",
503 dma_has_cap(DMA_INTERRUPT, dma->cap_mask) ? " intr" : "");
504
505}
506struct ioat_sysfs_entry ioat_cap_attr = __ATTR_RO(cap);
507
508static ssize_t version_show(struct dma_chan *c, char *page)
509{
510 struct dma_device *dma = c->device;
511 struct ioatdma_device *ioat_dma = to_ioatdma_device(dma);
512
513 return sprintf(page, "%d.%d\n",
514 ioat_dma->version >> 4, ioat_dma->version & 0xf);
515}
516struct ioat_sysfs_entry ioat_version_attr = __ATTR_RO(version);
517
518static ssize_t
519ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
520{
521 struct ioat_sysfs_entry *entry;
522 struct ioatdma_chan *ioat_chan;
523
524 entry = container_of(attr, struct ioat_sysfs_entry, attr);
525 ioat_chan = container_of(kobj, struct ioatdma_chan, kobj);
526
527 if (!entry->show)
528 return -EIO;
529 return entry->show(&ioat_chan->dma_chan, page);
530}
531
532const struct sysfs_ops ioat_sysfs_ops = {
533 .show = ioat_attr_show,
534};
535
536void ioat_kobject_add(struct ioatdma_device *ioat_dma, struct kobj_type *type)
537{
538 struct dma_device *dma = &ioat_dma->dma_dev;
539 struct dma_chan *c;
540
541 list_for_each_entry(c, &dma->channels, device_node) {
542 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
543 struct kobject *parent = &c->dev->device.kobj;
544 int err;
545
546 err = kobject_init_and_add(&ioat_chan->kobj, type,
547 parent, "quickdata");
548 if (err) {
549 dev_warn(to_dev(ioat_chan),
550 "sysfs init error (%d), continuing...\n", err);
551 kobject_put(&ioat_chan->kobj);
552 set_bit(IOAT_KOBJ_INIT_FAIL, &ioat_chan->state);
553 }
554 }
555}
556
557void ioat_kobject_del(struct ioatdma_device *ioat_dma)
558{
559 struct dma_device *dma = &ioat_dma->dma_dev;
560 struct dma_chan *c;
561
562 list_for_each_entry(c, &dma->channels, device_node) {
563 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
564
565 if (!test_bit(IOAT_KOBJ_INIT_FAIL, &ioat_chan->state)) {
566 kobject_del(&ioat_chan->kobj);
567 kobject_put(&ioat_chan->kobj);
568 }
569 }
570}
571
572void ioat_dma_remove(struct ioatdma_device *ioat_dma) 494void ioat_dma_remove(struct ioatdma_device *ioat_dma)
573{ 495{
574 struct dma_device *dma = &ioat_dma->dma_dev; 496 struct dma_device *dma = &ioat_dma->dma_dev;
@@ -1202,33 +1124,3 @@ ioat_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest,
1202 1124
1203 return &desc->txd; 1125 return &desc->txd;
1204} 1126}
1205
1206static ssize_t ring_size_show(struct dma_chan *c, char *page)
1207{
1208 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
1209
1210 return sprintf(page, "%d\n", (1 << ioat_chan->alloc_order) & ~1);
1211}
1212static struct ioat_sysfs_entry ring_size_attr = __ATTR_RO(ring_size);
1213
1214static ssize_t ring_active_show(struct dma_chan *c, char *page)
1215{
1216 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
1217
1218 /* ...taken outside the lock, no need to be precise */
1219 return sprintf(page, "%d\n", ioat_ring_active(ioat_chan));
1220}
1221static struct ioat_sysfs_entry ring_active_attr = __ATTR_RO(ring_active);
1222
1223static struct attribute *ioat_attrs[] = {
1224 &ring_size_attr.attr,
1225 &ring_active_attr.attr,
1226 &ioat_cap_attr.attr,
1227 &ioat_version_attr.attr,
1228 NULL,
1229};
1230
1231struct kobj_type ioat_ktype = {
1232 .sysfs_ops = &ioat_sysfs_ops,
1233 .default_attrs = ioat_attrs,
1234};
diff --git a/drivers/dma/ioat/sysfs.c b/drivers/dma/ioat/sysfs.c
new file mode 100644
index 000000000000..cb4a857ee21b
--- /dev/null
+++ b/drivers/dma/ioat/sysfs.c
@@ -0,0 +1,135 @@
1/*
2 * Intel I/OAT DMA Linux driver
3 * Copyright(c) 2004 - 2015 Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * The full GNU General Public License is included in this distribution in
15 * the file called "COPYING".
16 *
17 */
18
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/dmaengine.h>
22#include <linux/pci.h>
23#include "dma.h"
24#include "registers.h"
25#include "hw.h"
26
27#include "../dmaengine.h"
28
29static ssize_t cap_show(struct dma_chan *c, char *page)
30{
31 struct dma_device *dma = c->device;
32
33 return sprintf(page, "copy%s%s%s%s%s\n",
34 dma_has_cap(DMA_PQ, dma->cap_mask) ? " pq" : "",
35 dma_has_cap(DMA_PQ_VAL, dma->cap_mask) ? " pq_val" : "",
36 dma_has_cap(DMA_XOR, dma->cap_mask) ? " xor" : "",
37 dma_has_cap(DMA_XOR_VAL, dma->cap_mask) ? " xor_val" : "",
38 dma_has_cap(DMA_INTERRUPT, dma->cap_mask) ? " intr" : "");
39
40}
41struct ioat_sysfs_entry ioat_cap_attr = __ATTR_RO(cap);
42
43static ssize_t version_show(struct dma_chan *c, char *page)
44{
45 struct dma_device *dma = c->device;
46 struct ioatdma_device *ioat_dma = to_ioatdma_device(dma);
47
48 return sprintf(page, "%d.%d\n",
49 ioat_dma->version >> 4, ioat_dma->version & 0xf);
50}
51struct ioat_sysfs_entry ioat_version_attr = __ATTR_RO(version);
52
53static ssize_t
54ioat_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
55{
56 struct ioat_sysfs_entry *entry;
57 struct ioatdma_chan *ioat_chan;
58
59 entry = container_of(attr, struct ioat_sysfs_entry, attr);
60 ioat_chan = container_of(kobj, struct ioatdma_chan, kobj);
61
62 if (!entry->show)
63 return -EIO;
64 return entry->show(&ioat_chan->dma_chan, page);
65}
66
67const struct sysfs_ops ioat_sysfs_ops = {
68 .show = ioat_attr_show,
69};
70
71void ioat_kobject_add(struct ioatdma_device *ioat_dma, struct kobj_type *type)
72{
73 struct dma_device *dma = &ioat_dma->dma_dev;
74 struct dma_chan *c;
75
76 list_for_each_entry(c, &dma->channels, device_node) {
77 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
78 struct kobject *parent = &c->dev->device.kobj;
79 int err;
80
81 err = kobject_init_and_add(&ioat_chan->kobj, type,
82 parent, "quickdata");
83 if (err) {
84 dev_warn(to_dev(ioat_chan),
85 "sysfs init error (%d), continuing...\n", err);
86 kobject_put(&ioat_chan->kobj);
87 set_bit(IOAT_KOBJ_INIT_FAIL, &ioat_chan->state);
88 }
89 }
90}
91
92void ioat_kobject_del(struct ioatdma_device *ioat_dma)
93{
94 struct dma_device *dma = &ioat_dma->dma_dev;
95 struct dma_chan *c;
96
97 list_for_each_entry(c, &dma->channels, device_node) {
98 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
99
100 if (!test_bit(IOAT_KOBJ_INIT_FAIL, &ioat_chan->state)) {
101 kobject_del(&ioat_chan->kobj);
102 kobject_put(&ioat_chan->kobj);
103 }
104 }
105}
106
107static ssize_t ring_size_show(struct dma_chan *c, char *page)
108{
109 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
110
111 return sprintf(page, "%d\n", (1 << ioat_chan->alloc_order) & ~1);
112}
113static struct ioat_sysfs_entry ring_size_attr = __ATTR_RO(ring_size);
114
115static ssize_t ring_active_show(struct dma_chan *c, char *page)
116{
117 struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
118
119 /* ...taken outside the lock, no need to be precise */
120 return sprintf(page, "%d\n", ioat_ring_active(ioat_chan));
121}
122static struct ioat_sysfs_entry ring_active_attr = __ATTR_RO(ring_active);
123
124static struct attribute *ioat_attrs[] = {
125 &ring_size_attr.attr,
126 &ring_active_attr.attr,
127 &ioat_cap_attr.attr,
128 &ioat_version_attr.attr,
129 NULL,
130};
131
132struct kobj_type ioat_ktype = {
133 .sysfs_ops = &ioat_sysfs_ops,
134 .default_attrs = ioat_attrs,
135};