提交 957c5ab1 编写于 作者: K Kevin Barnett 提交者: Martin K. Petersen

scsi: smartpqi: improve handling for sync requests

Decrement the active thread count after the synchronous request was
submitted to the controller but before the driver blocks to wait for the
request to complete.
Reviewed-by: NScott Benesh <scott.benesh@microsemi.com>
Reviewed-by: NScott Teel <scott.teel@microsemi.com>
Signed-off-by: NKevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: NDon Brace <don.brace@microsemi.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 4beb4867
...@@ -3621,43 +3621,16 @@ static void pqi_raid_synchronous_complete(struct pqi_io_request *io_request, ...@@ -3621,43 +3621,16 @@ static void pqi_raid_synchronous_complete(struct pqi_io_request *io_request,
complete(waiting); complete(waiting);
} }
static int pqi_submit_raid_request_synchronous_with_io_request(
struct pqi_ctrl_info *ctrl_info, struct pqi_io_request *io_request,
unsigned long timeout_msecs)
{
int rc = 0;
DECLARE_COMPLETION_ONSTACK(wait);
io_request->io_complete_callback = pqi_raid_synchronous_complete;
io_request->context = &wait;
pqi_start_io(ctrl_info,
&ctrl_info->queue_groups[PQI_DEFAULT_QUEUE_GROUP], RAID_PATH,
io_request);
if (timeout_msecs == NO_TIMEOUT) {
pqi_wait_for_completion_io(ctrl_info, &wait);
} else {
if (!wait_for_completion_io_timeout(&wait,
msecs_to_jiffies(timeout_msecs))) {
dev_warn(&ctrl_info->pci_dev->dev,
"command timed out\n");
rc = -ETIMEDOUT;
}
}
return rc;
}
static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info,
struct pqi_iu_header *request, unsigned int flags, struct pqi_iu_header *request, unsigned int flags,
struct pqi_raid_error_info *error_info, unsigned long timeout_msecs) struct pqi_raid_error_info *error_info, unsigned long timeout_msecs)
{ {
int rc; int rc = 0;
struct pqi_io_request *io_request; struct pqi_io_request *io_request;
unsigned long start_jiffies; unsigned long start_jiffies;
unsigned long msecs_blocked; unsigned long msecs_blocked;
size_t iu_length; size_t iu_length;
DECLARE_COMPLETION_ONSTACK(wait);
/* /*
* Note that specifying PQI_SYNC_FLAGS_INTERRUPTABLE and a timeout value * Note that specifying PQI_SYNC_FLAGS_INTERRUPTABLE and a timeout value
...@@ -3686,11 +3659,13 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, ...@@ -3686,11 +3659,13 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info,
pqi_ctrl_busy(ctrl_info); pqi_ctrl_busy(ctrl_info);
timeout_msecs = pqi_wait_if_ctrl_blocked(ctrl_info, timeout_msecs); timeout_msecs = pqi_wait_if_ctrl_blocked(ctrl_info, timeout_msecs);
if (timeout_msecs == 0) { if (timeout_msecs == 0) {
pqi_ctrl_unbusy(ctrl_info);
rc = -ETIMEDOUT; rc = -ETIMEDOUT;
goto out; goto out;
} }
if (pqi_ctrl_offline(ctrl_info)) { if (pqi_ctrl_offline(ctrl_info)) {
pqi_ctrl_unbusy(ctrl_info);
rc = -ENXIO; rc = -ENXIO;
goto out; goto out;
} }
...@@ -3708,8 +3683,25 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, ...@@ -3708,8 +3683,25 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info,
PQI_REQUEST_HEADER_LENGTH; PQI_REQUEST_HEADER_LENGTH;
memcpy(io_request->iu, request, iu_length); memcpy(io_request->iu, request, iu_length);
rc = pqi_submit_raid_request_synchronous_with_io_request(ctrl_info, io_request->io_complete_callback = pqi_raid_synchronous_complete;
io_request, timeout_msecs); io_request->context = &wait;
pqi_start_io(ctrl_info,
&ctrl_info->queue_groups[PQI_DEFAULT_QUEUE_GROUP], RAID_PATH,
io_request);
pqi_ctrl_unbusy(ctrl_info);
if (timeout_msecs == NO_TIMEOUT) {
pqi_wait_for_completion_io(ctrl_info, &wait);
} else {
if (!wait_for_completion_io_timeout(&wait,
msecs_to_jiffies(timeout_msecs))) {
dev_warn(&ctrl_info->pci_dev->dev,
"command timed out\n");
rc = -ETIMEDOUT;
}
}
if (error_info) { if (error_info) {
if (io_request->error_info) if (io_request->error_info)
...@@ -3736,7 +3728,6 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, ...@@ -3736,7 +3728,6 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info,
pqi_free_io_request(io_request); pqi_free_io_request(io_request);
out: out:
pqi_ctrl_unbusy(ctrl_info);
up(&ctrl_info->sync_request_sem); up(&ctrl_info->sync_request_sem);
return rc; return rc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册