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>
33 #include <linux/slab.h>
34 #include <linux/timex.h> /* get_clock() */
36 #include <asm/ccwdev.h>
39 #include <asm/div64.h>
47 /* parameter to enable cmf during boot, possible uses are:
48 * "s390cmf" -- enable cmf and allocate 2 MB of ram so measuring can be
49 * used on any subchannel
50 * "s390cmf=<num>" -- enable cmf and allocate enough memory to measure
51 * <num> subchannel, where <num> is an integer
52 * between 1 and 65535, default is 1024
54 #define ARGSTRING "s390cmf"
56 /* indices for READCMB */
58 /* basic and exended format: */
61 cmb_device_connect_time,
62 cmb_function_pending_time,
63 cmb_device_disconnect_time,
64 cmb_control_unit_queuing_time,
65 cmb_device_active_only_time,
66 /* extended format only: */
68 cmb_initial_command_response_time,
72 * enum cmb_format - types of supported measurement block formats
74 * @CMF_BASIC: traditional channel measurement blocks supported
75 * by all machines that we run on
76 * @CMF_EXTENDED: improved format that was introduced with the z990
78 * @CMF_AUTODETECT: default: use extended format when running on a z990
79 * or later machine, otherwise fall back to basic format
87 * format - actual format for all measurement blocks
89 * The format module parameter can be set to a value of 0 (zero)
90 * or 1, indicating basic or extended format as described for
93 static int format = CMF_AUTODETECT;
94 module_param(format, bool, 0444);
97 * struct cmb_operations - functions to use depending on cmb_format
99 * all these functions operate on a struct cmf_device. There is only
100 * one instance of struct cmb_operations because all cmf_device
101 * objects are guaranteed to be of the same type.
103 * @alloc: allocate memory for a channel measurement block,
104 * either with the help of a special pool or with kmalloc
105 * @free: free memory allocated with @alloc
106 * @set: enable or disable measurement
107 * @readall: read a measurement block in a common format
108 * @reset: clear the data in the associated measurement block and
109 * reset its time stamp
111 struct cmb_operations {
112 int (*alloc) (struct ccw_device*);
113 void(*free) (struct ccw_device*);
114 int (*set) (struct ccw_device*, u32);
115 u64 (*read) (struct ccw_device*, int);
116 int (*readall)(struct ccw_device*, struct cmbdata *);
117 void (*reset) (struct ccw_device*);
119 struct attribute_group *attr_group;
121 static struct cmb_operations *cmbops;
123 /* our user interface is designed in terms of nanoseconds,
124 * while the hardware measures total times in its own
126 static inline u64 time_to_nsec(u32 value)
128 return ((u64)value) * 128000ull;
132 * Users are usually interested in average times,
133 * not accumulated time.
134 * This also helps us with atomicity problems
135 * when reading sinlge values.
137 static inline u64 time_to_avg_nsec(u32 value, u32 count)
141 /* no samples yet, avoid division by 0 */
145 /* value comes in units of 128 µsec */
146 ret = time_to_nsec(value);
152 /* activate or deactivate the channel monitor. When area is NULL,
153 * the monitor is deactivated. The channel monitor needs to
154 * be active in order to measure subchannels, which also need
157 cmf_activate(void *area, unsigned int onoff)
159 register void * __gpr2 asm("2");
160 register long __gpr1 asm("1");
163 __gpr1 = onoff ? 2 : 0;
164 /* activate channel measurement */
165 asm("schm" : : "d" (__gpr2), "d" (__gpr1) );
169 set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
173 struct subchannel *sch;
176 sch = to_subchannel(cdev->dev.parent);
178 /* msch can silently fail, so do it again if necessary */
179 for (retry = 0; retry < 3; retry++) {
181 stsch(sch->irq, schib);
182 schib->pmcw.mme = mme;
183 schib->pmcw.mbfc = mbfc;
184 /* address can be either a block address or a block index */
186 schib->mba = address;
188 schib->pmcw.mbi = address;
190 /* try to submit it */
191 switch(ret = msch_err(sch->irq, schib)) {
195 case 2: /* in I/O or status pending */
198 case 3: /* subchannel is no longer valid */
201 default: /* msch caught an exception */
205 stsch(sch->irq, schib); /* restore the schib */
210 /* check if it worked */
211 if (schib->pmcw.mme == mme &&
212 schib->pmcw.mbfc == mbfc &&
213 (mbfc ? (schib->mba == address)
214 : (schib->pmcw.mbi == address)))
223 struct set_schib_struct {
226 unsigned long address;
227 wait_queue_head_t wait;
231 static int set_schib_wait(struct ccw_device *cdev, u32 mme,
232 int mbfc, unsigned long address)
234 struct set_schib_struct s = {
238 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s.wait),
241 spin_lock_irq(cdev->ccwlock);
242 s.ret = set_schib(cdev, mme, mbfc, address);
243 if (s.ret != -EBUSY) {
247 if (cdev->private->state != DEV_STATE_ONLINE) {
249 /* if the device is not online, don't even try again */
252 cdev->private->state = DEV_STATE_CMFCHANGE;
253 cdev->private->cmb_wait = &s;
256 spin_unlock_irq(cdev->ccwlock);
257 if (wait_event_interruptible(s.wait, s.ret != 1)) {
258 spin_lock_irq(cdev->ccwlock);
260 s.ret = -ERESTARTSYS;
261 cdev->private->cmb_wait = 0;
262 if (cdev->private->state == DEV_STATE_CMFCHANGE)
263 cdev->private->state = DEV_STATE_ONLINE;
265 spin_unlock_irq(cdev->ccwlock);
270 spin_unlock_irq(cdev->ccwlock);
274 void retry_set_schib(struct ccw_device *cdev)
276 struct set_schib_struct *s;
278 s = cdev->private->cmb_wait;
279 cdev->private->cmb_wait = 0;
284 s->ret = set_schib(cdev, s->mme, s->mbfc, s->address);
289 * struct cmb_area - container for global cmb data
291 * @mem: pointer to CMBs (only in basic measurement mode)
292 * @list: contains a linked list of all subchannels
293 * @lock: protect concurrent access to @mem and @list
297 struct list_head list;
302 static struct cmb_area cmb_area = {
303 .lock = SPIN_LOCK_UNLOCKED,
304 .list = LIST_HEAD_INIT(cmb_area.list),
305 .num_channels = 1024,
309 /* ****** old style CMB handling ********/
313 * Basic channel measurement blocks are allocated in one contiguous
314 * block of memory, which can not be moved as long as any channel
315 * is active. Therefore, a maximum number of subchannels needs to
316 * be defined somewhere. This is a module parameter, defaulting to
317 * a resonable value of 1024, or 32 kb of memory.
318 * Current kernels don't allow kmalloc with more than 128kb, so the
322 module_param_named(maxchannels, cmb_area.num_channels, uint, 0444);
325 * struct cmb - basic channel measurement block
327 * cmb as used by the hardware the fields are described in z/Architecture
328 * Principles of Operation, chapter 17.
329 * The area to be a contiguous array and may not be reallocated or freed.
330 * Only one cmb area can be present in the system.
335 u32 device_connect_time;
336 u32 function_pending_time;
337 u32 device_disconnect_time;
338 u32 control_unit_queuing_time;
339 u32 device_active_only_time;
343 /* insert a single device into the cmb_area list
344 * called with cmb_area.lock held from alloc_cmb
347 alloc_cmb_single (struct ccw_device *cdev)
350 struct ccw_device_private *node;
353 spin_lock_irq(cdev->ccwlock);
354 if (!list_empty(&cdev->private->cmb_list)) {
359 /* find first unused cmb in cmb_area.mem.
360 * this is a little tricky: cmb_area.list
361 * remains sorted by ->cmb pointers */
363 list_for_each_entry(node, &cmb_area.list, cmb_list) {
364 if ((struct cmb*)node->cmb > cmb)
368 if (cmb - cmb_area.mem >= cmb_area.num_channels) {
374 list_add_tail(&cdev->private->cmb_list, &node->cmb_list);
375 cdev->private->cmb = cmb;
378 spin_unlock_irq(cdev->ccwlock);
383 alloc_cmb (struct ccw_device *cdev)
389 spin_lock(&cmb_area.lock);
392 /* there is no user yet, so we need a new area */
393 size = sizeof(struct cmb) * cmb_area.num_channels;
394 WARN_ON(!list_empty(&cmb_area.list));
396 spin_unlock(&cmb_area.lock);
397 mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
399 spin_lock(&cmb_area.lock);
402 /* ok, another thread was faster */
403 free_pages((unsigned long)mem, get_order(size));
410 memset(mem, 0, size);
412 cmf_activate(cmb_area.mem, 1);
416 /* do the actual allocation */
417 ret = alloc_cmb_single(cdev);
419 spin_unlock(&cmb_area.lock);
425 free_cmb(struct ccw_device *cdev)
427 struct ccw_device_private *priv;
429 priv = cdev->private;
431 spin_lock(&cmb_area.lock);
432 spin_lock_irq(cdev->ccwlock);
434 if (list_empty(&priv->cmb_list)) {
440 list_del_init(&priv->cmb_list);
442 if (list_empty(&cmb_area.list)) {
444 size = sizeof(struct cmb) * cmb_area.num_channels;
445 cmf_activate(NULL, 0);
446 free_pages((unsigned long)cmb_area.mem, get_order(size));
450 spin_unlock_irq(cdev->ccwlock);
451 spin_unlock(&cmb_area.lock);
455 set_cmb(struct ccw_device *cdev, u32 mme)
459 if (!cdev->private->cmb)
462 offset = mme ? (struct cmb *)cdev->private->cmb - cmb_area.mem : 0;
464 return set_schib_wait(cdev, mme, 0, offset);
468 read_cmb (struct ccw_device *cdev, int index)
470 /* yes, we have to put it on the stack
471 * because the cmb must only be accessed
472 * atomically, e.g. with mvc */
477 spin_lock_irqsave(cdev->ccwlock, flags);
478 if (!cdev->private->cmb) {
479 spin_unlock_irqrestore(cdev->ccwlock, flags);
483 cmb = *(struct cmb*)cdev->private->cmb;
484 spin_unlock_irqrestore(cdev->ccwlock, flags);
487 case cmb_ssch_rsch_count:
488 return cmb.ssch_rsch_count;
489 case cmb_sample_count:
490 return cmb.sample_count;
491 case cmb_device_connect_time:
492 val = cmb.device_connect_time;
494 case cmb_function_pending_time:
495 val = cmb.function_pending_time;
497 case cmb_device_disconnect_time:
498 val = cmb.device_disconnect_time;
500 case cmb_control_unit_queuing_time:
501 val = cmb.control_unit_queuing_time;
503 case cmb_device_active_only_time:
504 val = cmb.device_active_only_time;
509 return time_to_avg_nsec(val, cmb.sample_count);
513 readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
515 /* yes, we have to put it on the stack
516 * because the cmb must only be accessed
517 * atomically, e.g. with mvc */
522 spin_lock_irqsave(cdev->ccwlock, flags);
523 if (!cdev->private->cmb) {
524 spin_unlock_irqrestore(cdev->ccwlock, flags);
528 cmb = *(struct cmb*)cdev->private->cmb;
529 time = get_clock() - cdev->private->cmb_start_time;
530 spin_unlock_irqrestore(cdev->ccwlock, flags);
532 memset(data, 0, sizeof(struct cmbdata));
534 /* we only know values before device_busy_time */
535 data->size = offsetof(struct cmbdata, device_busy_time);
537 /* convert to nanoseconds */
538 data->elapsed_time = (time * 1000) >> 12;
540 /* copy data to new structure */
541 data->ssch_rsch_count = cmb.ssch_rsch_count;
542 data->sample_count = cmb.sample_count;
544 /* time fields are converted to nanoseconds while copying */
545 data->device_connect_time = time_to_nsec(cmb.device_connect_time);
546 data->function_pending_time = time_to_nsec(cmb.function_pending_time);
547 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time);
548 data->control_unit_queuing_time
549 = time_to_nsec(cmb.control_unit_queuing_time);
550 data->device_active_only_time
551 = time_to_nsec(cmb.device_active_only_time);
557 reset_cmb(struct ccw_device *cdev)
560 spin_lock_irq(cdev->ccwlock);
561 cmb = cdev->private->cmb;
563 memset (cmb, 0, sizeof (*cmb));
564 cdev->private->cmb_start_time = get_clock();
565 spin_unlock_irq(cdev->ccwlock);
568 static struct attribute_group cmf_attr_group;
570 static struct cmb_operations cmbops_basic = {
575 .readall = readall_cmb,
577 .attr_group = &cmf_attr_group,
580 /* ******** extended cmb handling ********/
583 * struct cmbe - extended channel measurement block
585 * cmb as used by the hardware, may be in any 64 bit physical location,
586 * the fields are described in z/Architecture Principles of Operation,
587 * third edition, chapter 17.
592 u32 device_connect_time;
593 u32 function_pending_time;
594 u32 device_disconnect_time;
595 u32 control_unit_queuing_time;
596 u32 device_active_only_time;
597 u32 device_busy_time;
598 u32 initial_command_response_time;
602 /* kmalloc only guarantees 8 byte alignment, but we need cmbe
603 * pointers to be naturally aligned. Make sure to allocate
604 * enough space for two cmbes */
605 static inline struct cmbe* cmbe_align(struct cmbe *c)
608 addr = ((unsigned long)c + sizeof (struct cmbe) - sizeof(long)) &
609 ~(sizeof (struct cmbe) - sizeof(long));
610 return (struct cmbe*)addr;
614 alloc_cmbe (struct ccw_device *cdev)
617 cmbe = kmalloc (sizeof (*cmbe) * 2, GFP_KERNEL);
621 spin_lock_irq(cdev->ccwlock);
622 if (cdev->private->cmb) {
624 spin_unlock_irq(cdev->ccwlock);
628 cdev->private->cmb = cmbe;
629 spin_unlock_irq(cdev->ccwlock);
631 /* activate global measurement if this is the first channel */
632 spin_lock(&cmb_area.lock);
633 if (list_empty(&cmb_area.list))
634 cmf_activate(NULL, 1);
635 list_add_tail(&cdev->private->cmb_list, &cmb_area.list);
636 spin_unlock(&cmb_area.lock);
642 free_cmbe (struct ccw_device *cdev)
644 spin_lock_irq(cdev->ccwlock);
645 if (cdev->private->cmb)
646 kfree(cdev->private->cmb);
647 cdev->private->cmb = NULL;
648 spin_unlock_irq(cdev->ccwlock);
650 /* deactivate global measurement if this is the last channel */
651 spin_lock(&cmb_area.lock);
652 list_del_init(&cdev->private->cmb_list);
653 if (list_empty(&cmb_area.list))
654 cmf_activate(NULL, 0);
655 spin_unlock(&cmb_area.lock);
659 set_cmbe(struct ccw_device *cdev, u32 mme)
663 if (!cdev->private->cmb)
665 mba = mme ? (unsigned long) cmbe_align(cdev->private->cmb) : 0;
667 return set_schib_wait(cdev, mme, 1, mba);
672 read_cmbe (struct ccw_device *cdev, int index)
674 /* yes, we have to put it on the stack
675 * because the cmb must only be accessed
676 * atomically, e.g. with mvc */
681 spin_lock_irqsave(cdev->ccwlock, flags);
682 if (!cdev->private->cmb) {
683 spin_unlock_irqrestore(cdev->ccwlock, flags);
687 cmb = *cmbe_align(cdev->private->cmb);
688 spin_unlock_irqrestore(cdev->ccwlock, flags);
691 case cmb_ssch_rsch_count:
692 return cmb.ssch_rsch_count;
693 case cmb_sample_count:
694 return cmb.sample_count;
695 case cmb_device_connect_time:
696 val = cmb.device_connect_time;
698 case cmb_function_pending_time:
699 val = cmb.function_pending_time;
701 case cmb_device_disconnect_time:
702 val = cmb.device_disconnect_time;
704 case cmb_control_unit_queuing_time:
705 val = cmb.control_unit_queuing_time;
707 case cmb_device_active_only_time:
708 val = cmb.device_active_only_time;
710 case cmb_device_busy_time:
711 val = cmb.device_busy_time;
713 case cmb_initial_command_response_time:
714 val = cmb.initial_command_response_time;
719 return time_to_avg_nsec(val, cmb.sample_count);
723 readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
725 /* yes, we have to put it on the stack
726 * because the cmb must only be accessed
727 * atomically, e.g. with mvc */
732 spin_lock_irqsave(cdev->ccwlock, flags);
733 if (!cdev->private->cmb) {
734 spin_unlock_irqrestore(cdev->ccwlock, flags);
738 cmb = *cmbe_align(cdev->private->cmb);
739 time = get_clock() - cdev->private->cmb_start_time;
740 spin_unlock_irqrestore(cdev->ccwlock, flags);
742 memset (data, 0, sizeof(struct cmbdata));
744 /* we only know values before device_busy_time */
745 data->size = offsetof(struct cmbdata, device_busy_time);
747 /* conver to nanoseconds */
748 data->elapsed_time = (time * 1000) >> 12;
750 /* copy data to new structure */
751 data->ssch_rsch_count = cmb.ssch_rsch_count;
752 data->sample_count = cmb.sample_count;
754 /* time fields are converted to nanoseconds while copying */
755 data->device_connect_time = time_to_nsec(cmb.device_connect_time);
756 data->function_pending_time = time_to_nsec(cmb.function_pending_time);
757 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time);
758 data->control_unit_queuing_time
759 = time_to_nsec(cmb.control_unit_queuing_time);
760 data->device_active_only_time
761 = time_to_nsec(cmb.device_active_only_time);
762 data->device_busy_time = time_to_nsec(cmb.device_busy_time);
763 data->initial_command_response_time
764 = time_to_nsec(cmb.initial_command_response_time);
770 reset_cmbe(struct ccw_device *cdev)
773 spin_lock_irq(cdev->ccwlock);
774 cmb = cmbe_align(cdev->private->cmb);
776 memset (cmb, 0, sizeof (*cmb));
777 cdev->private->cmb_start_time = get_clock();
778 spin_unlock_irq(cdev->ccwlock);
781 static struct attribute_group cmf_attr_group_ext;
783 static struct cmb_operations cmbops_extended = {
788 .readall = readall_cmbe,
790 .attr_group = &cmf_attr_group_ext,
795 cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
797 return sprintf(buf, "%lld\n",
798 (unsigned long long) cmf_read(to_ccwdev(dev), idx));
802 cmb_show_avg_sample_interval(struct device *dev, struct device_attribute *attr, char *buf)
804 struct ccw_device *cdev;
808 cdev = to_ccwdev(dev);
809 interval = get_clock() - cdev->private->cmb_start_time;
810 count = cmf_read(cdev, cmb_sample_count);
815 return sprintf(buf, "%ld\n", interval);
819 cmb_show_avg_utilization(struct device *dev, struct device_attribute *attr, char *buf)
826 ret = cmf_readall(to_ccwdev(dev), &data);
830 utilization = data.device_connect_time +
831 data.function_pending_time +
832 data.device_disconnect_time;
834 /* shift to avoid long long division */
835 while (-1ul < (data.elapsed_time | utilization)) {
837 data.elapsed_time >>= 8;
840 /* calculate value in 0.1 percent units */
841 t = (unsigned long) data.elapsed_time / 1000;
842 u = (unsigned long) utilization / t;
844 return sprintf(buf, "%02ld.%01ld%%\n", u/ 10, u - (u/ 10) * 10);
847 #define cmf_attr(name) \
848 static ssize_t show_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
849 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
850 static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
852 #define cmf_attr_avg(name) \
853 static ssize_t show_avg_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
854 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
855 static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
857 cmf_attr(ssch_rsch_count);
858 cmf_attr(sample_count);
859 cmf_attr_avg(device_connect_time);
860 cmf_attr_avg(function_pending_time);
861 cmf_attr_avg(device_disconnect_time);
862 cmf_attr_avg(control_unit_queuing_time);
863 cmf_attr_avg(device_active_only_time);
864 cmf_attr_avg(device_busy_time);
865 cmf_attr_avg(initial_command_response_time);
867 static DEVICE_ATTR(avg_sample_interval, 0444, cmb_show_avg_sample_interval, NULL);
868 static DEVICE_ATTR(avg_utilization, 0444, cmb_show_avg_utilization, NULL);
870 static struct attribute *cmf_attributes[] = {
871 &dev_attr_avg_sample_interval.attr,
872 &dev_attr_avg_utilization.attr,
873 &dev_attr_ssch_rsch_count.attr,
874 &dev_attr_sample_count.attr,
875 &dev_attr_avg_device_connect_time.attr,
876 &dev_attr_avg_function_pending_time.attr,
877 &dev_attr_avg_device_disconnect_time.attr,
878 &dev_attr_avg_control_unit_queuing_time.attr,
879 &dev_attr_avg_device_active_only_time.attr,
883 static struct attribute_group cmf_attr_group = {
885 .attrs = cmf_attributes,
888 static struct attribute *cmf_attributes_ext[] = {
889 &dev_attr_avg_sample_interval.attr,
890 &dev_attr_avg_utilization.attr,
891 &dev_attr_ssch_rsch_count.attr,
892 &dev_attr_sample_count.attr,
893 &dev_attr_avg_device_connect_time.attr,
894 &dev_attr_avg_function_pending_time.attr,
895 &dev_attr_avg_device_disconnect_time.attr,
896 &dev_attr_avg_control_unit_queuing_time.attr,
897 &dev_attr_avg_device_active_only_time.attr,
898 &dev_attr_avg_device_busy_time.attr,
899 &dev_attr_avg_initial_command_response_time.attr,
903 static struct attribute_group cmf_attr_group_ext = {
905 .attrs = cmf_attributes_ext,
908 static ssize_t cmb_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
910 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
913 static ssize_t cmb_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t c)
915 struct ccw_device *cdev;
918 cdev = to_ccwdev(dev);
922 ret = disable_cmf(cdev);
924 printk(KERN_INFO "disable_cmf failed (%d)\n", ret);
927 ret = enable_cmf(cdev);
928 if (ret && ret != -EBUSY)
929 printk(KERN_INFO "enable_cmf failed (%d)\n", ret);
936 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
938 /* enable_cmf/disable_cmf: module interface for cmf (de)activation */
940 enable_cmf(struct ccw_device *cdev)
944 ret = cmbops->alloc(cdev);
948 ret = cmbops->set(cdev, 2);
953 ret = sysfs_create_group(&cdev->dev.kobj, cmbops->attr_group);
956 cmbops->set(cdev, 0); //FIXME: this can fail
962 disable_cmf(struct ccw_device *cdev)
966 ret = cmbops->set(cdev, 0);
970 sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
975 cmf_read(struct ccw_device *cdev, int index)
977 return cmbops->read(cdev, index);
981 cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
983 return cmbops->readall(cdev, data);
990 char *detect_string = "parameter";
992 /* We cannot really autoprobe this. If the user did not give a parameter,
993 see if we are running on z990 or up, otherwise fall back to basic mode. */
995 if (format == CMF_AUTODETECT) {
996 if (!css_characteristics_avail ||
997 !css_general_characteristics.ext_mb) {
1000 format = CMF_EXTENDED;
1002 detect_string = "autodetected";
1004 detect_string = "parameter";
1009 format_string = "basic";
1010 cmbops = &cmbops_basic;
1011 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1012 printk(KERN_ERR "Basic channel measurement facility"
1013 " can only use 1 to 4096 devices\n"
1014 KERN_ERR "when the cmf driver is built"
1015 " as a loadable module\n");
1020 format_string = "extended";
1021 cmbops = &cmbops_extended;
1024 printk(KERN_ERR "Invalid format %d for channel "
1025 "measurement facility\n", format);
1029 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n",
1030 format_string, detect_string);
1034 module_init(init_cmf);
1037 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
1038 MODULE_LICENSE("GPL");
1039 MODULE_DESCRIPTION("channel measurement facility base driver\n"
1040 "Copyright 2003 IBM Corporation\n");
1042 EXPORT_SYMBOL_GPL(enable_cmf);
1043 EXPORT_SYMBOL_GPL(disable_cmf);
1044 EXPORT_SYMBOL_GPL(cmf_read);
1045 EXPORT_SYMBOL_GPL(cmf_readall);