| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* Author(s)......: Holger Smolinski <[email protected]> |
| 4 |
* Horst Hummel <[email protected]> |
| 5 |
* Carsten Otte <[email protected]> |
| 6 |
* Martin Schwidefsky <[email protected]> |
| 7 |
* Bugreports.to..: <[email protected]> |
| 8 |
* Copyright IBM Corp. 1999,2001 |
| 9 |
* |
| 10 |
* Device mapping and dasd= parameter parsing functions. All devmap |
| 11 |
* functions may not be called from interrupt context. In particular |
| 12 |
* dasd_get_device is a no-no from interrupt context. |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
#include <linux/export.h> |
| 17 |
#include <linux/ctype.h> |
| 18 |
#include <linux/init.h> |
| 19 |
#include <linux/module.h> |
| 20 |
#include <linux/slab.h> |
| 21 |
|
| 22 |
#include <asm/machine.h> |
| 23 |
#include <asm/debug.h> |
| 24 |
#include <linux/uaccess.h> |
| 25 |
#include <asm/ipl.h> |
| 26 |
|
| 27 |
#define DASD_MAX_PARAMS 256 |
| 28 |
|
| 29 |
#include "dasd_int.h" |
| 30 |
|
| 31 |
struct kmem_cache *dasd_page_cache; |
| 32 |
EXPORT_SYMBOL_GPL(dasd_page_cache); |
| 33 |
|
| 34 |
/* |
| 35 |
* dasd_devmap_t is used to store the features and the relation |
| 36 |
* between device number and device index. To find a dasd_devmap_t |
| 37 |
* that corresponds to a device number of a device index each |
| 38 |
* dasd_devmap_t is added to two linked lists, one to search by |
| 39 |
* the device number and one to search by the device index. As |
| 40 |
* soon as big minor numbers are available the device index list |
| 41 |
* can be removed since the device number will then be identical |
| 42 |
* to the device index. |
| 43 |
*/ |
| 44 |
struct dasd_devmap { |
| 45 |
struct list_head list; |
| 46 |
char bus_id[DASD_BUS_ID_SIZE]; |
| 47 |
unsigned int devindex; |
| 48 |
unsigned short features; |
| 49 |
struct dasd_device *device; |
| 50 |
struct dasd_copy_relation *copy; |
| 51 |
unsigned int aq_mask; |
| 52 |
}; |
| 53 |
|
| 54 |
/* |
| 55 |
* Parameter parsing functions for dasd= parameter. The syntax is: |
| 56 |
* <devno> : (0x)?[0-9a-fA-F]+ |
| 57 |
* <busid> : [0-0a-f]\.[0-9a-f]\.(0x)?[0-9a-fA-F]+ |
| 58 |
* <feature> : ro |
| 59 |
* <feature_list> : \(<feature>(:<feature>)*\) |
| 60 |
* <devno-range> : <devno>(-<devno>)?<feature_list>? |
| 61 |
* <busid-range> : <busid>(-<busid>)?<feature_list>? |
| 62 |
* <devices> : <devno-range>|<busid-range> |
| 63 |
* <dasd_module> : dasd_diag_mod|dasd_eckd_mod|dasd_fba_mod |
| 64 |
* |
| 65 |
* <dasd> : autodetect|probeonly|<devices>(,<devices>)* |
| 66 |
*/ |
| 67 |
|
| 68 |
int dasd_probeonly = 0; /* is true, when probeonly mode is active */ |
| 69 |
int dasd_autodetect = 0; /* is true, when autodetection is active */ |
| 70 |
int dasd_nopav = 0; /* is true, when PAV is disabled */ |
| 71 |
EXPORT_SYMBOL_GPL(dasd_nopav); |
| 72 |
int dasd_nofcx; /* disable High Performance Ficon */ |
| 73 |
EXPORT_SYMBOL_GPL(dasd_nofcx); |
| 74 |
|
| 75 |
/* |
| 76 |
* char *dasd[] is intended to hold the ranges supplied by the dasd= statement |
| 77 |
* it is named 'dasd' to directly be filled by insmod with the comma separated |
| 78 |
* strings when running as a module. |
| 79 |
*/ |
| 80 |
static char *dasd[DASD_MAX_PARAMS]; |
| 81 |
module_param_array(dasd, charp, NULL, S_IRUGO); |
| 82 |
|
| 83 |
/* |
| 84 |
* Single spinlock to protect devmap and servermap structures and lists. |
| 85 |
*/ |
| 86 |
static DEFINE_SPINLOCK(dasd_devmap_lock); |
| 87 |
|
| 88 |
/* |
| 89 |
* Hash lists for devmap structures. |
| 90 |
*/ |
| 91 |
static struct list_head dasd_hashlists[256]; |
| 92 |
int dasd_max_devindex; |
| 93 |
|
| 94 |
static struct dasd_devmap *dasd_add_busid(const char *, int); |
| 95 |
|
| 96 |
static inline int |
| 97 |
dasd_hash_busid(const char *bus_id) |
| 98 |
{ |
| 99 |
int hash, i; |
| 100 |
|
| 101 |
hash = 0; |
| 102 |
for (i = 0; (i < DASD_BUS_ID_SIZE) && *bus_id; i++, bus_id++) |
| 103 |
hash += *bus_id; |
| 104 |
return hash & 0xff; |
| 105 |
} |
| 106 |
|
| 107 |
#ifndef MODULE |
| 108 |
static int __init dasd_call_setup(char *opt) |
| 109 |
{ |
| 110 |
static int i __initdata; |
| 111 |
char *tmp; |
| 112 |
|
| 113 |
while (i < DASD_MAX_PARAMS) { |
| 114 |
tmp = strsep(&opt, ","); |
| 115 |
if (!tmp) |
| 116 |
break; |
| 117 |
|
| 118 |
dasd[i++] = tmp; |
| 119 |
} |
| 120 |
|
| 121 |
return 1; |
| 122 |
} |
| 123 |
|
| 124 |
__setup ("dasd=", dasd_call_setup); |
| 125 |
#endif /* #ifndef MODULE */ |
| 126 |
|
| 127 |
#define DASD_IPLDEV "ipldev" |
| 128 |
|
| 129 |
/* |
| 130 |
* Read a device busid/devno from a string. |
| 131 |
*/ |
| 132 |
static int dasd_busid(char *str, int *id0, int *id1, int *devno) |
| 133 |
{ |
| 134 |
unsigned int val; |
| 135 |
char *tok; |
| 136 |
|
| 137 |
/* Interpret ipldev busid */ |
| 138 |
if (strncmp(DASD_IPLDEV, str, strlen(DASD_IPLDEV)) == 0) { |
| 139 |
if (ipl_info.type != IPL_TYPE_CCW) { |
| 140 |
pr_err("The IPL device is not a CCW device\n"); |
| 141 |
return -EINVAL; |
| 142 |
} |
| 143 |
*id0 = 0; |
| 144 |
*id1 = ipl_info.data.ccw.dev_id.ssid; |
| 145 |
*devno = ipl_info.data.ccw.dev_id.devno; |
| 146 |
|
| 147 |
return 0; |
| 148 |
} |
| 149 |
|
| 150 |
/* Old style 0xXXXX or XXXX */ |
| 151 |
if (!kstrtouint(str, 16, &val)) { |
| 152 |
*id0 = *id1 = 0; |
| 153 |
if (val > 0xffff) |
| 154 |
return -EINVAL; |
| 155 |
*devno = val; |
| 156 |
return 0; |
| 157 |
} |
| 158 |
|
| 159 |
/* New style x.y.z busid */ |
| 160 |
tok = strsep(&str, "."); |
| 161 |
if (kstrtouint(tok, 16, &val) || val > 0xff) |
| 162 |
return -EINVAL; |
| 163 |
*id0 = val; |
| 164 |
|
| 165 |
tok = strsep(&str, "."); |
| 166 |
if (kstrtouint(tok, 16, &val) || val > 0xff) |
| 167 |
return -EINVAL; |
| 168 |
*id1 = val; |
| 169 |
|
| 170 |
tok = strsep(&str, "."); |
| 171 |
if (kstrtouint(tok, 16, &val) || val > 0xffff) |
| 172 |
return -EINVAL; |
| 173 |
*devno = val; |
| 174 |
|
| 175 |
return 0; |
| 176 |
} |
| 177 |
|
| 178 |
/* |
| 179 |
* Read colon separated list of dasd features. |
| 180 |
*/ |
| 181 |
static int __init dasd_feature_list(char *str) |
| 182 |
{ |
| 183 |
int features, len, rc; |
| 184 |
|
| 185 |
features = 0; |
| 186 |
rc = 0; |
| 187 |
|
| 188 |
if (!str) |
| 189 |
return DASD_FEATURE_DEFAULT; |
| 190 |
|
| 191 |
while (1) { |
| 192 |
for (len = 0; |
| 193 |
str[len] && str[len] != ':' && str[len] != ')'; len++); |
| 194 |
if (len == 2 && !strncmp(str, "ro", 2)) |
| 195 |
features |= DASD_FEATURE_READONLY; |
| 196 |
else if (len == 4 && !strncmp(str, "diag", 4)) |
| 197 |
features |= DASD_FEATURE_USEDIAG; |
| 198 |
else if (len == 3 && !strncmp(str, "raw", 3)) |
| 199 |
features |= DASD_FEATURE_USERAW; |
| 200 |
else if (len == 6 && !strncmp(str, "erplog", 6)) |
| 201 |
features |= DASD_FEATURE_ERPLOG; |
| 202 |
else if (len == 8 && !strncmp(str, "failfast", 8)) |
| 203 |
features |= DASD_FEATURE_FAILFAST; |
| 204 |
else { |
| 205 |
pr_warn("%.*s is not a supported device option\n", |
| 206 |
len, str); |
| 207 |
rc = -EINVAL; |
| 208 |
} |
| 209 |
str += len; |
| 210 |
if (*str != ':') |
| 211 |
break; |
| 212 |
str++; |
| 213 |
} |
| 214 |
|
| 215 |
return rc ? : features; |
| 216 |
} |
| 217 |
|
| 218 |
/* |
| 219 |
* Try to match the first element on the comma separated parse string |
| 220 |
* with one of the known keywords. If a keyword is found, take the approprate |
| 221 |
* action and return a pointer to the residual string. If the first element |
| 222 |
* could not be matched to any keyword then return an error code. |
| 223 |
*/ |
| 224 |
static int __init dasd_parse_keyword(char *keyword) |
| 225 |
{ |
| 226 |
int length = strlen(keyword); |
| 227 |
|
| 228 |
if (strncmp("autodetect", keyword, length) == 0) { |
| 229 |
dasd_autodetect = 1; |
| 230 |
pr_info("The autodetection mode has been activated\n"); |
| 231 |
return 0; |
| 232 |
} |
| 233 |
if (strncmp("probeonly", keyword, length) == 0) { |
| 234 |
dasd_probeonly = 1; |
| 235 |
pr_info("The probeonly mode has been activated\n"); |
| 236 |
return 0; |
| 237 |
} |
| 238 |
if (strncmp("nopav", keyword, length) == 0) { |
| 239 |
if (machine_is_vm()) |
| 240 |
pr_info("'nopav' is not supported on z/VM\n"); |
| 241 |
else { |
| 242 |
dasd_nopav = 1; |
| 243 |
pr_info("PAV support has be deactivated\n"); |
| 244 |
} |
| 245 |
return 0; |
| 246 |
} |
| 247 |
if (strncmp("nofcx", keyword, length) == 0) { |
| 248 |
dasd_nofcx = 1; |
| 249 |
pr_info("High Performance FICON support has been " |
| 250 |
"deactivated\n"); |
| 251 |
return 0; |
| 252 |
} |
| 253 |
if (strncmp("fixedbuffers", keyword, length) == 0) { |
| 254 |
if (dasd_page_cache) |
| 255 |
return 0; |
| 256 |
dasd_page_cache = |
| 257 |
kmem_cache_create("dasd_page_cache", PAGE_SIZE, |
| 258 |
PAGE_SIZE, SLAB_CACHE_DMA, |
| 259 |
NULL); |
| 260 |
if (!dasd_page_cache) |
| 261 |
DBF_EVENT(DBF_WARNING, "%s", "Failed to create slab, " |
| 262 |
"fixed buffer mode disabled."); |
| 263 |
else |
| 264 |
DBF_EVENT(DBF_INFO, "%s", |
| 265 |
"turning on fixed buffer mode"); |
| 266 |
return 0; |
| 267 |
} |
| 268 |
|
| 269 |
return -EINVAL; |
| 270 |
} |
| 271 |
|
| 272 |
/* |
| 273 |
* Split a string of a device range into its pieces and return the from, to, and |
| 274 |
* feature parts separately. |
| 275 |
* e.g.: |
| 276 |
* 0.0.1234-0.0.5678(ro:erplog) -> from: 0.0.1234 to: 0.0.5678 features: ro:erplog |
| 277 |
* 0.0.8765(raw) -> from: 0.0.8765 to: null features: raw |
| 278 |
* 0x4321 -> from: 0x4321 to: null features: null |
| 279 |
*/ |
| 280 |
static int __init dasd_evaluate_range_param(char *range, char **from_str, |
| 281 |
char **to_str, char **features_str) |
| 282 |
{ |
| 283 |
int rc = 0; |
| 284 |
|
| 285 |
/* Do we have a range or a single device? */ |
| 286 |
if (strchr(range, '-')) { |
| 287 |
*from_str = strsep(&range, "-"); |
| 288 |
*to_str = strsep(&range, "("); |
| 289 |
*features_str = strsep(&range, ")"); |
| 290 |
} else { |
| 291 |
*from_str = strsep(&range, "("); |
| 292 |
*features_str = strsep(&range, ")"); |
| 293 |
} |
| 294 |
|
| 295 |
if (*features_str && !range) { |
| 296 |
pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n"); |
| 297 |
rc = -EINVAL; |
| 298 |
} |
| 299 |
|
| 300 |
return rc; |
| 301 |
} |
| 302 |
|
| 303 |
/* |
| 304 |
* Try to interprete the range string as a device number or a range of devices. |
| 305 |
* If the interpretation is successful, create the matching dasd_devmap entries. |
| 306 |
* If interpretation fails or in case of an error, return an error code. |
| 307 |
*/ |
| 308 |
static int __init dasd_parse_range(const char *range) |
| 309 |
{ |
| 310 |
struct dasd_devmap *devmap; |
| 311 |
int from, from_id0, from_id1; |
| 312 |
int to, to_id0, to_id1; |
| 313 |
int features; |
| 314 |
char bus_id[DASD_BUS_ID_SIZE + 1]; |
| 315 |
char *features_str = NULL; |
| 316 |
char *from_str = NULL; |
| 317 |
char *to_str = NULL; |
| 318 |
int rc = 0; |
| 319 |
char *tmp; |
| 320 |
|
| 321 |
tmp = kstrdup(range, GFP_KERNEL); |
| 322 |
if (!tmp) |
| 323 |
return -ENOMEM; |
| 324 |
|
| 325 |
if (dasd_evaluate_range_param(tmp, &from_str, &to_str, &features_str)) { |
| 326 |
rc = -EINVAL; |
| 327 |
goto out; |
| 328 |
} |
| 329 |
|
| 330 |
if (dasd_busid(from_str, &from_id0, &from_id1, &from)) { |
| 331 |
rc = -EINVAL; |
| 332 |
goto out; |
| 333 |
} |
| 334 |
|
| 335 |
to = from; |
| 336 |
to_id0 = from_id0; |
| 337 |
to_id1 = from_id1; |
| 338 |
if (to_str) { |
| 339 |
if (dasd_busid(to_str, &to_id0, &to_id1, &to)) { |
| 340 |
rc = -EINVAL; |
| 341 |
goto out; |
| 342 |
} |
| 343 |
if (from_id0 != to_id0 || from_id1 != to_id1 || from > to) { |
| 344 |
pr_err("%s is not a valid device range\n", range); |
| 345 |
rc = -EINVAL; |
| 346 |
goto out; |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
features = dasd_feature_list(features_str); |
| 351 |
if (features < 0) { |
| 352 |
rc = -EINVAL; |
| 353 |
goto out; |
| 354 |
} |
| 355 |
/* each device in dasd= parameter should be set initially online */ |
| 356 |
features |= DASD_FEATURE_INITIAL_ONLINE; |
| 357 |
while (from <= to) { |
| 358 |
scnprintf(bus_id, sizeof(bus_id), |
| 359 |
"%01x.%01x.%04x", from_id0, from_id1, from++); |
| 360 |
devmap = dasd_add_busid(bus_id, features); |
| 361 |
if (IS_ERR(devmap)) { |
| 362 |
rc = PTR_ERR(devmap); |
| 363 |
goto out; |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
out: |
| 368 |
kfree(tmp); |
| 369 |
|
| 370 |
return rc; |
| 371 |
} |
| 372 |
|
| 373 |
/* |
| 374 |
* Parse parameters stored in dasd[] |
| 375 |
* The 'dasd=...' parameter allows to specify a comma separated list of |
| 376 |
* keywords and device ranges. The parameters in that list will be stored as |
| 377 |
* separate elementes in dasd[]. |
| 378 |
*/ |
| 379 |
int __init dasd_parse(void) |
| 380 |
{ |
| 381 |
int rc, i; |
| 382 |
char *cur; |
| 383 |
|
| 384 |
rc = 0; |
| 385 |
for (i = 0; i < DASD_MAX_PARAMS; i++) { |
| 386 |
cur = dasd[i]; |
| 387 |
if (!cur) |
| 388 |
break; |
| 389 |
if (*cur == '\0') |
| 390 |
continue; |
| 391 |
|
| 392 |
rc = dasd_parse_keyword(cur); |
| 393 |
if (rc) |
| 394 |
rc = dasd_parse_range(cur); |
| 395 |
|
| 396 |
if (rc) |
| 397 |
break; |
| 398 |
} |
| 399 |
|
| 400 |
return rc; |
| 401 |
} |
| 402 |
|
| 403 |
/* |
| 404 |
* Add a devmap for the device specified by busid. It is possible that |
| 405 |
* the devmap already exists (dasd= parameter). The order of the devices |
| 406 |
* added through this function will define the kdevs for the individual |
| 407 |
* devices. |
| 408 |
*/ |
| 409 |
static struct dasd_devmap * |
| 410 |
dasd_add_busid(const char *bus_id, int features) |
| 411 |
{ |
| 412 |
struct dasd_devmap *devmap, *new, *tmp; |
| 413 |
int hash; |
| 414 |
|
| 415 |
new = kzalloc_obj(struct dasd_devmap); |
| 416 |
if (!new) |
| 417 |
return ERR_PTR(-ENOMEM); |
| 418 |
spin_lock(&dasd_devmap_lock); |
| 419 |
devmap = NULL; |
| 420 |
hash = dasd_hash_busid(bus_id); |
| 421 |
list_for_each_entry(tmp, &dasd_hashlists[hash], list) |
| 422 |
if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { |
| 423 |
devmap = tmp; |
| 424 |
break; |
| 425 |
} |
| 426 |
if (!devmap) { |
| 427 |
/* This bus_id is new. */ |
| 428 |
new->devindex = dasd_max_devindex++; |
| 429 |
strscpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); |
| 430 |
new->features = features; |
| 431 |
new->device = NULL; |
| 432 |
list_add(&new->list, &dasd_hashlists[hash]); |
| 433 |
devmap = new; |
| 434 |
new = NULL; |
| 435 |
} |
| 436 |
spin_unlock(&dasd_devmap_lock); |
| 437 |
kfree(new); |
| 438 |
return devmap; |
| 439 |
} |
| 440 |
|
| 441 |
static struct dasd_devmap * |
| 442 |
dasd_find_busid_locked(const char *bus_id) |
| 443 |
{ |
| 444 |
struct dasd_devmap *devmap, *tmp; |
| 445 |
int hash; |
| 446 |
|
| 447 |
devmap = ERR_PTR(-ENODEV); |
| 448 |
hash = dasd_hash_busid(bus_id); |
| 449 |
list_for_each_entry(tmp, &dasd_hashlists[hash], list) { |
| 450 |
if (strncmp(tmp->bus_id, bus_id, DASD_BUS_ID_SIZE) == 0) { |
| 451 |
devmap = tmp; |
| 452 |
break; |
| 453 |
} |
| 454 |
} |
| 455 |
return devmap; |
| 456 |
} |
| 457 |
|
| 458 |
/* |
| 459 |
* Find devmap for device with given bus_id. |
| 460 |
*/ |
| 461 |
static struct dasd_devmap * |
| 462 |
dasd_find_busid(const char *bus_id) |
| 463 |
{ |
| 464 |
struct dasd_devmap *devmap; |
| 465 |
|
| 466 |
spin_lock(&dasd_devmap_lock); |
| 467 |
devmap = dasd_find_busid_locked(bus_id); |
| 468 |
spin_unlock(&dasd_devmap_lock); |
| 469 |
return devmap; |
| 470 |
} |
| 471 |
|
| 472 |
/* |
| 473 |
* Check if busid has been added to the list of dasd ranges. |
| 474 |
*/ |
| 475 |
int |
| 476 |
dasd_busid_known(const char *bus_id) |
| 477 |
{ |
| 478 |
return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0; |
| 479 |
} |
| 480 |
|
| 481 |
/* |
| 482 |
* Forget all about the device numbers added so far. |
| 483 |
* This may only be called at module unload or system shutdown. |
| 484 |
*/ |
| 485 |
static void |
| 486 |
dasd_forget_ranges(void) |
| 487 |
{ |
| 488 |
struct dasd_devmap *devmap, *n; |
| 489 |
int i; |
| 490 |
|
| 491 |
spin_lock(&dasd_devmap_lock); |
| 492 |
for (i = 0; i < 256; i++) { |
| 493 |
list_for_each_entry_safe(devmap, n, &dasd_hashlists[i], list) { |
| 494 |
BUG_ON(devmap->device != NULL); |
| 495 |
list_del(&devmap->list); |
| 496 |
kfree(devmap); |
| 497 |
} |
| 498 |
} |
| 499 |
spin_unlock(&dasd_devmap_lock); |
| 500 |
} |
| 501 |
|
| 502 |
/* |
| 503 |
* Find the device struct by its device index. |
| 504 |
*/ |
| 505 |
struct dasd_device * |
| 506 |
dasd_device_from_devindex(int devindex) |
| 507 |
{ |
| 508 |
struct dasd_devmap *devmap, *tmp; |
| 509 |
struct dasd_device *device; |
| 510 |
int i; |
| 511 |
|
| 512 |
spin_lock(&dasd_devmap_lock); |
| 513 |
devmap = NULL; |
| 514 |
for (i = 0; (i < 256) && !devmap; i++) |
| 515 |
list_for_each_entry(tmp, &dasd_hashlists[i], list) |
| 516 |
if (tmp->devindex == devindex) { |
| 517 |
/* Found the devmap for the device. */ |
| 518 |
devmap = tmp; |
| 519 |
break; |
| 520 |
} |
| 521 |
if (devmap && devmap->device) { |
| 522 |
device = devmap->device; |
| 523 |
dasd_get_device(device); |
| 524 |
} else |
| 525 |
device = ERR_PTR(-ENODEV); |
| 526 |
spin_unlock(&dasd_devmap_lock); |
| 527 |
return device; |
| 528 |
} |
| 529 |
|
| 530 |
/* |
| 531 |
* Return devmap for cdev. If no devmap exists yet, create one and |
| 532 |
* connect it to the cdev. |
| 533 |
*/ |
| 534 |
static struct dasd_devmap * |
| 535 |
dasd_devmap_from_cdev(struct ccw_device *cdev) |
| 536 |
{ |
| 537 |
struct dasd_devmap *devmap; |
| 538 |
|
| 539 |
devmap = dasd_find_busid(dev_name(&cdev->dev)); |
| 540 |
if (IS_ERR(devmap)) |
| 541 |
devmap = dasd_add_busid(dev_name(&cdev->dev), |
| 542 |
DASD_FEATURE_DEFAULT); |
| 543 |
return devmap; |
| 544 |
} |
| 545 |
|
| 546 |
/* |
| 547 |
* Create a dasd device structure for cdev. |
| 548 |
*/ |
| 549 |
struct dasd_device * |
| 550 |
dasd_create_device(struct ccw_device *cdev) |
| 551 |
{ |
| 552 |
struct dasd_devmap *devmap; |
| 553 |
struct dasd_device *device; |
| 554 |
unsigned long flags; |
| 555 |
int rc; |
| 556 |
|
| 557 |
devmap = dasd_devmap_from_cdev(cdev); |
| 558 |
if (IS_ERR(devmap)) |
| 559 |
return (void *) devmap; |
| 560 |
|
| 561 |
device = dasd_alloc_device(); |
| 562 |
if (IS_ERR(device)) |
| 563 |
return device; |
| 564 |
atomic_set(&device->ref_count, 3); |
| 565 |
|
| 566 |
spin_lock(&dasd_devmap_lock); |
| 567 |
if (!devmap->device) { |
| 568 |
devmap->device = device; |
| 569 |
device->devindex = devmap->devindex; |
| 570 |
device->features = devmap->features; |
| 571 |
get_device(&cdev->dev); |
| 572 |
device->cdev = cdev; |
| 573 |
rc = 0; |
| 574 |
} else |
| 575 |
/* Someone else was faster. */ |
| 576 |
rc = -EBUSY; |
| 577 |
spin_unlock(&dasd_devmap_lock); |
| 578 |
|
| 579 |
if (rc) { |
| 580 |
dasd_free_device(device); |
| 581 |
return ERR_PTR(rc); |
| 582 |
} |
| 583 |
|
| 584 |
spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 585 |
dev_set_drvdata(&cdev->dev, device); |
| 586 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 587 |
|
| 588 |
device->paths_info = kset_create_and_add("paths_info", NULL, |
| 589 |
&device->cdev->dev.kobj); |
| 590 |
if (!device->paths_info) |
| 591 |
dev_warn(&cdev->dev, "Could not create paths_info kset\n"); |
| 592 |
|
| 593 |
return device; |
| 594 |
} |
| 595 |
|
| 596 |
/* |
| 597 |
* allocate a PPRC data structure and call the discipline function to fill |
| 598 |
*/ |
| 599 |
static int dasd_devmap_get_pprc_status(struct dasd_device *device, |
| 600 |
struct dasd_pprc_data_sc4 **data) |
| 601 |
{ |
| 602 |
struct dasd_pprc_data_sc4 *temp; |
| 603 |
|
| 604 |
if (!device->discipline || !device->discipline->pprc_status) { |
| 605 |
dev_warn(&device->cdev->dev, "Unable to query copy relation status\n"); |
| 606 |
return -EOPNOTSUPP; |
| 607 |
} |
| 608 |
temp = kzalloc_obj(*temp); |
| 609 |
if (!temp) |
| 610 |
return -ENOMEM; |
| 611 |
|
| 612 |
/* get PPRC information from storage */ |
| 613 |
if (device->discipline->pprc_status(device, temp)) { |
| 614 |
dev_warn(&device->cdev->dev, "Error during copy relation status query\n"); |
| 615 |
kfree(temp); |
| 616 |
return -EINVAL; |
| 617 |
} |
| 618 |
*data = temp; |
| 619 |
|
| 620 |
return 0; |
| 621 |
} |
| 622 |
|
| 623 |
/* |
| 624 |
* find an entry in a PPRC device_info array by a given UID |
| 625 |
* depending on the primary/secondary state of the device it has to be |
| 626 |
* matched with the respective fields |
| 627 |
*/ |
| 628 |
static int dasd_devmap_entry_from_pprc_data(struct dasd_pprc_data_sc4 *data, |
| 629 |
struct dasd_uid uid, |
| 630 |
bool primary) |
| 631 |
{ |
| 632 |
int i; |
| 633 |
|
| 634 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 635 |
if (primary) { |
| 636 |
if (data->dev_info[i].prim_cu_ssid == uid.ssid && |
| 637 |
data->dev_info[i].primary == uid.real_unit_addr) |
| 638 |
return i; |
| 639 |
} else { |
| 640 |
if (data->dev_info[i].sec_cu_ssid == uid.ssid && |
| 641 |
data->dev_info[i].secondary == uid.real_unit_addr) |
| 642 |
return i; |
| 643 |
} |
| 644 |
} |
| 645 |
return -1; |
| 646 |
} |
| 647 |
|
| 648 |
/* |
| 649 |
* check the consistency of a specified copy relation by checking |
| 650 |
* the following things: |
| 651 |
* |
| 652 |
* - is the given device part of a copy pair setup |
| 653 |
* - does the state of the device match the state in the PPRC status data |
| 654 |
* - does the device UID match with the UID in the PPRC status data |
| 655 |
* - to prevent misrouted IO check if the given device is present in all |
| 656 |
* related PPRC status data |
| 657 |
*/ |
| 658 |
static int dasd_devmap_check_copy_relation(struct dasd_device *device, |
| 659 |
struct dasd_copy_entry *entry, |
| 660 |
struct dasd_pprc_data_sc4 *data, |
| 661 |
struct dasd_copy_relation *copy) |
| 662 |
{ |
| 663 |
struct dasd_pprc_data_sc4 *tmp_dat; |
| 664 |
struct dasd_device *tmp_dev; |
| 665 |
struct dasd_uid uid; |
| 666 |
int i, j; |
| 667 |
|
| 668 |
if (!device->discipline || !device->discipline->get_uid || |
| 669 |
device->discipline->get_uid(device, &uid)) |
| 670 |
return 1; |
| 671 |
|
| 672 |
i = dasd_devmap_entry_from_pprc_data(data, uid, entry->primary); |
| 673 |
if (i < 0) { |
| 674 |
dev_warn(&device->cdev->dev, "Device not part of a copy relation\n"); |
| 675 |
return 1; |
| 676 |
} |
| 677 |
|
| 678 |
/* double check which role the current device has */ |
| 679 |
if (entry->primary) { |
| 680 |
if (data->dev_info[i].flags & 0x80) { |
| 681 |
dev_warn(&device->cdev->dev, "Copy pair secondary is setup as primary\n"); |
| 682 |
return 1; |
| 683 |
} |
| 684 |
if (data->dev_info[i].prim_cu_ssid != uid.ssid || |
| 685 |
data->dev_info[i].primary != uid.real_unit_addr) { |
| 686 |
dev_warn(&device->cdev->dev, |
| 687 |
"Primary device %s does not match copy pair status primary device %04x\n", |
| 688 |
dev_name(&device->cdev->dev), |
| 689 |
data->dev_info[i].prim_cu_ssid | |
| 690 |
data->dev_info[i].primary); |
| 691 |
return 1; |
| 692 |
} |
| 693 |
} else { |
| 694 |
if (!(data->dev_info[i].flags & 0x80)) { |
| 695 |
dev_warn(&device->cdev->dev, "Copy pair primary is setup as secondary\n"); |
| 696 |
return 1; |
| 697 |
} |
| 698 |
if (data->dev_info[i].sec_cu_ssid != uid.ssid || |
| 699 |
data->dev_info[i].secondary != uid.real_unit_addr) { |
| 700 |
dev_warn(&device->cdev->dev, |
| 701 |
"Secondary device %s does not match copy pair status secondary device %04x\n", |
| 702 |
dev_name(&device->cdev->dev), |
| 703 |
data->dev_info[i].sec_cu_ssid | |
| 704 |
data->dev_info[i].secondary); |
| 705 |
return 1; |
| 706 |
} |
| 707 |
} |
| 708 |
|
| 709 |
/* |
| 710 |
* the current device has to be part of the copy relation of all |
| 711 |
* entries to prevent misrouted IO to another copy pair |
| 712 |
*/ |
| 713 |
for (j = 0; j < DASD_CP_ENTRIES; j++) { |
| 714 |
if (entry == ©->entry[j]) |
| 715 |
tmp_dev = device; |
| 716 |
else |
| 717 |
tmp_dev = copy->entry[j].device; |
| 718 |
|
| 719 |
if (!tmp_dev) |
| 720 |
continue; |
| 721 |
|
| 722 |
if (dasd_devmap_get_pprc_status(tmp_dev, &tmp_dat)) |
| 723 |
return 1; |
| 724 |
|
| 725 |
if (dasd_devmap_entry_from_pprc_data(tmp_dat, uid, entry->primary) < 0) { |
| 726 |
dev_warn(&tmp_dev->cdev->dev, |
| 727 |
"Copy pair relation does not contain device: %s\n", |
| 728 |
dev_name(&device->cdev->dev)); |
| 729 |
kfree(tmp_dat); |
| 730 |
return 1; |
| 731 |
} |
| 732 |
kfree(tmp_dat); |
| 733 |
} |
| 734 |
return 0; |
| 735 |
} |
| 736 |
|
| 737 |
/* delete device from copy relation entry */ |
| 738 |
static void dasd_devmap_delete_copy_relation_device(struct dasd_device *device) |
| 739 |
{ |
| 740 |
struct dasd_copy_relation *copy; |
| 741 |
int i; |
| 742 |
|
| 743 |
if (!device->copy) |
| 744 |
return; |
| 745 |
|
| 746 |
copy = device->copy; |
| 747 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 748 |
if (copy->entry[i].device == device) |
| 749 |
copy->entry[i].device = NULL; |
| 750 |
} |
| 751 |
dasd_put_device(device); |
| 752 |
device->copy = NULL; |
| 753 |
} |
| 754 |
|
| 755 |
/* |
| 756 |
* read all required information for a copy relation setup and setup the device |
| 757 |
* accordingly |
| 758 |
*/ |
| 759 |
int dasd_devmap_set_device_copy_relation(struct ccw_device *cdev, |
| 760 |
bool pprc_enabled) |
| 761 |
{ |
| 762 |
struct dasd_pprc_data_sc4 *data = NULL; |
| 763 |
struct dasd_copy_entry *entry = NULL; |
| 764 |
struct dasd_copy_relation *copy; |
| 765 |
struct dasd_devmap *devmap; |
| 766 |
struct dasd_device *device; |
| 767 |
int i, rc = 0; |
| 768 |
|
| 769 |
devmap = dasd_devmap_from_cdev(cdev); |
| 770 |
if (IS_ERR(devmap)) |
| 771 |
return PTR_ERR(devmap); |
| 772 |
|
| 773 |
device = devmap->device; |
| 774 |
if (!device) |
| 775 |
return -ENODEV; |
| 776 |
|
| 777 |
copy = devmap->copy; |
| 778 |
/* no copy pair setup for this device */ |
| 779 |
if (!copy) |
| 780 |
goto out; |
| 781 |
|
| 782 |
rc = dasd_devmap_get_pprc_status(device, &data); |
| 783 |
if (rc) |
| 784 |
return rc; |
| 785 |
|
| 786 |
/* print error if PPRC is requested but not enabled on storage server */ |
| 787 |
if (!pprc_enabled) { |
| 788 |
dev_err(&cdev->dev, "Copy relation not enabled on storage server\n"); |
| 789 |
rc = -EINVAL; |
| 790 |
goto out; |
| 791 |
} |
| 792 |
|
| 793 |
if (!data->dev_info[0].state) { |
| 794 |
dev_warn(&device->cdev->dev, "Copy pair setup requested for device not in copy relation\n"); |
| 795 |
rc = -EINVAL; |
| 796 |
goto out; |
| 797 |
} |
| 798 |
/* find entry */ |
| 799 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 800 |
if (copy->entry[i].configured && |
| 801 |
strncmp(dev_name(&cdev->dev), |
| 802 |
copy->entry[i].busid, DASD_BUS_ID_SIZE) == 0) { |
| 803 |
entry = ©->entry[i]; |
| 804 |
break; |
| 805 |
} |
| 806 |
} |
| 807 |
if (!entry) { |
| 808 |
dev_warn(&device->cdev->dev, "Copy relation entry not found\n"); |
| 809 |
rc = -EINVAL; |
| 810 |
goto out; |
| 811 |
} |
| 812 |
/* check if the copy relation is valid */ |
| 813 |
if (dasd_devmap_check_copy_relation(device, entry, data, copy)) { |
| 814 |
dev_warn(&device->cdev->dev, "Copy relation faulty\n"); |
| 815 |
rc = -EINVAL; |
| 816 |
goto out; |
| 817 |
} |
| 818 |
|
| 819 |
dasd_get_device(device); |
| 820 |
copy->entry[i].device = device; |
| 821 |
device->copy = copy; |
| 822 |
out: |
| 823 |
kfree(data); |
| 824 |
return rc; |
| 825 |
} |
| 826 |
EXPORT_SYMBOL_GPL(dasd_devmap_set_device_copy_relation); |
| 827 |
|
| 828 |
/* |
| 829 |
* Wait queue for dasd_delete_device waits. |
| 830 |
*/ |
| 831 |
static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq); |
| 832 |
|
| 833 |
/* |
| 834 |
* Remove a dasd device structure. The passed referenced |
| 835 |
* is destroyed. |
| 836 |
*/ |
| 837 |
void |
| 838 |
dasd_delete_device(struct dasd_device *device) |
| 839 |
{ |
| 840 |
struct ccw_device *cdev; |
| 841 |
struct dasd_devmap *devmap; |
| 842 |
unsigned long flags; |
| 843 |
|
| 844 |
/* First remove device pointer from devmap. */ |
| 845 |
devmap = dasd_find_busid(dev_name(&device->cdev->dev)); |
| 846 |
BUG_ON(IS_ERR(devmap)); |
| 847 |
spin_lock(&dasd_devmap_lock); |
| 848 |
if (devmap->device != device) { |
| 849 |
spin_unlock(&dasd_devmap_lock); |
| 850 |
dasd_put_device(device); |
| 851 |
return; |
| 852 |
} |
| 853 |
devmap->device = NULL; |
| 854 |
spin_unlock(&dasd_devmap_lock); |
| 855 |
|
| 856 |
/* Disconnect dasd_device structure from ccw_device structure. */ |
| 857 |
spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
| 858 |
dev_set_drvdata(&device->cdev->dev, NULL); |
| 859 |
spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 860 |
|
| 861 |
/* Remove copy relation */ |
| 862 |
dasd_devmap_delete_copy_relation_device(device); |
| 863 |
/* |
| 864 |
* Drop ref_count by 3, one for the devmap reference, one for |
| 865 |
* the cdev reference and one for the passed reference. |
| 866 |
*/ |
| 867 |
atomic_sub(3, &device->ref_count); |
| 868 |
|
| 869 |
/* Wait for reference counter to drop to zero. */ |
| 870 |
wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0); |
| 871 |
|
| 872 |
dasd_generic_free_discipline(device); |
| 873 |
|
| 874 |
kset_unregister(device->paths_info); |
| 875 |
|
| 876 |
/* Disconnect dasd_device structure from ccw_device structure. */ |
| 877 |
cdev = device->cdev; |
| 878 |
device->cdev = NULL; |
| 879 |
|
| 880 |
/* Put ccw_device structure. */ |
| 881 |
put_device(&cdev->dev); |
| 882 |
|
| 883 |
/* Now the device structure can be freed. */ |
| 884 |
dasd_free_device(device); |
| 885 |
} |
| 886 |
|
| 887 |
/* |
| 888 |
* Reference counter dropped to zero. Wake up waiter |
| 889 |
* in dasd_delete_device. |
| 890 |
*/ |
| 891 |
void |
| 892 |
dasd_put_device_wake(struct dasd_device *device) |
| 893 |
{ |
| 894 |
wake_up(&dasd_delete_wq); |
| 895 |
} |
| 896 |
EXPORT_SYMBOL_GPL(dasd_put_device_wake); |
| 897 |
|
| 898 |
/* |
| 899 |
* Return dasd_device structure associated with cdev. |
| 900 |
* This function needs to be called with the ccw device |
| 901 |
* lock held. It can be used from interrupt context. |
| 902 |
*/ |
| 903 |
struct dasd_device * |
| 904 |
dasd_device_from_cdev_locked(struct ccw_device *cdev) |
| 905 |
{ |
| 906 |
struct dasd_device *device = dev_get_drvdata(&cdev->dev); |
| 907 |
|
| 908 |
if (!device) |
| 909 |
return ERR_PTR(-ENODEV); |
| 910 |
dasd_get_device(device); |
| 911 |
return device; |
| 912 |
} |
| 913 |
|
| 914 |
/* |
| 915 |
* Return dasd_device structure associated with cdev. |
| 916 |
*/ |
| 917 |
struct dasd_device * |
| 918 |
dasd_device_from_cdev(struct ccw_device *cdev) |
| 919 |
{ |
| 920 |
struct dasd_device *device; |
| 921 |
unsigned long flags; |
| 922 |
|
| 923 |
spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 924 |
device = dasd_device_from_cdev_locked(cdev); |
| 925 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 926 |
return device; |
| 927 |
} |
| 928 |
|
| 929 |
void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device) |
| 930 |
{ |
| 931 |
struct dasd_devmap *devmap; |
| 932 |
|
| 933 |
devmap = dasd_find_busid(dev_name(&device->cdev->dev)); |
| 934 |
if (IS_ERR(devmap)) |
| 935 |
return; |
| 936 |
spin_lock(&dasd_devmap_lock); |
| 937 |
gdp->private_data = devmap; |
| 938 |
spin_unlock(&dasd_devmap_lock); |
| 939 |
} |
| 940 |
EXPORT_SYMBOL(dasd_add_link_to_gendisk); |
| 941 |
|
| 942 |
struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp) |
| 943 |
{ |
| 944 |
struct dasd_device *device; |
| 945 |
struct dasd_devmap *devmap; |
| 946 |
|
| 947 |
if (!gdp->private_data) |
| 948 |
return NULL; |
| 949 |
device = NULL; |
| 950 |
spin_lock(&dasd_devmap_lock); |
| 951 |
devmap = gdp->private_data; |
| 952 |
if (devmap && devmap->device) { |
| 953 |
device = devmap->device; |
| 954 |
dasd_get_device(device); |
| 955 |
} |
| 956 |
spin_unlock(&dasd_devmap_lock); |
| 957 |
return device; |
| 958 |
} |
| 959 |
|
| 960 |
/* |
| 961 |
* SECTION: files in sysfs |
| 962 |
*/ |
| 963 |
|
| 964 |
/* |
| 965 |
* failfast controls the behaviour, if no path is available |
| 966 |
*/ |
| 967 |
static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr, |
| 968 |
char *buf) |
| 969 |
{ |
| 970 |
struct dasd_devmap *devmap; |
| 971 |
int ff_flag; |
| 972 |
|
| 973 |
devmap = dasd_find_busid(dev_name(dev)); |
| 974 |
if (!IS_ERR(devmap)) |
| 975 |
ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0; |
| 976 |
else |
| 977 |
ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0; |
| 978 |
return sysfs_emit(buf, ff_flag ? "1\n" : "0\n"); |
| 979 |
} |
| 980 |
|
| 981 |
static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr, |
| 982 |
const char *buf, size_t count) |
| 983 |
{ |
| 984 |
unsigned int val; |
| 985 |
int rc; |
| 986 |
|
| 987 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 988 |
return -EINVAL; |
| 989 |
|
| 990 |
rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_FAILFAST, val); |
| 991 |
|
| 992 |
return rc ? : count; |
| 993 |
} |
| 994 |
|
| 995 |
static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store); |
| 996 |
|
| 997 |
/* |
| 998 |
* readonly controls the readonly status of a dasd |
| 999 |
*/ |
| 1000 |
static ssize_t |
| 1001 |
dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1002 |
{ |
| 1003 |
struct dasd_devmap *devmap; |
| 1004 |
struct dasd_device *device; |
| 1005 |
int ro_flag = 0; |
| 1006 |
|
| 1007 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1008 |
if (IS_ERR(devmap)) |
| 1009 |
goto out; |
| 1010 |
|
| 1011 |
ro_flag = !!(devmap->features & DASD_FEATURE_READONLY); |
| 1012 |
|
| 1013 |
spin_lock(&dasd_devmap_lock); |
| 1014 |
device = devmap->device; |
| 1015 |
if (device) |
| 1016 |
ro_flag |= test_bit(DASD_FLAG_DEVICE_RO, &device->flags); |
| 1017 |
spin_unlock(&dasd_devmap_lock); |
| 1018 |
|
| 1019 |
out: |
| 1020 |
return sysfs_emit(buf, ro_flag ? "1\n" : "0\n"); |
| 1021 |
} |
| 1022 |
|
| 1023 |
static ssize_t |
| 1024 |
dasd_ro_store(struct device *dev, struct device_attribute *attr, |
| 1025 |
const char *buf, size_t count) |
| 1026 |
{ |
| 1027 |
struct ccw_device *cdev = to_ccwdev(dev); |
| 1028 |
struct dasd_device *device; |
| 1029 |
unsigned long flags; |
| 1030 |
unsigned int val; |
| 1031 |
int rc; |
| 1032 |
|
| 1033 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 1034 |
return -EINVAL; |
| 1035 |
|
| 1036 |
rc = dasd_set_feature(cdev, DASD_FEATURE_READONLY, val); |
| 1037 |
if (rc) |
| 1038 |
return rc; |
| 1039 |
|
| 1040 |
device = dasd_device_from_cdev(cdev); |
| 1041 |
if (IS_ERR(device)) |
| 1042 |
return count; |
| 1043 |
|
| 1044 |
spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 1045 |
val = val || test_bit(DASD_FLAG_DEVICE_RO, &device->flags); |
| 1046 |
|
| 1047 |
if (!device->block || !device->block->gdp || |
| 1048 |
test_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 1049 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1050 |
goto out; |
| 1051 |
} |
| 1052 |
/* Increase open_count to avoid losing the block device */ |
| 1053 |
atomic_inc(&device->block->open_count); |
| 1054 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1055 |
|
| 1056 |
set_disk_ro(device->block->gdp, val); |
| 1057 |
atomic_dec(&device->block->open_count); |
| 1058 |
|
| 1059 |
out: |
| 1060 |
dasd_put_device(device); |
| 1061 |
|
| 1062 |
return count; |
| 1063 |
} |
| 1064 |
|
| 1065 |
static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store); |
| 1066 |
/* |
| 1067 |
* erplog controls the logging of ERP related data |
| 1068 |
* (e.g. failing channel programs). |
| 1069 |
*/ |
| 1070 |
static ssize_t |
| 1071 |
dasd_erplog_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1072 |
{ |
| 1073 |
struct dasd_devmap *devmap; |
| 1074 |
int erplog; |
| 1075 |
|
| 1076 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1077 |
if (!IS_ERR(devmap)) |
| 1078 |
erplog = (devmap->features & DASD_FEATURE_ERPLOG) != 0; |
| 1079 |
else |
| 1080 |
erplog = (DASD_FEATURE_DEFAULT & DASD_FEATURE_ERPLOG) != 0; |
| 1081 |
return sysfs_emit(buf, erplog ? "1\n" : "0\n"); |
| 1082 |
} |
| 1083 |
|
| 1084 |
static ssize_t |
| 1085 |
dasd_erplog_store(struct device *dev, struct device_attribute *attr, |
| 1086 |
const char *buf, size_t count) |
| 1087 |
{ |
| 1088 |
unsigned int val; |
| 1089 |
int rc; |
| 1090 |
|
| 1091 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 1092 |
return -EINVAL; |
| 1093 |
|
| 1094 |
rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_ERPLOG, val); |
| 1095 |
|
| 1096 |
return rc ? : count; |
| 1097 |
} |
| 1098 |
|
| 1099 |
static DEVICE_ATTR(erplog, 0644, dasd_erplog_show, dasd_erplog_store); |
| 1100 |
|
| 1101 |
/* |
| 1102 |
* use_diag controls whether the driver should use diag rather than ssch |
| 1103 |
* to talk to the device |
| 1104 |
*/ |
| 1105 |
static ssize_t |
| 1106 |
dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1107 |
{ |
| 1108 |
struct dasd_devmap *devmap; |
| 1109 |
int use_diag; |
| 1110 |
|
| 1111 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1112 |
if (!IS_ERR(devmap)) |
| 1113 |
use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0; |
| 1114 |
else |
| 1115 |
use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0; |
| 1116 |
return sysfs_emit(buf, use_diag ? "1\n" : "0\n"); |
| 1117 |
} |
| 1118 |
|
| 1119 |
static ssize_t |
| 1120 |
dasd_use_diag_store(struct device *dev, struct device_attribute *attr, |
| 1121 |
const char *buf, size_t count) |
| 1122 |
{ |
| 1123 |
struct dasd_devmap *devmap; |
| 1124 |
unsigned int val; |
| 1125 |
ssize_t rc; |
| 1126 |
|
| 1127 |
devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 1128 |
if (IS_ERR(devmap)) |
| 1129 |
return PTR_ERR(devmap); |
| 1130 |
|
| 1131 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 1132 |
return -EINVAL; |
| 1133 |
|
| 1134 |
spin_lock(&dasd_devmap_lock); |
| 1135 |
/* Changing diag discipline flag is only allowed in offline state. */ |
| 1136 |
rc = count; |
| 1137 |
if (!devmap->device && !(devmap->features & DASD_FEATURE_USERAW)) { |
| 1138 |
if (val) |
| 1139 |
devmap->features |= DASD_FEATURE_USEDIAG; |
| 1140 |
else |
| 1141 |
devmap->features &= ~DASD_FEATURE_USEDIAG; |
| 1142 |
} else |
| 1143 |
rc = -EPERM; |
| 1144 |
spin_unlock(&dasd_devmap_lock); |
| 1145 |
return rc; |
| 1146 |
} |
| 1147 |
|
| 1148 |
static DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store); |
| 1149 |
|
| 1150 |
/* |
| 1151 |
* use_raw controls whether the driver should give access to raw eckd data or |
| 1152 |
* operate in standard mode |
| 1153 |
*/ |
| 1154 |
static ssize_t |
| 1155 |
dasd_use_raw_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1156 |
{ |
| 1157 |
struct dasd_devmap *devmap; |
| 1158 |
int use_raw; |
| 1159 |
|
| 1160 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1161 |
if (!IS_ERR(devmap)) |
| 1162 |
use_raw = (devmap->features & DASD_FEATURE_USERAW) != 0; |
| 1163 |
else |
| 1164 |
use_raw = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USERAW) != 0; |
| 1165 |
return sysfs_emit(buf, use_raw ? "1\n" : "0\n"); |
| 1166 |
} |
| 1167 |
|
| 1168 |
static ssize_t |
| 1169 |
dasd_use_raw_store(struct device *dev, struct device_attribute *attr, |
| 1170 |
const char *buf, size_t count) |
| 1171 |
{ |
| 1172 |
struct dasd_devmap *devmap; |
| 1173 |
ssize_t rc; |
| 1174 |
unsigned long val; |
| 1175 |
|
| 1176 |
devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 1177 |
if (IS_ERR(devmap)) |
| 1178 |
return PTR_ERR(devmap); |
| 1179 |
|
| 1180 |
if ((kstrtoul(buf, 10, &val) != 0) || val > 1) |
| 1181 |
return -EINVAL; |
| 1182 |
|
| 1183 |
spin_lock(&dasd_devmap_lock); |
| 1184 |
/* Changing diag discipline flag is only allowed in offline state. */ |
| 1185 |
rc = count; |
| 1186 |
if (!devmap->device && !(devmap->features & DASD_FEATURE_USEDIAG)) { |
| 1187 |
if (val) |
| 1188 |
devmap->features |= DASD_FEATURE_USERAW; |
| 1189 |
else |
| 1190 |
devmap->features &= ~DASD_FEATURE_USERAW; |
| 1191 |
} else |
| 1192 |
rc = -EPERM; |
| 1193 |
spin_unlock(&dasd_devmap_lock); |
| 1194 |
return rc; |
| 1195 |
} |
| 1196 |
|
| 1197 |
static DEVICE_ATTR(raw_track_access, 0644, dasd_use_raw_show, |
| 1198 |
dasd_use_raw_store); |
| 1199 |
|
| 1200 |
static ssize_t |
| 1201 |
dasd_safe_offline_store(struct device *dev, struct device_attribute *attr, |
| 1202 |
const char *buf, size_t count) |
| 1203 |
{ |
| 1204 |
struct ccw_device *cdev = to_ccwdev(dev); |
| 1205 |
struct dasd_device *device; |
| 1206 |
unsigned long flags; |
| 1207 |
int rc; |
| 1208 |
|
| 1209 |
spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 1210 |
device = dasd_device_from_cdev_locked(cdev); |
| 1211 |
if (IS_ERR(device)) { |
| 1212 |
rc = PTR_ERR(device); |
| 1213 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1214 |
goto out; |
| 1215 |
} |
| 1216 |
|
| 1217 |
if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || |
| 1218 |
test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { |
| 1219 |
/* Already doing offline processing */ |
| 1220 |
dasd_put_device(device); |
| 1221 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1222 |
rc = -EBUSY; |
| 1223 |
goto out; |
| 1224 |
} |
| 1225 |
|
| 1226 |
set_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags); |
| 1227 |
dasd_put_device(device); |
| 1228 |
spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1229 |
|
| 1230 |
rc = ccw_device_set_offline(cdev); |
| 1231 |
|
| 1232 |
out: |
| 1233 |
return rc ? rc : count; |
| 1234 |
} |
| 1235 |
|
| 1236 |
static DEVICE_ATTR(safe_offline, 0200, NULL, dasd_safe_offline_store); |
| 1237 |
|
| 1238 |
static ssize_t |
| 1239 |
dasd_access_show(struct device *dev, struct device_attribute *attr, |
| 1240 |
char *buf) |
| 1241 |
{ |
| 1242 |
struct ccw_device *cdev = to_ccwdev(dev); |
| 1243 |
struct dasd_device *device; |
| 1244 |
int count; |
| 1245 |
|
| 1246 |
device = dasd_device_from_cdev(cdev); |
| 1247 |
if (IS_ERR(device)) |
| 1248 |
return PTR_ERR(device); |
| 1249 |
|
| 1250 |
if (!device->discipline) |
| 1251 |
count = -ENODEV; |
| 1252 |
else if (!device->discipline->host_access_count) |
| 1253 |
count = -EOPNOTSUPP; |
| 1254 |
else |
| 1255 |
count = device->discipline->host_access_count(device); |
| 1256 |
|
| 1257 |
dasd_put_device(device); |
| 1258 |
if (count < 0) |
| 1259 |
return count; |
| 1260 |
|
| 1261 |
return sysfs_emit(buf, "%d\n", count); |
| 1262 |
} |
| 1263 |
|
| 1264 |
static DEVICE_ATTR(host_access_count, 0444, dasd_access_show, NULL); |
| 1265 |
|
| 1266 |
static ssize_t |
| 1267 |
dasd_discipline_show(struct device *dev, struct device_attribute *attr, |
| 1268 |
char *buf) |
| 1269 |
{ |
| 1270 |
struct dasd_device *device; |
| 1271 |
ssize_t len; |
| 1272 |
|
| 1273 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1274 |
if (IS_ERR(device)) |
| 1275 |
goto out; |
| 1276 |
else if (!device->discipline) { |
| 1277 |
dasd_put_device(device); |
| 1278 |
goto out; |
| 1279 |
} else { |
| 1280 |
len = sysfs_emit(buf, "%s\n", |
| 1281 |
device->discipline->name); |
| 1282 |
dasd_put_device(device); |
| 1283 |
return len; |
| 1284 |
} |
| 1285 |
out: |
| 1286 |
len = sysfs_emit(buf, "none\n"); |
| 1287 |
return len; |
| 1288 |
} |
| 1289 |
|
| 1290 |
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); |
| 1291 |
|
| 1292 |
static ssize_t |
| 1293 |
dasd_device_status_show(struct device *dev, struct device_attribute *attr, |
| 1294 |
char *buf) |
| 1295 |
{ |
| 1296 |
struct dasd_device *device; |
| 1297 |
ssize_t len; |
| 1298 |
|
| 1299 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1300 |
if (!IS_ERR(device)) { |
| 1301 |
switch (device->state) { |
| 1302 |
case DASD_STATE_NEW: |
| 1303 |
len = sysfs_emit(buf, "new\n"); |
| 1304 |
break; |
| 1305 |
case DASD_STATE_KNOWN: |
| 1306 |
len = sysfs_emit(buf, "detected\n"); |
| 1307 |
break; |
| 1308 |
case DASD_STATE_BASIC: |
| 1309 |
len = sysfs_emit(buf, "basic\n"); |
| 1310 |
break; |
| 1311 |
case DASD_STATE_UNFMT: |
| 1312 |
len = sysfs_emit(buf, "unformatted\n"); |
| 1313 |
break; |
| 1314 |
case DASD_STATE_READY: |
| 1315 |
len = sysfs_emit(buf, "ready\n"); |
| 1316 |
break; |
| 1317 |
case DASD_STATE_ONLINE: |
| 1318 |
len = sysfs_emit(buf, "online\n"); |
| 1319 |
break; |
| 1320 |
default: |
| 1321 |
len = sysfs_emit(buf, "no stat\n"); |
| 1322 |
break; |
| 1323 |
} |
| 1324 |
dasd_put_device(device); |
| 1325 |
} else |
| 1326 |
len = sysfs_emit(buf, "unknown\n"); |
| 1327 |
return len; |
| 1328 |
} |
| 1329 |
|
| 1330 |
static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL); |
| 1331 |
|
| 1332 |
static ssize_t dasd_alias_show(struct device *dev, |
| 1333 |
struct device_attribute *attr, char *buf) |
| 1334 |
{ |
| 1335 |
struct dasd_device *device; |
| 1336 |
struct dasd_uid uid; |
| 1337 |
|
| 1338 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1339 |
if (IS_ERR(device)) |
| 1340 |
return sysfs_emit(buf, "0\n"); |
| 1341 |
|
| 1342 |
if (device->discipline && device->discipline->get_uid && |
| 1343 |
!device->discipline->get_uid(device, &uid)) { |
| 1344 |
if (uid.type == UA_BASE_PAV_ALIAS || |
| 1345 |
uid.type == UA_HYPER_PAV_ALIAS) { |
| 1346 |
dasd_put_device(device); |
| 1347 |
return sysfs_emit(buf, "1\n"); |
| 1348 |
} |
| 1349 |
} |
| 1350 |
dasd_put_device(device); |
| 1351 |
|
| 1352 |
return sysfs_emit(buf, "0\n"); |
| 1353 |
} |
| 1354 |
|
| 1355 |
static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL); |
| 1356 |
|
| 1357 |
static ssize_t dasd_vendor_show(struct device *dev, |
| 1358 |
struct device_attribute *attr, char *buf) |
| 1359 |
{ |
| 1360 |
struct dasd_device *device; |
| 1361 |
struct dasd_uid uid; |
| 1362 |
char *vendor; |
| 1363 |
|
| 1364 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1365 |
vendor = ""; |
| 1366 |
if (IS_ERR(device)) |
| 1367 |
return sysfs_emit(buf, "%s\n", vendor); |
| 1368 |
|
| 1369 |
if (device->discipline && device->discipline->get_uid && |
| 1370 |
!device->discipline->get_uid(device, &uid)) |
| 1371 |
vendor = uid.vendor; |
| 1372 |
|
| 1373 |
dasd_put_device(device); |
| 1374 |
|
| 1375 |
return sysfs_emit(buf, "%s\n", vendor); |
| 1376 |
} |
| 1377 |
|
| 1378 |
static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); |
| 1379 |
|
| 1380 |
static ssize_t |
| 1381 |
dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1382 |
{ |
| 1383 |
char uid_string[DASD_UID_STRLEN]; |
| 1384 |
struct dasd_device *device; |
| 1385 |
struct dasd_uid uid; |
| 1386 |
char ua_string[3]; |
| 1387 |
|
| 1388 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1389 |
uid_string[0] = 0; |
| 1390 |
if (IS_ERR(device)) |
| 1391 |
return sysfs_emit(buf, "%s\n", uid_string); |
| 1392 |
|
| 1393 |
if (device->discipline && device->discipline->get_uid && |
| 1394 |
!device->discipline->get_uid(device, &uid)) { |
| 1395 |
switch (uid.type) { |
| 1396 |
case UA_BASE_DEVICE: |
| 1397 |
snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1398 |
uid.real_unit_addr); |
| 1399 |
break; |
| 1400 |
case UA_BASE_PAV_ALIAS: |
| 1401 |
snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1402 |
uid.base_unit_addr); |
| 1403 |
break; |
| 1404 |
case UA_HYPER_PAV_ALIAS: |
| 1405 |
snprintf(ua_string, sizeof(ua_string), "xx"); |
| 1406 |
break; |
| 1407 |
default: |
| 1408 |
/* should not happen, treat like base device */ |
| 1409 |
snprintf(ua_string, sizeof(ua_string), "%02x", |
| 1410 |
uid.real_unit_addr); |
| 1411 |
break; |
| 1412 |
} |
| 1413 |
|
| 1414 |
snprintf(uid_string, sizeof(uid_string), "%s.%s.%04x.%s%s%s", |
| 1415 |
uid.vendor, uid.serial, uid.ssid, ua_string, |
| 1416 |
uid.vduit[0] ? "." : "", uid.vduit); |
| 1417 |
} |
| 1418 |
dasd_put_device(device); |
| 1419 |
|
| 1420 |
return sysfs_emit(buf, "%s\n", uid_string); |
| 1421 |
} |
| 1422 |
static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL); |
| 1423 |
|
| 1424 |
/* |
| 1425 |
* extended error-reporting |
| 1426 |
*/ |
| 1427 |
static ssize_t |
| 1428 |
dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1429 |
{ |
| 1430 |
struct dasd_devmap *devmap; |
| 1431 |
int eer_flag; |
| 1432 |
|
| 1433 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1434 |
if (!IS_ERR(devmap) && devmap->device) |
| 1435 |
eer_flag = dasd_eer_enabled(devmap->device); |
| 1436 |
else |
| 1437 |
eer_flag = 0; |
| 1438 |
return sysfs_emit(buf, eer_flag ? "1\n" : "0\n"); |
| 1439 |
} |
| 1440 |
|
| 1441 |
static ssize_t |
| 1442 |
dasd_eer_store(struct device *dev, struct device_attribute *attr, |
| 1443 |
const char *buf, size_t count) |
| 1444 |
{ |
| 1445 |
struct dasd_device *device; |
| 1446 |
unsigned int val; |
| 1447 |
int rc = 0; |
| 1448 |
|
| 1449 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1450 |
if (IS_ERR(device)) |
| 1451 |
return PTR_ERR(device); |
| 1452 |
|
| 1453 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 1454 |
return -EINVAL; |
| 1455 |
|
| 1456 |
if (val) |
| 1457 |
rc = dasd_eer_enable(device); |
| 1458 |
else |
| 1459 |
dasd_eer_disable(device); |
| 1460 |
|
| 1461 |
dasd_put_device(device); |
| 1462 |
|
| 1463 |
return rc ? : count; |
| 1464 |
} |
| 1465 |
|
| 1466 |
static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store); |
| 1467 |
|
| 1468 |
/* |
| 1469 |
* aq_mask controls if the DASD should be quiesced on certain triggers |
| 1470 |
* The aq_mask attribute is interpreted as bitmap of the DASD_EER_* triggers. |
| 1471 |
*/ |
| 1472 |
static ssize_t dasd_aq_mask_show(struct device *dev, struct device_attribute *attr, |
| 1473 |
char *buf) |
| 1474 |
{ |
| 1475 |
struct dasd_devmap *devmap; |
| 1476 |
unsigned int aq_mask = 0; |
| 1477 |
|
| 1478 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1479 |
if (!IS_ERR(devmap)) |
| 1480 |
aq_mask = devmap->aq_mask; |
| 1481 |
|
| 1482 |
return sysfs_emit(buf, "%d\n", aq_mask); |
| 1483 |
} |
| 1484 |
|
| 1485 |
static ssize_t dasd_aq_mask_store(struct device *dev, struct device_attribute *attr, |
| 1486 |
const char *buf, size_t count) |
| 1487 |
{ |
| 1488 |
struct dasd_devmap *devmap; |
| 1489 |
unsigned int val; |
| 1490 |
|
| 1491 |
if (kstrtouint(buf, 0, &val) || val > DASD_EER_VALID) |
| 1492 |
return -EINVAL; |
| 1493 |
|
| 1494 |
devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 1495 |
if (IS_ERR(devmap)) |
| 1496 |
return PTR_ERR(devmap); |
| 1497 |
|
| 1498 |
spin_lock(&dasd_devmap_lock); |
| 1499 |
devmap->aq_mask = val; |
| 1500 |
if (devmap->device) |
| 1501 |
devmap->device->aq_mask = devmap->aq_mask; |
| 1502 |
spin_unlock(&dasd_devmap_lock); |
| 1503 |
|
| 1504 |
return count; |
| 1505 |
} |
| 1506 |
|
| 1507 |
static DEVICE_ATTR(aq_mask, 0644, dasd_aq_mask_show, dasd_aq_mask_store); |
| 1508 |
|
| 1509 |
/* |
| 1510 |
* aq_requeue controls if requests are returned to the blocklayer on quiesce |
| 1511 |
* or if requests are only not started |
| 1512 |
*/ |
| 1513 |
static ssize_t dasd_aqr_show(struct device *dev, struct device_attribute *attr, |
| 1514 |
char *buf) |
| 1515 |
{ |
| 1516 |
struct dasd_devmap *devmap; |
| 1517 |
int flag; |
| 1518 |
|
| 1519 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1520 |
if (!IS_ERR(devmap)) |
| 1521 |
flag = (devmap->features & DASD_FEATURE_REQUEUEQUIESCE) != 0; |
| 1522 |
else |
| 1523 |
flag = (DASD_FEATURE_DEFAULT & |
| 1524 |
DASD_FEATURE_REQUEUEQUIESCE) != 0; |
| 1525 |
return sysfs_emit(buf, "%d\n", flag); |
| 1526 |
} |
| 1527 |
|
| 1528 |
static ssize_t dasd_aqr_store(struct device *dev, struct device_attribute *attr, |
| 1529 |
const char *buf, size_t count) |
| 1530 |
{ |
| 1531 |
bool val; |
| 1532 |
int rc; |
| 1533 |
|
| 1534 |
if (kstrtobool(buf, &val)) |
| 1535 |
return -EINVAL; |
| 1536 |
|
| 1537 |
rc = dasd_set_feature(to_ccwdev(dev), DASD_FEATURE_REQUEUEQUIESCE, val); |
| 1538 |
|
| 1539 |
return rc ? : count; |
| 1540 |
} |
| 1541 |
|
| 1542 |
static DEVICE_ATTR(aq_requeue, 0644, dasd_aqr_show, dasd_aqr_store); |
| 1543 |
|
| 1544 |
/* |
| 1545 |
* aq_timeouts controls how much retries have to time out until |
| 1546 |
* a device gets autoquiesced |
| 1547 |
*/ |
| 1548 |
static ssize_t |
| 1549 |
dasd_aq_timeouts_show(struct device *dev, struct device_attribute *attr, |
| 1550 |
char *buf) |
| 1551 |
{ |
| 1552 |
struct dasd_device *device; |
| 1553 |
int len; |
| 1554 |
|
| 1555 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1556 |
if (IS_ERR(device)) |
| 1557 |
return -ENODEV; |
| 1558 |
len = sysfs_emit(buf, "%u\n", device->aq_timeouts); |
| 1559 |
dasd_put_device(device); |
| 1560 |
return len; |
| 1561 |
} |
| 1562 |
|
| 1563 |
static ssize_t |
| 1564 |
dasd_aq_timeouts_store(struct device *dev, struct device_attribute *attr, |
| 1565 |
const char *buf, size_t count) |
| 1566 |
{ |
| 1567 |
struct dasd_device *device; |
| 1568 |
unsigned int val; |
| 1569 |
|
| 1570 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1571 |
if (IS_ERR(device)) |
| 1572 |
return -ENODEV; |
| 1573 |
|
| 1574 |
if ((kstrtouint(buf, 10, &val) != 0) || |
| 1575 |
val > DASD_RETRIES_MAX || val == 0) { |
| 1576 |
dasd_put_device(device); |
| 1577 |
return -EINVAL; |
| 1578 |
} |
| 1579 |
|
| 1580 |
if (val) |
| 1581 |
device->aq_timeouts = val; |
| 1582 |
|
| 1583 |
dasd_put_device(device); |
| 1584 |
return count; |
| 1585 |
} |
| 1586 |
|
| 1587 |
static DEVICE_ATTR(aq_timeouts, 0644, dasd_aq_timeouts_show, |
| 1588 |
dasd_aq_timeouts_store); |
| 1589 |
|
| 1590 |
/* |
| 1591 |
* expiration time for default requests |
| 1592 |
*/ |
| 1593 |
static ssize_t |
| 1594 |
dasd_expires_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1595 |
{ |
| 1596 |
struct dasd_device *device; |
| 1597 |
int len; |
| 1598 |
|
| 1599 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1600 |
if (IS_ERR(device)) |
| 1601 |
return -ENODEV; |
| 1602 |
len = sysfs_emit(buf, "%lu\n", device->default_expires); |
| 1603 |
dasd_put_device(device); |
| 1604 |
return len; |
| 1605 |
} |
| 1606 |
|
| 1607 |
static ssize_t |
| 1608 |
dasd_expires_store(struct device *dev, struct device_attribute *attr, |
| 1609 |
const char *buf, size_t count) |
| 1610 |
{ |
| 1611 |
struct dasd_device *device; |
| 1612 |
unsigned long val; |
| 1613 |
|
| 1614 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1615 |
if (IS_ERR(device)) |
| 1616 |
return -ENODEV; |
| 1617 |
|
| 1618 |
if ((kstrtoul(buf, 10, &val) != 0) || |
| 1619 |
(val > DASD_EXPIRES_MAX) || val == 0) { |
| 1620 |
dasd_put_device(device); |
| 1621 |
return -EINVAL; |
| 1622 |
} |
| 1623 |
|
| 1624 |
if (val) |
| 1625 |
device->default_expires = val; |
| 1626 |
|
| 1627 |
dasd_put_device(device); |
| 1628 |
return count; |
| 1629 |
} |
| 1630 |
|
| 1631 |
static DEVICE_ATTR(expires, 0644, dasd_expires_show, dasd_expires_store); |
| 1632 |
|
| 1633 |
static ssize_t |
| 1634 |
dasd_retries_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 1635 |
{ |
| 1636 |
struct dasd_device *device; |
| 1637 |
int len; |
| 1638 |
|
| 1639 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1640 |
if (IS_ERR(device)) |
| 1641 |
return -ENODEV; |
| 1642 |
len = sysfs_emit(buf, "%lu\n", device->default_retries); |
| 1643 |
dasd_put_device(device); |
| 1644 |
return len; |
| 1645 |
} |
| 1646 |
|
| 1647 |
static ssize_t |
| 1648 |
dasd_retries_store(struct device *dev, struct device_attribute *attr, |
| 1649 |
const char *buf, size_t count) |
| 1650 |
{ |
| 1651 |
struct dasd_device *device; |
| 1652 |
unsigned long val; |
| 1653 |
|
| 1654 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1655 |
if (IS_ERR(device)) |
| 1656 |
return -ENODEV; |
| 1657 |
|
| 1658 |
if ((kstrtoul(buf, 10, &val) != 0) || |
| 1659 |
(val > DASD_RETRIES_MAX)) { |
| 1660 |
dasd_put_device(device); |
| 1661 |
return -EINVAL; |
| 1662 |
} |
| 1663 |
|
| 1664 |
if (val) |
| 1665 |
device->default_retries = val; |
| 1666 |
|
| 1667 |
dasd_put_device(device); |
| 1668 |
return count; |
| 1669 |
} |
| 1670 |
|
| 1671 |
static DEVICE_ATTR(retries, 0644, dasd_retries_show, dasd_retries_store); |
| 1672 |
|
| 1673 |
static ssize_t |
| 1674 |
dasd_timeout_show(struct device *dev, struct device_attribute *attr, |
| 1675 |
char *buf) |
| 1676 |
{ |
| 1677 |
struct dasd_device *device; |
| 1678 |
int len; |
| 1679 |
|
| 1680 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1681 |
if (IS_ERR(device)) |
| 1682 |
return -ENODEV; |
| 1683 |
len = sysfs_emit(buf, "%lu\n", device->blk_timeout); |
| 1684 |
dasd_put_device(device); |
| 1685 |
return len; |
| 1686 |
} |
| 1687 |
|
| 1688 |
static ssize_t |
| 1689 |
dasd_timeout_store(struct device *dev, struct device_attribute *attr, |
| 1690 |
const char *buf, size_t count) |
| 1691 |
{ |
| 1692 |
struct dasd_device *device; |
| 1693 |
unsigned long val; |
| 1694 |
|
| 1695 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1696 |
if (IS_ERR(device) || !device->block) |
| 1697 |
return -ENODEV; |
| 1698 |
|
| 1699 |
if ((kstrtoul(buf, 10, &val) != 0) || |
| 1700 |
val > UINT_MAX / HZ) { |
| 1701 |
dasd_put_device(device); |
| 1702 |
return -EINVAL; |
| 1703 |
} |
| 1704 |
if (!device->block->gdp) { |
| 1705 |
dasd_put_device(device); |
| 1706 |
return -ENODEV; |
| 1707 |
} |
| 1708 |
|
| 1709 |
device->blk_timeout = val; |
| 1710 |
blk_queue_rq_timeout(device->block->gdp->queue, val * HZ); |
| 1711 |
|
| 1712 |
dasd_put_device(device); |
| 1713 |
return count; |
| 1714 |
} |
| 1715 |
|
| 1716 |
static DEVICE_ATTR(timeout, 0644, |
| 1717 |
dasd_timeout_show, dasd_timeout_store); |
| 1718 |
|
| 1719 |
|
| 1720 |
static ssize_t |
| 1721 |
dasd_path_reset_store(struct device *dev, struct device_attribute *attr, |
| 1722 |
const char *buf, size_t count) |
| 1723 |
{ |
| 1724 |
struct dasd_device *device; |
| 1725 |
unsigned int val; |
| 1726 |
|
| 1727 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1728 |
if (IS_ERR(device)) |
| 1729 |
return -ENODEV; |
| 1730 |
|
| 1731 |
if ((kstrtouint(buf, 16, &val) != 0) || val > 0xff) |
| 1732 |
val = 0; |
| 1733 |
|
| 1734 |
if (device->discipline && device->discipline->reset_path) |
| 1735 |
device->discipline->reset_path(device, (__u8) val); |
| 1736 |
|
| 1737 |
dasd_put_device(device); |
| 1738 |
return count; |
| 1739 |
} |
| 1740 |
|
| 1741 |
static DEVICE_ATTR(path_reset, 0200, NULL, dasd_path_reset_store); |
| 1742 |
|
| 1743 |
static ssize_t dasd_hpf_show(struct device *dev, struct device_attribute *attr, |
| 1744 |
char *buf) |
| 1745 |
{ |
| 1746 |
struct dasd_device *device; |
| 1747 |
int hpf; |
| 1748 |
|
| 1749 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1750 |
if (IS_ERR(device)) |
| 1751 |
return -ENODEV; |
| 1752 |
if (!device->discipline || !device->discipline->hpf_enabled) { |
| 1753 |
dasd_put_device(device); |
| 1754 |
return sysfs_emit(buf, "%d\n", dasd_nofcx); |
| 1755 |
} |
| 1756 |
hpf = device->discipline->hpf_enabled(device); |
| 1757 |
dasd_put_device(device); |
| 1758 |
return sysfs_emit(buf, "%d\n", hpf); |
| 1759 |
} |
| 1760 |
|
| 1761 |
static DEVICE_ATTR(hpf, 0444, dasd_hpf_show, NULL); |
| 1762 |
|
| 1763 |
static ssize_t dasd_reservation_policy_show(struct device *dev, |
| 1764 |
struct device_attribute *attr, |
| 1765 |
char *buf) |
| 1766 |
{ |
| 1767 |
struct dasd_devmap *devmap; |
| 1768 |
int rc = 0; |
| 1769 |
|
| 1770 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1771 |
if (IS_ERR(devmap)) { |
| 1772 |
rc = sysfs_emit(buf, "ignore\n"); |
| 1773 |
} else { |
| 1774 |
spin_lock(&dasd_devmap_lock); |
| 1775 |
if (devmap->features & DASD_FEATURE_FAILONSLCK) |
| 1776 |
rc = sysfs_emit(buf, "fail\n"); |
| 1777 |
else |
| 1778 |
rc = sysfs_emit(buf, "ignore\n"); |
| 1779 |
spin_unlock(&dasd_devmap_lock); |
| 1780 |
} |
| 1781 |
return rc; |
| 1782 |
} |
| 1783 |
|
| 1784 |
static ssize_t dasd_reservation_policy_store(struct device *dev, |
| 1785 |
struct device_attribute *attr, |
| 1786 |
const char *buf, size_t count) |
| 1787 |
{ |
| 1788 |
struct ccw_device *cdev = to_ccwdev(dev); |
| 1789 |
int rc; |
| 1790 |
|
| 1791 |
if (sysfs_streq("ignore", buf)) |
| 1792 |
rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 0); |
| 1793 |
else if (sysfs_streq("fail", buf)) |
| 1794 |
rc = dasd_set_feature(cdev, DASD_FEATURE_FAILONSLCK, 1); |
| 1795 |
else |
| 1796 |
rc = -EINVAL; |
| 1797 |
|
| 1798 |
return rc ? : count; |
| 1799 |
} |
| 1800 |
|
| 1801 |
static DEVICE_ATTR(reservation_policy, 0644, |
| 1802 |
dasd_reservation_policy_show, dasd_reservation_policy_store); |
| 1803 |
|
| 1804 |
static ssize_t dasd_reservation_state_show(struct device *dev, |
| 1805 |
struct device_attribute *attr, |
| 1806 |
char *buf) |
| 1807 |
{ |
| 1808 |
struct dasd_device *device; |
| 1809 |
int rc = 0; |
| 1810 |
|
| 1811 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1812 |
if (IS_ERR(device)) |
| 1813 |
return sysfs_emit(buf, "none\n"); |
| 1814 |
|
| 1815 |
if (test_bit(DASD_FLAG_IS_RESERVED, &device->flags)) |
| 1816 |
rc = sysfs_emit(buf, "reserved\n"); |
| 1817 |
else if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) |
| 1818 |
rc = sysfs_emit(buf, "lost\n"); |
| 1819 |
else |
| 1820 |
rc = sysfs_emit(buf, "none\n"); |
| 1821 |
dasd_put_device(device); |
| 1822 |
return rc; |
| 1823 |
} |
| 1824 |
|
| 1825 |
static ssize_t dasd_reservation_state_store(struct device *dev, |
| 1826 |
struct device_attribute *attr, |
| 1827 |
const char *buf, size_t count) |
| 1828 |
{ |
| 1829 |
struct dasd_device *device; |
| 1830 |
int rc = 0; |
| 1831 |
|
| 1832 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1833 |
if (IS_ERR(device)) |
| 1834 |
return -ENODEV; |
| 1835 |
if (sysfs_streq("reset", buf)) |
| 1836 |
clear_bit(DASD_FLAG_LOCK_STOLEN, &device->flags); |
| 1837 |
else |
| 1838 |
rc = -EINVAL; |
| 1839 |
dasd_put_device(device); |
| 1840 |
|
| 1841 |
if (rc) |
| 1842 |
return rc; |
| 1843 |
else |
| 1844 |
return count; |
| 1845 |
} |
| 1846 |
|
| 1847 |
static DEVICE_ATTR(last_known_reservation_state, 0644, |
| 1848 |
dasd_reservation_state_show, dasd_reservation_state_store); |
| 1849 |
|
| 1850 |
static ssize_t dasd_pm_show(struct device *dev, |
| 1851 |
struct device_attribute *attr, char *buf) |
| 1852 |
{ |
| 1853 |
struct dasd_device *device; |
| 1854 |
u8 opm, nppm, cablepm, cuirpm, hpfpm, ifccpm; |
| 1855 |
|
| 1856 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1857 |
if (IS_ERR(device)) |
| 1858 |
return sysfs_emit(buf, "0\n"); |
| 1859 |
|
| 1860 |
opm = dasd_path_get_opm(device); |
| 1861 |
nppm = dasd_path_get_nppm(device); |
| 1862 |
cablepm = dasd_path_get_cablepm(device); |
| 1863 |
cuirpm = dasd_path_get_cuirpm(device); |
| 1864 |
hpfpm = dasd_path_get_hpfpm(device); |
| 1865 |
ifccpm = dasd_path_get_ifccpm(device); |
| 1866 |
dasd_put_device(device); |
| 1867 |
|
| 1868 |
return sysfs_emit(buf, "%02x %02x %02x %02x %02x %02x\n", opm, nppm, |
| 1869 |
cablepm, cuirpm, hpfpm, ifccpm); |
| 1870 |
} |
| 1871 |
|
| 1872 |
static DEVICE_ATTR(path_masks, 0444, dasd_pm_show, NULL); |
| 1873 |
|
| 1874 |
/* |
| 1875 |
* threshold value for IFCC/CCC errors |
| 1876 |
*/ |
| 1877 |
static ssize_t |
| 1878 |
dasd_path_threshold_show(struct device *dev, |
| 1879 |
struct device_attribute *attr, char *buf) |
| 1880 |
{ |
| 1881 |
struct dasd_device *device; |
| 1882 |
int len; |
| 1883 |
|
| 1884 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1885 |
if (IS_ERR(device)) |
| 1886 |
return -ENODEV; |
| 1887 |
len = sysfs_emit(buf, "%lu\n", device->path_thrhld); |
| 1888 |
dasd_put_device(device); |
| 1889 |
return len; |
| 1890 |
} |
| 1891 |
|
| 1892 |
static ssize_t |
| 1893 |
dasd_path_threshold_store(struct device *dev, struct device_attribute *attr, |
| 1894 |
const char *buf, size_t count) |
| 1895 |
{ |
| 1896 |
struct dasd_device *device; |
| 1897 |
unsigned long flags; |
| 1898 |
unsigned long val; |
| 1899 |
|
| 1900 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1901 |
if (IS_ERR(device)) |
| 1902 |
return -ENODEV; |
| 1903 |
|
| 1904 |
if (kstrtoul(buf, 10, &val) != 0 || val > DASD_THRHLD_MAX) { |
| 1905 |
dasd_put_device(device); |
| 1906 |
return -EINVAL; |
| 1907 |
} |
| 1908 |
spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags); |
| 1909 |
device->path_thrhld = val; |
| 1910 |
spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags); |
| 1911 |
dasd_put_device(device); |
| 1912 |
return count; |
| 1913 |
} |
| 1914 |
static DEVICE_ATTR(path_threshold, 0644, dasd_path_threshold_show, |
| 1915 |
dasd_path_threshold_store); |
| 1916 |
|
| 1917 |
/* |
| 1918 |
* configure if path is disabled after IFCC/CCC error threshold is |
| 1919 |
* exceeded |
| 1920 |
*/ |
| 1921 |
static ssize_t |
| 1922 |
dasd_path_autodisable_show(struct device *dev, |
| 1923 |
struct device_attribute *attr, char *buf) |
| 1924 |
{ |
| 1925 |
struct dasd_devmap *devmap; |
| 1926 |
int flag; |
| 1927 |
|
| 1928 |
devmap = dasd_find_busid(dev_name(dev)); |
| 1929 |
if (!IS_ERR(devmap)) |
| 1930 |
flag = (devmap->features & DASD_FEATURE_PATH_AUTODISABLE) != 0; |
| 1931 |
else |
| 1932 |
flag = (DASD_FEATURE_DEFAULT & |
| 1933 |
DASD_FEATURE_PATH_AUTODISABLE) != 0; |
| 1934 |
return sysfs_emit(buf, flag ? "1\n" : "0\n"); |
| 1935 |
} |
| 1936 |
|
| 1937 |
static ssize_t |
| 1938 |
dasd_path_autodisable_store(struct device *dev, |
| 1939 |
struct device_attribute *attr, |
| 1940 |
const char *buf, size_t count) |
| 1941 |
{ |
| 1942 |
unsigned int val; |
| 1943 |
int rc; |
| 1944 |
|
| 1945 |
if (kstrtouint(buf, 0, &val) || val > 1) |
| 1946 |
return -EINVAL; |
| 1947 |
|
| 1948 |
rc = dasd_set_feature(to_ccwdev(dev), |
| 1949 |
DASD_FEATURE_PATH_AUTODISABLE, val); |
| 1950 |
|
| 1951 |
return rc ? : count; |
| 1952 |
} |
| 1953 |
|
| 1954 |
static DEVICE_ATTR(path_autodisable, 0644, |
| 1955 |
dasd_path_autodisable_show, |
| 1956 |
dasd_path_autodisable_store); |
| 1957 |
/* |
| 1958 |
* interval for IFCC/CCC checks |
| 1959 |
* meaning time with no IFCC/CCC error before the error counter |
| 1960 |
* gets reset |
| 1961 |
*/ |
| 1962 |
static ssize_t |
| 1963 |
dasd_path_interval_show(struct device *dev, |
| 1964 |
struct device_attribute *attr, char *buf) |
| 1965 |
{ |
| 1966 |
struct dasd_device *device; |
| 1967 |
int len; |
| 1968 |
|
| 1969 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1970 |
if (IS_ERR(device)) |
| 1971 |
return -ENODEV; |
| 1972 |
len = sysfs_emit(buf, "%lu\n", device->path_interval); |
| 1973 |
dasd_put_device(device); |
| 1974 |
return len; |
| 1975 |
} |
| 1976 |
|
| 1977 |
static ssize_t |
| 1978 |
dasd_path_interval_store(struct device *dev, struct device_attribute *attr, |
| 1979 |
const char *buf, size_t count) |
| 1980 |
{ |
| 1981 |
struct dasd_device *device; |
| 1982 |
unsigned long flags; |
| 1983 |
unsigned long val; |
| 1984 |
|
| 1985 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 1986 |
if (IS_ERR(device)) |
| 1987 |
return -ENODEV; |
| 1988 |
|
| 1989 |
if ((kstrtoul(buf, 10, &val) != 0) || |
| 1990 |
(val > DASD_INTERVAL_MAX) || val == 0) { |
| 1991 |
dasd_put_device(device); |
| 1992 |
return -EINVAL; |
| 1993 |
} |
| 1994 |
spin_lock_irqsave(get_ccwdev_lock(to_ccwdev(dev)), flags); |
| 1995 |
if (val) |
| 1996 |
device->path_interval = val; |
| 1997 |
spin_unlock_irqrestore(get_ccwdev_lock(to_ccwdev(dev)), flags); |
| 1998 |
dasd_put_device(device); |
| 1999 |
return count; |
| 2000 |
} |
| 2001 |
|
| 2002 |
static DEVICE_ATTR(path_interval, 0644, dasd_path_interval_show, |
| 2003 |
dasd_path_interval_store); |
| 2004 |
|
| 2005 |
static ssize_t |
| 2006 |
dasd_device_fcs_show(struct device *dev, struct device_attribute *attr, |
| 2007 |
char *buf) |
| 2008 |
{ |
| 2009 |
struct dasd_device *device; |
| 2010 |
int fc_sec; |
| 2011 |
int rc; |
| 2012 |
|
| 2013 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 2014 |
if (IS_ERR(device)) |
| 2015 |
return -ENODEV; |
| 2016 |
fc_sec = dasd_path_get_fcs_device(device); |
| 2017 |
if (fc_sec == -EINVAL) |
| 2018 |
rc = sysfs_emit(buf, "Inconsistent\n"); |
| 2019 |
else |
| 2020 |
rc = sysfs_emit(buf, "%s\n", dasd_path_get_fcs_str(fc_sec)); |
| 2021 |
dasd_put_device(device); |
| 2022 |
|
| 2023 |
return rc; |
| 2024 |
} |
| 2025 |
static DEVICE_ATTR(fc_security, 0444, dasd_device_fcs_show, NULL); |
| 2026 |
|
| 2027 |
static ssize_t |
| 2028 |
dasd_path_fcs_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) |
| 2029 |
{ |
| 2030 |
struct dasd_path *path = to_dasd_path(kobj); |
| 2031 |
unsigned int fc_sec = path->fc_security; |
| 2032 |
|
| 2033 |
return sysfs_emit(buf, "%s\n", dasd_path_get_fcs_str(fc_sec)); |
| 2034 |
} |
| 2035 |
|
| 2036 |
static struct kobj_attribute path_fcs_attribute = |
| 2037 |
__ATTR(fc_security, 0444, dasd_path_fcs_show, NULL); |
| 2038 |
|
| 2039 |
/* |
| 2040 |
* print copy relation in the form |
| 2041 |
* primary,secondary[1] primary,secondary[2], ... |
| 2042 |
*/ |
| 2043 |
static ssize_t |
| 2044 |
dasd_copy_pair_show(struct device *dev, |
| 2045 |
struct device_attribute *attr, char *buf) |
| 2046 |
{ |
| 2047 |
char prim_busid[DASD_BUS_ID_SIZE]; |
| 2048 |
struct dasd_copy_relation *copy; |
| 2049 |
struct dasd_devmap *devmap; |
| 2050 |
int len = 0; |
| 2051 |
int i; |
| 2052 |
|
| 2053 |
devmap = dasd_find_busid(dev_name(dev)); |
| 2054 |
if (IS_ERR(devmap)) |
| 2055 |
return -ENODEV; |
| 2056 |
|
| 2057 |
if (!devmap->copy) |
| 2058 |
return -ENODEV; |
| 2059 |
|
| 2060 |
copy = devmap->copy; |
| 2061 |
/* find primary */ |
| 2062 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2063 |
if (copy->entry[i].configured && copy->entry[i].primary) { |
| 2064 |
strscpy(prim_busid, copy->entry[i].busid, |
| 2065 |
DASD_BUS_ID_SIZE); |
| 2066 |
break; |
| 2067 |
} |
| 2068 |
} |
| 2069 |
if (i == DASD_CP_ENTRIES) |
| 2070 |
goto out; |
| 2071 |
|
| 2072 |
/* print all secondary */ |
| 2073 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2074 |
if (copy->entry[i].configured && !copy->entry[i].primary) |
| 2075 |
len += sysfs_emit_at(buf, len, "%s,%s ", prim_busid, |
| 2076 |
copy->entry[i].busid); |
| 2077 |
} |
| 2078 |
|
| 2079 |
len += sysfs_emit_at(buf, len, "\n"); |
| 2080 |
out: |
| 2081 |
return len; |
| 2082 |
} |
| 2083 |
|
| 2084 |
static int dasd_devmap_set_copy_relation(struct dasd_devmap *devmap, |
| 2085 |
struct dasd_copy_relation *copy, |
| 2086 |
char *busid, bool primary) |
| 2087 |
{ |
| 2088 |
int i; |
| 2089 |
|
| 2090 |
/* find free entry */ |
| 2091 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2092 |
/* current bus_id already included, nothing to do */ |
| 2093 |
if (copy->entry[i].configured && |
| 2094 |
strncmp(copy->entry[i].busid, busid, DASD_BUS_ID_SIZE) == 0) |
| 2095 |
return 0; |
| 2096 |
|
| 2097 |
if (!copy->entry[i].configured) |
| 2098 |
break; |
| 2099 |
} |
| 2100 |
if (i == DASD_CP_ENTRIES) |
| 2101 |
return -EINVAL; |
| 2102 |
|
| 2103 |
copy->entry[i].configured = true; |
| 2104 |
strscpy(copy->entry[i].busid, busid, DASD_BUS_ID_SIZE); |
| 2105 |
if (primary) { |
| 2106 |
copy->active = ©->entry[i]; |
| 2107 |
copy->entry[i].primary = true; |
| 2108 |
} |
| 2109 |
if (!devmap->copy) |
| 2110 |
devmap->copy = copy; |
| 2111 |
|
| 2112 |
return 0; |
| 2113 |
} |
| 2114 |
|
| 2115 |
static void dasd_devmap_del_copy_relation(struct dasd_copy_relation *copy, |
| 2116 |
char *busid) |
| 2117 |
{ |
| 2118 |
int i; |
| 2119 |
|
| 2120 |
spin_lock(&dasd_devmap_lock); |
| 2121 |
/* find entry */ |
| 2122 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2123 |
if (copy->entry[i].configured && |
| 2124 |
strncmp(copy->entry[i].busid, busid, DASD_BUS_ID_SIZE) == 0) |
| 2125 |
break; |
| 2126 |
} |
| 2127 |
if (i == DASD_CP_ENTRIES || !copy->entry[i].configured) { |
| 2128 |
spin_unlock(&dasd_devmap_lock); |
| 2129 |
return; |
| 2130 |
} |
| 2131 |
|
| 2132 |
copy->entry[i].configured = false; |
| 2133 |
memset(copy->entry[i].busid, 0, DASD_BUS_ID_SIZE); |
| 2134 |
if (copy->active == ©->entry[i]) { |
| 2135 |
copy->active = NULL; |
| 2136 |
copy->entry[i].primary = false; |
| 2137 |
} |
| 2138 |
spin_unlock(&dasd_devmap_lock); |
| 2139 |
} |
| 2140 |
|
| 2141 |
static int dasd_devmap_clear_copy_relation(struct device *dev) |
| 2142 |
{ |
| 2143 |
struct dasd_copy_relation *copy; |
| 2144 |
struct dasd_devmap *devmap; |
| 2145 |
int i, rc = 1; |
| 2146 |
|
| 2147 |
devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
| 2148 |
if (IS_ERR(devmap)) |
| 2149 |
return 1; |
| 2150 |
|
| 2151 |
spin_lock(&dasd_devmap_lock); |
| 2152 |
if (!devmap->copy) |
| 2153 |
goto out; |
| 2154 |
|
| 2155 |
copy = devmap->copy; |
| 2156 |
/* first check if all secondary devices are offline*/ |
| 2157 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2158 |
if (!copy->entry[i].configured) |
| 2159 |
continue; |
| 2160 |
|
| 2161 |
if (copy->entry[i].device == copy->active->device) |
| 2162 |
continue; |
| 2163 |
|
| 2164 |
if (copy->entry[i].device) |
| 2165 |
goto out; |
| 2166 |
} |
| 2167 |
/* clear all devmap entries */ |
| 2168 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2169 |
if (strlen(copy->entry[i].busid) == 0) |
| 2170 |
continue; |
| 2171 |
if (copy->entry[i].device) { |
| 2172 |
dasd_put_device(copy->entry[i].device); |
| 2173 |
copy->entry[i].device->copy = NULL; |
| 2174 |
copy->entry[i].device = NULL; |
| 2175 |
} |
| 2176 |
devmap = dasd_find_busid_locked(copy->entry[i].busid); |
| 2177 |
devmap->copy = NULL; |
| 2178 |
memset(copy->entry[i].busid, 0, DASD_BUS_ID_SIZE); |
| 2179 |
} |
| 2180 |
kfree(copy); |
| 2181 |
rc = 0; |
| 2182 |
out: |
| 2183 |
spin_unlock(&dasd_devmap_lock); |
| 2184 |
return rc; |
| 2185 |
} |
| 2186 |
|
| 2187 |
/* |
| 2188 |
* parse BUSIDs from a copy pair |
| 2189 |
*/ |
| 2190 |
static int dasd_devmap_parse_busid(const char *buf, char *prim_busid, |
| 2191 |
char *sec_busid) |
| 2192 |
{ |
| 2193 |
char *primary, *secondary, *tmp, *pt; |
| 2194 |
int id0, id1, id2; |
| 2195 |
|
| 2196 |
pt = kstrdup(buf, GFP_KERNEL); |
| 2197 |
tmp = pt; |
| 2198 |
if (!tmp) |
| 2199 |
return -ENOMEM; |
| 2200 |
|
| 2201 |
primary = strsep(&tmp, ","); |
| 2202 |
if (!primary) { |
| 2203 |
kfree(pt); |
| 2204 |
return -EINVAL; |
| 2205 |
} |
| 2206 |
secondary = strsep(&tmp, ","); |
| 2207 |
if (!secondary) { |
| 2208 |
kfree(pt); |
| 2209 |
return -EINVAL; |
| 2210 |
} |
| 2211 |
if (dasd_busid(primary, &id0, &id1, &id2)) { |
| 2212 |
kfree(pt); |
| 2213 |
return -EINVAL; |
| 2214 |
} |
| 2215 |
sprintf(prim_busid, "%01x.%01x.%04x", id0, id1, id2); |
| 2216 |
if (dasd_busid(secondary, &id0, &id1, &id2)) { |
| 2217 |
kfree(pt); |
| 2218 |
return -EINVAL; |
| 2219 |
} |
| 2220 |
sprintf(sec_busid, "%01x.%01x.%04x", id0, id1, id2); |
| 2221 |
kfree(pt); |
| 2222 |
|
| 2223 |
return 0; |
| 2224 |
} |
| 2225 |
|
| 2226 |
static ssize_t dasd_copy_pair_store(struct device *dev, |
| 2227 |
struct device_attribute *attr, |
| 2228 |
const char *buf, size_t count) |
| 2229 |
{ |
| 2230 |
struct dasd_devmap *prim_devmap, *sec_devmap; |
| 2231 |
char prim_busid[DASD_BUS_ID_SIZE]; |
| 2232 |
char sec_busid[DASD_BUS_ID_SIZE]; |
| 2233 |
struct dasd_copy_relation *copy; |
| 2234 |
struct dasd_device *device; |
| 2235 |
bool pprc_enabled; |
| 2236 |
int rc; |
| 2237 |
|
| 2238 |
if (strncmp(buf, "clear", strlen("clear")) == 0) { |
| 2239 |
if (dasd_devmap_clear_copy_relation(dev)) |
| 2240 |
return -EINVAL; |
| 2241 |
return count; |
| 2242 |
} |
| 2243 |
|
| 2244 |
rc = dasd_devmap_parse_busid(buf, prim_busid, sec_busid); |
| 2245 |
if (rc) |
| 2246 |
return rc; |
| 2247 |
|
| 2248 |
if (strncmp(dev_name(dev), prim_busid, DASD_BUS_ID_SIZE) != 0 && |
| 2249 |
strncmp(dev_name(dev), sec_busid, DASD_BUS_ID_SIZE) != 0) |
| 2250 |
return -EINVAL; |
| 2251 |
|
| 2252 |
/* allocate primary devmap if needed */ |
| 2253 |
prim_devmap = dasd_find_busid(prim_busid); |
| 2254 |
if (IS_ERR(prim_devmap)) { |
| 2255 |
prim_devmap = dasd_add_busid(prim_busid, DASD_FEATURE_DEFAULT); |
| 2256 |
if (IS_ERR(prim_devmap)) |
| 2257 |
return PTR_ERR(prim_devmap); |
| 2258 |
} |
| 2259 |
|
| 2260 |
/* allocate secondary devmap if needed */ |
| 2261 |
sec_devmap = dasd_find_busid(sec_busid); |
| 2262 |
if (IS_ERR(sec_devmap)) { |
| 2263 |
sec_devmap = dasd_add_busid(sec_busid, DASD_FEATURE_DEFAULT); |
| 2264 |
if (IS_ERR(sec_devmap)) |
| 2265 |
return PTR_ERR(sec_devmap); |
| 2266 |
} |
| 2267 |
|
| 2268 |
/* setting copy relation is only allowed for offline secondary */ |
| 2269 |
if (sec_devmap->device) |
| 2270 |
return -EINVAL; |
| 2271 |
|
| 2272 |
if (prim_devmap->copy) { |
| 2273 |
copy = prim_devmap->copy; |
| 2274 |
} else if (sec_devmap->copy) { |
| 2275 |
copy = sec_devmap->copy; |
| 2276 |
} else { |
| 2277 |
copy = kzalloc_obj(*copy); |
| 2278 |
if (!copy) |
| 2279 |
return -ENOMEM; |
| 2280 |
} |
| 2281 |
spin_lock(&dasd_devmap_lock); |
| 2282 |
rc = dasd_devmap_set_copy_relation(prim_devmap, copy, prim_busid, true); |
| 2283 |
if (rc) { |
| 2284 |
spin_unlock(&dasd_devmap_lock); |
| 2285 |
return rc; |
| 2286 |
} |
| 2287 |
rc = dasd_devmap_set_copy_relation(sec_devmap, copy, sec_busid, false); |
| 2288 |
if (rc) { |
| 2289 |
spin_unlock(&dasd_devmap_lock); |
| 2290 |
return rc; |
| 2291 |
} |
| 2292 |
spin_unlock(&dasd_devmap_lock); |
| 2293 |
|
| 2294 |
/* if primary device is already online call device setup directly */ |
| 2295 |
if (prim_devmap->device && !prim_devmap->device->copy) { |
| 2296 |
device = prim_devmap->device; |
| 2297 |
if (device->discipline->pprc_enabled) { |
| 2298 |
pprc_enabled = device->discipline->pprc_enabled(device); |
| 2299 |
rc = dasd_devmap_set_device_copy_relation(device->cdev, |
| 2300 |
pprc_enabled); |
| 2301 |
} else { |
| 2302 |
rc = -EOPNOTSUPP; |
| 2303 |
} |
| 2304 |
} |
| 2305 |
if (rc) { |
| 2306 |
dasd_devmap_del_copy_relation(copy, prim_busid); |
| 2307 |
dasd_devmap_del_copy_relation(copy, sec_busid); |
| 2308 |
count = rc; |
| 2309 |
} |
| 2310 |
|
| 2311 |
return count; |
| 2312 |
} |
| 2313 |
static DEVICE_ATTR(copy_pair, 0644, dasd_copy_pair_show, |
| 2314 |
dasd_copy_pair_store); |
| 2315 |
|
| 2316 |
static ssize_t |
| 2317 |
dasd_copy_role_show(struct device *dev, |
| 2318 |
struct device_attribute *attr, char *buf) |
| 2319 |
{ |
| 2320 |
struct dasd_copy_relation *copy; |
| 2321 |
struct dasd_device *device; |
| 2322 |
int len, i; |
| 2323 |
|
| 2324 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 2325 |
if (IS_ERR(device)) |
| 2326 |
return -ENODEV; |
| 2327 |
|
| 2328 |
if (!device->copy) { |
| 2329 |
len = sysfs_emit(buf, "none\n"); |
| 2330 |
goto out; |
| 2331 |
} |
| 2332 |
copy = device->copy; |
| 2333 |
/* only the active device is primary */ |
| 2334 |
if (copy->active->device == device) { |
| 2335 |
len = sysfs_emit(buf, "primary\n"); |
| 2336 |
goto out; |
| 2337 |
} |
| 2338 |
for (i = 0; i < DASD_CP_ENTRIES; i++) { |
| 2339 |
if (copy->entry[i].device == device) { |
| 2340 |
len = sysfs_emit(buf, "secondary\n"); |
| 2341 |
goto out; |
| 2342 |
} |
| 2343 |
} |
| 2344 |
/* not in the list, no COPY role */ |
| 2345 |
len = sysfs_emit(buf, "none\n"); |
| 2346 |
out: |
| 2347 |
dasd_put_device(device); |
| 2348 |
return len; |
| 2349 |
} |
| 2350 |
static DEVICE_ATTR(copy_role, 0444, dasd_copy_role_show, NULL); |
| 2351 |
|
| 2352 |
static ssize_t dasd_device_ping(struct device *dev, |
| 2353 |
struct device_attribute *attr, |
| 2354 |
const char *buf, size_t count) |
| 2355 |
{ |
| 2356 |
struct dasd_device *device; |
| 2357 |
size_t rc; |
| 2358 |
|
| 2359 |
device = dasd_device_from_cdev(to_ccwdev(dev)); |
| 2360 |
if (IS_ERR(device)) |
| 2361 |
return -ENODEV; |
| 2362 |
|
| 2363 |
/* |
| 2364 |
* do not try during offline processing |
| 2365 |
* early check only |
| 2366 |
* the sleep_on function itself checks for offline |
| 2367 |
* processing again |
| 2368 |
*/ |
| 2369 |
if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 2370 |
rc = -EBUSY; |
| 2371 |
goto out; |
| 2372 |
} |
| 2373 |
if (!device->discipline || !device->discipline->device_ping) { |
| 2374 |
rc = -EOPNOTSUPP; |
| 2375 |
goto out; |
| 2376 |
} |
| 2377 |
rc = device->discipline->device_ping(device); |
| 2378 |
if (!rc) |
| 2379 |
rc = count; |
| 2380 |
out: |
| 2381 |
dasd_put_device(device); |
| 2382 |
return rc; |
| 2383 |
} |
| 2384 |
static DEVICE_ATTR(ping, 0200, NULL, dasd_device_ping); |
| 2385 |
|
| 2386 |
#define DASD_DEFINE_ATTR(_name, _func) \ |
| 2387 |
static ssize_t dasd_##_name##_show(struct device *dev, \ |
| 2388 |
struct device_attribute *attr, \ |
| 2389 |
char *buf) \ |
| 2390 |
{ \ |
| 2391 |
struct ccw_device *cdev = to_ccwdev(dev); \ |
| 2392 |
struct dasd_device *device = dasd_device_from_cdev(cdev); \ |
| 2393 |
int val = 0; \ |
| 2394 |
\ |
| 2395 |
if (IS_ERR(device)) \ |
| 2396 |
return -ENODEV; \ |
| 2397 |
if (device->discipline && _func) \ |
| 2398 |
val = _func(device); \ |
| 2399 |
dasd_put_device(device); \ |
| 2400 |
\ |
| 2401 |
return sysfs_emit(buf, "%d\n", val); \ |
| 2402 |
} \ |
| 2403 |
static DEVICE_ATTR(_name, 0444, dasd_##_name##_show, NULL); \ |
| 2404 |
|
| 2405 |
DASD_DEFINE_ATTR(ese, device->discipline->is_ese); |
| 2406 |
DASD_DEFINE_ATTR(extent_size, device->discipline->ext_size); |
| 2407 |
DASD_DEFINE_ATTR(pool_id, device->discipline->ext_pool_id); |
| 2408 |
DASD_DEFINE_ATTR(space_configured, device->discipline->space_configured); |
| 2409 |
DASD_DEFINE_ATTR(space_allocated, device->discipline->space_allocated); |
| 2410 |
DASD_DEFINE_ATTR(logical_capacity, device->discipline->logical_capacity); |
| 2411 |
DASD_DEFINE_ATTR(warn_threshold, device->discipline->ext_pool_warn_thrshld); |
| 2412 |
DASD_DEFINE_ATTR(cap_at_warnlevel, device->discipline->ext_pool_cap_at_warnlevel); |
| 2413 |
DASD_DEFINE_ATTR(pool_oos, device->discipline->ext_pool_oos); |
| 2414 |
|
| 2415 |
static struct attribute * dasd_attrs[] = { |
| 2416 |
&dev_attr_readonly.attr, |
| 2417 |
&dev_attr_discipline.attr, |
| 2418 |
&dev_attr_status.attr, |
| 2419 |
&dev_attr_alias.attr, |
| 2420 |
&dev_attr_vendor.attr, |
| 2421 |
&dev_attr_uid.attr, |
| 2422 |
&dev_attr_use_diag.attr, |
| 2423 |
&dev_attr_raw_track_access.attr, |
| 2424 |
&dev_attr_eer_enabled.attr, |
| 2425 |
&dev_attr_erplog.attr, |
| 2426 |
&dev_attr_failfast.attr, |
| 2427 |
&dev_attr_expires.attr, |
| 2428 |
&dev_attr_retries.attr, |
| 2429 |
&dev_attr_timeout.attr, |
| 2430 |
&dev_attr_reservation_policy.attr, |
| 2431 |
&dev_attr_last_known_reservation_state.attr, |
| 2432 |
&dev_attr_safe_offline.attr, |
| 2433 |
&dev_attr_host_access_count.attr, |
| 2434 |
&dev_attr_path_masks.attr, |
| 2435 |
&dev_attr_path_threshold.attr, |
| 2436 |
&dev_attr_path_autodisable.attr, |
| 2437 |
&dev_attr_path_interval.attr, |
| 2438 |
&dev_attr_path_reset.attr, |
| 2439 |
&dev_attr_hpf.attr, |
| 2440 |
&dev_attr_ese.attr, |
| 2441 |
&dev_attr_fc_security.attr, |
| 2442 |
&dev_attr_copy_pair.attr, |
| 2443 |
&dev_attr_copy_role.attr, |
| 2444 |
&dev_attr_ping.attr, |
| 2445 |
&dev_attr_aq_mask.attr, |
| 2446 |
&dev_attr_aq_requeue.attr, |
| 2447 |
&dev_attr_aq_timeouts.attr, |
| 2448 |
NULL, |
| 2449 |
}; |
| 2450 |
|
| 2451 |
static const struct attribute_group dasd_attr_group = { |
| 2452 |
.attrs = dasd_attrs, |
| 2453 |
}; |
| 2454 |
|
| 2455 |
static struct attribute *capacity_attrs[] = { |
| 2456 |
&dev_attr_space_configured.attr, |
| 2457 |
&dev_attr_space_allocated.attr, |
| 2458 |
&dev_attr_logical_capacity.attr, |
| 2459 |
NULL, |
| 2460 |
}; |
| 2461 |
|
| 2462 |
static const struct attribute_group capacity_attr_group = { |
| 2463 |
.name = "capacity", |
| 2464 |
.attrs = capacity_attrs, |
| 2465 |
}; |
| 2466 |
|
| 2467 |
static struct attribute *ext_pool_attrs[] = { |
| 2468 |
&dev_attr_pool_id.attr, |
| 2469 |
&dev_attr_extent_size.attr, |
| 2470 |
&dev_attr_warn_threshold.attr, |
| 2471 |
&dev_attr_cap_at_warnlevel.attr, |
| 2472 |
&dev_attr_pool_oos.attr, |
| 2473 |
NULL, |
| 2474 |
}; |
| 2475 |
|
| 2476 |
static const struct attribute_group ext_pool_attr_group = { |
| 2477 |
.name = "extent_pool", |
| 2478 |
.attrs = ext_pool_attrs, |
| 2479 |
}; |
| 2480 |
|
| 2481 |
const struct attribute_group *dasd_dev_groups[] = { |
| 2482 |
&dasd_attr_group, |
| 2483 |
&capacity_attr_group, |
| 2484 |
&ext_pool_attr_group, |
| 2485 |
NULL, |
| 2486 |
}; |
| 2487 |
EXPORT_SYMBOL_GPL(dasd_dev_groups); |
| 2488 |
|
| 2489 |
/* |
| 2490 |
* Return value of the specified feature. |
| 2491 |
*/ |
| 2492 |
int |
| 2493 |
dasd_get_feature(struct ccw_device *cdev, int feature) |
| 2494 |
{ |
| 2495 |
struct dasd_devmap *devmap; |
| 2496 |
|
| 2497 |
devmap = dasd_find_busid(dev_name(&cdev->dev)); |
| 2498 |
if (IS_ERR(devmap)) |
| 2499 |
return PTR_ERR(devmap); |
| 2500 |
|
| 2501 |
return ((devmap->features & feature) != 0); |
| 2502 |
} |
| 2503 |
|
| 2504 |
/* |
| 2505 |
* Set / reset given feature. |
| 2506 |
* Flag indicates whether to set (!=0) or the reset (=0) the feature. |
| 2507 |
*/ |
| 2508 |
int |
| 2509 |
dasd_set_feature(struct ccw_device *cdev, int feature, int flag) |
| 2510 |
{ |
| 2511 |
struct dasd_devmap *devmap; |
| 2512 |
|
| 2513 |
devmap = dasd_devmap_from_cdev(cdev); |
| 2514 |
if (IS_ERR(devmap)) |
| 2515 |
return PTR_ERR(devmap); |
| 2516 |
|
| 2517 |
spin_lock(&dasd_devmap_lock); |
| 2518 |
if (flag) |
| 2519 |
devmap->features |= feature; |
| 2520 |
else |
| 2521 |
devmap->features &= ~feature; |
| 2522 |
if (devmap->device) |
| 2523 |
devmap->device->features = devmap->features; |
| 2524 |
spin_unlock(&dasd_devmap_lock); |
| 2525 |
return 0; |
| 2526 |
} |
| 2527 |
EXPORT_SYMBOL(dasd_set_feature); |
| 2528 |
|
| 2529 |
static struct attribute *paths_info_attrs[] = { |
| 2530 |
&path_fcs_attribute.attr, |
| 2531 |
NULL, |
| 2532 |
}; |
| 2533 |
ATTRIBUTE_GROUPS(paths_info); |
| 2534 |
|
| 2535 |
static struct kobj_type path_attr_type = { |
| 2536 |
.release = dasd_path_release, |
| 2537 |
.default_groups = paths_info_groups, |
| 2538 |
.sysfs_ops = &kobj_sysfs_ops, |
| 2539 |
}; |
| 2540 |
|
| 2541 |
static void dasd_path_init_kobj(struct dasd_device *device, int chp) |
| 2542 |
{ |
| 2543 |
device->path[chp].kobj.kset = device->paths_info; |
| 2544 |
kobject_init(&device->path[chp].kobj, &path_attr_type); |
| 2545 |
} |
| 2546 |
|
| 2547 |
void dasd_path_create_kobj(struct dasd_device *device, int chp) |
| 2548 |
{ |
| 2549 |
int rc; |
| 2550 |
|
| 2551 |
if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) |
| 2552 |
return; |
| 2553 |
if (!device->paths_info) { |
| 2554 |
dev_warn(&device->cdev->dev, "Unable to create paths objects\n"); |
| 2555 |
return; |
| 2556 |
} |
| 2557 |
if (device->path[chp].in_sysfs) |
| 2558 |
return; |
| 2559 |
if (!device->path[chp].conf_data) |
| 2560 |
return; |
| 2561 |
|
| 2562 |
dasd_path_init_kobj(device, chp); |
| 2563 |
|
| 2564 |
rc = kobject_add(&device->path[chp].kobj, NULL, "%x.%02x", |
| 2565 |
device->path[chp].cssid, device->path[chp].chpid); |
| 2566 |
if (rc) |
| 2567 |
kobject_put(&device->path[chp].kobj); |
| 2568 |
device->path[chp].in_sysfs = true; |
| 2569 |
} |
| 2570 |
EXPORT_SYMBOL(dasd_path_create_kobj); |
| 2571 |
|
| 2572 |
void dasd_path_create_kobjects(struct dasd_device *device) |
| 2573 |
{ |
| 2574 |
u8 lpm, opm; |
| 2575 |
|
| 2576 |
opm = dasd_path_get_opm(device); |
| 2577 |
for (lpm = 0x80; lpm; lpm >>= 1) { |
| 2578 |
if (!(lpm & opm)) |
| 2579 |
continue; |
| 2580 |
dasd_path_create_kobj(device, pathmask_to_pos(lpm)); |
| 2581 |
} |
| 2582 |
} |
| 2583 |
EXPORT_SYMBOL(dasd_path_create_kobjects); |
| 2584 |
|
| 2585 |
static void dasd_path_remove_kobj(struct dasd_device *device, int chp) |
| 2586 |
{ |
| 2587 |
if (device->path[chp].in_sysfs) { |
| 2588 |
kobject_put(&device->path[chp].kobj); |
| 2589 |
device->path[chp].in_sysfs = false; |
| 2590 |
} |
| 2591 |
} |
| 2592 |
|
| 2593 |
/* |
| 2594 |
* As we keep kobjects for the lifetime of a device, this function must not be |
| 2595 |
* called anywhere but in the context of offlining a device. |
| 2596 |
*/ |
| 2597 |
void dasd_path_remove_kobjects(struct dasd_device *device) |
| 2598 |
{ |
| 2599 |
int i; |
| 2600 |
|
| 2601 |
for (i = 0; i < 8; i++) |
| 2602 |
dasd_path_remove_kobj(device, i); |
| 2603 |
} |
| 2604 |
EXPORT_SYMBOL(dasd_path_remove_kobjects); |
| 2605 |
|
| 2606 |
int |
| 2607 |
dasd_devmap_init(void) |
| 2608 |
{ |
| 2609 |
int i; |
| 2610 |
|
| 2611 |
/* Initialize devmap structures. */ |
| 2612 |
dasd_max_devindex = 0; |
| 2613 |
for (i = 0; i < 256; i++) |
| 2614 |
INIT_LIST_HEAD(&dasd_hashlists[i]); |
| 2615 |
return 0; |
| 2616 |
} |
| 2617 |
|
| 2618 |
void |
| 2619 |
dasd_devmap_exit(void) |
| 2620 |
{ |
| 2621 |
dasd_forget_ranges(); |
| 2622 |
} |