diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-03-03 11:56:07 -0500 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2011-03-03 11:56:14 -0500 |
commit | 0c2bd9b24e73287aa4ee87844c847205e0da8a9b (patch) | |
tree | 4e56fae8cb7f8dcbc022771436e573c5c12b94fb /drivers/s390/char/tape_3590.c | |
parent | b652277b09d3d030cb074cc6a98ba80b34244c03 (diff) |
[S390] tape: deadlock on system work queue
The 34xx and 3590 tape driver uses the system work queue to defer work
from the interrupt function to process context, e.g. a medium sense
after an unsolicited interrupt. The tape commands started by the work
handler need to be asynchronous, otherwise a deadlock on the system
work queue can occur.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/tape_3590.c')
-rw-r--r-- | drivers/s390/char/tape_3590.c | 83 |
1 files changed, 67 insertions, 16 deletions
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c index fbe361fcd2c0..de2e99e0a71b 100644 --- a/drivers/s390/char/tape_3590.c +++ b/drivers/s390/char/tape_3590.c | |||
@@ -329,17 +329,17 @@ out: | |||
329 | /* | 329 | /* |
330 | * Enable encryption | 330 | * Enable encryption |
331 | */ | 331 | */ |
332 | static int tape_3592_enable_crypt(struct tape_device *device) | 332 | static struct tape_request *__tape_3592_enable_crypt(struct tape_device *device) |
333 | { | 333 | { |
334 | struct tape_request *request; | 334 | struct tape_request *request; |
335 | char *data; | 335 | char *data; |
336 | 336 | ||
337 | DBF_EVENT(6, "tape_3592_enable_crypt\n"); | 337 | DBF_EVENT(6, "tape_3592_enable_crypt\n"); |
338 | if (!crypt_supported(device)) | 338 | if (!crypt_supported(device)) |
339 | return -ENOSYS; | 339 | return ERR_PTR(-ENOSYS); |
340 | request = tape_alloc_request(2, 72); | 340 | request = tape_alloc_request(2, 72); |
341 | if (IS_ERR(request)) | 341 | if (IS_ERR(request)) |
342 | return PTR_ERR(request); | 342 | return request; |
343 | data = request->cpdata; | 343 | data = request->cpdata; |
344 | memset(data,0,72); | 344 | memset(data,0,72); |
345 | 345 | ||
@@ -354,23 +354,42 @@ static int tape_3592_enable_crypt(struct tape_device *device) | |||
354 | request->op = TO_CRYPT_ON; | 354 | request->op = TO_CRYPT_ON; |
355 | tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); | 355 | tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); |
356 | tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); | 356 | tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); |
357 | return request; | ||
358 | } | ||
359 | |||
360 | static int tape_3592_enable_crypt(struct tape_device *device) | ||
361 | { | ||
362 | struct tape_request *request; | ||
363 | |||
364 | request = __tape_3592_enable_crypt(device); | ||
365 | if (IS_ERR(request)) | ||
366 | return PTR_ERR(request); | ||
357 | return tape_do_io_free(device, request); | 367 | return tape_do_io_free(device, request); |
358 | } | 368 | } |
359 | 369 | ||
370 | static void tape_3592_enable_crypt_async(struct tape_device *device) | ||
371 | { | ||
372 | struct tape_request *request; | ||
373 | |||
374 | request = __tape_3592_enable_crypt(device); | ||
375 | if (!IS_ERR(request)) | ||
376 | tape_do_io_async_free(device, request); | ||
377 | } | ||
378 | |||
360 | /* | 379 | /* |
361 | * Disable encryption | 380 | * Disable encryption |
362 | */ | 381 | */ |
363 | static int tape_3592_disable_crypt(struct tape_device *device) | 382 | static struct tape_request *__tape_3592_disable_crypt(struct tape_device *device) |
364 | { | 383 | { |
365 | struct tape_request *request; | 384 | struct tape_request *request; |
366 | char *data; | 385 | char *data; |
367 | 386 | ||
368 | DBF_EVENT(6, "tape_3592_disable_crypt\n"); | 387 | DBF_EVENT(6, "tape_3592_disable_crypt\n"); |
369 | if (!crypt_supported(device)) | 388 | if (!crypt_supported(device)) |
370 | return -ENOSYS; | 389 | return ERR_PTR(-ENOSYS); |
371 | request = tape_alloc_request(2, 72); | 390 | request = tape_alloc_request(2, 72); |
372 | if (IS_ERR(request)) | 391 | if (IS_ERR(request)) |
373 | return PTR_ERR(request); | 392 | return request; |
374 | data = request->cpdata; | 393 | data = request->cpdata; |
375 | memset(data,0,72); | 394 | memset(data,0,72); |
376 | 395 | ||
@@ -383,9 +402,28 @@ static int tape_3592_disable_crypt(struct tape_device *device) | |||
383 | tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); | 402 | tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); |
384 | tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); | 403 | tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); |
385 | 404 | ||
405 | return request; | ||
406 | } | ||
407 | |||
408 | static int tape_3592_disable_crypt(struct tape_device *device) | ||
409 | { | ||
410 | struct tape_request *request; | ||
411 | |||
412 | request = __tape_3592_disable_crypt(device); | ||
413 | if (IS_ERR(request)) | ||
414 | return PTR_ERR(request); | ||
386 | return tape_do_io_free(device, request); | 415 | return tape_do_io_free(device, request); |
387 | } | 416 | } |
388 | 417 | ||
418 | static void tape_3592_disable_crypt_async(struct tape_device *device) | ||
419 | { | ||
420 | struct tape_request *request; | ||
421 | |||
422 | request = __tape_3592_disable_crypt(device); | ||
423 | if (!IS_ERR(request)) | ||
424 | tape_do_io_async_free(device, request); | ||
425 | } | ||
426 | |||
389 | /* | 427 | /* |
390 | * IOCTL: Set encryption status | 428 | * IOCTL: Set encryption status |
391 | */ | 429 | */ |
@@ -457,8 +495,7 @@ tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg) | |||
457 | /* | 495 | /* |
458 | * SENSE Medium: Get Sense data about medium state | 496 | * SENSE Medium: Get Sense data about medium state |
459 | */ | 497 | */ |
460 | static int | 498 | static int tape_3590_sense_medium(struct tape_device *device) |
461 | tape_3590_sense_medium(struct tape_device *device) | ||
462 | { | 499 | { |
463 | struct tape_request *request; | 500 | struct tape_request *request; |
464 | 501 | ||
@@ -470,6 +507,18 @@ tape_3590_sense_medium(struct tape_device *device) | |||
470 | return tape_do_io_free(device, request); | 507 | return tape_do_io_free(device, request); |
471 | } | 508 | } |
472 | 509 | ||
510 | static void tape_3590_sense_medium_async(struct tape_device *device) | ||
511 | { | ||
512 | struct tape_request *request; | ||
513 | |||
514 | request = tape_alloc_request(1, 128); | ||
515 | if (IS_ERR(request)) | ||
516 | return; | ||
517 | request->op = TO_MSEN; | ||
518 | tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata); | ||
519 | tape_do_io_async_free(device, request); | ||
520 | } | ||
521 | |||
473 | /* | 522 | /* |
474 | * MTTELL: Tell block. Return the number of block relative to current file. | 523 | * MTTELL: Tell block. Return the number of block relative to current file. |
475 | */ | 524 | */ |
@@ -546,15 +595,14 @@ tape_3590_read_opposite(struct tape_device *device, | |||
546 | * 2. The attention msg is written to the "read subsystem data" buffer. | 595 | * 2. The attention msg is written to the "read subsystem data" buffer. |
547 | * In this case we probably should print it to the console. | 596 | * In this case we probably should print it to the console. |
548 | */ | 597 | */ |
549 | static int | 598 | static void tape_3590_read_attmsg_async(struct tape_device *device) |
550 | tape_3590_read_attmsg(struct tape_device *device) | ||
551 | { | 599 | { |
552 | struct tape_request *request; | 600 | struct tape_request *request; |
553 | char *buf; | 601 | char *buf; |
554 | 602 | ||
555 | request = tape_alloc_request(3, 4096); | 603 | request = tape_alloc_request(3, 4096); |
556 | if (IS_ERR(request)) | 604 | if (IS_ERR(request)) |
557 | return PTR_ERR(request); | 605 | return; |
558 | request->op = TO_READ_ATTMSG; | 606 | request->op = TO_READ_ATTMSG; |
559 | buf = request->cpdata; | 607 | buf = request->cpdata; |
560 | buf[0] = PREP_RD_SS_DATA; | 608 | buf[0] = PREP_RD_SS_DATA; |
@@ -562,12 +610,15 @@ tape_3590_read_attmsg(struct tape_device *device) | |||
562 | tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf); | 610 | tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf); |
563 | tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12); | 611 | tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12); |
564 | tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); | 612 | tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); |
565 | return tape_do_io_free(device, request); | 613 | tape_do_io_async_free(device, request); |
566 | } | 614 | } |
567 | 615 | ||
568 | /* | 616 | /* |
569 | * These functions are used to schedule follow-up actions from within an | 617 | * These functions are used to schedule follow-up actions from within an |
570 | * interrupt context (like unsolicited interrupts). | 618 | * interrupt context (like unsolicited interrupts). |
619 | * Note: the work handler is called by the system work queue. The tape | ||
620 | * commands started by the handler need to be asynchrounous, otherwise | ||
621 | * a deadlock can occur e.g. in case of a deferred cc=1 (see __tape_do_irq). | ||
571 | */ | 622 | */ |
572 | struct work_handler_data { | 623 | struct work_handler_data { |
573 | struct tape_device *device; | 624 | struct tape_device *device; |
@@ -583,16 +634,16 @@ tape_3590_work_handler(struct work_struct *work) | |||
583 | 634 | ||
584 | switch (p->op) { | 635 | switch (p->op) { |
585 | case TO_MSEN: | 636 | case TO_MSEN: |
586 | tape_3590_sense_medium(p->device); | 637 | tape_3590_sense_medium_async(p->device); |
587 | break; | 638 | break; |
588 | case TO_READ_ATTMSG: | 639 | case TO_READ_ATTMSG: |
589 | tape_3590_read_attmsg(p->device); | 640 | tape_3590_read_attmsg_async(p->device); |
590 | break; | 641 | break; |
591 | case TO_CRYPT_ON: | 642 | case TO_CRYPT_ON: |
592 | tape_3592_enable_crypt(p->device); | 643 | tape_3592_enable_crypt_async(p->device); |
593 | break; | 644 | break; |
594 | case TO_CRYPT_OFF: | 645 | case TO_CRYPT_OFF: |
595 | tape_3592_disable_crypt(p->device); | 646 | tape_3592_disable_crypt_async(p->device); |
596 | break; | 647 | break; |
597 | default: | 648 | default: |
598 | DBF_EVENT(3, "T3590: work handler undefined for " | 649 | DBF_EVENT(3, "T3590: work handler undefined for " |