summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2015-10-26 07:38:13 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-10-27 04:34:44 -0400
commitef12cb904e096335ef179bfe30e637a9c2464343 (patch)
treea7c287908667bbcb3dbd3aafc50e468252090141
parent8421d212e831cb03ba65bada57a733ad875286bf (diff)
s390/cio: move ccw_device_stlck functions
device_ops.c should only contain functions that are called by ccw device drivers. Move the cio internal functions that handle unconditional reserve + release to device_pgid.c Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/cio/device.h3
-rw-r--r--drivers/s390/cio/device_ops.c61
-rw-r--r--drivers/s390/cio/device_pgid.c66
3 files changed, 60 insertions, 70 deletions
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index 23c1e19776d8..065b1be98e2c 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -125,9 +125,6 @@ void ccw_device_verify_done(struct ccw_device *, int);
125void ccw_device_disband_start(struct ccw_device *); 125void ccw_device_disband_start(struct ccw_device *);
126void ccw_device_disband_done(struct ccw_device *, int); 126void ccw_device_disband_done(struct ccw_device *, int);
127 127
128void ccw_device_stlck_start(struct ccw_device *, void *, void *, void *);
129void ccw_device_stlck_done(struct ccw_device *, void *, int);
130
131int ccw_device_stlck(struct ccw_device *); 128int ccw_device_stlck(struct ccw_device *);
132 129
133/* Helper function for machine check handling. */ 130/* Helper function for machine check handling. */
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 5be77254547c..a69f702a2fcc 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -456,67 +456,6 @@ __u8 ccw_device_get_path_mask(struct ccw_device *cdev)
456 return sch->lpm; 456 return sch->lpm;
457} 457}
458 458
459struct stlck_data {
460 struct completion done;
461 int rc;
462};
463
464void ccw_device_stlck_done(struct ccw_device *cdev, void *data, int rc)
465{
466 struct stlck_data *sdata = data;
467
468 sdata->rc = rc;
469 complete(&sdata->done);
470}
471
472/*
473 * Perform unconditional reserve + release.
474 */
475int ccw_device_stlck(struct ccw_device *cdev)
476{
477 struct subchannel *sch = to_subchannel(cdev->dev.parent);
478 struct stlck_data data;
479 u8 *buffer;
480 int rc;
481
482 /* Check if steal lock operation is valid for this device. */
483 if (cdev->drv) {
484 if (!cdev->private->options.force)
485 return -EINVAL;
486 }
487 buffer = kzalloc(64, GFP_DMA | GFP_KERNEL);
488 if (!buffer)
489 return -ENOMEM;
490 init_completion(&data.done);
491 data.rc = -EIO;
492 spin_lock_irq(sch->lock);
493 rc = cio_enable_subchannel(sch, (u32) (addr_t) sch);
494 if (rc)
495 goto out_unlock;
496 /* Perform operation. */
497 cdev->private->state = DEV_STATE_STEAL_LOCK;
498 ccw_device_stlck_start(cdev, &data, &buffer[0], &buffer[32]);
499 spin_unlock_irq(sch->lock);
500 /* Wait for operation to finish. */
501 if (wait_for_completion_interruptible(&data.done)) {
502 /* Got a signal. */
503 spin_lock_irq(sch->lock);
504 ccw_request_cancel(cdev);
505 spin_unlock_irq(sch->lock);
506 wait_for_completion(&data.done);
507 }
508 rc = data.rc;
509 /* Check results. */
510 spin_lock_irq(sch->lock);
511 cio_disable_subchannel(sch);
512 cdev->private->state = DEV_STATE_BOXED;
513out_unlock:
514 spin_unlock_irq(sch->lock);
515 kfree(buffer);
516
517 return rc;
518}
519
520/** 459/**
521 * chp_get_chp_desc - return newly allocated channel-path descriptor 460 * chp_get_chp_desc - return newly allocated channel-path descriptor
522 * @cdev: device to obtain the descriptor for 461 * @cdev: device to obtain the descriptor for
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index 148b3fadac00..da246b67edfe 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -9,9 +9,10 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/bitops.h>
12#include <linux/types.h> 13#include <linux/types.h>
13#include <linux/errno.h> 14#include <linux/errno.h>
14#include <linux/bitops.h> 15#include <linux/slab.h>
15#include <asm/ccwdev.h> 16#include <asm/ccwdev.h>
16#include <asm/cio.h> 17#include <asm/cio.h>
17 18
@@ -616,6 +617,11 @@ void ccw_device_disband_start(struct ccw_device *cdev)
616 ccw_request_start(cdev); 617 ccw_request_start(cdev);
617} 618}
618 619
620struct stlck_data {
621 struct completion done;
622 int rc;
623};
624
619static void stlck_build_cp(struct ccw_device *cdev, void *buf1, void *buf2) 625static void stlck_build_cp(struct ccw_device *cdev, void *buf1, void *buf2)
620{ 626{
621 struct ccw_request *req = &cdev->private->req; 627 struct ccw_request *req = &cdev->private->req;
@@ -634,7 +640,10 @@ static void stlck_build_cp(struct ccw_device *cdev, void *buf1, void *buf2)
634 640
635static void stlck_callback(struct ccw_device *cdev, void *data, int rc) 641static void stlck_callback(struct ccw_device *cdev, void *data, int rc)
636{ 642{
637 ccw_device_stlck_done(cdev, data, rc); 643 struct stlck_data *sdata = data;
644
645 sdata->rc = rc;
646 complete(&sdata->done);
638} 647}
639 648
640/** 649/**
@@ -645,11 +654,9 @@ static void stlck_callback(struct ccw_device *cdev, void *data, int rc)
645 * @buf2: data pointer used in channel program 654 * @buf2: data pointer used in channel program
646 * 655 *
647 * Execute a channel program on @cdev to release an existing PGID reservation. 656 * Execute a channel program on @cdev to release an existing PGID reservation.
648 * When finished, call ccw_device_stlck_done with a return code specifying the
649 * result.
650 */ 657 */
651void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1, 658static void ccw_device_stlck_start(struct ccw_device *cdev, void *data,
652 void *buf2) 659 void *buf1, void *buf2)
653{ 660{
654 struct subchannel *sch = to_subchannel(cdev->dev.parent); 661 struct subchannel *sch = to_subchannel(cdev->dev.parent);
655 struct ccw_request *req = &cdev->private->req; 662 struct ccw_request *req = &cdev->private->req;
@@ -667,3 +674,50 @@ void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1,
667 ccw_request_start(cdev); 674 ccw_request_start(cdev);
668} 675}
669 676
677/*
678 * Perform unconditional reserve + release.
679 */
680int ccw_device_stlck(struct ccw_device *cdev)
681{
682 struct subchannel *sch = to_subchannel(cdev->dev.parent);
683 struct stlck_data data;
684 u8 *buffer;
685 int rc;
686
687 /* Check if steal lock operation is valid for this device. */
688 if (cdev->drv) {
689 if (!cdev->private->options.force)
690 return -EINVAL;
691 }
692 buffer = kzalloc(64, GFP_DMA | GFP_KERNEL);
693 if (!buffer)
694 return -ENOMEM;
695 init_completion(&data.done);
696 data.rc = -EIO;
697 spin_lock_irq(sch->lock);
698 rc = cio_enable_subchannel(sch, (u32) (addr_t) sch);
699 if (rc)
700 goto out_unlock;
701 /* Perform operation. */
702 cdev->private->state = DEV_STATE_STEAL_LOCK;
703 ccw_device_stlck_start(cdev, &data, &buffer[0], &buffer[32]);
704 spin_unlock_irq(sch->lock);
705 /* Wait for operation to finish. */
706 if (wait_for_completion_interruptible(&data.done)) {
707 /* Got a signal. */
708 spin_lock_irq(sch->lock);
709 ccw_request_cancel(cdev);
710 spin_unlock_irq(sch->lock);
711 wait_for_completion(&data.done);
712 }
713 rc = data.rc;
714 /* Check results. */
715 spin_lock_irq(sch->lock);
716 cio_disable_subchannel(sch);
717 cdev->private->state = DEV_STATE_BOXED;
718out_unlock:
719 spin_unlock_irq(sch->lock);
720 kfree(buffer);
721
722 return rc;
723}