diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2010-04-30 18:09:35 +0200 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-02 15:42:32 -0400 |
commit | 6b9e1520094a8aa68009c265eb694e0be9f5be3f (patch) | |
tree | d6abee81a84fe8e43c26c0db75a9917599f0b835 /drivers/s390/scsi/zfcp_qdio.c | |
parent | 1674b4054744c2cfd6573e43eca45d86ff581d0e (diff) |
[SCSI] zfcp: Move sbal_get function to zfcp_qdio.c
Waiting for a free sbal is a operation on the qdio queue. Move the
code implementing the wait to zfcp_qdio.c and rename the functions
accordingly.
Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_qdio.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 98d54a9cd56..28117e130e2 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c @@ -246,6 +246,46 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, return bytes; } +static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) +{ + struct zfcp_qdio_queue *req_q = &qdio->req_q; + + spin_lock_bh(&qdio->req_q_lock); + if (atomic_read(&req_q->count)) + return 1; + spin_unlock_bh(&qdio->req_q_lock); + return 0; +} + +/** + * zfcp_qdio_sbal_get - get free sbal in request queue, wait if necessary + * @qdio: pointer to struct zfcp_qdio + * + * The req_q_lock must be held by the caller of this function, and + * this function may only be called from process context; it will + * sleep when waiting for a free sbal. + * + * Returns: 0 on success, -EIO if there is no free sbal after waiting. + */ +int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio) +{ + long ret; + + spin_unlock_bh(&qdio->req_q_lock); + ret = wait_event_interruptible_timeout(qdio->req_q_wq, + zfcp_qdio_sbal_check(qdio), 5 * HZ); + if (ret > 0) + return 0; + if (!ret) { + atomic_inc(&qdio->req_q_full); + /* assume hanging outbound queue, try queue recovery */ + zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1", NULL); + } + + spin_lock_bh(&qdio->req_q_lock); + return -EIO; +} + /** * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO * @qdio: pointer to struct zfcp_qdio |