2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.16 $)
4 * Linux on zSeries Channel Measurement Facility support
6 * Copyright 2000,2003 IBM Corporation
8 * Author: Arnd Bergmann <arndb@de.ibm.com>
10 * original idea from Natarajan Krishnaswami <nkrishna@us.ibm.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <linux/bootmem.h>
28 #include <linux/device.h>
29 #include <linux/init.h>
30 #include <linux/list.h>
31 #include <linux/module.h>
32 #include <linux/moduleparam.h>
34 #include <asm/ccwdev.h>
44 /* parameter to enable cmf during boot, possible uses are:
45 * "s390cmf" -- enable cmf and allocate 2 MB of ram so measuring can be
46 * used on any subchannel
47 * "s390cmf=<num>" -- enable cmf and allocate enough memory to measure
48 * <num> subchannel, where <num> is an integer
49 * between 1 and 65535, default is 1024
51 #define ARGSTRING "s390cmf"
53 /* indices for READCMB */
55 /* basic and exended format: */
58 cmb_device_connect_time,
59 cmb_function_pending_time,
60 cmb_device_disconnect_time,
61 cmb_control_unit_queuing_time,
62 cmb_device_active_only_time,
63 /* extended format only: */
65 cmb_initial_command_response_time,
69 * enum cmb_format - types of supported measurement block formats
71 * @CMF_BASIC: traditional channel measurement blocks supported
72 * by all machines that we run on
73 * @CMF_EXTENDED: improved format that was introduced with the z990
75 * @CMF_AUTODETECT: default: use extended format when running on a z990
76 * or later machine, otherwise fall back to basic format
84 * format - actual format for all measurement blocks
86 * The format module parameter can be set to a value of 0 (zero)
87 * or 1, indicating basic or extended format as described for
90 static int format = CMF_AUTODETECT;
91 module_param(format, bool, 0444);
94 * struct cmb_operations - functions to use depending on cmb_format
96 * all these functions operate on a struct cmf_device. There is only
97 * one instance of struct cmb_operations because all cmf_device
98 * objects are guaranteed to be of the same type.
100 * @alloc: allocate memory for a channel measurement block,
101 * either with the help of a special pool or with kmalloc
102 * @free: free memory allocated with @alloc
103 * @set: enable or disable measurement
104 * @readall: read a measurement block in a common format
105 * @reset: clear the data in the associated measurement block and
106 * reset its time stamp
108 struct cmb_operations {
109 int (*alloc) (struct ccw_device*);
110 void(*free) (struct ccw_device*);
111 int (*set) (struct ccw_device*, u32);
112 u64 (*read) (struct ccw_device*, int);
113 int (*readall)(struct ccw_device*, struct cmbdata *);
114 void (*reset) (struct ccw_device*);
116 struct attribute_group *attr_group;
118 static struct cmb_operations *cmbops;
120 /* our user interface is designed in terms of nanoseconds,
121 * while the hardware measures total times in its own
123 static inline u64 time_to_nsec(u32 value)
125 return ((u64)value) * 128000ull;
129 * Users are usually interested in average times,
130 * not accumulated time.
131 * This also helps us with atomicity problems
132 * when reading sinlge values.
134 static inline u64 time_to_avg_nsec(u32 value, u32 count)
138 /* no samples yet, avoid division by 0 */
142 /* value comes in units of 128 µsec */
143 ret = time_to_nsec(value);
149 /* activate or deactivate the channel monitor. When area is NULL,
150 * the monitor is deactivated. The channel monitor needs to
151 * be active in order to measure subchannels, which also need
154 cmf_activate(void *area, unsigned int onoff)
156 register void * __gpr2 asm("2");
157 register long __gpr1 asm("1");
160 __gpr1 = onoff ? 2 : 0;
161 /* activate channel measurement */
162 asm("schm" : : "d" (__gpr2), "d" (__gpr1) );
166 set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
170 struct subchannel *sch;
173 sch = to_subchannel(cdev->dev.parent);
175 /* msch can silently fail, so do it again if necessary */
176 for (retry = 0; retry < 3; retry++) {
178 stsch(sch->irq, schib);
179 schib->pmcw.mme = mme;
180 schib->pmcw.mbfc = mbfc;
181 /* address can be either a block address or a block index */
183 schib->mba = address;
185 schib->pmcw.mbi = address;
187 /* try to submit it */
188 switch(ret = msch_err(sch->irq, schib)) {
192 case 2: /* in I/O or status pending */
195 case 3: /* subchannel is no longer valid */
198 default: /* msch caught an exception */
202 stsch(sch->irq, schib); /* restore the schib */
207 /* check if it worked */
208 if (schib->pmcw.mme == mme &&
209 schib->pmcw.mbfc == mbfc &&
210 (mbfc ? (schib->mba == address)
211 : (schib->pmcw.mbi == address)))
220 struct set_schib_struct {
223 unsigned long address;
224 wait_queue_head_t wait;
228 static int set_schib_wait(struct ccw_device *cdev, u32 mme,
229 int mbfc, unsigned long address)
231 struct set_schib_struct s = {
235 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s.wait),
238 spin_lock_irq(cdev->ccwlock);
239 s.ret = set_schib(cdev, mme, mbfc, address);
240 if (s.ret != -EBUSY) {
244 if (cdev->private->state != DEV_STATE_ONLINE) {
246 /* if the device is not online, don't even try again */
249 cdev->private->state = DEV_STATE_CMFCHANGE;
250 cdev->private->cmb_wait = &s;
253 spin_unlock_irq(cdev->ccwlock);
254 if (wait_event_interruptible(s.wait, s.ret != 1)) {
255 spin_lock_irq(cdev->ccwlock);
257 s.ret = -ERESTARTSYS;
258 cdev->private->cmb_wait = 0;
259 if (cdev->private->state == DEV_STATE_CMFCHANGE)
260 cdev->private->state = DEV_STATE_ONLINE;
262 spin_unlock_irq(cdev->ccwlock);
267 spin_unlock_irq(cdev->ccwlock);
271 void retry_set_schib(struct ccw_device *cdev)
273 struct set_schib_struct *s;
275 s = cdev->private->cmb_wait;
276 cdev->private->cmb_wait = 0;
281 s->ret = set_schib(cdev, s->mme, s->mbfc, s->address);
286 * struct cmb_area - container for global cmb data
288 * @mem: pointer to CMBs (only in basic measurement mode)
289 * @list: contains a linked list of all subchannels
290 * @lock: protect concurrent access to @mem and @list
294 struct list_head list;
299 static struct cmb_area cmb_area = {
300 .lock = SPIN_LOCK_UNLOCKED,
301 .list = LIST_HEAD_INIT(cmb_area.list),
302 .num_channels = 1024,
306 /* ****** old style CMB handling ********/
310 * Basic channel measurement blocks are allocated in one contiguous
311 * block of memory, which can not be moved as long as any channel
312 * is active. Therefore, a maximum number of subchannels needs to
313 * be defined somewhere. This is a module parameter, defaulting to
314 * a resonable value of 1024, or 32 kb of memory.
315 * Current kernels don't allow kmalloc with more than 128kb, so the
319 module_param_named(maxchannels, cmb_area.num_channels, uint, 0444);
322 * struct cmb - basic channel measurement block
324 * cmb as used by the hardware the fields are described in z/Architecture
325 * Principles of Operation, chapter 17.
326 * The area to be a contiguous array and may not be reallocated or freed.
327 * Only one cmb area can be present in the system.
332 u32 device_connect_time;
333 u32 function_pending_time;
334 u32 device_disconnect_time;
335 u32 control_unit_queuing_time;
336 u32 device_active_only_time;
340 /* insert a single device into the cmb_area list
341 * called with cmb_area.lock held from alloc_cmb
344 alloc_cmb_single (struct ccw_device *cdev)
347 struct ccw_device_private *node;
350 spin_lock_irq(cdev->ccwlock);
351 if (!list_empty(&cdev->private->cmb_list)) {
356 /* find first unused cmb in cmb_area.mem.
357 * this is a little tricky: cmb_area.list
358 * remains sorted by ->cmb pointers */
360 list_for_each_entry(node, &cmb_area.list, cmb_list) {
361 if ((struct cmb*)node->cmb > cmb)
365 if (cmb - cmb_area.mem >= cmb_area.num_channels) {
371 list_add_tail(&cdev->private->cmb_list, &node->cmb_list);
372 cdev->private->cmb = cmb;
375 spin_unlock_irq(cdev->ccwlock);
380 alloc_cmb (struct ccw_device *cdev)
386 spin_lock(&cmb_area.lock);
389 /* there is no user yet, so we need a new area */
390 size = sizeof(struct cmb) * cmb_area.num_channels;
391 WARN_ON(!list_empty(&cmb_area.list));
393 spin_unlock(&cmb_area.lock);
394 mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
396 spin_lock(&cmb_area.lock);
399 /* ok, another thread was faster */
400 free_pages((unsigned long)mem, get_order(size));
407 memset(mem, 0, size);
409 cmf_activate(cmb_area.mem, 1);
413 /* do the actual allocation */
414 ret = alloc_cmb_single(cdev);
416 spin_unlock(&cmb_area.lock);
422 free_cmb(struct ccw_device *cdev)
424 struct ccw_device_private *priv;
426 priv = cdev->private;
428 spin_lock(&cmb_area.lock);
429 spin_lock_irq(cdev->ccwlock);
431 if (list_empty(&priv->cmb_list)) {
437 list_del_init(&priv->cmb_list);
439 if (list_empty(&cmb_area.list)) {
441 size = sizeof(struct cmb) * cmb_area.num_channels;
442 cmf_activate(NULL, 0);
443 free_pages((unsigned long)cmb_area.mem, get_order(size));
447 spin_unlock_irq(cdev->ccwlock);
448 spin_unlock(&cmb_area.lock);
452 set_cmb(struct ccw_device *cdev, u32 mme)
456 if (!cdev->private->cmb)
459 offset = mme ? (struct cmb *)cdev->private->cmb - cmb_area.mem : 0;
461 return set_schib_wait(cdev, mme, 0, offset);
465 read_cmb (struct ccw_device *cdev, int index)
467 /* yes, we have to put it on the stack
468 * because the cmb must only be accessed
469 * atomically, e.g. with mvc */
474 spin_lock_irqsave(cdev->ccwlock, flags);
475 if (!cdev->private->cmb) {
476 spin_unlock_irqrestore(cdev->ccwlock, flags);
480 cmb = *(struct cmb*)cdev->private->cmb;
481 spin_unlock_irqrestore(cdev->ccwlock, flags);
484 case cmb_ssch_rsch_count:
485 return cmb.ssch_rsch_count;
486 case cmb_sample_count:
487 return cmb.sample_count;
488 case cmb_device_connect_time:
489 val = cmb.device_connect_time;
491 case cmb_function_pending_time:
492 val = cmb.function_pending_time;
494 case cmb_device_disconnect_time:
495 val = cmb.device_disconnect_time;
497 case cmb_control_unit_queuing_time:
498 val = cmb.control_unit_queuing_time;
500 case cmb_device_active_only_time:
501 val = cmb.device_active_only_time;
506 return time_to_avg_nsec(val, cmb.sample_count);
510 readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
512 /* yes, we have to put it on the stack
513 * because the cmb must only be accessed
514 * atomically, e.g. with mvc */
519 spin_lock_irqsave(cdev->ccwlock, flags);
520 if (!cdev->private->cmb) {
521 spin_unlock_irqrestore(cdev->ccwlock, flags);
525 cmb = *(struct cmb*)cdev->private->cmb;
526 time = get_clock() - cdev->private->cmb_start_time;
527 spin_unlock_irqrestore(cdev->ccwlock, flags);
529 memset(data, 0, sizeof(struct cmbdata));
531 /* we only know values before device_busy_time */
532 data->size = offsetof(struct cmbdata, device_busy_time);
534 /* convert to nanoseconds */
535 data->elapsed_time = (time * 1000) >> 12;
537 /* copy data to new structure */
538 data->ssch_rsch_count = cmb.ssch_rsch_count;
539 data->sample_count = cmb.sample_count;
541 /* time fields are converted to nanoseconds while copying */
542 data->device_connect_time = time_to_nsec(cmb.device_connect_time);
543 data->function_pending_time = time_to_nsec(cmb.function_pending_time);
544 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time);
545 data->control_unit_queuing_time
546 = time_to_nsec(cmb.control_unit_queuing_time);
547 data->device_active_only_time
548 = time_to_nsec(cmb.device_active_only_time);
554 reset_cmb(struct ccw_device *cdev)
557 spin_lock_irq(cdev->ccwlock);
558 cmb = cdev->private->cmb;
560 memset (cmb, 0, sizeof (*cmb));
561 cdev->private->cmb_start_time = get_clock();
562 spin_unlock_irq(cdev->ccwlock);
565 static struct attribute_group cmf_attr_group;
567 static struct cmb_operations cmbops_basic = {
572 .readall = readall_cmb,
574 .attr_group = &cmf_attr_group,
577 /* ******** extended cmb handling ********/
580 * struct cmbe - extended channel measurement block
582 * cmb as used by the hardware, may be in any 64 bit physical location,
583 * the fields are described in z/Architecture Principles of Operation,
584 * third edition, chapter 17.
589 u32 device_connect_time;
590 u32 function_pending_time;
591 u32 device_disconnect_time;
592 u32 control_unit_queuing_time;
593 u32 device_active_only_time;
594 u32 device_busy_time;
595 u32 initial_command_response_time;
599 /* kmalloc only guarantees 8 byte alignment, but we need cmbe
600 * pointers to be naturally aligned. Make sure to allocate
601 * enough space for two cmbes */
602 static inline struct cmbe* cmbe_align(struct cmbe *c)
605 addr = ((unsigned long)c + sizeof (struct cmbe) - sizeof(long)) &
606 ~(sizeof (struct cmbe) - sizeof(long));
607 return (struct cmbe*)addr;
611 alloc_cmbe (struct ccw_device *cdev)
614 cmbe = kmalloc (sizeof (*cmbe) * 2, GFP_KERNEL);
618 spin_lock_irq(cdev->ccwlock);
619 if (cdev->private->cmb) {
621 spin_unlock_irq(cdev->ccwlock);
625 cdev->private->cmb = cmbe;
626 spin_unlock_irq(cdev->ccwlock);
628 /* activate global measurement if this is the first channel */
629 spin_lock(&cmb_area.lock);
630 if (list_empty(&cmb_area.list))
631 cmf_activate(NULL, 1);
632 list_add_tail(&cdev->private->cmb_list, &cmb_area.list);
633 spin_unlock(&cmb_area.lock);
639 free_cmbe (struct ccw_device *cdev)
641 spin_lock_irq(cdev->ccwlock);
642 if (cdev->private->cmb)
643 kfree(cdev->private->cmb);
644 cdev->private->cmb = NULL;
645 spin_unlock_irq(cdev->ccwlock);
647 /* deactivate global measurement if this is the last channel */
648 spin_lock(&cmb_area.lock);
649 list_del_init(&cdev->private->cmb_list);
650 if (list_empty(&cmb_area.list))
651 cmf_activate(NULL, 0);
652 spin_unlock(&cmb_area.lock);
656 set_cmbe(struct ccw_device *cdev, u32 mme)
660 if (!cdev->private->cmb)
662 mba = mme ? (unsigned long) cmbe_align(cdev->private->cmb) : 0;
664 return set_schib_wait(cdev, mme, 1, mba);
669 read_cmbe (struct ccw_device *cdev, int index)
671 /* yes, we have to put it on the stack
672 * because the cmb must only be accessed
673 * atomically, e.g. with mvc */
678 spin_lock_irqsave(cdev->ccwlock, flags);
679 if (!cdev->private->cmb) {
680 spin_unlock_irqrestore(cdev->ccwlock, flags);
684 cmb = *cmbe_align(cdev->private->cmb);
685 spin_unlock_irqrestore(cdev->ccwlock, flags);
688 case cmb_ssch_rsch_count:
689 return cmb.ssch_rsch_count;
690 case cmb_sample_count:
691 return cmb.sample_count;
692 case cmb_device_connect_time:
693 val = cmb.device_connect_time;
695 case cmb_function_pending_time:
696 val = cmb.function_pending_time;
698 case cmb_device_disconnect_time:
699 val = cmb.device_disconnect_time;
701 case cmb_control_unit_queuing_time:
702 val = cmb.control_unit_queuing_time;
704 case cmb_device_active_only_time:
705 val = cmb.device_active_only_time;
707 case cmb_device_busy_time:
708 val = cmb.device_busy_time;
710 case cmb_initial_command_response_time:
711 val = cmb.initial_command_response_time;
716 return time_to_avg_nsec(val, cmb.sample_count);
720 readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
722 /* yes, we have to put it on the stack
723 * because the cmb must only be accessed
724 * atomically, e.g. with mvc */
729 spin_lock_irqsave(cdev->ccwlock, flags);
730 if (!cdev->private->cmb) {
731 spin_unlock_irqrestore(cdev->ccwlock, flags);
735 cmb = *cmbe_align(cdev->private->cmb);
736 time = get_clock() - cdev->private->cmb_start_time;
737 spin_unlock_irqrestore(cdev->ccwlock, flags);
739 memset (data, 0, sizeof(struct cmbdata));
741 /* we only know values before device_busy_time */
742 data->size = offsetof(struct cmbdata, device_busy_time);
744 /* conver to nanoseconds */
745 data->elapsed_time = (time * 1000) >> 12;
747 /* copy data to new structure */
748 data->ssch_rsch_count = cmb.ssch_rsch_count;
749 data->sample_count = cmb.sample_count;
751 /* time fields are converted to nanoseconds while copying */
752 data->device_connect_time = time_to_nsec(cmb.device_connect_time);
753 data->function_pending_time = time_to_nsec(cmb.function_pending_time);
754 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time);
755 data->control_unit_queuing_time
756 = time_to_nsec(cmb.control_unit_queuing_time);
757 data->device_active_only_time
758 = time_to_nsec(cmb.device_active_only_time);
759 data->device_busy_time = time_to_nsec(cmb.device_busy_time);
760 data->initial_command_response_time
761 = time_to_nsec(cmb.initial_command_response_time);
767 reset_cmbe(struct ccw_device *cdev)
770 spin_lock_irq(cdev->ccwlock);
771 cmb = cmbe_align(cdev->private->cmb);
773 memset (cmb, 0, sizeof (*cmb));
774 cdev->private->cmb_start_time = get_clock();
775 spin_unlock_irq(cdev->ccwlock);
778 static struct attribute_group cmf_attr_group_ext;
780 static struct cmb_operations cmbops_extended = {
785 .readall = readall_cmbe,
787 .attr_group = &cmf_attr_group_ext,
792 cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
794 return sprintf(buf, "%lld\n",
795 (unsigned long long) cmf_read(to_ccwdev(dev), idx));
799 cmb_show_avg_sample_interval(struct device *dev, struct device_attribute *attr, char *buf)
801 struct ccw_device *cdev;
805 cdev = to_ccwdev(dev);
806 interval = get_clock() - cdev->private->cmb_start_time;
807 count = cmf_read(cdev, cmb_sample_count);
812 return sprintf(buf, "%ld\n", interval);
816 cmb_show_avg_utilization(struct device *dev, struct device_attribute *attr, char *buf)
823 ret = cmf_readall(to_ccwdev(dev), &data);
827 utilization = data.device_connect_time +
828 data.function_pending_time +
829 data.device_disconnect_time;
831 /* shift to avoid long long division */
832 while (-1ul < (data.elapsed_time | utilization)) {
834 data.elapsed_time >>= 8;
837 /* calculate value in 0.1 percent units */
838 t = (unsigned long) data.elapsed_time / 1000;
839 u = (unsigned long) utilization / t;
841 return sprintf(buf, "%02ld.%01ld%%\n", u/ 10, u - (u/ 10) * 10);
844 #define cmf_attr(name) \
845 static ssize_t show_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
846 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
847 static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
849 #define cmf_attr_avg(name) \
850 static ssize_t show_avg_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
851 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
852 static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
854 cmf_attr(ssch_rsch_count);
855 cmf_attr(sample_count);
856 cmf_attr_avg(device_connect_time);
857 cmf_attr_avg(function_pending_time);
858 cmf_attr_avg(device_disconnect_time);
859 cmf_attr_avg(control_unit_queuing_time);
860 cmf_attr_avg(device_active_only_time);
861 cmf_attr_avg(device_busy_time);
862 cmf_attr_avg(initial_command_response_time);
864 static DEVICE_ATTR(avg_sample_interval, 0444, cmb_show_avg_sample_interval, NULL);
865 static DEVICE_ATTR(avg_utilization, 0444, cmb_show_avg_utilization, NULL);
867 static struct attribute *cmf_attributes[] = {
868 &dev_attr_avg_sample_interval.attr,
869 &dev_attr_avg_utilization.attr,
870 &dev_attr_ssch_rsch_count.attr,
871 &dev_attr_sample_count.attr,
872 &dev_attr_avg_device_connect_time.attr,
873 &dev_attr_avg_function_pending_time.attr,
874 &dev_attr_avg_device_disconnect_time.attr,
875 &dev_attr_avg_control_unit_queuing_time.attr,
876 &dev_attr_avg_device_active_only_time.attr,
880 static struct attribute_group cmf_attr_group = {
882 .attrs = cmf_attributes,
885 static struct attribute *cmf_attributes_ext[] = {
886 &dev_attr_avg_sample_interval.attr,
887 &dev_attr_avg_utilization.attr,
888 &dev_attr_ssch_rsch_count.attr,
889 &dev_attr_sample_count.attr,
890 &dev_attr_avg_device_connect_time.attr,
891 &dev_attr_avg_function_pending_time.attr,
892 &dev_attr_avg_device_disconnect_time.attr,
893 &dev_attr_avg_control_unit_queuing_time.attr,
894 &dev_attr_avg_device_active_only_time.attr,
895 &dev_attr_avg_device_busy_time.attr,
896 &dev_attr_avg_initial_command_response_time.attr,
900 static struct attribute_group cmf_attr_group_ext = {
902 .attrs = cmf_attributes_ext,
905 static ssize_t cmb_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
907 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
910 static ssize_t cmb_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t c)
912 struct ccw_device *cdev;
915 cdev = to_ccwdev(dev);
919 ret = disable_cmf(cdev);
921 printk(KERN_INFO "disable_cmf failed (%d)\n", ret);
924 ret = enable_cmf(cdev);
925 if (ret && ret != -EBUSY)
926 printk(KERN_INFO "enable_cmf failed (%d)\n", ret);
933 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
935 /* enable_cmf/disable_cmf: module interface for cmf (de)activation */
937 enable_cmf(struct ccw_device *cdev)
941 ret = cmbops->alloc(cdev);
945 ret = cmbops->set(cdev, 2);
950 ret = sysfs_create_group(&cdev->dev.kobj, cmbops->attr_group);
953 cmbops->set(cdev, 0); //FIXME: this can fail
959 disable_cmf(struct ccw_device *cdev)
963 ret = cmbops->set(cdev, 0);
967 sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
972 cmf_read(struct ccw_device *cdev, int index)
974 return cmbops->read(cdev, index);
978 cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
980 return cmbops->readall(cdev, data);
987 char *detect_string = "parameter";
989 /* We cannot really autoprobe this. If the user did not give a parameter,
990 see if we are running on z990 or up, otherwise fall back to basic mode. */
992 if (format == CMF_AUTODETECT) {
993 if (!css_characteristics_avail ||
994 !css_general_characteristics.ext_mb) {
997 format = CMF_EXTENDED;
999 detect_string = "autodetected";
1001 detect_string = "parameter";
1006 format_string = "basic";
1007 cmbops = &cmbops_basic;
1008 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1009 printk(KERN_ERR "Basic channel measurement facility"
1010 " can only use 1 to 4096 devices\n"
1011 KERN_ERR "when the cmf driver is built"
1012 " as a loadable module\n");
1017 format_string = "extended";
1018 cmbops = &cmbops_extended;
1021 printk(KERN_ERR "Invalid format %d for channel "
1022 "measurement facility\n", format);
1026 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n",
1027 format_string, detect_string);
1031 module_init(init_cmf);
1034 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
1035 MODULE_LICENSE("GPL");
1036 MODULE_DESCRIPTION("channel measurement facility base driver\n"
1037 "Copyright 2003 IBM Corporation\n");
1039 EXPORT_SYMBOL_GPL(enable_cmf);
1040 EXPORT_SYMBOL_GPL(disable_cmf);
1041 EXPORT_SYMBOL_GPL(cmf_read);
1042 EXPORT_SYMBOL_GPL(cmf_readall);