2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.19 $)
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->schid, 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->schid, 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->schid, 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 kfree(cdev->private->cmb);
646 cdev->private->cmb = NULL;
647 spin_unlock_irq(cdev->ccwlock);
649 /* deactivate global measurement if this is the last channel */
650 spin_lock(&cmb_area.lock);
651 list_del_init(&cdev->private->cmb_list);
652 if (list_empty(&cmb_area.list))
653 cmf_activate(NULL, 0);
654 spin_unlock(&cmb_area.lock);
658 set_cmbe(struct ccw_device *cdev, u32 mme)
662 if (!cdev->private->cmb)
664 mba = mme ? (unsigned long) cmbe_align(cdev->private->cmb) : 0;
666 return set_schib_wait(cdev, mme, 1, mba);
671 read_cmbe (struct ccw_device *cdev, int index)
673 /* yes, we have to put it on the stack
674 * because the cmb must only be accessed
675 * atomically, e.g. with mvc */
680 spin_lock_irqsave(cdev->ccwlock, flags);
681 if (!cdev->private->cmb) {
682 spin_unlock_irqrestore(cdev->ccwlock, flags);
686 cmb = *cmbe_align(cdev->private->cmb);
687 spin_unlock_irqrestore(cdev->ccwlock, flags);
690 case cmb_ssch_rsch_count:
691 return cmb.ssch_rsch_count;
692 case cmb_sample_count:
693 return cmb.sample_count;
694 case cmb_device_connect_time:
695 val = cmb.device_connect_time;
697 case cmb_function_pending_time:
698 val = cmb.function_pending_time;
700 case cmb_device_disconnect_time:
701 val = cmb.device_disconnect_time;
703 case cmb_control_unit_queuing_time:
704 val = cmb.control_unit_queuing_time;
706 case cmb_device_active_only_time:
707 val = cmb.device_active_only_time;
709 case cmb_device_busy_time:
710 val = cmb.device_busy_time;
712 case cmb_initial_command_response_time:
713 val = cmb.initial_command_response_time;
718 return time_to_avg_nsec(val, cmb.sample_count);
722 readall_cmbe (struct ccw_device *cdev, struct cmbdata *data)
724 /* yes, we have to put it on the stack
725 * because the cmb must only be accessed
726 * atomically, e.g. with mvc */
731 spin_lock_irqsave(cdev->ccwlock, flags);
732 if (!cdev->private->cmb) {
733 spin_unlock_irqrestore(cdev->ccwlock, flags);
737 cmb = *cmbe_align(cdev->private->cmb);
738 time = get_clock() - cdev->private->cmb_start_time;
739 spin_unlock_irqrestore(cdev->ccwlock, flags);
741 memset (data, 0, sizeof(struct cmbdata));
743 /* we only know values before device_busy_time */
744 data->size = offsetof(struct cmbdata, device_busy_time);
746 /* conver to nanoseconds */
747 data->elapsed_time = (time * 1000) >> 12;
749 /* copy data to new structure */
750 data->ssch_rsch_count = cmb.ssch_rsch_count;
751 data->sample_count = cmb.sample_count;
753 /* time fields are converted to nanoseconds while copying */
754 data->device_connect_time = time_to_nsec(cmb.device_connect_time);
755 data->function_pending_time = time_to_nsec(cmb.function_pending_time);
756 data->device_disconnect_time = time_to_nsec(cmb.device_disconnect_time);
757 data->control_unit_queuing_time
758 = time_to_nsec(cmb.control_unit_queuing_time);
759 data->device_active_only_time
760 = time_to_nsec(cmb.device_active_only_time);
761 data->device_busy_time = time_to_nsec(cmb.device_busy_time);
762 data->initial_command_response_time
763 = time_to_nsec(cmb.initial_command_response_time);
769 reset_cmbe(struct ccw_device *cdev)
772 spin_lock_irq(cdev->ccwlock);
773 cmb = cmbe_align(cdev->private->cmb);
775 memset (cmb, 0, sizeof (*cmb));
776 cdev->private->cmb_start_time = get_clock();
777 spin_unlock_irq(cdev->ccwlock);
780 static struct attribute_group cmf_attr_group_ext;
782 static struct cmb_operations cmbops_extended = {
787 .readall = readall_cmbe,
789 .attr_group = &cmf_attr_group_ext,
794 cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
796 return sprintf(buf, "%lld\n",
797 (unsigned long long) cmf_read(to_ccwdev(dev), idx));
801 cmb_show_avg_sample_interval(struct device *dev, struct device_attribute *attr, char *buf)
803 struct ccw_device *cdev;
807 cdev = to_ccwdev(dev);
808 interval = get_clock() - cdev->private->cmb_start_time;
809 count = cmf_read(cdev, cmb_sample_count);
814 return sprintf(buf, "%ld\n", interval);
818 cmb_show_avg_utilization(struct device *dev, struct device_attribute *attr, char *buf)
825 ret = cmf_readall(to_ccwdev(dev), &data);
829 utilization = data.device_connect_time +
830 data.function_pending_time +
831 data.device_disconnect_time;
833 /* shift to avoid long long division */
834 while (-1ul < (data.elapsed_time | utilization)) {
836 data.elapsed_time >>= 8;
839 /* calculate value in 0.1 percent units */
840 t = (unsigned long) data.elapsed_time / 1000;
841 u = (unsigned long) utilization / t;
843 return sprintf(buf, "%02ld.%01ld%%\n", u/ 10, u - (u/ 10) * 10);
846 #define cmf_attr(name) \
847 static ssize_t show_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
848 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
849 static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
851 #define cmf_attr_avg(name) \
852 static ssize_t show_avg_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
853 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
854 static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
856 cmf_attr(ssch_rsch_count);
857 cmf_attr(sample_count);
858 cmf_attr_avg(device_connect_time);
859 cmf_attr_avg(function_pending_time);
860 cmf_attr_avg(device_disconnect_time);
861 cmf_attr_avg(control_unit_queuing_time);
862 cmf_attr_avg(device_active_only_time);
863 cmf_attr_avg(device_busy_time);
864 cmf_attr_avg(initial_command_response_time);
866 static DEVICE_ATTR(avg_sample_interval, 0444, cmb_show_avg_sample_interval, NULL);
867 static DEVICE_ATTR(avg_utilization, 0444, cmb_show_avg_utilization, NULL);
869 static struct attribute *cmf_attributes[] = {
870 &dev_attr_avg_sample_interval.attr,
871 &dev_attr_avg_utilization.attr,
872 &dev_attr_ssch_rsch_count.attr,
873 &dev_attr_sample_count.attr,
874 &dev_attr_avg_device_connect_time.attr,
875 &dev_attr_avg_function_pending_time.attr,
876 &dev_attr_avg_device_disconnect_time.attr,
877 &dev_attr_avg_control_unit_queuing_time.attr,
878 &dev_attr_avg_device_active_only_time.attr,
882 static struct attribute_group cmf_attr_group = {
884 .attrs = cmf_attributes,
887 static struct attribute *cmf_attributes_ext[] = {
888 &dev_attr_avg_sample_interval.attr,
889 &dev_attr_avg_utilization.attr,
890 &dev_attr_ssch_rsch_count.attr,
891 &dev_attr_sample_count.attr,
892 &dev_attr_avg_device_connect_time.attr,
893 &dev_attr_avg_function_pending_time.attr,
894 &dev_attr_avg_device_disconnect_time.attr,
895 &dev_attr_avg_control_unit_queuing_time.attr,
896 &dev_attr_avg_device_active_only_time.attr,
897 &dev_attr_avg_device_busy_time.attr,
898 &dev_attr_avg_initial_command_response_time.attr,
902 static struct attribute_group cmf_attr_group_ext = {
904 .attrs = cmf_attributes_ext,
907 static ssize_t cmb_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
909 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
912 static ssize_t cmb_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t c)
914 struct ccw_device *cdev;
917 cdev = to_ccwdev(dev);
921 ret = disable_cmf(cdev);
923 printk(KERN_INFO "disable_cmf failed (%d)\n", ret);
926 ret = enable_cmf(cdev);
927 if (ret && ret != -EBUSY)
928 printk(KERN_INFO "enable_cmf failed (%d)\n", ret);
935 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
937 /* enable_cmf/disable_cmf: module interface for cmf (de)activation */
939 enable_cmf(struct ccw_device *cdev)
943 ret = cmbops->alloc(cdev);
947 ret = cmbops->set(cdev, 2);
952 ret = sysfs_create_group(&cdev->dev.kobj, cmbops->attr_group);
955 cmbops->set(cdev, 0); //FIXME: this can fail
961 disable_cmf(struct ccw_device *cdev)
965 ret = cmbops->set(cdev, 0);
969 sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
974 cmf_read(struct ccw_device *cdev, int index)
976 return cmbops->read(cdev, index);
980 cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
982 return cmbops->readall(cdev, data);
989 char *detect_string = "parameter";
991 /* We cannot really autoprobe this. If the user did not give a parameter,
992 see if we are running on z990 or up, otherwise fall back to basic mode. */
994 if (format == CMF_AUTODETECT) {
995 if (!css_characteristics_avail ||
996 !css_general_characteristics.ext_mb) {
999 format = CMF_EXTENDED;
1001 detect_string = "autodetected";
1003 detect_string = "parameter";
1008 format_string = "basic";
1009 cmbops = &cmbops_basic;
1010 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1011 printk(KERN_ERR "Basic channel measurement facility"
1012 " can only use 1 to 4096 devices\n"
1013 KERN_ERR "when the cmf driver is built"
1014 " as a loadable module\n");
1019 format_string = "extended";
1020 cmbops = &cmbops_extended;
1023 printk(KERN_ERR "Invalid format %d for channel "
1024 "measurement facility\n", format);
1028 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n",
1029 format_string, detect_string);
1033 module_init(init_cmf);
1036 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
1037 MODULE_LICENSE("GPL");
1038 MODULE_DESCRIPTION("channel measurement facility base driver\n"
1039 "Copyright 2003 IBM Corporation\n");
1041 EXPORT_SYMBOL_GPL(enable_cmf);
1042 EXPORT_SYMBOL_GPL(disable_cmf);
1043 EXPORT_SYMBOL_GPL(cmf_read);
1044 EXPORT_SYMBOL_GPL(cmf_readall);