aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/block/dasd_alias.c
diff options
context:
space:
mode:
authorStefan Haberland <stefan.haberland@de.ibm.com>2010-05-17 04:00:11 -0400
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2010-05-17 04:00:16 -0400
commit2dedf0d9eadf39660f2e1686b5d36e4a7515803f (patch)
tree39fefcb959ee6e7c9c15b07b58eb9ef6a9e6304d /drivers/s390/block/dasd_alias.c
parent501183f2ed74434e30a1b039b2f3af30f1f3f461 (diff)
[S390] dasd: remove uid from devmap
Remove the duplicate of the DASD uid from the devmap structure. Use the uid from the device private structure instead. This also removes a lockdep warning complaining about a possible SOFTIRQ-safe -> SOFTIRQ-unsafe lock order. Signed-off-by: Stefan Haberland <stefan.haberland@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/block/dasd_alias.c')
-rw-r--r--drivers/s390/block/dasd_alias.c117
1 files changed, 75 insertions, 42 deletions
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index a564b9941114..4155805dcdff 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -190,20 +190,21 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
190 struct alias_server *server, *newserver; 190 struct alias_server *server, *newserver;
191 struct alias_lcu *lcu, *newlcu; 191 struct alias_lcu *lcu, *newlcu;
192 int is_lcu_known; 192 int is_lcu_known;
193 struct dasd_uid *uid; 193 struct dasd_uid uid;
194 194
195 private = (struct dasd_eckd_private *) device->private; 195 private = (struct dasd_eckd_private *) device->private;
196 uid = &private->uid; 196
197 device->discipline->get_uid(device, &uid);
197 spin_lock_irqsave(&aliastree.lock, flags); 198 spin_lock_irqsave(&aliastree.lock, flags);
198 is_lcu_known = 1; 199 is_lcu_known = 1;
199 server = _find_server(uid); 200 server = _find_server(&uid);
200 if (!server) { 201 if (!server) {
201 spin_unlock_irqrestore(&aliastree.lock, flags); 202 spin_unlock_irqrestore(&aliastree.lock, flags);
202 newserver = _allocate_server(uid); 203 newserver = _allocate_server(&uid);
203 if (IS_ERR(newserver)) 204 if (IS_ERR(newserver))
204 return PTR_ERR(newserver); 205 return PTR_ERR(newserver);
205 spin_lock_irqsave(&aliastree.lock, flags); 206 spin_lock_irqsave(&aliastree.lock, flags);
206 server = _find_server(uid); 207 server = _find_server(&uid);
207 if (!server) { 208 if (!server) {
208 list_add(&newserver->server, &aliastree.serverlist); 209 list_add(&newserver->server, &aliastree.serverlist);
209 server = newserver; 210 server = newserver;
@@ -214,14 +215,14 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
214 } 215 }
215 } 216 }
216 217
217 lcu = _find_lcu(server, uid); 218 lcu = _find_lcu(server, &uid);
218 if (!lcu) { 219 if (!lcu) {
219 spin_unlock_irqrestore(&aliastree.lock, flags); 220 spin_unlock_irqrestore(&aliastree.lock, flags);
220 newlcu = _allocate_lcu(uid); 221 newlcu = _allocate_lcu(&uid);
221 if (IS_ERR(newlcu)) 222 if (IS_ERR(newlcu))
222 return PTR_ERR(newlcu); 223 return PTR_ERR(newlcu);
223 spin_lock_irqsave(&aliastree.lock, flags); 224 spin_lock_irqsave(&aliastree.lock, flags);
224 lcu = _find_lcu(server, uid); 225 lcu = _find_lcu(server, &uid);
225 if (!lcu) { 226 if (!lcu) {
226 list_add(&newlcu->lcu, &server->lculist); 227 list_add(&newlcu->lcu, &server->lculist);
227 lcu = newlcu; 228 lcu = newlcu;
@@ -256,20 +257,20 @@ void dasd_alias_lcu_setup_complete(struct dasd_device *device)
256 unsigned long flags; 257 unsigned long flags;
257 struct alias_server *server; 258 struct alias_server *server;
258 struct alias_lcu *lcu; 259 struct alias_lcu *lcu;
259 struct dasd_uid *uid; 260 struct dasd_uid uid;
260 261
261 private = (struct dasd_eckd_private *) device->private; 262 private = (struct dasd_eckd_private *) device->private;
262 uid = &private->uid; 263 device->discipline->get_uid(device, &uid);
263 lcu = NULL; 264 lcu = NULL;
264 spin_lock_irqsave(&aliastree.lock, flags); 265 spin_lock_irqsave(&aliastree.lock, flags);
265 server = _find_server(uid); 266 server = _find_server(&uid);
266 if (server) 267 if (server)
267 lcu = _find_lcu(server, uid); 268 lcu = _find_lcu(server, &uid);
268 spin_unlock_irqrestore(&aliastree.lock, flags); 269 spin_unlock_irqrestore(&aliastree.lock, flags);
269 if (!lcu) { 270 if (!lcu) {
270 DBF_EVENT_DEVID(DBF_ERR, device->cdev, 271 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
271 "could not find lcu for %04x %02x", 272 "could not find lcu for %04x %02x",
272 uid->ssid, uid->real_unit_addr); 273 uid.ssid, uid.real_unit_addr);
273 WARN_ON(1); 274 WARN_ON(1);
274 return; 275 return;
275 } 276 }
@@ -282,20 +283,20 @@ void dasd_alias_wait_for_lcu_setup(struct dasd_device *device)
282 unsigned long flags; 283 unsigned long flags;
283 struct alias_server *server; 284 struct alias_server *server;
284 struct alias_lcu *lcu; 285 struct alias_lcu *lcu;
285 struct dasd_uid *uid; 286 struct dasd_uid uid;
286 287
287 private = (struct dasd_eckd_private *) device->private; 288 private = (struct dasd_eckd_private *) device->private;
288 uid = &private->uid; 289 device->discipline->get_uid(device, &uid);
289 lcu = NULL; 290 lcu = NULL;
290 spin_lock_irqsave(&aliastree.lock, flags); 291 spin_lock_irqsave(&aliastree.lock, flags);
291 server = _find_server(uid); 292 server = _find_server(&uid);
292 if (server) 293 if (server)
293 lcu = _find_lcu(server, uid); 294 lcu = _find_lcu(server, &uid);
294 spin_unlock_irqrestore(&aliastree.lock, flags); 295 spin_unlock_irqrestore(&aliastree.lock, flags);
295 if (!lcu) { 296 if (!lcu) {
296 DBF_EVENT_DEVID(DBF_ERR, device->cdev, 297 DBF_EVENT_DEVID(DBF_ERR, device->cdev,
297 "could not find lcu for %04x %02x", 298 "could not find lcu for %04x %02x",
298 uid->ssid, uid->real_unit_addr); 299 uid.ssid, uid.real_unit_addr);
299 WARN_ON(1); 300 WARN_ON(1);
300 return; 301 return;
301 } 302 }
@@ -314,9 +315,11 @@ void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
314 struct alias_lcu *lcu; 315 struct alias_lcu *lcu;
315 struct alias_server *server; 316 struct alias_server *server;
316 int was_pending; 317 int was_pending;
318 struct dasd_uid uid;
317 319
318 private = (struct dasd_eckd_private *) device->private; 320 private = (struct dasd_eckd_private *) device->private;
319 lcu = private->lcu; 321 lcu = private->lcu;
322 device->discipline->get_uid(device, &uid);
320 spin_lock_irqsave(&lcu->lock, flags); 323 spin_lock_irqsave(&lcu->lock, flags);
321 list_del_init(&device->alias_list); 324 list_del_init(&device->alias_list);
322 /* make sure that the workers don't use this device */ 325 /* make sure that the workers don't use this device */
@@ -353,7 +356,7 @@ void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
353 _schedule_lcu_update(lcu, NULL); 356 _schedule_lcu_update(lcu, NULL);
354 spin_unlock(&lcu->lock); 357 spin_unlock(&lcu->lock);
355 } 358 }
356 server = _find_server(&private->uid); 359 server = _find_server(&uid);
357 if (server && list_empty(&server->lculist)) { 360 if (server && list_empty(&server->lculist)) {
358 list_del(&server->server); 361 list_del(&server->server);
359 _free_server(server); 362 _free_server(server);
@@ -366,19 +369,30 @@ void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
366 * in the lcu is up to date and will update the device uid before 369 * in the lcu is up to date and will update the device uid before
367 * adding it to a pav group. 370 * adding it to a pav group.
368 */ 371 */
372
369static int _add_device_to_lcu(struct alias_lcu *lcu, 373static int _add_device_to_lcu(struct alias_lcu *lcu,
370 struct dasd_device *device) 374 struct dasd_device *device,
375 struct dasd_device *pos)
371{ 376{
372 377
373 struct dasd_eckd_private *private; 378 struct dasd_eckd_private *private;
374 struct alias_pav_group *group; 379 struct alias_pav_group *group;
375 struct dasd_uid *uid; 380 struct dasd_uid uid;
381 unsigned long flags;
376 382
377 private = (struct dasd_eckd_private *) device->private; 383 private = (struct dasd_eckd_private *) device->private;
378 uid = &private->uid; 384
379 uid->type = lcu->uac->unit[uid->real_unit_addr].ua_type; 385 /* only lock if not already locked */
380 uid->base_unit_addr = lcu->uac->unit[uid->real_unit_addr].base_ua; 386 if (device != pos)
381 dasd_set_uid(device->cdev, &private->uid); 387 spin_lock_irqsave_nested(get_ccwdev_lock(device->cdev), flags,
388 CDEV_NESTED_SECOND);
389 private->uid.type = lcu->uac->unit[private->uid.real_unit_addr].ua_type;
390 private->uid.base_unit_addr =
391 lcu->uac->unit[private->uid.real_unit_addr].base_ua;
392 uid = private->uid;
393
394 if (device != pos)
395 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
382 396
383 /* if we have no PAV anyway, we don't need to bother with PAV groups */ 397 /* if we have no PAV anyway, we don't need to bother with PAV groups */
384 if (lcu->pav == NO_PAV) { 398 if (lcu->pav == NO_PAV) {
@@ -386,25 +400,25 @@ static int _add_device_to_lcu(struct alias_lcu *lcu,
386 return 0; 400 return 0;
387 } 401 }
388 402
389 group = _find_group(lcu, uid); 403 group = _find_group(lcu, &uid);
390 if (!group) { 404 if (!group) {
391 group = kzalloc(sizeof(*group), GFP_ATOMIC); 405 group = kzalloc(sizeof(*group), GFP_ATOMIC);
392 if (!group) 406 if (!group)
393 return -ENOMEM; 407 return -ENOMEM;
394 memcpy(group->uid.vendor, uid->vendor, sizeof(uid->vendor)); 408 memcpy(group->uid.vendor, uid.vendor, sizeof(uid.vendor));
395 memcpy(group->uid.serial, uid->serial, sizeof(uid->serial)); 409 memcpy(group->uid.serial, uid.serial, sizeof(uid.serial));
396 group->uid.ssid = uid->ssid; 410 group->uid.ssid = uid.ssid;
397 if (uid->type == UA_BASE_DEVICE) 411 if (uid.type == UA_BASE_DEVICE)
398 group->uid.base_unit_addr = uid->real_unit_addr; 412 group->uid.base_unit_addr = uid.real_unit_addr;
399 else 413 else
400 group->uid.base_unit_addr = uid->base_unit_addr; 414 group->uid.base_unit_addr = uid.base_unit_addr;
401 memcpy(group->uid.vduit, uid->vduit, sizeof(uid->vduit)); 415 memcpy(group->uid.vduit, uid.vduit, sizeof(uid.vduit));
402 INIT_LIST_HEAD(&group->group); 416 INIT_LIST_HEAD(&group->group);
403 INIT_LIST_HEAD(&group->baselist); 417 INIT_LIST_HEAD(&group->baselist);
404 INIT_LIST_HEAD(&group->aliaslist); 418 INIT_LIST_HEAD(&group->aliaslist);
405 list_add(&group->group, &lcu->grouplist); 419 list_add(&group->group, &lcu->grouplist);
406 } 420 }
407 if (uid->type == UA_BASE_DEVICE) 421 if (uid.type == UA_BASE_DEVICE)
408 list_move(&device->alias_list, &group->baselist); 422 list_move(&device->alias_list, &group->baselist);
409 else 423 else
410 list_move(&device->alias_list, &group->aliaslist); 424 list_move(&device->alias_list, &group->aliaslist);
@@ -525,7 +539,10 @@ static int _lcu_update(struct dasd_device *refdev, struct alias_lcu *lcu)
525 if (rc) 539 if (rc)
526 return rc; 540 return rc;
527 541
528 spin_lock_irqsave(&lcu->lock, flags); 542 /* need to take cdev lock before lcu lock */
543 spin_lock_irqsave_nested(get_ccwdev_lock(refdev->cdev), flags,
544 CDEV_NESTED_FIRST);
545 spin_lock(&lcu->lock);
529 lcu->pav = NO_PAV; 546 lcu->pav = NO_PAV;
530 for (i = 0; i < MAX_DEVICES_PER_LCU; ++i) { 547 for (i = 0; i < MAX_DEVICES_PER_LCU; ++i) {
531 switch (lcu->uac->unit[i].ua_type) { 548 switch (lcu->uac->unit[i].ua_type) {
@@ -542,9 +559,10 @@ static int _lcu_update(struct dasd_device *refdev, struct alias_lcu *lcu)
542 559
543 list_for_each_entry_safe(device, tempdev, &lcu->active_devices, 560 list_for_each_entry_safe(device, tempdev, &lcu->active_devices,
544 alias_list) { 561 alias_list) {
545 _add_device_to_lcu(lcu, device); 562 _add_device_to_lcu(lcu, device, refdev);
546 } 563 }
547 spin_unlock_irqrestore(&lcu->lock, flags); 564 spin_unlock(&lcu->lock);
565 spin_unlock_irqrestore(get_ccwdev_lock(refdev->cdev), flags);
548 return 0; 566 return 0;
549} 567}
550 568
@@ -628,9 +646,12 @@ int dasd_alias_add_device(struct dasd_device *device)
628 private = (struct dasd_eckd_private *) device->private; 646 private = (struct dasd_eckd_private *) device->private;
629 lcu = private->lcu; 647 lcu = private->lcu;
630 rc = 0; 648 rc = 0;
631 spin_lock_irqsave(&lcu->lock, flags); 649
650 /* need to take cdev lock before lcu lock */
651 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
652 spin_lock(&lcu->lock);
632 if (!(lcu->flags & UPDATE_PENDING)) { 653 if (!(lcu->flags & UPDATE_PENDING)) {
633 rc = _add_device_to_lcu(lcu, device); 654 rc = _add_device_to_lcu(lcu, device, device);
634 if (rc) 655 if (rc)
635 lcu->flags |= UPDATE_PENDING; 656 lcu->flags |= UPDATE_PENDING;
636 } 657 }
@@ -638,7 +659,8 @@ int dasd_alias_add_device(struct dasd_device *device)
638 list_move(&device->alias_list, &lcu->active_devices); 659 list_move(&device->alias_list, &lcu->active_devices);
639 _schedule_lcu_update(lcu, device); 660 _schedule_lcu_update(lcu, device);
640 } 661 }
641 spin_unlock_irqrestore(&lcu->lock, flags); 662 spin_unlock(&lcu->lock);
663 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
642 return rc; 664 return rc;
643} 665}
644 666
@@ -748,19 +770,30 @@ static void _restart_all_base_devices_on_lcu(struct alias_lcu *lcu)
748 struct alias_pav_group *pavgroup; 770 struct alias_pav_group *pavgroup;
749 struct dasd_device *device; 771 struct dasd_device *device;
750 struct dasd_eckd_private *private; 772 struct dasd_eckd_private *private;
773 unsigned long flags;
751 774
752 /* active and inactive list can contain alias as well as base devices */ 775 /* active and inactive list can contain alias as well as base devices */
753 list_for_each_entry(device, &lcu->active_devices, alias_list) { 776 list_for_each_entry(device, &lcu->active_devices, alias_list) {
754 private = (struct dasd_eckd_private *) device->private; 777 private = (struct dasd_eckd_private *) device->private;
755 if (private->uid.type != UA_BASE_DEVICE) 778 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
779 if (private->uid.type != UA_BASE_DEVICE) {
780 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev),
781 flags);
756 continue; 782 continue;
783 }
784 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
757 dasd_schedule_block_bh(device->block); 785 dasd_schedule_block_bh(device->block);
758 dasd_schedule_device_bh(device); 786 dasd_schedule_device_bh(device);
759 } 787 }
760 list_for_each_entry(device, &lcu->inactive_devices, alias_list) { 788 list_for_each_entry(device, &lcu->inactive_devices, alias_list) {
761 private = (struct dasd_eckd_private *) device->private; 789 private = (struct dasd_eckd_private *) device->private;
762 if (private->uid.type != UA_BASE_DEVICE) 790 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
791 if (private->uid.type != UA_BASE_DEVICE) {
792 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev),
793 flags);
763 continue; 794 continue;
795 }
796 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
764 dasd_schedule_block_bh(device->block); 797 dasd_schedule_block_bh(device->block);
765 dasd_schedule_device_bh(device); 798 dasd_schedule_device_bh(device);
766 } 799 }