2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.13 $)
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>
43 /* parameter to enable cmf during boot, possible uses are:
44 * "s390cmf" -- enable cmf and allocate 2 MB of ram so measuring can be
45 * used on any subchannel
46 * "s390cmf=<num>" -- enable cmf and allocate enough memory to measure
47 * <num> subchannel, where <num> is an integer
48 * between 1 and 65535, default is 1024
50 #define ARGSTRING "s390cmf"
52 /* indices for READCMB */
54 /* basic and exended format: */
57 cmb_device_connect_time,
58 cmb_function_pending_time,
59 cmb_device_disconnect_time,
60 cmb_control_unit_queuing_time,
61 cmb_device_active_only_time,
62 /* extended format only: */
64 cmb_initial_command_response_time,
68 * enum cmb_format - types of supported measurement block formats
70 * @CMF_BASIC: traditional channel measurement blocks supported
71 * by all machines that we run on
72 * @CMF_EXTENDED: improved format that was introduced with the z990
74 * @CMF_AUTODETECT: default: use extended format when running on a z990
75 * or later machine, otherwise fall back to basic format
83 * format - actual format for all measurement blocks
85 * The format module parameter can be set to a value of 0 (zero)
86 * or 1, indicating basic or extended format as described for
89 static int format = CMF_AUTODETECT;
90 module_param(format, bool, 0444);
93 * struct cmb_operations - functions to use depending on cmb_format
95 * all these functions operate on a struct cmf_device. There is only
96 * one instance of struct cmb_operations because all cmf_device
97 * objects are guaranteed to be of the same type.
99 * @alloc: allocate memory for a channel measurement block,
100 * either with the help of a special pool or with kmalloc
101 * @free: free memory allocated with @alloc
102 * @set: enable or disable measurement
103 * @readall: read a measurement block in a common format
104 * @reset: clear the data in the associated measurement block and
105 * reset its time stamp
107 struct cmb_operations {
108 int (*alloc) (struct ccw_device*);
109 void(*free) (struct ccw_device*);
110 int (*set) (struct ccw_device*, u32);
111 u64 (*read) (struct ccw_device*, int);
112 int (*readall)(struct ccw_device*, struct cmbdata *);
113 void (*reset) (struct ccw_device*);
115 struct attribute_group *attr_group;
117 static struct cmb_operations *cmbops;
119 /* our user interface is designed in terms of nanoseconds,
120 * while the hardware measures total times in its own
122 static inline u64 time_to_nsec(u32 value)
124 return ((u64)value) * 128000ull;
128 * Users are usually interested in average times,
129 * not accumulated time.
130 * This also helps us with atomicity problems
131 * when reading sinlge values.
133 static inline u64 time_to_avg_nsec(u32 value, u32 count)
137 /* no samples yet, avoid division by 0 */
141 /* value comes in units of 128 µsec */
142 ret = time_to_nsec(value);
148 /* activate or deactivate the channel monitor. When area is NULL,
149 * the monitor is deactivated. The channel monitor needs to
150 * be active in order to measure subchannels, which also need
153 cmf_activate(void *area, unsigned int onoff)
155 register void * __gpr2 asm("2");
156 register long __gpr1 asm("1");
159 __gpr1 = onoff ? 2 : 0;
160 /* activate channel measurement */
161 asm("schm" : : "d" (__gpr2), "d" (__gpr1) );
165 set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
169 struct subchannel *sch;
172 sch = to_subchannel(cdev->dev.parent);
174 /* msch can silently fail, so do it again if necessary */
175 for (retry = 0; retry < 3; retry++) {
177 stsch(sch->irq, schib);
178 schib->pmcw.mme = mme;
179 schib->pmcw.mbfc = mbfc;
180 /* address can be either a block address or a block index */
182 schib->mba = address;
184 schib->pmcw.mbi = address;
186 /* try to submit it */
187 switch(ret = msch_err(sch->irq, schib)) {
191 case 2: /* in I/O or status pending */
194 case 3: /* subchannel is no longer valid */
197 default: /* msch caught an exception */
201 stsch(sch->irq, schib); /* restore the schib */
206 /* check if it worked */
207 if (schib->pmcw.mme == mme &&
208 schib->pmcw.mbfc == mbfc &&
209 (mbfc ? (schib->mba == address)
210 : (schib->pmcw.mbi == address)))
219 struct set_schib_struct {
222 unsigned long address;
223 wait_queue_head_t wait;
227 static int set_schib_wait(struct ccw_device *cdev, u32 mme,
228 int mbfc, unsigned long address)
230 struct set_schib_struct s = {
234 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s.wait),
237 spin_lock_irq(cdev->ccwlock);
238 s.ret = set_schib(cdev, mme, mbfc, address);
239 if (s.ret != -EBUSY) {
243 if (cdev->private->state != DEV_STATE_ONLINE) {
245 /* if the device is not online, don't even try again */
248 cdev->private->state = DEV_STATE_CMFCHANGE;
249 cdev->private->cmb_wait = &s;
252 spin_unlock_irq(cdev->ccwlock);
253 if (wait_event_interruptible(s.wait, s.ret != 1)) {
254 spin_lock_irq(cdev->ccwlock);
256 s.ret = -ERESTARTSYS;
257 cdev->private->cmb_wait = 0;
258 if (cdev->private->state == DEV_STATE_CMFCHANGE)
259 cdev->private->state = DEV_STATE_ONLINE;
261 spin_unlock_irq(cdev->ccwlock);
266 spin_unlock_irq(cdev->ccwlock);
270 void retry_set_schib(struct ccw_device *cdev)
272 struct set_schib_struct *s;
274 s = cdev->private->cmb_wait;
275 cdev->private->cmb_wait = 0;
280 s->ret = set_schib(cdev, s->mme, s->mbfc, s->address);
285 * struct cmb_area - container for global cmb data
287 * @mem: pointer to CMBs (only in basic measurement mode)
288 * @list: contains a linked list of all subchannels
289 * @lock: protect concurrent access to @mem and @list
293 struct list_head list;
298 static struct cmb_area cmb_area = {
299 .lock = SPIN_LOCK_UNLOCKED,
300 .list = LIST_HEAD_INIT(cmb_area.list),
301 .num_channels = 1024,
305 /* ****** old style CMB handling ********/
309 * Basic channel measurement blocks are allocated in one contiguous
310 * block of memory, which can not be moved as long as any channel
311 * is active. Therefore, a maximum number of subchannels needs to
312 * be defined somewhere. This is a module parameter, defaulting to
313 * a resonable value of 1024, or 32 kb of memory.
314 * Current kernels don't allow kmalloc with more than 128kb, so the
318 module_param_named(maxchannels, cmb_area.num_channels, uint, 0444);
321 * struct cmb - basic channel measurement block
323 * cmb as used by the hardware the fields are described in z/Architecture
324 * Principles of Operation, chapter 17.
325 * The area to be a contiguous array and may not be reallocated or freed.
326 * Only one cmb area can be present in the system.
331 u32 device_connect_time;
332 u32 function_pending_time;
333 u32 device_disconnect_time;
334 u32 control_unit_queuing_time;
335 u32 device_active_only_time;
339 /* insert a single device into the cmb_area list
340 * called with cmb_area.lock held from alloc_cmb
343 alloc_cmb_single (struct ccw_device *cdev)
346 struct ccw_device_private *node;
349 spin_lock_irq(cdev->ccwlock);
350 if (!list_empty(&cdev->private->cmb_list)) {
355 /* find first unused cmb in cmb_area.mem.
356 * this is a little tricky: cmb_area.list
357 * remains sorted by ->cmb pointers */
359 list_for_each_entry(node, &cmb_area.list, cmb_list) {
360 if ((struct cmb*)node->cmb > cmb)
364 if (cmb - cmb_area.mem >= cmb_area.num_channels) {
370 list_add_tail(&cdev->private->cmb_list, &node->cmb_list);
371 cdev->private->cmb = cmb;
374 spin_unlock_irq(cdev->ccwlock);
379 alloc_cmb (struct ccw_device *cdev)
385 spin_lock(&cmb_area.lock);
388 /* there is no user yet, so we need a new area */
389 size = sizeof(struct cmb) * cmb_area.num_channels;
390 WARN_ON(!list_empty(&cmb_area.list));
392 spin_unlock(&cmb_area.lock);
393 mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
395 spin_lock(&cmb_area.lock);
398 /* ok, another thread was faster */
399 free_pages((unsigned long)mem, get_order(size));
406 memset(mem, 0, size);
408 cmf_activate(cmb_area.mem, 1);
412 /* do the actual allocation */
413 ret = alloc_cmb_single(cdev);
415 spin_unlock(&cmb_area.lock);
421 free_cmb(struct ccw_device *cdev)
423 struct ccw_device_private *priv;
425 priv = cdev->private;
427 spin_lock(&cmb_area.lock);
428 spin_lock_irq(cdev->ccwlock);
430 if (list_empty(&priv->cmb_list)) {
436 list_del_init(&priv->cmb_list);
438 if (list_empty(&cmb_area.list)) {
440 size = sizeof(struct cmb) * cmb_area.num_channels;
441 cmf_activate(NULL, 0);
442 free_pages((unsigned long)cmb_area.mem, get_order(size));
446 spin_unlock_irq(cdev->ccwlock);
447 spin_unlock(&cmb_area.lock);
451 set_cmb(struct ccw_device *cdev, u32 mme)
455 if (!cdev->private->cmb)
458 offset = mme ? (struct cmb *)cdev->private->cmb - cmb_area.mem : 0;
460 return set_schib_wait(cdev, mme, 0, offset);
464 read_cmb (struct ccw_device *cdev, int index)
466 /* yes, we have to put it on the stack
467 * because the cmb must only be accessed
468 * atomically, e.g. with mvc */
473 spin_lock_irqsave(cdev->ccwlock, flags);
474 if (!cdev->private->cmb) {
475 spin_unlock_irqrestore(cdev->ccwlock, flags);
479 cmb = *(struct cmb*)cdev->private->cmb;
480 spin_unlock_irqrestore(cdev->ccwlock, flags);
483 case cmb_ssch_rsch_count:
484 return cmb.ssch_rsch_count;
485 case cmb_sample_count:
486 return cmb.sample_count;
487 case cmb_device_connect_time:
488 val = cmb.device_connect_time;
490 case cmb_function_pending_time:
491 val = cmb.function_pending_time;
493 case cmb_device_disconnect_time:
494 val = cmb.device_disconnect_time;
496 case cmb_control_unit_queuing_time:
497 val = cmb.control_unit_queuing_time;
499 case cmb_device_active_only_time:
500 val = cmb.device_active_only_time;
505 return time_to_avg_nsec(val, cmb.sample_count);
509 readall_cmb (struct ccw_device *cdev, struct cmbdata *data)
511 /* yes, we have to put it on the stack
512 * because the cmb must only be accessed
513 * atomically, e.g. with mvc */
518 spin_lock_irqsave(cdev->ccwlock, flags);
519 if (!cdev->private->cmb) {
520 spin_unlock_irqrestore(cdev->ccwlock, flags);
524 cmb = *(struct cmb*)cdev->private->cmb;
525 time = get_clock() - cdev->private->cmb_start_time;
526 spin_unlock_irqrestore(cdev->ccwlock, flags);
528 *data = (struct cmbdata) {
529 /* we only know values before device_busy_time */
530 .size = offsetof(struct cmbdata, device_busy_time),
532 /* conver to nanoseconds */
533 .elapsed_time = (time * 1000) >> 12,
535 /* copy data to new structure */
536 .ssch_rsch_count = cmb.ssch_rsch_count,
537 .sample_count = cmb.sample_count,
539 /* time fields are converted to nanoseconds while copying */
541 = time_to_nsec(cmb.device_connect_time),
542 .function_pending_time
543 = time_to_nsec(cmb.function_pending_time),
544 .device_disconnect_time
545 = time_to_nsec(cmb.device_disconnect_time),
546 .control_unit_queuing_time
547 = time_to_nsec(cmb.control_unit_queuing_time),
548 .device_active_only_time
549 = time_to_nsec(cmb.device_active_only_time),
556 reset_cmb(struct ccw_device *cdev)
559 spin_lock_irq(cdev->ccwlock);
560 cmb = cdev->private->cmb;
562 memset (cmb, 0, sizeof (*cmb));
563 cdev->private->cmb_start_time = get_clock();
564 spin_unlock_irq(cdev->ccwlock);
567 static struct attribute_group cmf_attr_group;
569 static struct cmb_operations cmbops_basic = {
574 .readall = readall_cmb,
576 .attr_group = &cmf_attr_group,
579 /* ******** extended cmb handling ********/
582 * struct cmbe - extended channel measurement block
584 * cmb as used by the hardware, may be in any 64 bit physical location,
585 * the fields are described in z/Architecture Principles of Operation,
586 * third edition, chapter 17.
591 u32 device_connect_time;
592 u32 function_pending_time;
593 u32 device_disconnect_time;
594 u32 control_unit_queuing_time;
595 u32 device_active_only_time;
596 u32 device_busy_time;
597 u32 initial_command_response_time;
601 /* kmalloc only guarantees 8 byte alignment, but we need cmbe
602 * pointers to be naturally aligned. Make sure to allocate
603 * enough space for two cmbes */
604 static inline struct cmbe* cmbe_align(struct cmbe *c)
607 addr = ((unsigned long)c + sizeof (struct cmbe) - sizeof(long)) &
608 ~(sizeof (struct cmbe) - sizeof(long));
609 return (struct cmbe*)addr;
613 alloc_cmbe (struct ccw_device *cdev)
616 cmbe = kmalloc (sizeof (*cmbe) * 2, GFP_KERNEL);
620 spin_lock_irq(cdev->ccwlock);
621 if (cdev->private->cmb) {
623 spin_unlock_irq(cdev->ccwlock);
627 cdev->private->cmb = cmbe;
628 spin_unlock_irq(cdev->ccwlock);
630 /* activate global measurement if this is the first channel */
631 spin_lock(&cmb_area.lock);
632 if (list_empty(&cmb_area.list))
633 cmf_activate(NULL, 1);
634 list_add_tail(&cdev->private->cmb_list, &cmb_area.list);
635 spin_unlock(&cmb_area.lock);
641 free_cmbe (struct ccw_device *cdev)
643 spin_lock_irq(cdev->ccwlock);
644 if (cdev->private->cmb)
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 *data = (struct cmbdata) {
742 /* we only know values before device_busy_time */
743 .size = offsetof(struct cmbdata, device_busy_time),
745 /* conver to nanoseconds */
746 .elapsed_time = (time * 1000) >> 12,
748 /* copy data to new structure */
749 .ssch_rsch_count = cmb.ssch_rsch_count,
750 .sample_count = cmb.sample_count,
752 /* time fields are converted to nanoseconds while copying */
754 = time_to_nsec(cmb.device_connect_time),
755 .function_pending_time
756 = time_to_nsec(cmb.function_pending_time),
757 .device_disconnect_time
758 = time_to_nsec(cmb.device_disconnect_time),
759 .control_unit_queuing_time
760 = time_to_nsec(cmb.control_unit_queuing_time),
761 .device_active_only_time
762 = time_to_nsec(cmb.device_active_only_time),
764 = time_to_nsec(cmb.device_busy_time),
765 .initial_command_response_time
766 = time_to_nsec(cmb.initial_command_response_time),
773 reset_cmbe(struct ccw_device *cdev)
776 spin_lock_irq(cdev->ccwlock);
777 cmb = cmbe_align(cdev->private->cmb);
779 memset (cmb, 0, sizeof (*cmb));
780 cdev->private->cmb_start_time = get_clock();
781 spin_unlock_irq(cdev->ccwlock);
784 static struct attribute_group cmf_attr_group_ext;
786 static struct cmb_operations cmbops_extended = {
791 .readall = readall_cmbe,
793 .attr_group = &cmf_attr_group_ext,
798 cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
800 return sprintf(buf, "%lld\n",
801 (unsigned long long) cmf_read(to_ccwdev(dev), idx));
805 cmb_show_avg_sample_interval(struct device *dev, char *buf)
807 struct ccw_device *cdev;
811 cdev = to_ccwdev(dev);
812 interval = get_clock() - cdev->private->cmb_start_time;
813 count = cmf_read(cdev, cmb_sample_count);
818 return sprintf(buf, "%ld\n", interval);
822 cmb_show_avg_utilization(struct device *dev, char *buf)
829 ret = cmf_readall(to_ccwdev(dev), &data);
833 utilization = data.device_connect_time +
834 data.function_pending_time +
835 data.device_disconnect_time;
837 /* shift to avoid long long division */
838 while (-1ul < (data.elapsed_time | utilization)) {
840 data.elapsed_time >>= 8;
843 /* calculate value in 0.1 percent units */
844 t = (unsigned long) data.elapsed_time / 1000;
845 u = (unsigned long) utilization / t;
847 return sprintf(buf, "%02ld.%01ld%%\n", u/ 10, u - (u/ 10) * 10);
850 #define cmf_attr(name) \
851 static ssize_t show_ ## name (struct device * dev, char * buf) \
852 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
853 static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
855 #define cmf_attr_avg(name) \
856 static ssize_t show_avg_ ## name (struct device * dev, char * buf) \
857 { return cmb_show_attr((dev), buf, cmb_ ## name); } \
858 static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
860 cmf_attr(ssch_rsch_count);
861 cmf_attr(sample_count);
862 cmf_attr_avg(device_connect_time);
863 cmf_attr_avg(function_pending_time);
864 cmf_attr_avg(device_disconnect_time);
865 cmf_attr_avg(control_unit_queuing_time);
866 cmf_attr_avg(device_active_only_time);
867 cmf_attr_avg(device_busy_time);
868 cmf_attr_avg(initial_command_response_time);
870 static DEVICE_ATTR(avg_sample_interval, 0444, cmb_show_avg_sample_interval, NULL);
871 static DEVICE_ATTR(avg_utilization, 0444, cmb_show_avg_utilization, NULL);
873 static struct attribute *cmf_attributes[] = {
874 &dev_attr_avg_sample_interval.attr,
875 &dev_attr_avg_utilization.attr,
876 &dev_attr_ssch_rsch_count.attr,
877 &dev_attr_sample_count.attr,
878 &dev_attr_avg_device_connect_time.attr,
879 &dev_attr_avg_function_pending_time.attr,
880 &dev_attr_avg_device_disconnect_time.attr,
881 &dev_attr_avg_control_unit_queuing_time.attr,
882 &dev_attr_avg_device_active_only_time.attr,
886 static struct attribute_group cmf_attr_group = {
888 .attrs = cmf_attributes,
891 static struct attribute *cmf_attributes_ext[] = {
892 &dev_attr_avg_sample_interval.attr,
893 &dev_attr_avg_utilization.attr,
894 &dev_attr_ssch_rsch_count.attr,
895 &dev_attr_sample_count.attr,
896 &dev_attr_avg_device_connect_time.attr,
897 &dev_attr_avg_function_pending_time.attr,
898 &dev_attr_avg_device_disconnect_time.attr,
899 &dev_attr_avg_control_unit_queuing_time.attr,
900 &dev_attr_avg_device_active_only_time.attr,
901 &dev_attr_avg_device_busy_time.attr,
902 &dev_attr_avg_initial_command_response_time.attr,
906 static struct attribute_group cmf_attr_group_ext = {
908 .attrs = cmf_attributes_ext,
911 static ssize_t cmb_enable_show(struct device *dev, char *buf)
913 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
916 static ssize_t cmb_enable_store(struct device *dev, const char *buf, size_t c)
918 struct ccw_device *cdev;
921 cdev = to_ccwdev(dev);
925 ret = disable_cmf(cdev);
927 printk(KERN_INFO "disable_cmf failed (%d)\n", ret);
930 ret = enable_cmf(cdev);
931 if (ret && ret != -EBUSY)
932 printk(KERN_INFO "enable_cmf failed (%d)\n", ret);
939 DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
941 /* enable_cmf/disable_cmf: module interface for cmf (de)activation */
943 enable_cmf(struct ccw_device *cdev)
947 ret = cmbops->alloc(cdev);
951 ret = cmbops->set(cdev, 2);
956 ret = sysfs_create_group(&cdev->dev.kobj, cmbops->attr_group);
959 cmbops->set(cdev, 0); //FIXME: this can fail
965 disable_cmf(struct ccw_device *cdev)
969 ret = cmbops->set(cdev, 0);
973 sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
978 cmf_read(struct ccw_device *cdev, int index)
980 return cmbops->read(cdev, index);
984 cmf_readall(struct ccw_device *cdev, struct cmbdata *data)
986 return cmbops->readall(cdev, data);
993 char *detect_string = "parameter";
995 /* We cannot really autoprobe this. If the user did not give a parameter,
996 see if we are running on z990 or up, otherwise fall back to basic mode. */
998 if (format == CMF_AUTODETECT) {
999 if (!MACHINE_NEW_STIDP) {
1002 format = CMF_EXTENDED;
1004 detect_string = "autodetected";
1006 detect_string = "parameter";
1011 format_string = "basic";
1012 cmbops = &cmbops_basic;
1013 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1014 printk(KERN_ERR "Basic channel measurement facility"
1015 " can only use 1 to 4096 devices\n"
1016 KERN_ERR "when the cmf driver is built"
1017 " as a loadable module\n");
1022 format_string = "extended";
1023 cmbops = &cmbops_extended;
1026 printk(KERN_ERR "Invalid format %d for channel "
1027 "measurement facility\n", format);
1031 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n",
1032 format_string, detect_string);
1036 module_init(init_cmf);
1039 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
1040 MODULE_LICENSE("GPL");
1041 MODULE_DESCRIPTION("channel measurement facility base driver\n"
1042 "Copyright 2003 IBM Corporation\n");
1044 EXPORT_SYMBOL_GPL(enable_cmf);
1045 EXPORT_SYMBOL_GPL(disable_cmf);
1046 EXPORT_SYMBOL_GPL(cmf_read);
1047 EXPORT_SYMBOL_GPL(cmf_readall);