Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/s390/cio/device.c |
| 3 | * bus driver for ccw devices |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 5 | * Copyright IBM Corp. 2002,2008 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Author(s): Arnd Bergmann (arndb@de.ibm.com) |
Cornelia Huck | 4ce3b30 | 2006-01-14 13:21:04 -0800 | [diff] [blame] | 7 | * Cornelia Huck (cornelia.huck@de.ibm.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Martin Schwidefsky (schwidefsky@de.ibm.com) |
| 9 | */ |
Peter Oberparleiter | a7ae2c02 | 2009-12-07 12:51:20 +0100 | [diff] [blame] | 10 | |
| 11 | #define KMSG_COMPONENT "cio" |
| 12 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/spinlock.h> |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/err.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/list.h> |
| 21 | #include <linux/device.h> |
| 22 | #include <linux/workqueue.h> |
Peter Oberparleiter | 90ab133 | 2008-01-26 14:10:52 +0100 | [diff] [blame] | 23 | #include <linux/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | #include <asm/ccwdev.h> |
| 26 | #include <asm/cio.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 27 | #include <asm/param.h> /* HZ */ |
Cornelia Huck | 1842f2b | 2007-10-12 16:11:22 +0200 | [diff] [blame] | 28 | #include <asm/cmb.h> |
Cornelia Huck | 3a3fc29 | 2008-07-14 09:58:58 +0200 | [diff] [blame] | 29 | #include <asm/isc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 31 | #include "chp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "cio.h" |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 33 | #include "cio_debug.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "css.h" |
| 35 | #include "device.h" |
| 36 | #include "ioasm.h" |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 37 | #include "io_sch.h" |
Peter Oberparleiter | ecf5d9e | 2008-10-10 21:33:06 +0200 | [diff] [blame] | 38 | #include "blacklist.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Peter Oberparleiter | 90ab133 | 2008-01-26 14:10:52 +0100 | [diff] [blame] | 40 | static struct timer_list recovery_timer; |
Cornelia Huck | 486d0a0 | 2008-02-19 15:29:23 +0100 | [diff] [blame] | 41 | static DEFINE_SPINLOCK(recovery_lock); |
Peter Oberparleiter | 90ab133 | 2008-01-26 14:10:52 +0100 | [diff] [blame] | 42 | static int recovery_phase; |
| 43 | static const unsigned long recovery_delay[] = { 3, 30, 300 }; |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /******************* bus type handling ***********************/ |
| 46 | |
| 47 | /* The Linux driver model distinguishes between a bus type and |
| 48 | * the bus itself. Of course we only have one channel |
| 49 | * subsystem driver and one channel system per machine, but |
| 50 | * we still use the abstraction. T.R. says it's a good idea. */ |
| 51 | static int |
| 52 | ccw_bus_match (struct device * dev, struct device_driver * drv) |
| 53 | { |
| 54 | struct ccw_device *cdev = to_ccwdev(dev); |
| 55 | struct ccw_driver *cdrv = to_ccwdrv(drv); |
| 56 | const struct ccw_device_id *ids = cdrv->ids, *found; |
| 57 | |
| 58 | if (!ids) |
| 59 | return 0; |
| 60 | |
| 61 | found = ccw_device_id_match(ids, &cdev->id); |
| 62 | if (!found) |
| 63 | return 0; |
| 64 | |
| 65 | cdev->id.driver_info = found->driver_info; |
| 66 | |
| 67 | return 1; |
| 68 | } |
| 69 | |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 70 | /* Store modalias string delimited by prefix/suffix string into buffer with |
| 71 | * specified size. Return length of resulting string (excluding trailing '\0') |
| 72 | * even if string doesn't fit buffer (snprintf semantics). */ |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 73 | static int snprint_alias(char *buf, size_t size, |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 74 | struct ccw_device_id *id, const char *suffix) |
| 75 | { |
| 76 | int len; |
| 77 | |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 78 | len = snprintf(buf, size, "ccw:t%04Xm%02X", id->cu_type, id->cu_model); |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 79 | if (len > size) |
| 80 | return len; |
| 81 | buf += len; |
| 82 | size -= len; |
| 83 | |
| 84 | if (id->dev_type != 0) |
| 85 | len += snprintf(buf, size, "dt%04Xdm%02X%s", id->dev_type, |
| 86 | id->dev_model, suffix); |
| 87 | else |
| 88 | len += snprintf(buf, size, "dtdm%s", suffix); |
| 89 | |
| 90 | return len; |
| 91 | } |
| 92 | |
| 93 | /* Set up environment variables for ccw device uevent. Return 0 on success, |
| 94 | * non-zero otherwise. */ |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 95 | static int ccw_uevent(struct device *dev, struct kobj_uevent_env *env) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
| 97 | struct ccw_device *cdev = to_ccwdev(dev); |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 98 | struct ccw_device_id *id = &(cdev->id); |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 99 | int ret; |
| 100 | char modalias_buf[30]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 102 | /* CU_TYPE= */ |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 103 | ret = add_uevent_var(env, "CU_TYPE=%04X", id->cu_type); |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 104 | if (ret) |
| 105 | return ret; |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 106 | |
| 107 | /* CU_MODEL= */ |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 108 | ret = add_uevent_var(env, "CU_MODEL=%02X", id->cu_model); |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 109 | if (ret) |
| 110 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | /* The next two can be zero, that's ok for us */ |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 113 | /* DEV_TYPE= */ |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 114 | ret = add_uevent_var(env, "DEV_TYPE=%04X", id->dev_type); |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 115 | if (ret) |
| 116 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 118 | /* DEV_MODEL= */ |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 119 | ret = add_uevent_var(env, "DEV_MODEL=%02X", id->dev_model); |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 120 | if (ret) |
| 121 | return ret; |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 122 | |
| 123 | /* MODALIAS= */ |
Cornelia Huck | cfbe9bb | 2007-04-27 16:01:32 +0200 | [diff] [blame] | 124 | snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); |
Kay Sievers | 7eff2e7 | 2007-08-14 15:15:12 +0200 | [diff] [blame] | 125 | ret = add_uevent_var(env, "MODALIAS=%s", modalias_buf); |
| 126 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 129 | struct bus_type ccw_bus_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 131 | static void io_subchannel_irq(struct subchannel *); |
| 132 | static int io_subchannel_probe(struct subchannel *); |
| 133 | static int io_subchannel_remove(struct subchannel *); |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 134 | static void io_subchannel_shutdown(struct subchannel *); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 135 | static int io_subchannel_sch_event(struct subchannel *, int); |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 136 | static int io_subchannel_chp_event(struct subchannel *, struct chp_link *, |
| 137 | int); |
Sebastian Ott | 8ea7f55 | 2009-09-22 22:58:35 +0200 | [diff] [blame] | 138 | static void recovery_func(unsigned long data); |
| 139 | struct workqueue_struct *ccw_device_work; |
| 140 | wait_queue_head_t ccw_device_init_wq; |
| 141 | atomic_t ccw_device_init_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Cornelia Huck | f08adc0 | 2008-07-14 09:59:03 +0200 | [diff] [blame] | 143 | static struct css_device_id io_subchannel_ids[] = { |
| 144 | { .match_flags = 0x1, .type = SUBCHANNEL_TYPE_IO, }, |
| 145 | { /* end of list */ }, |
| 146 | }; |
| 147 | MODULE_DEVICE_TABLE(css, io_subchannel_ids); |
| 148 | |
Cornelia Huck | 93a2759 | 2009-06-16 10:30:23 +0200 | [diff] [blame] | 149 | static int io_subchannel_prepare(struct subchannel *sch) |
| 150 | { |
| 151 | struct ccw_device *cdev; |
| 152 | /* |
| 153 | * Don't allow suspend while a ccw device registration |
| 154 | * is still outstanding. |
| 155 | */ |
| 156 | cdev = sch_get_cdev(sch); |
| 157 | if (cdev && !device_is_registered(&cdev->dev)) |
| 158 | return -EAGAIN; |
| 159 | return 0; |
| 160 | } |
| 161 | |
Sebastian Ott | 8ea7f55 | 2009-09-22 22:58:35 +0200 | [diff] [blame] | 162 | static void io_subchannel_settle(void) |
| 163 | { |
| 164 | wait_event(ccw_device_init_wq, |
| 165 | atomic_read(&ccw_device_init_count) == 0); |
| 166 | flush_workqueue(ccw_device_work); |
| 167 | } |
| 168 | |
Cornelia Huck | f7e5d67 | 2007-05-10 15:45:43 +0200 | [diff] [blame] | 169 | static struct css_driver io_subchannel_driver = { |
Cornelia Huck | 4beee64 | 2008-01-26 14:10:47 +0100 | [diff] [blame] | 170 | .owner = THIS_MODULE, |
Cornelia Huck | f08adc0 | 2008-07-14 09:59:03 +0200 | [diff] [blame] | 171 | .subchannel_type = io_subchannel_ids, |
Cornelia Huck | 25b7bb5 | 2008-01-26 14:10:41 +0100 | [diff] [blame] | 172 | .name = "io_subchannel", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | .irq = io_subchannel_irq, |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 174 | .sch_event = io_subchannel_sch_event, |
| 175 | .chp_event = io_subchannel_chp_event, |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 176 | .probe = io_subchannel_probe, |
| 177 | .remove = io_subchannel_remove, |
| 178 | .shutdown = io_subchannel_shutdown, |
Cornelia Huck | 93a2759 | 2009-06-16 10:30:23 +0200 | [diff] [blame] | 179 | .prepare = io_subchannel_prepare, |
Sebastian Ott | 8ea7f55 | 2009-09-22 22:58:35 +0200 | [diff] [blame] | 180 | .settle = io_subchannel_settle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | }; |
| 182 | |
Sebastian Ott | 2f17644 | 2009-09-22 22:58:33 +0200 | [diff] [blame] | 183 | int __init io_subchannel_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | int ret; |
| 186 | |
| 187 | init_waitqueue_head(&ccw_device_init_wq); |
| 188 | atomic_set(&ccw_device_init_count, 0); |
Peter Oberparleiter | 90ab133 | 2008-01-26 14:10:52 +0100 | [diff] [blame] | 189 | setup_timer(&recovery_timer, recovery_func, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
| 191 | ccw_device_work = create_singlethread_workqueue("cio"); |
| 192 | if (!ccw_device_work) |
Sebastian Ott | 2f17644 | 2009-09-22 22:58:33 +0200 | [diff] [blame] | 193 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | slow_path_wq = create_singlethread_workqueue("kslowcrw"); |
| 195 | if (!slow_path_wq) { |
Sebastian Ott | 2f17644 | 2009-09-22 22:58:33 +0200 | [diff] [blame] | 196 | ret = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | goto out_err; |
| 198 | } |
| 199 | if ((ret = bus_register (&ccw_bus_type))) |
| 200 | goto out_err; |
| 201 | |
Cornelia Huck | 25b7bb5 | 2008-01-26 14:10:41 +0100 | [diff] [blame] | 202 | ret = css_driver_register(&io_subchannel_driver); |
| 203 | if (ret) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | goto out_err; |
| 205 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | return 0; |
| 207 | out_err: |
| 208 | if (ccw_device_work) |
| 209 | destroy_workqueue(ccw_device_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | if (slow_path_wq) |
| 211 | destroy_workqueue(slow_path_wq); |
| 212 | return ret; |
| 213 | } |
| 214 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | /************************ device handling **************************/ |
| 217 | |
| 218 | /* |
| 219 | * A ccw_device has some interfaces in sysfs in addition to the |
| 220 | * standard ones. |
| 221 | * The following entries are designed to export the information which |
| 222 | * resided in 2.4 in /proc/subchannels. Subchannel and device number |
| 223 | * are obvious, so they don't have an entry :) |
| 224 | * TODO: Split chpids and pimpampom up? Where is "in use" in the tree? |
| 225 | */ |
| 226 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 227 | chpids_show (struct device * dev, struct device_attribute *attr, char * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | { |
| 229 | struct subchannel *sch = to_subchannel(dev); |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 230 | struct chsc_ssd_info *ssd = &sch->ssd_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | ssize_t ret = 0; |
| 232 | int chp; |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 233 | int mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | |
Peter Oberparleiter | 7ad6a24 | 2007-04-27 16:01:35 +0200 | [diff] [blame] | 235 | for (chp = 0; chp < 8; chp++) { |
| 236 | mask = 0x80 >> chp; |
| 237 | if (ssd->path_mask & mask) |
| 238 | ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id); |
| 239 | else |
| 240 | ret += sprintf(buf + ret, "00 "); |
| 241 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | ret += sprintf (buf+ret, "\n"); |
| 243 | return min((ssize_t)PAGE_SIZE, ret); |
| 244 | } |
| 245 | |
| 246 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 247 | pimpampom_show (struct device * dev, struct device_attribute *attr, char * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | { |
| 249 | struct subchannel *sch = to_subchannel(dev); |
| 250 | struct pmcw *pmcw = &sch->schib.pmcw; |
| 251 | |
| 252 | return sprintf (buf, "%02x %02x %02x\n", |
| 253 | pmcw->pim, pmcw->pam, pmcw->pom); |
| 254 | } |
| 255 | |
| 256 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 257 | devtype_show (struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | { |
| 259 | struct ccw_device *cdev = to_ccwdev(dev); |
| 260 | struct ccw_device_id *id = &(cdev->id); |
| 261 | |
| 262 | if (id->dev_type != 0) |
| 263 | return sprintf(buf, "%04x/%02x\n", |
| 264 | id->dev_type, id->dev_model); |
| 265 | else |
| 266 | return sprintf(buf, "n/a\n"); |
| 267 | } |
| 268 | |
| 269 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 270 | cutype_show (struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | { |
| 272 | struct ccw_device *cdev = to_ccwdev(dev); |
| 273 | struct ccw_device_id *id = &(cdev->id); |
| 274 | |
| 275 | return sprintf(buf, "%04x/%02x\n", |
| 276 | id->cu_type, id->cu_model); |
| 277 | } |
| 278 | |
| 279 | static ssize_t |
Bastian Blank | f1fc78a | 2005-10-30 15:00:12 -0800 | [diff] [blame] | 280 | modalias_show (struct device *dev, struct device_attribute *attr, char *buf) |
| 281 | { |
| 282 | struct ccw_device *cdev = to_ccwdev(dev); |
| 283 | struct ccw_device_id *id = &(cdev->id); |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 284 | int len; |
Bastian Blank | f1fc78a | 2005-10-30 15:00:12 -0800 | [diff] [blame] | 285 | |
Cornelia Huck | 086a6c6 | 2007-07-17 13:36:08 +0200 | [diff] [blame] | 286 | len = snprint_alias(buf, PAGE_SIZE, id, "\n"); |
Peter Oberparleiter | db0c2d5 | 2006-09-20 15:59:49 +0200 | [diff] [blame] | 287 | |
| 288 | return len > PAGE_SIZE ? PAGE_SIZE : len; |
Bastian Blank | f1fc78a | 2005-10-30 15:00:12 -0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 292 | online_show (struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | { |
| 294 | struct ccw_device *cdev = to_ccwdev(dev); |
| 295 | |
| 296 | return sprintf(buf, cdev->online ? "1\n" : "0\n"); |
| 297 | } |
| 298 | |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 299 | int ccw_device_is_orphan(struct ccw_device *cdev) |
| 300 | { |
| 301 | return sch_is_pseudo_sch(to_subchannel(cdev->dev.parent)); |
| 302 | } |
| 303 | |
Cornelia Huck | ef99516 | 2007-04-27 16:01:39 +0200 | [diff] [blame] | 304 | static void ccw_device_unregister(struct ccw_device *cdev) |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 305 | { |
Sebastian Ott | 7d253b9 | 2009-12-07 12:51:33 +0100 | [diff] [blame^] | 306 | if (device_is_registered(&cdev->dev)) { |
Cornelia Huck | ef99516 | 2007-04-27 16:01:39 +0200 | [diff] [blame] | 307 | device_del(&cdev->dev); |
Sebastian Ott | 3b554a1 | 2009-09-11 10:28:26 +0200 | [diff] [blame] | 308 | /* Release reference from device_initialize(). */ |
| 309 | put_device(&cdev->dev); |
| 310 | } |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 313 | /** |
| 314 | * ccw_device_set_offline() - disable a ccw device for I/O |
| 315 | * @cdev: target ccw device |
| 316 | * |
| 317 | * This function calls the driver's set_offline() function for @cdev, if |
| 318 | * given, and then disables @cdev. |
| 319 | * Returns: |
| 320 | * %0 on success and a negative error value on failure. |
| 321 | * Context: |
| 322 | * enabled, ccw device lock not held |
| 323 | */ |
| 324 | int ccw_device_set_offline(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
| 326 | int ret; |
| 327 | |
| 328 | if (!cdev) |
| 329 | return -ENODEV; |
| 330 | if (!cdev->online || !cdev->drv) |
| 331 | return -EINVAL; |
| 332 | |
| 333 | if (cdev->drv->set_offline) { |
| 334 | ret = cdev->drv->set_offline(cdev); |
| 335 | if (ret != 0) |
| 336 | return ret; |
| 337 | } |
| 338 | cdev->online = 0; |
| 339 | spin_lock_irq(cdev->ccwlock); |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 340 | /* Wait until a final state or DISCONNECTED is reached */ |
| 341 | while (!dev_fsm_final_state(cdev) && |
| 342 | cdev->private->state != DEV_STATE_DISCONNECTED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | spin_unlock_irq(cdev->ccwlock); |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 344 | wait_event(cdev->private->wait_q, (dev_fsm_final_state(cdev) || |
| 345 | cdev->private->state == DEV_STATE_DISCONNECTED)); |
| 346 | spin_lock_irq(cdev->ccwlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 348 | ret = ccw_device_offline(cdev); |
| 349 | if (ret) |
| 350 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | spin_unlock_irq(cdev->ccwlock); |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 352 | wait_event(cdev->private->wait_q, (dev_fsm_final_state(cdev) || |
| 353 | cdev->private->state == DEV_STATE_DISCONNECTED)); |
Peter Oberparleiter | a7ae2c02 | 2009-12-07 12:51:20 +0100 | [diff] [blame] | 354 | /* Inform the user if set offline failed. */ |
| 355 | if (cdev->private->state == DEV_STATE_BOXED) { |
| 356 | pr_warning("%s: The device entered boxed state while " |
| 357 | "being set offline\n", dev_name(&cdev->dev)); |
| 358 | } else if (cdev->private->state == DEV_STATE_NOT_OPER) { |
| 359 | pr_warning("%s: The device stopped operating while " |
| 360 | "being set offline\n", dev_name(&cdev->dev)); |
| 361 | } |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 362 | /* Give up reference from ccw_device_set_online(). */ |
| 363 | put_device(&cdev->dev); |
| 364 | return 0; |
| 365 | |
| 366 | error: |
| 367 | CIO_MSG_EVENT(0, "ccw_device_offline returned %d, device 0.%x.%04x\n", |
| 368 | ret, cdev->private->dev_id.ssid, |
| 369 | cdev->private->dev_id.devno); |
| 370 | cdev->private->state = DEV_STATE_OFFLINE; |
| 371 | dev_fsm_event(cdev, DEV_EVENT_NOTOPER); |
| 372 | spin_unlock_irq(cdev->ccwlock); |
| 373 | /* Give up reference from ccw_device_set_online(). */ |
| 374 | put_device(&cdev->dev); |
| 375 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 378 | /** |
| 379 | * ccw_device_set_online() - enable a ccw device for I/O |
| 380 | * @cdev: target ccw device |
| 381 | * |
| 382 | * This function first enables @cdev and then calls the driver's set_online() |
| 383 | * function for @cdev, if given. If set_online() returns an error, @cdev is |
| 384 | * disabled again. |
| 385 | * Returns: |
| 386 | * %0 on success and a negative error value on failure. |
| 387 | * Context: |
| 388 | * enabled, ccw device lock not held |
| 389 | */ |
| 390 | int ccw_device_set_online(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
| 392 | int ret; |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 393 | int ret2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
| 395 | if (!cdev) |
| 396 | return -ENODEV; |
| 397 | if (cdev->online || !cdev->drv) |
| 398 | return -EINVAL; |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 399 | /* Hold on to an extra reference while device is online. */ |
| 400 | if (!get_device(&cdev->dev)) |
| 401 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | |
| 403 | spin_lock_irq(cdev->ccwlock); |
| 404 | ret = ccw_device_online(cdev); |
| 405 | spin_unlock_irq(cdev->ccwlock); |
| 406 | if (ret == 0) |
| 407 | wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); |
| 408 | else { |
Michael Ernst | 139b83dd | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 409 | CIO_MSG_EVENT(0, "ccw_device_online returned %d, " |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 410 | "device 0.%x.%04x\n", |
| 411 | ret, cdev->private->dev_id.ssid, |
| 412 | cdev->private->dev_id.devno); |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 413 | /* Give up online reference since onlining failed. */ |
| 414 | put_device(&cdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | return ret; |
| 416 | } |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 417 | spin_lock_irq(cdev->ccwlock); |
| 418 | /* Check if online processing was successful */ |
| 419 | if ((cdev->private->state != DEV_STATE_ONLINE) && |
| 420 | (cdev->private->state != DEV_STATE_W4SENSE)) { |
| 421 | spin_unlock_irq(cdev->ccwlock); |
Peter Oberparleiter | a7ae2c02 | 2009-12-07 12:51:20 +0100 | [diff] [blame] | 422 | /* Inform the user that set online failed. */ |
| 423 | if (cdev->private->state == DEV_STATE_BOXED) { |
| 424 | pr_warning("%s: Setting the device online failed " |
| 425 | "because it is boxed\n", |
| 426 | dev_name(&cdev->dev)); |
| 427 | } else if (cdev->private->state == DEV_STATE_NOT_OPER) { |
| 428 | pr_warning("%s: Setting the device online failed " |
| 429 | "because it is not operational\n", |
| 430 | dev_name(&cdev->dev)); |
| 431 | } |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 432 | /* Give up online reference since onlining failed. */ |
| 433 | put_device(&cdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | return -ENODEV; |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 435 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | spin_unlock_irq(cdev->ccwlock); |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 437 | if (cdev->drv->set_online) |
| 438 | ret = cdev->drv->set_online(cdev); |
| 439 | if (ret) |
| 440 | goto rollback; |
| 441 | cdev->online = 1; |
| 442 | return 0; |
| 443 | |
| 444 | rollback: |
| 445 | spin_lock_irq(cdev->ccwlock); |
| 446 | /* Wait until a final state or DISCONNECTED is reached */ |
| 447 | while (!dev_fsm_final_state(cdev) && |
| 448 | cdev->private->state != DEV_STATE_DISCONNECTED) { |
| 449 | spin_unlock_irq(cdev->ccwlock); |
| 450 | wait_event(cdev->private->wait_q, (dev_fsm_final_state(cdev) || |
| 451 | cdev->private->state == DEV_STATE_DISCONNECTED)); |
| 452 | spin_lock_irq(cdev->ccwlock); |
| 453 | } |
| 454 | ret2 = ccw_device_offline(cdev); |
| 455 | if (ret2) |
| 456 | goto error; |
| 457 | spin_unlock_irq(cdev->ccwlock); |
| 458 | wait_event(cdev->private->wait_q, (dev_fsm_final_state(cdev) || |
| 459 | cdev->private->state == DEV_STATE_DISCONNECTED)); |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 460 | /* Give up online reference since onlining failed. */ |
| 461 | put_device(&cdev->dev); |
Michael Ernst | 217ee6c | 2009-09-11 10:28:21 +0200 | [diff] [blame] | 462 | return ret; |
| 463 | |
| 464 | error: |
| 465 | CIO_MSG_EVENT(0, "rollback ccw_device_offline returned %d, " |
| 466 | "device 0.%x.%04x\n", |
| 467 | ret2, cdev->private->dev_id.ssid, |
| 468 | cdev->private->dev_id.devno); |
| 469 | cdev->private->state = DEV_STATE_OFFLINE; |
| 470 | spin_unlock_irq(cdev->ccwlock); |
| 471 | /* Give up online reference since onlining failed. */ |
| 472 | put_device(&cdev->dev); |
| 473 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Sebastian Ott | e74fe0c | 2009-03-26 15:24:08 +0100 | [diff] [blame] | 476 | static int online_store_handle_offline(struct ccw_device *cdev) |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 477 | { |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 478 | if (cdev->private->state == DEV_STATE_DISCONNECTED) { |
| 479 | spin_lock_irq(cdev->ccwlock); |
| 480 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG_EVAL); |
| 481 | spin_unlock_irq(cdev->ccwlock); |
| 482 | } else if (cdev->online && cdev->drv && cdev->drv->set_offline) |
Sebastian Ott | e74fe0c | 2009-03-26 15:24:08 +0100 | [diff] [blame] | 483 | return ccw_device_set_offline(cdev); |
| 484 | return 0; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | static int online_store_recog_and_online(struct ccw_device *cdev) |
| 488 | { |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 489 | /* Do device recognition, if needed. */ |
Sebastian Ott | 99f6a570 | 2009-03-31 19:16:07 +0200 | [diff] [blame] | 490 | if (cdev->private->state == DEV_STATE_BOXED) { |
Peter Oberparleiter | 1f5bd3848 | 2009-12-07 12:51:23 +0100 | [diff] [blame] | 491 | spin_lock_irq(cdev->ccwlock); |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 492 | ccw_device_recognition(cdev); |
Peter Oberparleiter | 1f5bd3848 | 2009-12-07 12:51:23 +0100 | [diff] [blame] | 493 | spin_unlock_irq(cdev->ccwlock); |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 494 | wait_event(cdev->private->wait_q, |
| 495 | cdev->private->flags.recog_done); |
Sebastian Ott | 156013f | 2009-03-31 19:16:03 +0200 | [diff] [blame] | 496 | if (cdev->private->state != DEV_STATE_OFFLINE) |
| 497 | /* recognition failed */ |
| 498 | return -EAGAIN; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 499 | } |
| 500 | if (cdev->drv && cdev->drv->set_online) |
| 501 | ccw_device_set_online(cdev); |
| 502 | return 0; |
| 503 | } |
Sebastian Ott | 156013f | 2009-03-31 19:16:03 +0200 | [diff] [blame] | 504 | |
Michael Ernst | c78aa6c | 2008-07-14 09:59:22 +0200 | [diff] [blame] | 505 | static int online_store_handle_online(struct ccw_device *cdev, int force) |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 506 | { |
| 507 | int ret; |
| 508 | |
| 509 | ret = online_store_recog_and_online(cdev); |
Sebastian Ott | 156013f | 2009-03-31 19:16:03 +0200 | [diff] [blame] | 510 | if (ret && !force) |
Michael Ernst | c78aa6c | 2008-07-14 09:59:22 +0200 | [diff] [blame] | 511 | return ret; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 512 | if (force && cdev->private->state == DEV_STATE_BOXED) { |
| 513 | ret = ccw_device_stlck(cdev); |
Michael Ernst | c78aa6c | 2008-07-14 09:59:22 +0200 | [diff] [blame] | 514 | if (ret) |
| 515 | return ret; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 516 | if (cdev->id.cu_type == 0) |
| 517 | cdev->private->state = DEV_STATE_NOT_OPER; |
Sebastian Ott | 156013f | 2009-03-31 19:16:03 +0200 | [diff] [blame] | 518 | ret = online_store_recog_and_online(cdev); |
| 519 | if (ret) |
| 520 | return ret; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 521 | } |
Michael Ernst | c78aa6c | 2008-07-14 09:59:22 +0200 | [diff] [blame] | 522 | return 0; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | static ssize_t online_store (struct device *dev, struct device_attribute *attr, |
| 526 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | { |
| 528 | struct ccw_device *cdev = to_ccwdev(dev); |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 529 | int force, ret; |
| 530 | unsigned long i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | |
Peter Oberparleiter | 350e912 | 2009-12-07 12:51:28 +0100 | [diff] [blame] | 532 | if (!dev_fsm_final_state(cdev) && |
| 533 | cdev->private->state != DEV_STATE_DISCONNECTED) |
| 534 | return -EAGAIN; |
| 535 | if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | return -EAGAIN; |
| 537 | |
| 538 | if (cdev->drv && !try_module_get(cdev->drv->owner)) { |
| 539 | atomic_set(&cdev->private->onoff, 0); |
| 540 | return -EINVAL; |
| 541 | } |
| 542 | if (!strncmp(buf, "force\n", count)) { |
| 543 | force = 1; |
| 544 | i = 1; |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 545 | ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | } else { |
| 547 | force = 0; |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 548 | ret = strict_strtoul(buf, 16, &i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | } |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 550 | if (ret) |
| 551 | goto out; |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 552 | switch (i) { |
| 553 | case 0: |
Sebastian Ott | e74fe0c | 2009-03-26 15:24:08 +0100 | [diff] [blame] | 554 | ret = online_store_handle_offline(cdev); |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 555 | break; |
| 556 | case 1: |
Michael Ernst | c78aa6c | 2008-07-14 09:59:22 +0200 | [diff] [blame] | 557 | ret = online_store_handle_online(cdev, force); |
Cornelia Huck | f5ba6c8 | 2007-04-27 16:01:30 +0200 | [diff] [blame] | 558 | break; |
| 559 | default: |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 560 | ret = -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | } |
Cornelia Huck | 2f97220 | 2008-04-30 13:38:33 +0200 | [diff] [blame] | 562 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | if (cdev->drv) |
| 564 | module_put(cdev->drv->owner); |
| 565 | atomic_set(&cdev->private->onoff, 0); |
Sebastian Ott | e74fe0c | 2009-03-26 15:24:08 +0100 | [diff] [blame] | 566 | return (ret < 0) ? ret : count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | static ssize_t |
Yani Ioannou | 3fd3c0a | 2005-05-17 06:43:27 -0400 | [diff] [blame] | 570 | available_show (struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | { |
| 572 | struct ccw_device *cdev = to_ccwdev(dev); |
| 573 | struct subchannel *sch; |
| 574 | |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 575 | if (ccw_device_is_orphan(cdev)) |
| 576 | return sprintf(buf, "no device\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | switch (cdev->private->state) { |
| 578 | case DEV_STATE_BOXED: |
| 579 | return sprintf(buf, "boxed\n"); |
| 580 | case DEV_STATE_DISCONNECTED: |
| 581 | case DEV_STATE_DISCONNECTED_SENSE_ID: |
| 582 | case DEV_STATE_NOT_OPER: |
| 583 | sch = to_subchannel(dev->parent); |
| 584 | if (!sch->lpm) |
| 585 | return sprintf(buf, "no path\n"); |
| 586 | else |
| 587 | return sprintf(buf, "no device\n"); |
| 588 | default: |
| 589 | /* All other states considered fine. */ |
| 590 | return sprintf(buf, "good\n"); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | static DEVICE_ATTR(chpids, 0444, chpids_show, NULL); |
| 595 | static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL); |
| 596 | static DEVICE_ATTR(devtype, 0444, devtype_show, NULL); |
| 597 | static DEVICE_ATTR(cutype, 0444, cutype_show, NULL); |
Bastian Blank | f1fc78a | 2005-10-30 15:00:12 -0800 | [diff] [blame] | 598 | static DEVICE_ATTR(modalias, 0444, modalias_show, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | static DEVICE_ATTR(online, 0644, online_show, online_store); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | static DEVICE_ATTR(availability, 0444, available_show, NULL); |
| 601 | |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 602 | static struct attribute *io_subchannel_attrs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | &dev_attr_chpids.attr, |
| 604 | &dev_attr_pimpampom.attr, |
| 605 | NULL, |
| 606 | }; |
| 607 | |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 608 | static struct attribute_group io_subchannel_attr_group = { |
| 609 | .attrs = io_subchannel_attrs, |
Cornelia Huck | 529192f | 2006-12-08 15:55:57 +0100 | [diff] [blame] | 610 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | |
| 612 | static struct attribute * ccwdev_attrs[] = { |
| 613 | &dev_attr_devtype.attr, |
| 614 | &dev_attr_cutype.attr, |
Bastian Blank | f1fc78a | 2005-10-30 15:00:12 -0800 | [diff] [blame] | 615 | &dev_attr_modalias.attr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | &dev_attr_online.attr, |
| 617 | &dev_attr_cmb_enable.attr, |
| 618 | &dev_attr_availability.attr, |
| 619 | NULL, |
| 620 | }; |
| 621 | |
| 622 | static struct attribute_group ccwdev_attr_group = { |
| 623 | .attrs = ccwdev_attrs, |
| 624 | }; |
| 625 | |
David Brownell | a4dbd67 | 2009-06-24 10:06:31 -0700 | [diff] [blame] | 626 | static const struct attribute_group *ccwdev_attr_groups[] = { |
Cornelia Huck | ef99516 | 2007-04-27 16:01:39 +0200 | [diff] [blame] | 627 | &ccwdev_attr_group, |
| 628 | NULL, |
| 629 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
| 631 | /* this is a simple abstraction for device_register that sets the |
| 632 | * correct bus type and adds the bus specific files */ |
Cornelia Huck | 3c9da7b | 2006-10-27 12:39:33 +0200 | [diff] [blame] | 633 | static int ccw_device_register(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | { |
| 635 | struct device *dev = &cdev->dev; |
| 636 | int ret; |
| 637 | |
| 638 | dev->bus = &ccw_bus_type; |
Sebastian Ott | 3ac276f | 2009-09-11 10:28:27 +0200 | [diff] [blame] | 639 | ret = dev_set_name(&cdev->dev, "0.%x.%04x", cdev->private->dev_id.ssid, |
| 640 | cdev->private->dev_id.devno); |
| 641 | if (ret) |
| 642 | return ret; |
Sebastian Ott | 7d253b9 | 2009-12-07 12:51:33 +0100 | [diff] [blame^] | 643 | return device_add(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } |
| 645 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 646 | static int match_dev_id(struct device *dev, void *data) |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 647 | { |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 648 | struct ccw_device *cdev = to_ccwdev(dev); |
| 649 | struct ccw_dev_id *dev_id = data; |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 650 | |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 651 | return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id); |
| 652 | } |
| 653 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 654 | static struct ccw_device *get_ccwdev_by_dev_id(struct ccw_dev_id *dev_id) |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 655 | { |
| 656 | struct device *dev; |
| 657 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 658 | dev = bus_find_device(&ccw_bus_type, NULL, dev_id, match_dev_id); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 659 | |
| 660 | return dev ? to_ccwdev(dev) : NULL; |
| 661 | } |
| 662 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 663 | static void ccw_device_do_unbind_bind(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | { |
Cornelia Huck | eb32ae8 | 2009-03-26 15:24:05 +0100 | [diff] [blame] | 665 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | |
Sebastian Ott | 7d253b9 | 2009-12-07 12:51:33 +0100 | [diff] [blame^] | 667 | if (device_is_registered(&cdev->dev)) { |
Cornelia Huck | eb32ae8 | 2009-03-26 15:24:05 +0100 | [diff] [blame] | 668 | device_release_driver(&cdev->dev); |
| 669 | ret = device_attach(&cdev->dev); |
| 670 | WARN_ON(ret == -ENODEV); |
| 671 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | static void |
| 675 | ccw_device_release(struct device *dev) |
| 676 | { |
| 677 | struct ccw_device *cdev; |
| 678 | |
| 679 | cdev = to_ccwdev(dev); |
Cornelia Huck | 6eff208 | 2008-12-25 13:39:07 +0100 | [diff] [blame] | 680 | /* Release reference of parent subchannel. */ |
| 681 | put_device(cdev->dev.parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | kfree(cdev->private); |
| 683 | kfree(cdev); |
| 684 | } |
| 685 | |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 686 | static struct ccw_device * io_subchannel_allocate_dev(struct subchannel *sch) |
| 687 | { |
| 688 | struct ccw_device *cdev; |
| 689 | |
| 690 | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); |
| 691 | if (cdev) { |
| 692 | cdev->private = kzalloc(sizeof(struct ccw_device_private), |
| 693 | GFP_KERNEL | GFP_DMA); |
| 694 | if (cdev->private) |
| 695 | return cdev; |
| 696 | } |
| 697 | kfree(cdev); |
| 698 | return ERR_PTR(-ENOMEM); |
| 699 | } |
| 700 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 701 | static void ccw_device_todo(struct work_struct *work); |
| 702 | |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 703 | static int io_subchannel_initialize_dev(struct subchannel *sch, |
| 704 | struct ccw_device *cdev) |
| 705 | { |
| 706 | cdev->private->cdev = cdev; |
| 707 | atomic_set(&cdev->private->onoff, 0); |
| 708 | cdev->dev.parent = &sch->dev; |
| 709 | cdev->dev.release = ccw_device_release; |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 710 | INIT_WORK(&cdev->private->todo_work, ccw_device_todo); |
Cornelia Huck | ef99516 | 2007-04-27 16:01:39 +0200 | [diff] [blame] | 711 | cdev->dev.groups = ccwdev_attr_groups; |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 712 | /* Do first half of device_register. */ |
| 713 | device_initialize(&cdev->dev); |
| 714 | if (!get_device(&sch->dev)) { |
Cornelia Huck | 283fdd0 | 2008-12-25 13:39:10 +0100 | [diff] [blame] | 715 | /* Release reference from device_initialize(). */ |
| 716 | put_device(&cdev->dev); |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 717 | return -ENODEV; |
| 718 | } |
| 719 | return 0; |
| 720 | } |
| 721 | |
| 722 | static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch) |
| 723 | { |
| 724 | struct ccw_device *cdev; |
| 725 | int ret; |
| 726 | |
| 727 | cdev = io_subchannel_allocate_dev(sch); |
| 728 | if (!IS_ERR(cdev)) { |
| 729 | ret = io_subchannel_initialize_dev(sch, cdev); |
Sebastian Ott | 06739a8 | 2009-08-23 18:09:04 +0200 | [diff] [blame] | 730 | if (ret) |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 731 | cdev = ERR_PTR(ret); |
Cornelia Huck | 7674da7 | 2006-12-08 15:54:21 +0100 | [diff] [blame] | 732 | } |
| 733 | return cdev; |
| 734 | } |
| 735 | |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 736 | static void io_subchannel_recog(struct ccw_device *, struct subchannel *); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 737 | |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 738 | static void sch_create_and_recog_new_device(struct subchannel *sch) |
| 739 | { |
| 740 | struct ccw_device *cdev; |
| 741 | |
| 742 | /* Need to allocate a new ccw device. */ |
| 743 | cdev = io_subchannel_create_ccwdev(sch); |
| 744 | if (IS_ERR(cdev)) { |
| 745 | /* OK, we did everything we could... */ |
| 746 | css_sch_device_unregister(sch); |
| 747 | return; |
| 748 | } |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 749 | /* Start recognition for the new ccw device. */ |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 750 | io_subchannel_recog(cdev, sch); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 751 | } |
| 752 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | /* |
| 754 | * Register recognized device. |
| 755 | */ |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 756 | static void io_subchannel_register(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | struct subchannel *sch; |
| 759 | int ret; |
| 760 | unsigned long flags; |
| 761 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | sch = to_subchannel(cdev->dev.parent); |
Cornelia Huck | 5fb6b85 | 2008-12-25 13:39:08 +0100 | [diff] [blame] | 763 | /* |
| 764 | * Check if subchannel is still registered. It may have become |
| 765 | * unregistered if a machine check hit us after finishing |
| 766 | * device recognition but before the register work could be |
| 767 | * queued. |
| 768 | */ |
| 769 | if (!device_is_registered(&sch->dev)) |
| 770 | goto out_err; |
Cornelia Huck | 82b7ac0 | 2007-04-27 16:01:36 +0200 | [diff] [blame] | 771 | css_update_ssd_info(sch); |
Cornelia Huck | 47af551 | 2006-12-04 15:41:07 +0100 | [diff] [blame] | 772 | /* |
| 773 | * io_subchannel_register() will also be called after device |
| 774 | * recognition has been done for a boxed device (which will already |
| 775 | * be registered). We need to reprobe since we may now have sense id |
| 776 | * information. |
| 777 | */ |
Cornelia Huck | d6a3076 | 2008-12-25 13:39:11 +0100 | [diff] [blame] | 778 | if (device_is_registered(&cdev->dev)) { |
Cornelia Huck | 47af551 | 2006-12-04 15:41:07 +0100 | [diff] [blame] | 779 | if (!cdev->drv) { |
| 780 | ret = device_reprobe(&cdev->dev); |
| 781 | if (ret) |
| 782 | /* We can't do much here. */ |
Michael Ernst | 139b83dd | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 783 | CIO_MSG_EVENT(0, "device_reprobe() returned" |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 784 | " %d for 0.%x.%04x\n", ret, |
| 785 | cdev->private->dev_id.ssid, |
| 786 | cdev->private->dev_id.devno); |
Cornelia Huck | 47af551 | 2006-12-04 15:41:07 +0100 | [diff] [blame] | 787 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | goto out; |
| 789 | } |
Cornelia Huck | fa1a8c2 | 2007-04-26 00:12:03 -0700 | [diff] [blame] | 790 | /* |
| 791 | * Now we know this subchannel will stay, we can throw |
| 792 | * our delayed uevent. |
| 793 | */ |
Ming Lei | f67f129 | 2009-03-01 21:10:49 +0800 | [diff] [blame] | 794 | dev_set_uevent_suppress(&sch->dev, 0); |
Cornelia Huck | fa1a8c2 | 2007-04-26 00:12:03 -0700 | [diff] [blame] | 795 | kobject_uevent(&sch->dev.kobj, KOBJ_ADD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | /* make it known to the system */ |
| 797 | ret = ccw_device_register(cdev); |
| 798 | if (ret) { |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 799 | CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n", |
| 800 | cdev->private->dev_id.ssid, |
| 801 | cdev->private->dev_id.devno, ret); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 802 | spin_lock_irqsave(sch->lock, flags); |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 803 | sch_set_cdev(sch, NULL); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 804 | spin_unlock_irqrestore(sch->lock, flags); |
Cornelia Huck | 6eff208 | 2008-12-25 13:39:07 +0100 | [diff] [blame] | 805 | /* Release initial device reference. */ |
| 806 | put_device(&cdev->dev); |
Cornelia Huck | 5fb6b85 | 2008-12-25 13:39:08 +0100 | [diff] [blame] | 807 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | out: |
| 810 | cdev->private->flags.recog_done = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | wake_up(&cdev->private->wait_q); |
Cornelia Huck | 5fb6b85 | 2008-12-25 13:39:08 +0100 | [diff] [blame] | 812 | out_err: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | if (atomic_dec_and_test(&ccw_device_init_count)) |
| 814 | wake_up(&ccw_device_init_wq); |
| 815 | } |
| 816 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 817 | static void ccw_device_call_sch_unregister(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | struct subchannel *sch; |
| 820 | |
Peter Oberparleiter | 46fbe4e | 2008-10-10 21:33:05 +0200 | [diff] [blame] | 821 | /* Get subchannel reference for local processing. */ |
| 822 | if (!get_device(cdev->dev.parent)) |
| 823 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | sch = to_subchannel(cdev->dev.parent); |
Cornelia Huck | 6ab4879 | 2006-07-12 16:39:50 +0200 | [diff] [blame] | 825 | css_sch_device_unregister(sch); |
Peter Oberparleiter | 46fbe4e | 2008-10-10 21:33:05 +0200 | [diff] [blame] | 826 | /* Release subchannel reference for local processing. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | put_device(&sch->dev); |
| 828 | } |
| 829 | |
| 830 | /* |
| 831 | * subchannel recognition done. Called from the state machine. |
| 832 | */ |
| 833 | void |
| 834 | io_subchannel_recog_done(struct ccw_device *cdev) |
| 835 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | if (css_init_done == 0) { |
| 837 | cdev->private->flags.recog_done = 1; |
| 838 | return; |
| 839 | } |
| 840 | switch (cdev->private->state) { |
Sebastian Ott | 47593bf | 2009-03-31 19:16:05 +0200 | [diff] [blame] | 841 | case DEV_STATE_BOXED: |
| 842 | /* Device did not respond in time. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | case DEV_STATE_NOT_OPER: |
| 844 | cdev->private->flags.recog_done = 1; |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 845 | /* Remove device found not operational. */ |
| 846 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | if (atomic_dec_and_test(&ccw_device_init_count)) |
| 848 | wake_up(&ccw_device_init_wq); |
| 849 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | case DEV_STATE_OFFLINE: |
| 851 | /* |
| 852 | * We can't register the device in interrupt context so |
| 853 | * we schedule a work item. |
| 854 | */ |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 855 | ccw_device_sched_todo(cdev, CDEV_TODO_REGISTER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | break; |
| 857 | } |
| 858 | } |
| 859 | |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 860 | static void io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | struct ccw_device_private *priv; |
| 863 | |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 864 | cdev->ccwlock = sch->lock; |
Cornelia Huck | fb6958a | 2006-01-06 00:19:25 -0800 | [diff] [blame] | 865 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | /* Init private data. */ |
| 867 | priv = cdev->private; |
Cornelia Huck | 7896426 | 2006-10-11 15:31:38 +0200 | [diff] [blame] | 868 | priv->dev_id.devno = sch->schib.pmcw.dev; |
| 869 | priv->dev_id.ssid = sch->schid.ssid; |
| 870 | priv->schid = sch->schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | priv->state = DEV_STATE_NOT_OPER; |
| 872 | INIT_LIST_HEAD(&priv->cmb_list); |
| 873 | init_waitqueue_head(&priv->wait_q); |
| 874 | init_timer(&priv->timer); |
| 875 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | /* Increase counter of devices currently in recognition. */ |
| 877 | atomic_inc(&ccw_device_init_count); |
| 878 | |
| 879 | /* Start async. device sensing. */ |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 880 | spin_lock_irq(sch->lock); |
Peter Oberparleiter | 60e4dac | 2009-12-07 12:51:16 +0100 | [diff] [blame] | 881 | sch_set_cdev(sch, cdev); |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 882 | ccw_device_recognition(cdev); |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 883 | spin_unlock_irq(sch->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | } |
| 885 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 886 | static int ccw_device_move_to_sch(struct ccw_device *cdev, |
| 887 | struct subchannel *sch) |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 888 | { |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 889 | struct subchannel *old_sch; |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 890 | int rc; |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 891 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 892 | old_sch = to_subchannel(cdev->dev.parent); |
| 893 | /* Obtain child reference for new parent. */ |
Cornelia Huck | 6eff208 | 2008-12-25 13:39:07 +0100 | [diff] [blame] | 894 | if (!get_device(&sch->dev)) |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 895 | return -ENODEV; |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 896 | mutex_lock(&sch->reg_mutex); |
Cornelia Huck | ffa6a70 | 2009-03-04 12:44:00 +0100 | [diff] [blame] | 897 | rc = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 898 | mutex_unlock(&sch->reg_mutex); |
| 899 | if (rc) { |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 900 | CIO_MSG_EVENT(0, "device_move(0.%x.%04x,0.%x.%04x)=%d\n", |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 901 | cdev->private->dev_id.ssid, |
| 902 | cdev->private->dev_id.devno, sch->schid.ssid, |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 903 | sch->schib.pmcw.dev, rc); |
| 904 | /* Release child reference for new parent. */ |
Cornelia Huck | 6eff208 | 2008-12-25 13:39:07 +0100 | [diff] [blame] | 905 | put_device(&sch->dev); |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 906 | return rc; |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 907 | } |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 908 | /* Clean up old subchannel. */ |
| 909 | if (!sch_is_pseudo_sch(old_sch)) { |
| 910 | spin_lock_irq(old_sch->lock); |
| 911 | sch_set_cdev(old_sch, NULL); |
| 912 | cio_disable_subchannel(old_sch); |
| 913 | spin_unlock_irq(old_sch->lock); |
| 914 | css_schedule_eval(old_sch->schid); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 915 | } |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 916 | /* Release child reference for old parent. */ |
| 917 | put_device(&old_sch->dev); |
| 918 | /* Initialize new subchannel. */ |
| 919 | spin_lock_irq(sch->lock); |
| 920 | cdev->private->schid = sch->schid; |
| 921 | cdev->ccwlock = sch->lock; |
| 922 | if (!sch_is_pseudo_sch(sch)) |
| 923 | sch_set_cdev(sch, cdev); |
| 924 | spin_unlock_irq(sch->lock); |
| 925 | if (!sch_is_pseudo_sch(sch)) |
| 926 | css_update_ssd_info(sch); |
| 927 | return 0; |
| 928 | } |
| 929 | |
| 930 | static int ccw_device_move_to_orph(struct ccw_device *cdev) |
| 931 | { |
| 932 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
| 933 | struct channel_subsystem *css = to_css(sch->dev.parent); |
| 934 | |
| 935 | return ccw_device_move_to_sch(cdev, css->pseudo_subchannel); |
Cornelia Huck | d7b5a4c9 | 2006-12-08 15:54:28 +0100 | [diff] [blame] | 936 | } |
| 937 | |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 938 | static void io_subchannel_irq(struct subchannel *sch) |
| 939 | { |
| 940 | struct ccw_device *cdev; |
| 941 | |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 942 | cdev = sch_get_cdev(sch); |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 943 | |
Sebastian Ott | efd986d | 2009-09-11 10:28:18 +0200 | [diff] [blame] | 944 | CIO_TRACE_EVENT(6, "IRQ"); |
| 945 | CIO_TRACE_EVENT(6, dev_name(&sch->dev)); |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 946 | if (cdev) |
| 947 | dev_fsm_event(cdev, DEV_EVENT_INTERRUPT); |
| 948 | } |
| 949 | |
Sebastian Ott | 13952ec | 2008-12-25 13:39:13 +0100 | [diff] [blame] | 950 | void io_subchannel_init_config(struct subchannel *sch) |
| 951 | { |
| 952 | memset(&sch->config, 0, sizeof(sch->config)); |
| 953 | sch->config.csense = 1; |
Sebastian Ott | 13952ec | 2008-12-25 13:39:13 +0100 | [diff] [blame] | 954 | } |
| 955 | |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 956 | static void io_subchannel_init_fields(struct subchannel *sch) |
| 957 | { |
| 958 | if (cio_is_console(sch->schid)) |
| 959 | sch->opm = 0xff; |
| 960 | else |
| 961 | sch->opm = chp_get_sch_opm(sch); |
| 962 | sch->lpm = sch->schib.pmcw.pam & sch->opm; |
Cornelia Huck | 3a3fc29 | 2008-07-14 09:58:58 +0200 | [diff] [blame] | 963 | sch->isc = cio_is_console(sch->schid) ? CONSOLE_ISC : IO_SCH_ISC; |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 964 | |
| 965 | CIO_MSG_EVENT(6, "Detected device %04x on subchannel 0.%x.%04X" |
| 966 | " - PIM = %02X, PAM = %02X, POM = %02X\n", |
| 967 | sch->schib.pmcw.dev, sch->schid.ssid, |
| 968 | sch->schid.sch_no, sch->schib.pmcw.pim, |
| 969 | sch->schib.pmcw.pam, sch->schib.pmcw.pom); |
Sebastian Ott | 13952ec | 2008-12-25 13:39:13 +0100 | [diff] [blame] | 970 | |
| 971 | io_subchannel_init_config(sch); |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 972 | } |
| 973 | |
Cornelia Huck | 90ed2b6 | 2008-12-25 13:39:09 +0100 | [diff] [blame] | 974 | /* |
| 975 | * Note: We always return 0 so that we bind to the device even on error. |
| 976 | * This is needed so that our remove function is called on unregister. |
| 977 | */ |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 978 | static int io_subchannel_probe(struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | struct ccw_device *cdev; |
| 981 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | |
Peter Oberparleiter | 6d7c5af | 2009-10-14 12:43:50 +0200 | [diff] [blame] | 983 | if (cio_is_console(sch->schid)) { |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 984 | rc = sysfs_create_group(&sch->dev.kobj, |
| 985 | &io_subchannel_attr_group); |
| 986 | if (rc) |
| 987 | CIO_MSG_EVENT(0, "Failed to create io subchannel " |
| 988 | "attributes for subchannel " |
| 989 | "0.%x.%04x (rc=%d)\n", |
| 990 | sch->schid.ssid, sch->schid.sch_no, rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | /* |
Peter Oberparleiter | 6d7c5af | 2009-10-14 12:43:50 +0200 | [diff] [blame] | 992 | * The console subchannel already has an associated ccw_device. |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 993 | * Throw the delayed uevent for the subchannel, register |
Peter Oberparleiter | 6d7c5af | 2009-10-14 12:43:50 +0200 | [diff] [blame] | 994 | * the ccw_device and exit. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | */ |
Ming Lei | f67f129 | 2009-03-01 21:10:49 +0800 | [diff] [blame] | 996 | dev_set_uevent_suppress(&sch->dev, 0); |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 997 | kobject_uevent(&sch->dev.kobj, KOBJ_ADD); |
Peter Oberparleiter | 6d7c5af | 2009-10-14 12:43:50 +0200 | [diff] [blame] | 998 | cdev = sch_get_cdev(sch); |
Cornelia Huck | e103178 | 2007-10-12 16:11:23 +0200 | [diff] [blame] | 999 | cdev->dev.groups = ccwdev_attr_groups; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | device_initialize(&cdev->dev); |
| 1001 | ccw_device_register(cdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | /* |
| 1003 | * Check if the device is already online. If it is |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 1004 | * the reference count needs to be corrected since we |
| 1005 | * didn't obtain a reference in ccw_device_set_online. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | */ |
| 1007 | if (cdev->private->state != DEV_STATE_NOT_OPER && |
| 1008 | cdev->private->state != DEV_STATE_OFFLINE && |
| 1009 | cdev->private->state != DEV_STATE_BOXED) |
| 1010 | get_device(&cdev->dev); |
| 1011 | return 0; |
| 1012 | } |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 1013 | io_subchannel_init_fields(sch); |
Sebastian Ott | f444cc0 | 2008-12-25 13:39:14 +0100 | [diff] [blame] | 1014 | rc = cio_commit_config(sch); |
| 1015 | if (rc) |
| 1016 | goto out_schedule; |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 1017 | rc = sysfs_create_group(&sch->dev.kobj, |
| 1018 | &io_subchannel_attr_group); |
| 1019 | if (rc) |
Cornelia Huck | 90ed2b6 | 2008-12-25 13:39:09 +0100 | [diff] [blame] | 1020 | goto out_schedule; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 1021 | /* Allocate I/O subchannel private data. */ |
| 1022 | sch->private = kzalloc(sizeof(struct io_subchannel_private), |
| 1023 | GFP_KERNEL | GFP_DMA); |
Cornelia Huck | 90ed2b6 | 2008-12-25 13:39:09 +0100 | [diff] [blame] | 1024 | if (!sch->private) |
Peter Oberparleiter | 48e4c38 | 2009-12-07 12:51:15 +0100 | [diff] [blame] | 1025 | goto out_schedule; |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1026 | css_schedule_eval(sch->schid); |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 1027 | return 0; |
Peter Oberparleiter | 48e4c38 | 2009-12-07 12:51:15 +0100 | [diff] [blame] | 1028 | |
Cornelia Huck | 90ed2b6 | 2008-12-25 13:39:09 +0100 | [diff] [blame] | 1029 | out_schedule: |
Peter Oberparleiter | 390935a | 2009-12-07 12:51:18 +0100 | [diff] [blame] | 1030 | spin_lock_irq(sch->lock); |
| 1031 | css_sched_sch_todo(sch, SCH_TODO_UNREG); |
| 1032 | spin_unlock_irq(sch->lock); |
Cornelia Huck | 90ed2b6 | 2008-12-25 13:39:09 +0100 | [diff] [blame] | 1033 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | } |
| 1035 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | static int |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 1037 | io_subchannel_remove (struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | { |
| 1039 | struct ccw_device *cdev; |
| 1040 | unsigned long flags; |
| 1041 | |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 1042 | cdev = sch_get_cdev(sch); |
| 1043 | if (!cdev) |
Peter Oberparleiter | 48e4c38 | 2009-12-07 12:51:15 +0100 | [diff] [blame] | 1044 | goto out_free; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | /* Set ccw device to not operational and drop reference. */ |
| 1046 | spin_lock_irqsave(cdev->ccwlock, flags); |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 1047 | sch_set_cdev(sch, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | cdev->private->state = DEV_STATE_NOT_OPER; |
| 1049 | spin_unlock_irqrestore(cdev->ccwlock, flags); |
Cornelia Huck | ef99516 | 2007-04-27 16:01:39 +0200 | [diff] [blame] | 1050 | ccw_device_unregister(cdev); |
Peter Oberparleiter | 48e4c38 | 2009-12-07 12:51:15 +0100 | [diff] [blame] | 1051 | out_free: |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 1052 | kfree(sch->private); |
Cornelia Huck | 7e9db9e | 2008-07-14 09:58:44 +0200 | [diff] [blame] | 1053 | sysfs_remove_group(&sch->dev.kobj, &io_subchannel_attr_group); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | return 0; |
| 1055 | } |
| 1056 | |
Cornelia Huck | 602b20f | 2008-01-26 14:10:39 +0100 | [diff] [blame] | 1057 | static void io_subchannel_verify(struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | { |
| 1059 | struct ccw_device *cdev; |
| 1060 | |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 1061 | cdev = sch_get_cdev(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | if (cdev) |
| 1063 | dev_fsm_event(cdev, DEV_EVENT_VERIFY); |
| 1064 | } |
| 1065 | |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1066 | static void io_subchannel_terminate_path(struct subchannel *sch, u8 mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | { |
| 1068 | struct ccw_device *cdev; |
| 1069 | |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 1070 | cdev = sch_get_cdev(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | if (!cdev) |
| 1072 | return; |
Peter Oberparleiter | 4257aae | 2009-12-07 12:51:29 +0100 | [diff] [blame] | 1073 | if (cio_update_schib(sch)) |
| 1074 | goto err; |
| 1075 | /* Check for I/O on path. */ |
| 1076 | if (scsw_actl(&sch->schib.scsw) == 0 || sch->schib.pmcw.lpum != mask) |
| 1077 | goto out; |
| 1078 | if (cdev->private->state == DEV_STATE_ONLINE) { |
| 1079 | ccw_device_kill_io(cdev); |
| 1080 | goto out; |
| 1081 | } |
| 1082 | if (cio_clear(sch)) |
| 1083 | goto err; |
| 1084 | out: |
| 1085 | /* Trigger path verification. */ |
| 1086 | dev_fsm_event(cdev, DEV_EVENT_VERIFY); |
| 1087 | return; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1088 | |
Peter Oberparleiter | 4257aae | 2009-12-07 12:51:29 +0100 | [diff] [blame] | 1089 | err: |
| 1090 | dev_fsm_event(cdev, DEV_EVENT_NOTOPER); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1091 | } |
| 1092 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 1093 | static int io_subchannel_chp_event(struct subchannel *sch, |
| 1094 | struct chp_link *link, int event) |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1095 | { |
| 1096 | int mask; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1097 | |
Cornelia Huck | 99611f8 | 2008-07-14 09:59:02 +0200 | [diff] [blame] | 1098 | mask = chp_ssd_get_mask(&sch->ssd_info, link); |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1099 | if (!mask) |
| 1100 | return 0; |
| 1101 | switch (event) { |
| 1102 | case CHP_VARY_OFF: |
| 1103 | sch->opm &= ~mask; |
| 1104 | sch->lpm &= ~mask; |
| 1105 | io_subchannel_terminate_path(sch, mask); |
| 1106 | break; |
| 1107 | case CHP_VARY_ON: |
| 1108 | sch->opm |= mask; |
| 1109 | sch->lpm |= mask; |
| 1110 | io_subchannel_verify(sch); |
| 1111 | break; |
| 1112 | case CHP_OFFLINE: |
Sebastian Ott | cdb912a | 2008-12-25 13:39:12 +0100 | [diff] [blame] | 1113 | if (cio_update_schib(sch)) |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1114 | return -ENODEV; |
| 1115 | io_subchannel_terminate_path(sch, mask); |
| 1116 | break; |
| 1117 | case CHP_ONLINE: |
Sebastian Ott | cdb912a | 2008-12-25 13:39:12 +0100 | [diff] [blame] | 1118 | if (cio_update_schib(sch)) |
| 1119 | return -ENODEV; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1120 | sch->lpm |= mask & sch->opm; |
| 1121 | io_subchannel_verify(sch); |
| 1122 | break; |
| 1123 | } |
| 1124 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | static void |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 1128 | io_subchannel_shutdown(struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | struct ccw_device *cdev; |
| 1131 | int ret; |
| 1132 | |
Cornelia Huck | db6a642 | 2008-01-26 14:10:46 +0100 | [diff] [blame] | 1133 | cdev = sch_get_cdev(sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 1135 | if (cio_is_console(sch->schid)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | return; |
| 1137 | if (!sch->schib.pmcw.ena) |
| 1138 | /* Nothing to do. */ |
| 1139 | return; |
| 1140 | ret = cio_disable_subchannel(sch); |
| 1141 | if (ret != -EBUSY) |
| 1142 | /* Subchannel is disabled, we're done. */ |
| 1143 | return; |
| 1144 | cdev->private->state = DEV_STATE_QUIESCE; |
| 1145 | if (cdev->handler) |
| 1146 | cdev->handler(cdev, cdev->private->intparm, |
| 1147 | ERR_PTR(-EIO)); |
| 1148 | ret = ccw_device_cancel_halt_clear(cdev); |
| 1149 | if (ret == -EBUSY) { |
| 1150 | ccw_device_set_timeout(cdev, HZ/10); |
| 1151 | wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); |
| 1152 | } |
| 1153 | cio_disable_subchannel(sch); |
| 1154 | } |
| 1155 | |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1156 | static int device_is_disconnected(struct ccw_device *cdev) |
| 1157 | { |
| 1158 | if (!cdev) |
| 1159 | return 0; |
| 1160 | return (cdev->private->state == DEV_STATE_DISCONNECTED || |
| 1161 | cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID); |
| 1162 | } |
| 1163 | |
| 1164 | static int recovery_check(struct device *dev, void *data) |
| 1165 | { |
| 1166 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1167 | int *redo = data; |
| 1168 | |
| 1169 | spin_lock_irq(cdev->ccwlock); |
| 1170 | switch (cdev->private->state) { |
| 1171 | case DEV_STATE_DISCONNECTED: |
| 1172 | CIO_MSG_EVENT(3, "recovery: trigger 0.%x.%04x\n", |
| 1173 | cdev->private->dev_id.ssid, |
| 1174 | cdev->private->dev_id.devno); |
| 1175 | dev_fsm_event(cdev, DEV_EVENT_VERIFY); |
| 1176 | *redo = 1; |
| 1177 | break; |
| 1178 | case DEV_STATE_DISCONNECTED_SENSE_ID: |
| 1179 | *redo = 1; |
| 1180 | break; |
| 1181 | } |
| 1182 | spin_unlock_irq(cdev->ccwlock); |
| 1183 | |
| 1184 | return 0; |
| 1185 | } |
| 1186 | |
| 1187 | static void recovery_work_func(struct work_struct *unused) |
| 1188 | { |
| 1189 | int redo = 0; |
| 1190 | |
| 1191 | bus_for_each_dev(&ccw_bus_type, NULL, &redo, recovery_check); |
| 1192 | if (redo) { |
| 1193 | spin_lock_irq(&recovery_lock); |
| 1194 | if (!timer_pending(&recovery_timer)) { |
| 1195 | if (recovery_phase < ARRAY_SIZE(recovery_delay) - 1) |
| 1196 | recovery_phase++; |
| 1197 | mod_timer(&recovery_timer, jiffies + |
| 1198 | recovery_delay[recovery_phase] * HZ); |
| 1199 | } |
| 1200 | spin_unlock_irq(&recovery_lock); |
| 1201 | } else |
| 1202 | CIO_MSG_EVENT(4, "recovery: end\n"); |
| 1203 | } |
| 1204 | |
| 1205 | static DECLARE_WORK(recovery_work, recovery_work_func); |
| 1206 | |
| 1207 | static void recovery_func(unsigned long data) |
| 1208 | { |
| 1209 | /* |
| 1210 | * We can't do our recovery in softirq context and it's not |
| 1211 | * performance critical, so we schedule it. |
| 1212 | */ |
| 1213 | schedule_work(&recovery_work); |
| 1214 | } |
| 1215 | |
| 1216 | static void ccw_device_schedule_recovery(void) |
| 1217 | { |
| 1218 | unsigned long flags; |
| 1219 | |
| 1220 | CIO_MSG_EVENT(4, "recovery: schedule\n"); |
| 1221 | spin_lock_irqsave(&recovery_lock, flags); |
| 1222 | if (!timer_pending(&recovery_timer) || (recovery_phase != 0)) { |
| 1223 | recovery_phase = 0; |
| 1224 | mod_timer(&recovery_timer, jiffies + recovery_delay[0] * HZ); |
| 1225 | } |
| 1226 | spin_unlock_irqrestore(&recovery_lock, flags); |
| 1227 | } |
| 1228 | |
Peter Oberparleiter | ecf5d9e | 2008-10-10 21:33:06 +0200 | [diff] [blame] | 1229 | static int purge_fn(struct device *dev, void *data) |
| 1230 | { |
| 1231 | struct ccw_device *cdev = to_ccwdev(dev); |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1232 | struct ccw_dev_id *id = &cdev->private->dev_id; |
Peter Oberparleiter | ecf5d9e | 2008-10-10 21:33:06 +0200 | [diff] [blame] | 1233 | |
| 1234 | spin_lock_irq(cdev->ccwlock); |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1235 | if (is_blacklisted(id->ssid, id->devno) && |
| 1236 | (cdev->private->state == DEV_STATE_OFFLINE)) { |
| 1237 | CIO_MSG_EVENT(3, "ccw: purging 0.%x.%04x\n", id->ssid, |
| 1238 | id->devno); |
| 1239 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG); |
| 1240 | } |
Peter Oberparleiter | ecf5d9e | 2008-10-10 21:33:06 +0200 | [diff] [blame] | 1241 | spin_unlock_irq(cdev->ccwlock); |
Peter Oberparleiter | ecf5d9e | 2008-10-10 21:33:06 +0200 | [diff] [blame] | 1242 | /* Abort loop in case of pending signal. */ |
| 1243 | if (signal_pending(current)) |
| 1244 | return -EINTR; |
| 1245 | |
| 1246 | return 0; |
| 1247 | } |
| 1248 | |
| 1249 | /** |
| 1250 | * ccw_purge_blacklisted - purge unused, blacklisted devices |
| 1251 | * |
| 1252 | * Unregister all ccw devices that are offline and on the blacklist. |
| 1253 | */ |
| 1254 | int ccw_purge_blacklisted(void) |
| 1255 | { |
| 1256 | CIO_MSG_EVENT(2, "ccw: purging blacklisted devices\n"); |
| 1257 | bus_for_each_dev(&ccw_bus_type, NULL, NULL, purge_fn); |
| 1258 | return 0; |
| 1259 | } |
| 1260 | |
Peter Oberparleiter | 6afcc77 | 2009-10-06 10:34:02 +0200 | [diff] [blame] | 1261 | void ccw_device_set_disconnected(struct ccw_device *cdev) |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1262 | { |
| 1263 | if (!cdev) |
| 1264 | return; |
| 1265 | ccw_device_set_timeout(cdev, 0); |
| 1266 | cdev->private->flags.fake_irb = 0; |
| 1267 | cdev->private->state = DEV_STATE_DISCONNECTED; |
| 1268 | if (cdev->online) |
| 1269 | ccw_device_schedule_recovery(); |
| 1270 | } |
| 1271 | |
Peter Oberparleiter | 91c3691 | 2008-08-21 19:46:39 +0200 | [diff] [blame] | 1272 | void ccw_device_set_notoper(struct ccw_device *cdev) |
| 1273 | { |
| 1274 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
| 1275 | |
| 1276 | CIO_TRACE_EVENT(2, "notoper"); |
Cornelia Huck | b9d3aed | 2008-10-10 21:33:11 +0200 | [diff] [blame] | 1277 | CIO_TRACE_EVENT(2, dev_name(&sch->dev)); |
Peter Oberparleiter | 91c3691 | 2008-08-21 19:46:39 +0200 | [diff] [blame] | 1278 | ccw_device_set_timeout(cdev, 0); |
| 1279 | cio_disable_subchannel(sch); |
| 1280 | cdev->private->state = DEV_STATE_NOT_OPER; |
| 1281 | } |
| 1282 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1283 | enum io_sch_action { |
| 1284 | IO_SCH_UNREG, |
| 1285 | IO_SCH_ORPH_UNREG, |
| 1286 | IO_SCH_ATTACH, |
| 1287 | IO_SCH_UNREG_ATTACH, |
| 1288 | IO_SCH_ORPH_ATTACH, |
| 1289 | IO_SCH_REPROBE, |
| 1290 | IO_SCH_VERIFY, |
| 1291 | IO_SCH_DISC, |
| 1292 | IO_SCH_NOP, |
| 1293 | }; |
| 1294 | |
| 1295 | static enum io_sch_action sch_get_action(struct subchannel *sch) |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1296 | { |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1297 | struct ccw_device *cdev; |
| 1298 | |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1299 | cdev = sch_get_cdev(sch); |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1300 | if (cio_update_schib(sch)) { |
| 1301 | /* Not operational. */ |
| 1302 | if (!cdev) |
| 1303 | return IO_SCH_UNREG; |
| 1304 | if (!ccw_device_notify(cdev, CIO_GONE)) |
| 1305 | return IO_SCH_UNREG; |
| 1306 | return IO_SCH_ORPH_UNREG; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1307 | } |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1308 | /* Operational. */ |
| 1309 | if (!cdev) |
| 1310 | return IO_SCH_ATTACH; |
| 1311 | if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { |
| 1312 | if (!ccw_device_notify(cdev, CIO_GONE)) |
| 1313 | return IO_SCH_UNREG_ATTACH; |
| 1314 | return IO_SCH_ORPH_ATTACH; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1315 | } |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1316 | if ((sch->schib.pmcw.pam & sch->opm) == 0) { |
| 1317 | if (!ccw_device_notify(cdev, CIO_NO_PATH)) |
| 1318 | return IO_SCH_UNREG; |
| 1319 | return IO_SCH_DISC; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1320 | } |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1321 | if (device_is_disconnected(cdev)) |
| 1322 | return IO_SCH_REPROBE; |
| 1323 | if (cdev->online) |
| 1324 | return IO_SCH_VERIFY; |
| 1325 | return IO_SCH_NOP; |
| 1326 | } |
| 1327 | |
| 1328 | /** |
| 1329 | * io_subchannel_sch_event - process subchannel event |
| 1330 | * @sch: subchannel |
| 1331 | * @process: non-zero if function is called in process context |
| 1332 | * |
| 1333 | * An unspecified event occurred for this subchannel. Adjust data according |
| 1334 | * to the current operational state of the subchannel and device. Return |
| 1335 | * zero when the event has been handled sufficiently or -EAGAIN when this |
| 1336 | * function should be called again in process context. |
| 1337 | */ |
| 1338 | static int io_subchannel_sch_event(struct subchannel *sch, int process) |
| 1339 | { |
| 1340 | unsigned long flags; |
| 1341 | struct ccw_device *cdev; |
| 1342 | struct ccw_dev_id dev_id; |
| 1343 | enum io_sch_action action; |
| 1344 | int rc = -EAGAIN; |
| 1345 | |
| 1346 | spin_lock_irqsave(sch->lock, flags); |
| 1347 | if (!device_is_registered(&sch->dev)) |
| 1348 | goto out_unlock; |
Peter Oberparleiter | 390935a | 2009-12-07 12:51:18 +0100 | [diff] [blame] | 1349 | if (work_pending(&sch->todo_work)) |
| 1350 | goto out_unlock; |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1351 | cdev = sch_get_cdev(sch); |
| 1352 | if (cdev && work_pending(&cdev->private->todo_work)) |
| 1353 | goto out_unlock; |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1354 | action = sch_get_action(sch); |
| 1355 | CIO_MSG_EVENT(2, "event: sch 0.%x.%04x, process=%d, action=%d\n", |
| 1356 | sch->schid.ssid, sch->schid.sch_no, process, |
| 1357 | action); |
| 1358 | /* Perform immediate actions while holding the lock. */ |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1359 | switch (action) { |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1360 | case IO_SCH_REPROBE: |
| 1361 | /* Trigger device recognition. */ |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1362 | ccw_device_trigger_reprobe(cdev); |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1363 | rc = 0; |
| 1364 | goto out_unlock; |
| 1365 | case IO_SCH_VERIFY: |
| 1366 | /* Trigger path verification. */ |
| 1367 | io_subchannel_verify(sch); |
| 1368 | rc = 0; |
| 1369 | goto out_unlock; |
| 1370 | case IO_SCH_DISC: |
| 1371 | ccw_device_set_disconnected(cdev); |
| 1372 | rc = 0; |
| 1373 | goto out_unlock; |
| 1374 | case IO_SCH_ORPH_UNREG: |
| 1375 | case IO_SCH_ORPH_ATTACH: |
Peter Oberparleiter | 6afcc77 | 2009-10-06 10:34:02 +0200 | [diff] [blame] | 1376 | ccw_device_set_disconnected(cdev); |
Peter Oberparleiter | 91c3691 | 2008-08-21 19:46:39 +0200 | [diff] [blame] | 1377 | break; |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1378 | case IO_SCH_UNREG_ATTACH: |
| 1379 | case IO_SCH_UNREG: |
| 1380 | if (cdev) |
| 1381 | ccw_device_set_notoper(cdev); |
| 1382 | break; |
| 1383 | case IO_SCH_NOP: |
| 1384 | rc = 0; |
| 1385 | goto out_unlock; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1386 | default: |
| 1387 | break; |
| 1388 | } |
| 1389 | spin_unlock_irqrestore(sch->lock, flags); |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1390 | /* All other actions require process context. */ |
| 1391 | if (!process) |
| 1392 | goto out; |
| 1393 | /* Handle attached ccw device. */ |
| 1394 | switch (action) { |
| 1395 | case IO_SCH_ORPH_UNREG: |
| 1396 | case IO_SCH_ORPH_ATTACH: |
| 1397 | /* Move ccw device to orphanage. */ |
| 1398 | rc = ccw_device_move_to_orph(cdev); |
| 1399 | if (rc) |
| 1400 | goto out; |
| 1401 | break; |
| 1402 | case IO_SCH_UNREG_ATTACH: |
| 1403 | /* Unregister ccw device. */ |
| 1404 | ccw_device_unregister(cdev); |
| 1405 | break; |
| 1406 | default: |
| 1407 | break; |
| 1408 | } |
| 1409 | /* Handle subchannel. */ |
| 1410 | switch (action) { |
| 1411 | case IO_SCH_ORPH_UNREG: |
| 1412 | case IO_SCH_UNREG: |
| 1413 | css_sch_device_unregister(sch); |
| 1414 | break; |
| 1415 | case IO_SCH_ORPH_ATTACH: |
| 1416 | case IO_SCH_UNREG_ATTACH: |
| 1417 | case IO_SCH_ATTACH: |
| 1418 | dev_id.ssid = sch->schid.ssid; |
| 1419 | dev_id.devno = sch->schib.pmcw.dev; |
| 1420 | cdev = get_ccwdev_by_dev_id(&dev_id); |
| 1421 | if (!cdev) { |
| 1422 | sch_create_and_recog_new_device(sch); |
| 1423 | break; |
| 1424 | } |
| 1425 | rc = ccw_device_move_to_sch(cdev, sch); |
| 1426 | if (rc) { |
| 1427 | /* Release reference from get_ccwdev_by_dev_id() */ |
| 1428 | put_device(&cdev->dev); |
| 1429 | goto out; |
| 1430 | } |
| 1431 | spin_lock_irqsave(sch->lock, flags); |
| 1432 | ccw_device_trigger_reprobe(cdev); |
| 1433 | spin_unlock_irqrestore(sch->lock, flags); |
| 1434 | /* Release reference from get_ccwdev_by_dev_id() */ |
| 1435 | put_device(&cdev->dev); |
| 1436 | break; |
| 1437 | default: |
| 1438 | break; |
| 1439 | } |
| 1440 | return 0; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1441 | |
Peter Oberparleiter | 5d6e6b6 | 2009-12-07 12:51:17 +0100 | [diff] [blame] | 1442 | out_unlock: |
| 1443 | spin_unlock_irqrestore(sch->lock, flags); |
| 1444 | out: |
| 1445 | return rc; |
Cornelia Huck | c820de3 | 2008-07-14 09:58:45 +0200 | [diff] [blame] | 1446 | } |
| 1447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | #ifdef CONFIG_CCW_CONSOLE |
| 1449 | static struct ccw_device console_cdev; |
| 1450 | static struct ccw_device_private console_private; |
| 1451 | static int console_cdev_in_use; |
| 1452 | |
Cornelia Huck | 2ec2298 | 2006-12-08 15:54:26 +0100 | [diff] [blame] | 1453 | static DEFINE_SPINLOCK(ccw_console_lock); |
| 1454 | |
| 1455 | spinlock_t * cio_get_console_lock(void) |
| 1456 | { |
| 1457 | return &ccw_console_lock; |
| 1458 | } |
| 1459 | |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 1460 | static int ccw_device_console_enable(struct ccw_device *cdev, |
| 1461 | struct subchannel *sch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | { |
| 1463 | int rc; |
| 1464 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 1465 | /* Attach subchannel private data. */ |
| 1466 | sch->private = cio_get_console_priv(); |
| 1467 | memset(sch->private, 0, sizeof(struct io_subchannel_private)); |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 1468 | io_subchannel_init_fields(sch); |
Sebastian Ott | f444cc0 | 2008-12-25 13:39:14 +0100 | [diff] [blame] | 1469 | rc = cio_commit_config(sch); |
| 1470 | if (rc) |
| 1471 | return rc; |
Cornelia Huck | 0ae7a7b | 2008-07-14 09:58:43 +0200 | [diff] [blame] | 1472 | sch->driver = &io_subchannel_driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | /* Initialize the ccw_device structure. */ |
Heiko Carstens | 292888c | 2006-08-30 14:33:35 +0200 | [diff] [blame] | 1474 | cdev->dev.parent= &sch->dev; |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 1475 | io_subchannel_recog(cdev, sch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | /* Now wait for the async. recognition to come to an end. */ |
| 1477 | spin_lock_irq(cdev->ccwlock); |
| 1478 | while (!dev_fsm_final_state(cdev)) |
| 1479 | wait_cons_dev(); |
| 1480 | rc = -EIO; |
| 1481 | if (cdev->private->state != DEV_STATE_OFFLINE) |
| 1482 | goto out_unlock; |
| 1483 | ccw_device_online(cdev); |
| 1484 | while (!dev_fsm_final_state(cdev)) |
| 1485 | wait_cons_dev(); |
| 1486 | if (cdev->private->state != DEV_STATE_ONLINE) |
| 1487 | goto out_unlock; |
| 1488 | rc = 0; |
| 1489 | out_unlock: |
| 1490 | spin_unlock_irq(cdev->ccwlock); |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 1491 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | } |
| 1493 | |
| 1494 | struct ccw_device * |
| 1495 | ccw_device_probe_console(void) |
| 1496 | { |
| 1497 | struct subchannel *sch; |
| 1498 | int ret; |
| 1499 | |
| 1500 | if (xchg(&console_cdev_in_use, 1) != 0) |
Peter Oberparleiter | 600b5d1 | 2006-02-01 03:06:35 -0800 | [diff] [blame] | 1501 | return ERR_PTR(-EBUSY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | sch = cio_probe_console(); |
| 1503 | if (IS_ERR(sch)) { |
| 1504 | console_cdev_in_use = 0; |
| 1505 | return (void *) sch; |
| 1506 | } |
| 1507 | memset(&console_cdev, 0, sizeof(struct ccw_device)); |
| 1508 | memset(&console_private, 0, sizeof(struct ccw_device_private)); |
| 1509 | console_cdev.private = &console_private; |
Martin Schwidefsky | c163753 | 2006-12-08 15:53:57 +0100 | [diff] [blame] | 1510 | console_private.cdev = &console_cdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1511 | ret = ccw_device_console_enable(&console_cdev, sch); |
| 1512 | if (ret) { |
| 1513 | cio_release_console(); |
| 1514 | console_cdev_in_use = 0; |
| 1515 | return ERR_PTR(ret); |
| 1516 | } |
| 1517 | console_cdev.online = 1; |
| 1518 | return &console_cdev; |
| 1519 | } |
Cornelia Huck | 1f4e7ed | 2008-10-10 21:33:14 +0200 | [diff] [blame] | 1520 | |
Martin Schwidefsky | 6664845 | 2009-06-16 10:30:28 +0200 | [diff] [blame] | 1521 | static int ccw_device_pm_restore(struct device *dev); |
| 1522 | |
| 1523 | int ccw_device_force_console(void) |
| 1524 | { |
| 1525 | if (!console_cdev_in_use) |
| 1526 | return -ENODEV; |
| 1527 | return ccw_device_pm_restore(&console_cdev.dev); |
| 1528 | } |
| 1529 | EXPORT_SYMBOL_GPL(ccw_device_force_console); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | #endif |
| 1531 | |
| 1532 | /* |
| 1533 | * get ccw_device matching the busid, but only if owned by cdrv |
| 1534 | */ |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1535 | static int |
| 1536 | __ccwdev_check_busid(struct device *dev, void *id) |
| 1537 | { |
| 1538 | char *bus_id; |
| 1539 | |
Cornelia Huck | 12975ae | 2006-10-11 15:31:47 +0200 | [diff] [blame] | 1540 | bus_id = id; |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1541 | |
Kay Sievers | 98df67b | 2008-12-25 13:38:55 +0100 | [diff] [blame] | 1542 | return (strcmp(bus_id, dev_name(dev)) == 0); |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 1546 | /** |
| 1547 | * get_ccwdev_by_busid() - obtain device from a bus id |
| 1548 | * @cdrv: driver the device is owned by |
| 1549 | * @bus_id: bus id of the device to be searched |
| 1550 | * |
| 1551 | * This function searches all devices owned by @cdrv for a device with a bus |
| 1552 | * id matching @bus_id. |
| 1553 | * Returns: |
| 1554 | * If a match is found, its reference count of the found device is increased |
| 1555 | * and it is returned; else %NULL is returned. |
| 1556 | */ |
| 1557 | struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv, |
| 1558 | const char *bus_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1559 | { |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1560 | struct device *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | struct device_driver *drv; |
| 1562 | |
| 1563 | drv = get_driver(&cdrv->driver); |
| 1564 | if (!drv) |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1565 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | |
Cornelia Huck | b0744bd | 2005-06-25 14:55:27 -0700 | [diff] [blame] | 1567 | dev = driver_find_device(drv, NULL, (void *)bus_id, |
| 1568 | __ccwdev_check_busid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | put_driver(drv); |
| 1570 | |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 1571 | return dev ? to_ccwdev(dev) : NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1572 | } |
| 1573 | |
| 1574 | /************************** device driver handling ************************/ |
| 1575 | |
| 1576 | /* This is the implementation of the ccw_driver class. The probe, remove |
| 1577 | * and release methods are initially very similar to the device_driver |
| 1578 | * implementations, with the difference that they have ccw_device |
| 1579 | * arguments. |
| 1580 | * |
| 1581 | * A ccw driver also contains the information that is needed for |
| 1582 | * device matching. |
| 1583 | */ |
| 1584 | static int |
| 1585 | ccw_device_probe (struct device *dev) |
| 1586 | { |
| 1587 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1588 | struct ccw_driver *cdrv = to_ccwdrv(dev->driver); |
| 1589 | int ret; |
| 1590 | |
| 1591 | cdev->drv = cdrv; /* to let the driver call _set_online */ |
| 1592 | |
| 1593 | ret = cdrv->probe ? cdrv->probe(cdev) : -ENODEV; |
| 1594 | |
| 1595 | if (ret) { |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 1596 | cdev->drv = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1597 | return ret; |
| 1598 | } |
| 1599 | |
| 1600 | return 0; |
| 1601 | } |
| 1602 | |
| 1603 | static int |
| 1604 | ccw_device_remove (struct device *dev) |
| 1605 | { |
| 1606 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1607 | struct ccw_driver *cdrv = cdev->drv; |
| 1608 | int ret; |
| 1609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | if (cdrv->remove) |
| 1611 | cdrv->remove(cdev); |
| 1612 | if (cdev->online) { |
| 1613 | cdev->online = 0; |
| 1614 | spin_lock_irq(cdev->ccwlock); |
| 1615 | ret = ccw_device_offline(cdev); |
| 1616 | spin_unlock_irq(cdev->ccwlock); |
| 1617 | if (ret == 0) |
| 1618 | wait_event(cdev->private->wait_q, |
| 1619 | dev_fsm_final_state(cdev)); |
| 1620 | else |
Michael Ernst | 139b83dd | 2008-05-07 09:22:54 +0200 | [diff] [blame] | 1621 | CIO_MSG_EVENT(0, "ccw_device_offline returned %d, " |
Cornelia Huck | e556bbb | 2007-07-27 12:29:19 +0200 | [diff] [blame] | 1622 | "device 0.%x.%04x\n", |
| 1623 | ret, cdev->private->dev_id.ssid, |
| 1624 | cdev->private->dev_id.devno); |
Cornelia Huck | 9cd6742 | 2008-12-25 13:39:06 +0100 | [diff] [blame] | 1625 | /* Give up reference obtained in ccw_device_set_online(). */ |
| 1626 | put_device(&cdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | } |
| 1628 | ccw_device_set_timeout(cdev, 0); |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 1629 | cdev->drv = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | return 0; |
| 1631 | } |
| 1632 | |
Cornelia Huck | 958974fb | 2007-10-12 16:11:21 +0200 | [diff] [blame] | 1633 | static void ccw_device_shutdown(struct device *dev) |
| 1634 | { |
| 1635 | struct ccw_device *cdev; |
| 1636 | |
| 1637 | cdev = to_ccwdev(dev); |
| 1638 | if (cdev->drv && cdev->drv->shutdown) |
| 1639 | cdev->drv->shutdown(cdev); |
Cornelia Huck | 1842f2b | 2007-10-12 16:11:22 +0200 | [diff] [blame] | 1640 | disable_cmf(cdev); |
Cornelia Huck | 958974fb | 2007-10-12 16:11:21 +0200 | [diff] [blame] | 1641 | } |
| 1642 | |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1643 | static int ccw_device_pm_prepare(struct device *dev) |
| 1644 | { |
| 1645 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1646 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1647 | if (work_pending(&cdev->private->todo_work)) |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1648 | return -EAGAIN; |
| 1649 | /* Fail while device is being set online/offline. */ |
| 1650 | if (atomic_read(&cdev->private->onoff)) |
| 1651 | return -EAGAIN; |
| 1652 | |
| 1653 | if (cdev->online && cdev->drv && cdev->drv->prepare) |
| 1654 | return cdev->drv->prepare(cdev); |
| 1655 | |
| 1656 | return 0; |
| 1657 | } |
| 1658 | |
| 1659 | static void ccw_device_pm_complete(struct device *dev) |
| 1660 | { |
| 1661 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1662 | |
| 1663 | if (cdev->online && cdev->drv && cdev->drv->complete) |
| 1664 | cdev->drv->complete(cdev); |
| 1665 | } |
| 1666 | |
| 1667 | static int ccw_device_pm_freeze(struct device *dev) |
| 1668 | { |
| 1669 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1670 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
| 1671 | int ret, cm_enabled; |
| 1672 | |
| 1673 | /* Fail suspend while device is in transistional state. */ |
| 1674 | if (!dev_fsm_final_state(cdev)) |
| 1675 | return -EAGAIN; |
| 1676 | if (!cdev->online) |
| 1677 | return 0; |
| 1678 | if (cdev->drv && cdev->drv->freeze) { |
| 1679 | ret = cdev->drv->freeze(cdev); |
| 1680 | if (ret) |
| 1681 | return ret; |
| 1682 | } |
| 1683 | |
| 1684 | spin_lock_irq(sch->lock); |
| 1685 | cm_enabled = cdev->private->cmb != NULL; |
| 1686 | spin_unlock_irq(sch->lock); |
| 1687 | if (cm_enabled) { |
| 1688 | /* Don't have the css write on memory. */ |
| 1689 | ret = ccw_set_cmf(cdev, 0); |
| 1690 | if (ret) |
| 1691 | return ret; |
| 1692 | } |
| 1693 | /* From here on, disallow device driver I/O. */ |
| 1694 | spin_lock_irq(sch->lock); |
| 1695 | ret = cio_disable_subchannel(sch); |
| 1696 | spin_unlock_irq(sch->lock); |
| 1697 | |
| 1698 | return ret; |
| 1699 | } |
| 1700 | |
| 1701 | static int ccw_device_pm_thaw(struct device *dev) |
| 1702 | { |
| 1703 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1704 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
| 1705 | int ret, cm_enabled; |
| 1706 | |
| 1707 | if (!cdev->online) |
| 1708 | return 0; |
| 1709 | |
| 1710 | spin_lock_irq(sch->lock); |
| 1711 | /* Allow device driver I/O again. */ |
| 1712 | ret = cio_enable_subchannel(sch, (u32)(addr_t)sch); |
| 1713 | cm_enabled = cdev->private->cmb != NULL; |
| 1714 | spin_unlock_irq(sch->lock); |
| 1715 | if (ret) |
| 1716 | return ret; |
| 1717 | |
| 1718 | if (cm_enabled) { |
| 1719 | ret = ccw_set_cmf(cdev, 1); |
| 1720 | if (ret) |
| 1721 | return ret; |
| 1722 | } |
| 1723 | |
| 1724 | if (cdev->drv && cdev->drv->thaw) |
| 1725 | ret = cdev->drv->thaw(cdev); |
| 1726 | |
| 1727 | return ret; |
| 1728 | } |
| 1729 | |
| 1730 | static void __ccw_device_pm_restore(struct ccw_device *cdev) |
| 1731 | { |
| 1732 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1733 | |
| 1734 | if (cio_is_console(sch->schid)) |
| 1735 | goto out; |
| 1736 | /* |
| 1737 | * While we were sleeping, devices may have gone or become |
| 1738 | * available again. Kick re-detection. |
| 1739 | */ |
| 1740 | spin_lock_irq(sch->lock); |
| 1741 | cdev->private->flags.resuming = 1; |
Peter Oberparleiter | 736b5db | 2009-12-07 12:51:21 +0100 | [diff] [blame] | 1742 | ccw_device_recognition(cdev); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1743 | spin_unlock_irq(sch->lock); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1744 | wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev) || |
| 1745 | cdev->private->state == DEV_STATE_DISCONNECTED); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1746 | out: |
| 1747 | cdev->private->flags.resuming = 0; |
| 1748 | } |
| 1749 | |
| 1750 | static int resume_handle_boxed(struct ccw_device *cdev) |
| 1751 | { |
| 1752 | cdev->private->state = DEV_STATE_BOXED; |
| 1753 | if (ccw_device_notify(cdev, CIO_BOXED)) |
| 1754 | return 0; |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1755 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1756 | return -ENODEV; |
| 1757 | } |
| 1758 | |
| 1759 | static int resume_handle_disc(struct ccw_device *cdev) |
| 1760 | { |
| 1761 | cdev->private->state = DEV_STATE_DISCONNECTED; |
| 1762 | if (ccw_device_notify(cdev, CIO_GONE)) |
| 1763 | return 0; |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1764 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1765 | return -ENODEV; |
| 1766 | } |
| 1767 | |
| 1768 | static int ccw_device_pm_restore(struct device *dev) |
| 1769 | { |
| 1770 | struct ccw_device *cdev = to_ccwdev(dev); |
| 1771 | struct subchannel *sch = to_subchannel(cdev->dev.parent); |
| 1772 | int ret = 0, cm_enabled; |
| 1773 | |
| 1774 | __ccw_device_pm_restore(cdev); |
| 1775 | spin_lock_irq(sch->lock); |
| 1776 | if (cio_is_console(sch->schid)) { |
| 1777 | cio_enable_subchannel(sch, (u32)(addr_t)sch); |
| 1778 | spin_unlock_irq(sch->lock); |
| 1779 | goto out_restore; |
| 1780 | } |
| 1781 | cdev->private->flags.donotify = 0; |
| 1782 | /* check recognition results */ |
| 1783 | switch (cdev->private->state) { |
| 1784 | case DEV_STATE_OFFLINE: |
| 1785 | break; |
| 1786 | case DEV_STATE_BOXED: |
| 1787 | ret = resume_handle_boxed(cdev); |
| 1788 | spin_unlock_irq(sch->lock); |
| 1789 | if (ret) |
| 1790 | goto out; |
| 1791 | goto out_restore; |
| 1792 | case DEV_STATE_DISCONNECTED: |
| 1793 | goto out_disc_unlock; |
| 1794 | default: |
| 1795 | goto out_unreg_unlock; |
| 1796 | } |
| 1797 | /* check if the device id has changed */ |
| 1798 | if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { |
Sebastian Ott | f014824 | 2009-09-11 10:28:23 +0200 | [diff] [blame] | 1799 | CIO_MSG_EVENT(0, "resume: sch 0.%x.%04x: failed (devno " |
| 1800 | "changed from %04x to %04x)\n", |
| 1801 | sch->schid.ssid, sch->schid.sch_no, |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1802 | cdev->private->dev_id.devno, |
| 1803 | sch->schib.pmcw.dev); |
| 1804 | goto out_unreg_unlock; |
| 1805 | } |
| 1806 | /* check if the device type has changed */ |
| 1807 | if (!ccw_device_test_sense_data(cdev)) { |
| 1808 | ccw_device_update_sense_data(cdev); |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1809 | ccw_device_sched_todo(cdev, CDEV_TODO_REBIND); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1810 | ret = -ENODEV; |
| 1811 | goto out_unlock; |
| 1812 | } |
| 1813 | if (!cdev->online) { |
| 1814 | ret = 0; |
| 1815 | goto out_unlock; |
| 1816 | } |
| 1817 | ret = ccw_device_online(cdev); |
| 1818 | if (ret) |
| 1819 | goto out_disc_unlock; |
| 1820 | |
| 1821 | cm_enabled = cdev->private->cmb != NULL; |
| 1822 | spin_unlock_irq(sch->lock); |
| 1823 | |
| 1824 | wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); |
| 1825 | if (cdev->private->state != DEV_STATE_ONLINE) { |
| 1826 | spin_lock_irq(sch->lock); |
| 1827 | goto out_disc_unlock; |
| 1828 | } |
| 1829 | if (cm_enabled) { |
| 1830 | ret = ccw_set_cmf(cdev, 1); |
| 1831 | if (ret) { |
Sebastian Ott | f014824 | 2009-09-11 10:28:23 +0200 | [diff] [blame] | 1832 | CIO_MSG_EVENT(2, "resume: cdev 0.%x.%04x: cmf failed " |
| 1833 | "(rc=%d)\n", cdev->private->dev_id.ssid, |
| 1834 | cdev->private->dev_id.devno, ret); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1835 | ret = 0; |
| 1836 | } |
| 1837 | } |
| 1838 | |
| 1839 | out_restore: |
| 1840 | if (cdev->online && cdev->drv && cdev->drv->restore) |
| 1841 | ret = cdev->drv->restore(cdev); |
| 1842 | out: |
| 1843 | return ret; |
| 1844 | |
| 1845 | out_disc_unlock: |
| 1846 | ret = resume_handle_disc(cdev); |
| 1847 | spin_unlock_irq(sch->lock); |
| 1848 | if (ret) |
| 1849 | return ret; |
| 1850 | goto out_restore; |
| 1851 | |
| 1852 | out_unreg_unlock: |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1853 | ccw_device_sched_todo(cdev, CDEV_TODO_UNREG_EVAL); |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1854 | ret = -ENODEV; |
| 1855 | out_unlock: |
| 1856 | spin_unlock_irq(sch->lock); |
| 1857 | return ret; |
| 1858 | } |
| 1859 | |
| 1860 | static struct dev_pm_ops ccw_pm_ops = { |
| 1861 | .prepare = ccw_device_pm_prepare, |
| 1862 | .complete = ccw_device_pm_complete, |
| 1863 | .freeze = ccw_device_pm_freeze, |
| 1864 | .thaw = ccw_device_pm_thaw, |
| 1865 | .restore = ccw_device_pm_restore, |
| 1866 | }; |
| 1867 | |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 1868 | struct bus_type ccw_bus_type = { |
| 1869 | .name = "ccw", |
| 1870 | .match = ccw_bus_match, |
| 1871 | .uevent = ccw_uevent, |
| 1872 | .probe = ccw_device_probe, |
| 1873 | .remove = ccw_device_remove, |
Cornelia Huck | 958974fb | 2007-10-12 16:11:21 +0200 | [diff] [blame] | 1874 | .shutdown = ccw_device_shutdown, |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 1875 | .pm = &ccw_pm_ops, |
Cornelia Huck | 8bbace7 | 2006-01-11 10:56:22 +0100 | [diff] [blame] | 1876 | }; |
| 1877 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 1878 | /** |
| 1879 | * ccw_driver_register() - register a ccw driver |
| 1880 | * @cdriver: driver to be registered |
| 1881 | * |
| 1882 | * This function is mainly a wrapper around driver_register(). |
| 1883 | * Returns: |
| 1884 | * %0 on success and a negative error value on failure. |
| 1885 | */ |
| 1886 | int ccw_driver_register(struct ccw_driver *cdriver) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1887 | { |
| 1888 | struct device_driver *drv = &cdriver->driver; |
| 1889 | |
| 1890 | drv->bus = &ccw_bus_type; |
| 1891 | drv->name = cdriver->name; |
Cornelia Huck | 4beee64 | 2008-01-26 14:10:47 +0100 | [diff] [blame] | 1892 | drv->owner = cdriver->owner; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1893 | |
| 1894 | return driver_register(drv); |
| 1895 | } |
| 1896 | |
Cornelia Huck | b2ffd8e | 2007-10-12 16:11:17 +0200 | [diff] [blame] | 1897 | /** |
| 1898 | * ccw_driver_unregister() - deregister a ccw driver |
| 1899 | * @cdriver: driver to be deregistered |
| 1900 | * |
| 1901 | * This function is mainly a wrapper around driver_unregister(). |
| 1902 | */ |
| 1903 | void ccw_driver_unregister(struct ccw_driver *cdriver) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1904 | { |
| 1905 | driver_unregister(&cdriver->driver); |
| 1906 | } |
| 1907 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 1908 | /* Helper func for qdio. */ |
| 1909 | struct subchannel_id |
| 1910 | ccw_device_get_subchannel_id(struct ccw_device *cdev) |
| 1911 | { |
| 1912 | struct subchannel *sch; |
| 1913 | |
| 1914 | sch = to_subchannel(cdev->dev.parent); |
| 1915 | return sch->schid; |
| 1916 | } |
| 1917 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 1918 | static void ccw_device_todo(struct work_struct *work) |
| 1919 | { |
| 1920 | struct ccw_device_private *priv; |
| 1921 | struct ccw_device *cdev; |
| 1922 | struct subchannel *sch; |
| 1923 | enum cdev_todo todo; |
| 1924 | |
| 1925 | priv = container_of(work, struct ccw_device_private, todo_work); |
| 1926 | cdev = priv->cdev; |
| 1927 | sch = to_subchannel(cdev->dev.parent); |
| 1928 | /* Find out todo. */ |
| 1929 | spin_lock_irq(cdev->ccwlock); |
| 1930 | todo = priv->todo; |
| 1931 | priv->todo = CDEV_TODO_NOTHING; |
| 1932 | CIO_MSG_EVENT(4, "cdev_todo: cdev=0.%x.%04x todo=%d\n", |
| 1933 | priv->dev_id.ssid, priv->dev_id.devno, todo); |
| 1934 | spin_unlock_irq(cdev->ccwlock); |
| 1935 | /* Perform todo. */ |
| 1936 | switch (todo) { |
| 1937 | case CDEV_TODO_ENABLE_CMF: |
| 1938 | cmf_reenable(cdev); |
| 1939 | break; |
| 1940 | case CDEV_TODO_REBIND: |
| 1941 | ccw_device_do_unbind_bind(cdev); |
| 1942 | break; |
| 1943 | case CDEV_TODO_REGISTER: |
| 1944 | io_subchannel_register(cdev); |
| 1945 | break; |
| 1946 | case CDEV_TODO_UNREG_EVAL: |
| 1947 | if (!sch_is_pseudo_sch(sch)) |
| 1948 | css_schedule_eval(sch->schid); |
| 1949 | /* fall-through */ |
| 1950 | case CDEV_TODO_UNREG: |
| 1951 | if (sch_is_pseudo_sch(sch)) |
| 1952 | ccw_device_unregister(cdev); |
| 1953 | else |
| 1954 | ccw_device_call_sch_unregister(cdev); |
| 1955 | break; |
| 1956 | default: |
| 1957 | break; |
| 1958 | } |
| 1959 | /* Release workqueue ref. */ |
| 1960 | put_device(&cdev->dev); |
| 1961 | } |
| 1962 | |
| 1963 | /** |
| 1964 | * ccw_device_sched_todo - schedule ccw device operation |
| 1965 | * @cdev: ccw device |
| 1966 | * @todo: todo |
| 1967 | * |
| 1968 | * Schedule the operation identified by @todo to be performed on the slow path |
| 1969 | * workqueue. Do nothing if another operation with higher priority is already |
| 1970 | * scheduled. Needs to be called with ccwdev lock held. |
| 1971 | */ |
| 1972 | void ccw_device_sched_todo(struct ccw_device *cdev, enum cdev_todo todo) |
| 1973 | { |
| 1974 | CIO_MSG_EVENT(4, "cdev_todo: sched cdev=0.%x.%04x todo=%d\n", |
| 1975 | cdev->private->dev_id.ssid, cdev->private->dev_id.devno, |
| 1976 | todo); |
| 1977 | if (cdev->private->todo >= todo) |
| 1978 | return; |
| 1979 | cdev->private->todo = todo; |
| 1980 | /* Get workqueue ref. */ |
| 1981 | if (!get_device(&cdev->dev)) |
| 1982 | return; |
| 1983 | if (!queue_work(slow_path_wq, &cdev->private->todo_work)) { |
| 1984 | /* Already queued, release workqueue ref. */ |
| 1985 | put_device(&cdev->dev); |
| 1986 | } |
| 1987 | } |
| 1988 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1989 | MODULE_LICENSE("GPL"); |
| 1990 | EXPORT_SYMBOL(ccw_device_set_online); |
| 1991 | EXPORT_SYMBOL(ccw_device_set_offline); |
| 1992 | EXPORT_SYMBOL(ccw_driver_register); |
| 1993 | EXPORT_SYMBOL(ccw_driver_unregister); |
| 1994 | EXPORT_SYMBOL(get_ccwdev_by_busid); |
| 1995 | EXPORT_SYMBOL(ccw_bus_type); |
| 1996 | EXPORT_SYMBOL(ccw_device_work); |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 1997 | EXPORT_SYMBOL_GPL(ccw_device_get_subchannel_id); |