Commit 6c0a60ec authored by Brian King's avatar Brian King Committed by James Bottomley

[SCSI] ibmvscsi: Enhanced error logging

Converts ibmvscsi to use dev_printk and friends to simplify
debugging. ibmvscsi adapter initialization now looks like this:

ibmvscsi 30000005: SRP_VERSION: 16.a
ibmvscsi 30000005: partner initialization complete
ibmvscsi 30000005: sent SRP login
ibmvscsi 30000005: SRP_LOGIN succeeded

Additionally, this patch adds the logging of a couple return codes in
a couple logs.
Signed-off-by: default avatarBrian King <brking@linux.vnet.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 2a730937
...@@ -173,9 +173,8 @@ static void release_event_pool(struct event_pool *pool, ...@@ -173,9 +173,8 @@ static void release_event_pool(struct event_pool *pool,
} }
} }
if (in_use) if (in_use)
printk(KERN_WARNING dev_warn(hostdata->dev, "releasing event pool with %d "
"ibmvscsi: releasing event pool with %d " "events still in use?\n", in_use);
"events still in use?\n", in_use);
kfree(pool->events); kfree(pool->events);
dma_free_coherent(hostdata->dev, dma_free_coherent(hostdata->dev,
pool->size * sizeof(*pool->iu_storage), pool->size * sizeof(*pool->iu_storage),
...@@ -210,15 +209,13 @@ static void free_event_struct(struct event_pool *pool, ...@@ -210,15 +209,13 @@ static void free_event_struct(struct event_pool *pool,
struct srp_event_struct *evt) struct srp_event_struct *evt)
{ {
if (!valid_event_struct(pool, evt)) { if (!valid_event_struct(pool, evt)) {
printk(KERN_ERR dev_err(evt->hostdata->dev, "Freeing invalid event_struct %p "
"ibmvscsi: Freeing invalid event_struct %p " "(not in pool %p)\n", evt, pool->events);
"(not in pool %p)\n", evt, pool->events);
return; return;
} }
if (atomic_inc_return(&evt->free) != 1) { if (atomic_inc_return(&evt->free) != 1) {
printk(KERN_ERR dev_err(evt->hostdata->dev, "Freeing event_struct %p "
"ibmvscsi: Freeing event_struct %p " "which is not in use!\n", evt);
"which is not in use!\n", evt);
return; return;
} }
} }
...@@ -426,10 +423,9 @@ static int map_sg_data(struct scsi_cmnd *cmd, ...@@ -426,10 +423,9 @@ static int map_sg_data(struct scsi_cmnd *cmd,
SG_ALL * sizeof(struct srp_direct_buf), SG_ALL * sizeof(struct srp_direct_buf),
&evt_struct->ext_list_token, 0); &evt_struct->ext_list_token, 0);
if (!evt_struct->ext_list) { if (!evt_struct->ext_list) {
printk(KERN_ERR sdev_printk(KERN_ERR, cmd->device,
"ibmvscsi: Can't allocate memory for indirect table\n"); "Can't allocate memory for indirect table\n");
return 0; return 0;
} }
} }
...@@ -464,8 +460,8 @@ static int map_single_data(struct scsi_cmnd *cmd, ...@@ -464,8 +460,8 @@ static int map_single_data(struct scsi_cmnd *cmd,
cmd->request_bufflen, cmd->request_bufflen,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (dma_mapping_error(data->va)) { if (dma_mapping_error(data->va)) {
printk(KERN_ERR sdev_printk(KERN_ERR, cmd->device,
"ibmvscsi: Unable to map request_buffer for command!\n"); "Unable to map request_buffer for command!\n");
return 0; return 0;
} }
data->len = cmd->request_bufflen; data->len = cmd->request_bufflen;
...@@ -496,13 +492,13 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd, ...@@ -496,13 +492,13 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd,
case DMA_NONE: case DMA_NONE:
return 1; return 1;
case DMA_BIDIRECTIONAL: case DMA_BIDIRECTIONAL:
printk(KERN_ERR sdev_printk(KERN_ERR, cmd->device,
"ibmvscsi: Can't map DMA_BIDIRECTIONAL to read/write\n"); "Can't map DMA_BIDIRECTIONAL to read/write\n");
return 0; return 0;
default: default:
printk(KERN_ERR sdev_printk(KERN_ERR, cmd->device,
"ibmvscsi: Unknown data direction 0x%02x; can't map!\n", "Unknown data direction 0x%02x; can't map!\n",
cmd->sc_data_direction); cmd->sc_data_direction);
return 0; return 0;
} }
...@@ -585,8 +581,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, ...@@ -585,8 +581,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) {
list_del(&evt_struct->list); list_del(&evt_struct->list);
printk(KERN_ERR "ibmvscsi: send error %d\n", dev_err(hostdata->dev, "send error %d\n", rc);
rc);
atomic_inc(&hostdata->request_limit); atomic_inc(&hostdata->request_limit);
goto send_error; goto send_error;
} }
...@@ -627,9 +622,8 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct) ...@@ -627,9 +622,8 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct)
if (unlikely(rsp->opcode != SRP_RSP)) { if (unlikely(rsp->opcode != SRP_RSP)) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING dev_warn(evt_struct->hostdata->dev,
"ibmvscsi: bad SRP RSP type %d\n", "bad SRP RSP type %d\n", rsp->opcode);
rsp->opcode);
} }
if (cmnd) { if (cmnd) {
...@@ -690,7 +684,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, ...@@ -690,7 +684,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd,
srp_cmd->lun = ((u64) lun) << 48; srp_cmd->lun = ((u64) lun) << 48;
if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) {
printk(KERN_ERR "ibmvscsi: couldn't convert cmd to srp_cmd\n"); sdev_printk(KERN_ERR, cmnd->device, "couldn't convert cmd to srp_cmd\n");
free_event_struct(&hostdata->pool, evt_struct); free_event_struct(&hostdata->pool, evt_struct);
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
...@@ -737,16 +731,16 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) ...@@ -737,16 +731,16 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct)
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (evt_struct->xfer_iu->mad.adapter_info.common.status) { if (evt_struct->xfer_iu->mad.adapter_info.common.status) {
printk("ibmvscsi: error %d getting adapter info\n", dev_err(hostdata->dev, "error %d getting adapter info\n",
evt_struct->xfer_iu->mad.adapter_info.common.status); evt_struct->xfer_iu->mad.adapter_info.common.status);
} else { } else {
printk("ibmvscsi: host srp version: %s, " dev_info(hostdata->dev, "host srp version: %s, "
"host partition %s (%d), OS %d, max io %u\n", "host partition %s (%d), OS %d, max io %u\n",
hostdata->madapter_info.srp_version, hostdata->madapter_info.srp_version,
hostdata->madapter_info.partition_name, hostdata->madapter_info.partition_name,
hostdata->madapter_info.partition_number, hostdata->madapter_info.partition_number,
hostdata->madapter_info.os_type, hostdata->madapter_info.os_type,
hostdata->madapter_info.port_max_txu[0]); hostdata->madapter_info.port_max_txu[0]);
if (hostdata->madapter_info.port_max_txu[0]) if (hostdata->madapter_info.port_max_txu[0])
hostdata->host->max_sectors = hostdata->host->max_sectors =
...@@ -754,11 +748,10 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) ...@@ -754,11 +748,10 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct)
if (hostdata->madapter_info.os_type == 3 && if (hostdata->madapter_info.os_type == 3 &&
strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) {
printk("ibmvscsi: host (Ver. %s) doesn't support large" dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n",
"transfers\n", hostdata->madapter_info.srp_version);
hostdata->madapter_info.srp_version); dev_err(hostdata->dev, "limiting scatterlists to %d\n",
printk("ibmvscsi: limiting scatterlists to %d\n", MAX_INDIRECT_BUFS);
MAX_INDIRECT_BUFS);
hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS;
} }
} }
...@@ -781,8 +774,8 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) ...@@ -781,8 +774,8 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata)
evt_struct = get_event_struct(&hostdata->pool); evt_struct = get_event_struct(&hostdata->pool);
if (!evt_struct) { if (!evt_struct) {
printk(KERN_ERR "ibmvscsi: couldn't allocate an event " dev_err(hostdata->dev,
"for ADAPTER_INFO_REQ!\n"); "couldn't allocate an event for ADAPTER_INFO_REQ!\n");
return; return;
} }
...@@ -802,15 +795,13 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) ...@@ -802,15 +795,13 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata)
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (dma_mapping_error(req->buffer)) { if (dma_mapping_error(req->buffer)) {
printk(KERN_ERR dev_err(hostdata->dev, "Unable to map request_buffer for adapter_info!\n");
"ibmvscsi: Unable to map request_buffer "
"for adapter_info!\n");
free_event_struct(&hostdata->pool, evt_struct); free_event_struct(&hostdata->pool, evt_struct);
return; return;
} }
if (ibmvscsi_send_srp_event(evt_struct, hostdata)) { if (ibmvscsi_send_srp_event(evt_struct, hostdata)) {
printk(KERN_ERR "ibmvscsi: couldn't send ADAPTER_INFO_REQ!\n"); dev_err(hostdata->dev, "couldn't send ADAPTER_INFO_REQ!\n");
dma_unmap_single(hostdata->dev, dma_unmap_single(hostdata->dev,
addr, addr,
sizeof(hostdata->madapter_info), sizeof(hostdata->madapter_info),
...@@ -832,24 +823,23 @@ static void login_rsp(struct srp_event_struct *evt_struct) ...@@ -832,24 +823,23 @@ static void login_rsp(struct srp_event_struct *evt_struct)
case SRP_LOGIN_RSP: /* it worked! */ case SRP_LOGIN_RSP: /* it worked! */
break; break;
case SRP_LOGIN_REJ: /* refused! */ case SRP_LOGIN_REJ: /* refused! */
printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REJ reason %u\n", dev_info(hostdata->dev, "SRP_LOGIN_REJ reason %u\n",
evt_struct->xfer_iu->srp.login_rej.reason); evt_struct->xfer_iu->srp.login_rej.reason);
/* Login failed. */ /* Login failed. */
atomic_set(&hostdata->request_limit, -1); atomic_set(&hostdata->request_limit, -1);
return; return;
default: default:
printk(KERN_ERR dev_err(hostdata->dev, "Invalid login response typecode 0x%02x!\n",
"ibmvscsi: Invalid login response typecode 0x%02x!\n", evt_struct->xfer_iu->srp.login_rsp.opcode);
evt_struct->xfer_iu->srp.login_rsp.opcode);
/* Login failed. */ /* Login failed. */
atomic_set(&hostdata->request_limit, -1); atomic_set(&hostdata->request_limit, -1);
return; return;
} }
printk(KERN_INFO "ibmvscsi: SRP_LOGIN succeeded\n"); dev_info(hostdata->dev, "SRP_LOGIN succeeded\n");
if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0) if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0)
printk(KERN_ERR "ibmvscsi: Invalid request_limit.\n"); dev_err(hostdata->dev, "Invalid request_limit.\n");
/* Now we know what the real request-limit is. /* Now we know what the real request-limit is.
* This value is set rather than added to request_limit because * This value is set rather than added to request_limit because
...@@ -878,8 +868,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata) ...@@ -878,8 +868,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata)
struct srp_login_req *login; struct srp_login_req *login;
struct srp_event_struct *evt_struct = get_event_struct(&hostdata->pool); struct srp_event_struct *evt_struct = get_event_struct(&hostdata->pool);
if (!evt_struct) { if (!evt_struct) {
printk(KERN_ERR dev_err(hostdata->dev, "couldn't allocate an event for login req!\n");
"ibmvscsi: couldn't allocate an event for login req!\n");
return FAILED; return FAILED;
} }
...@@ -902,7 +891,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata) ...@@ -902,7 +891,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata)
rc = ibmvscsi_send_srp_event(evt_struct, hostdata); rc = ibmvscsi_send_srp_event(evt_struct, hostdata);
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
printk("ibmvscsic: sent SRP login\n"); dev_info(hostdata->dev, "sent SRP login\n");
return rc; return rc;
}; };
...@@ -957,7 +946,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) ...@@ -957,7 +946,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
evt = get_event_struct(&hostdata->pool); evt = get_event_struct(&hostdata->pool);
if (evt == NULL) { if (evt == NULL) {
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
printk(KERN_ERR "ibmvscsi: failed to allocate abort event\n"); sdev_printk(KERN_ERR, cmd->device, "failed to allocate abort event\n");
return FAILED; return FAILED;
} }
...@@ -975,15 +964,16 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) ...@@ -975,15 +964,16 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK; tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;
tsk_mgmt->task_tag = (u64) found_evt; tsk_mgmt->task_tag = (u64) found_evt;
printk(KERN_INFO "ibmvscsi: aborting command. lun 0x%lx, tag 0x%lx\n", sdev_printk(KERN_INFO, cmd->device, "aborting command. lun 0x%lx, tag 0x%lx\n",
tsk_mgmt->lun, tsk_mgmt->task_tag); tsk_mgmt->lun, tsk_mgmt->task_tag);
evt->sync_srp = &srp_rsp; evt->sync_srp = &srp_rsp;
init_completion(&evt->comp); init_completion(&evt->comp);
rsp_rc = ibmvscsi_send_srp_event(evt, hostdata); rsp_rc = ibmvscsi_send_srp_event(evt, hostdata);
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
if (rsp_rc != 0) { if (rsp_rc != 0) {
printk(KERN_ERR "ibmvscsi: failed to send abort() event\n"); sdev_printk(KERN_ERR, cmd->device,
"failed to send abort() event. rc=%d\n", rsp_rc);
return FAILED; return FAILED;
} }
...@@ -992,9 +982,8 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) ...@@ -992,9 +982,8 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
/* make sure we got a good response */ /* make sure we got a good response */
if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) { if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING sdev_printk(KERN_WARNING, cmd->device, "abort bad SRP RSP type %d\n",
"ibmvscsi: abort bad SRP RSP type %d\n", srp_rsp.srp.rsp.opcode);
srp_rsp.srp.rsp.opcode);
return FAILED; return FAILED;
} }
...@@ -1005,10 +994,9 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) ...@@ -1005,10 +994,9 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
if (rsp_rc) { if (rsp_rc) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING sdev_printk(KERN_WARNING, cmd->device,
"ibmvscsi: abort code %d for task tag 0x%lx\n", "abort code %d for task tag 0x%lx\n",
rsp_rc, rsp_rc, tsk_mgmt->task_tag);
tsk_mgmt->task_tag);
return FAILED; return FAILED;
} }
...@@ -1027,15 +1015,13 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) ...@@ -1027,15 +1015,13 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
if (found_evt == NULL) { if (found_evt == NULL) {
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
printk(KERN_INFO sdev_printk(KERN_INFO, cmd->device, "aborted task tag 0x%lx completed\n",
"ibmvscsi: aborted task tag 0x%lx completed\n", tsk_mgmt->task_tag);
tsk_mgmt->task_tag);
return SUCCESS; return SUCCESS;
} }
printk(KERN_INFO sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%lx\n",
"ibmvscsi: successfully aborted task tag 0x%lx\n", tsk_mgmt->task_tag);
tsk_mgmt->task_tag);
cmd->result = (DID_ABORT << 16); cmd->result = (DID_ABORT << 16);
list_del(&found_evt->list); list_del(&found_evt->list);
...@@ -1069,7 +1055,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) ...@@ -1069,7 +1055,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
evt = get_event_struct(&hostdata->pool); evt = get_event_struct(&hostdata->pool);
if (evt == NULL) { if (evt == NULL) {
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
printk(KERN_ERR "ibmvscsi: failed to allocate reset event\n"); sdev_printk(KERN_ERR, cmd->device, "failed to allocate reset event\n");
return FAILED; return FAILED;
} }
...@@ -1086,15 +1072,16 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) ...@@ -1086,15 +1072,16 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
tsk_mgmt->lun = ((u64) lun) << 48; tsk_mgmt->lun = ((u64) lun) << 48;
tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET; tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;
printk(KERN_INFO "ibmvscsi: resetting device. lun 0x%lx\n", sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n",
tsk_mgmt->lun); tsk_mgmt->lun);
evt->sync_srp = &srp_rsp; evt->sync_srp = &srp_rsp;
init_completion(&evt->comp); init_completion(&evt->comp);
rsp_rc = ibmvscsi_send_srp_event(evt, hostdata); rsp_rc = ibmvscsi_send_srp_event(evt, hostdata);
spin_unlock_irqrestore(hostdata->host->host_lock, flags); spin_unlock_irqrestore(hostdata->host->host_lock, flags);
if (rsp_rc != 0) { if (rsp_rc != 0) {
printk(KERN_ERR "ibmvscsi: failed to send reset event\n"); sdev_printk(KERN_ERR, cmd->device,
"failed to send reset event. rc=%d\n", rsp_rc);
return FAILED; return FAILED;
} }
...@@ -1103,9 +1090,8 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) ...@@ -1103,9 +1090,8 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
/* make sure we got a good response */ /* make sure we got a good response */
if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) { if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING sdev_printk(KERN_WARNING, cmd->device, "reset bad SRP RSP type %d\n",
"ibmvscsi: reset bad SRP RSP type %d\n", srp_rsp.srp.rsp.opcode);
srp_rsp.srp.rsp.opcode);
return FAILED; return FAILED;
} }
...@@ -1116,9 +1102,9 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) ...@@ -1116,9 +1102,9 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
if (rsp_rc) { if (rsp_rc) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_WARNING sdev_printk(KERN_WARNING, cmd->device,
"ibmvscsi: reset code %d for task tag 0x%lx\n", "reset code %d for task tag 0x%lx\n",
rsp_rc, tsk_mgmt->task_tag); rsp_rc, tsk_mgmt->task_tag);
return FAILED; return FAILED;
} }
...@@ -1184,6 +1170,7 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code) ...@@ -1184,6 +1170,7 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
void ibmvscsi_handle_crq(struct viosrp_crq *crq, void ibmvscsi_handle_crq(struct viosrp_crq *crq,
struct ibmvscsi_host_data *hostdata) struct ibmvscsi_host_data *hostdata)
{ {
long rc;
unsigned long flags; unsigned long flags;
struct srp_event_struct *evt_struct = struct srp_event_struct *evt_struct =
(struct srp_event_struct *)crq->IU_data_ptr; (struct srp_event_struct *)crq->IU_data_ptr;
...@@ -1191,27 +1178,25 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1191,27 +1178,25 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
case 0xC0: /* initialization */ case 0xC0: /* initialization */
switch (crq->format) { switch (crq->format) {
case 0x01: /* Initialization message */ case 0x01: /* Initialization message */
printk(KERN_INFO "ibmvscsi: partner initialized\n"); dev_info(hostdata->dev, "partner initialized\n");
/* Send back a response */ /* Send back a response */
if (ibmvscsi_send_crq(hostdata, if ((rc = ibmvscsi_send_crq(hostdata,
0xC002000000000000LL, 0) == 0) { 0xC002000000000000LL, 0)) == 0) {
/* Now login */ /* Now login */
send_srp_login(hostdata); send_srp_login(hostdata);
} else { } else {
printk(KERN_ERR dev_err(hostdata->dev, "Unable to send init rsp. rc=%ld\n", rc);
"ibmvscsi: Unable to send init rsp\n");
} }
break; break;
case 0x02: /* Initialization response */ case 0x02: /* Initialization response */
printk(KERN_INFO dev_info(hostdata->dev, "partner initialization complete\n");
"ibmvscsi: partner initialization complete\n");
/* Now login */ /* Now login */
send_srp_login(hostdata); send_srp_login(hostdata);
break; break;
default: default:
printk(KERN_ERR "ibmvscsi: unknown crq message type\n"); dev_err(hostdata->dev, "unknown crq message type: %d\n", crq->format);
} }
return; return;
case 0xFF: /* Hypervisor telling us the connection is closed */ case 0xFF: /* Hypervisor telling us the connection is closed */
...@@ -1219,8 +1204,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1219,8 +1204,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
atomic_set(&hostdata->request_limit, 0); atomic_set(&hostdata->request_limit, 0);
if (crq->format == 0x06) { if (crq->format == 0x06) {
/* We need to re-setup the interpartition connection */ /* We need to re-setup the interpartition connection */
printk(KERN_INFO dev_info(hostdata->dev, "Re-enabling adapter!\n");
"ibmvscsi: Re-enabling adapter!\n");
purge_requests(hostdata, DID_REQUEUE); purge_requests(hostdata, DID_REQUEUE);
if ((ibmvscsi_reenable_crq_queue(&hostdata->queue, if ((ibmvscsi_reenable_crq_queue(&hostdata->queue,
hostdata)) || hostdata)) ||
...@@ -1228,14 +1212,11 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1228,14 +1212,11 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
0xC001000000000000LL, 0))) { 0xC001000000000000LL, 0))) {
atomic_set(&hostdata->request_limit, atomic_set(&hostdata->request_limit,
-1); -1);
printk(KERN_ERR dev_err(hostdata->dev, "error after enable\n");
"ibmvscsi: error after"
" enable\n");
} }
} else { } else {
printk(KERN_INFO dev_err(hostdata->dev, "Virtual adapter failed rc %d!\n",
"ibmvscsi: Virtual adapter failed rc %d!\n", crq->format);
crq->format);
purge_requests(hostdata, DID_ERROR); purge_requests(hostdata, DID_ERROR);
if ((ibmvscsi_reset_crq_queue(&hostdata->queue, if ((ibmvscsi_reset_crq_queue(&hostdata->queue,
...@@ -1244,8 +1225,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1244,8 +1225,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
0xC001000000000000LL, 0))) { 0xC001000000000000LL, 0))) {
atomic_set(&hostdata->request_limit, atomic_set(&hostdata->request_limit,
-1); -1);
printk(KERN_ERR dev_err(hostdata->dev, "error after reset\n");
"ibmvscsi: error after reset\n");
} }
} }
scsi_unblock_requests(hostdata->host); scsi_unblock_requests(hostdata->host);
...@@ -1253,9 +1233,8 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1253,9 +1233,8 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
case 0x80: /* real payload */ case 0x80: /* real payload */
break; break;
default: default:
printk(KERN_ERR dev_err(hostdata->dev, "got an invalid message type 0x%02x\n",
"ibmvscsi: got an invalid message type 0x%02x\n", crq->valid);
crq->valid);
return; return;
} }
...@@ -1264,16 +1243,14 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1264,16 +1243,14 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
* actually sent * actually sent
*/ */
if (!valid_event_struct(&hostdata->pool, evt_struct)) { if (!valid_event_struct(&hostdata->pool, evt_struct)) {
printk(KERN_ERR dev_err(hostdata->dev, "returned correlation_token 0x%p is invalid!\n",
"ibmvscsi: returned correlation_token 0x%p is invalid!\n",
(void *)crq->IU_data_ptr); (void *)crq->IU_data_ptr);
return; return;
} }
if (atomic_read(&evt_struct->free)) { if (atomic_read(&evt_struct->free)) {
printk(KERN_ERR dev_err(hostdata->dev, "received duplicate correlation_token 0x%p!\n",
"ibmvscsi: received duplicate correlation_token 0x%p!\n", (void *)crq->IU_data_ptr);
(void *)crq->IU_data_ptr);
return; return;
} }
...@@ -1284,8 +1261,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq, ...@@ -1284,8 +1261,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
if (evt_struct->done) if (evt_struct->done)
evt_struct->done(evt_struct); evt_struct->done(evt_struct);
else else
printk(KERN_ERR dev_err(hostdata->dev, "returned done() is NULL; not running it!\n");
"ibmvscsi: returned done() is NULL; not running it!\n");
/* /*
* Lock the host_lock before messing with these structures, since we * Lock the host_lock before messing with these structures, since we
...@@ -1311,8 +1287,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, ...@@ -1311,8 +1287,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata,
evt_struct = get_event_struct(&hostdata->pool); evt_struct = get_event_struct(&hostdata->pool);
if (!evt_struct) { if (!evt_struct) {
printk(KERN_ERR dev_err(hostdata->dev, "couldn't allocate event for HOST_CONFIG!\n");
"ibmvscsi: could't allocate event for HOST_CONFIG!\n");
return -1; return -1;
} }
...@@ -1332,8 +1307,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, ...@@ -1332,8 +1307,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
if (dma_mapping_error(host_config->buffer)) { if (dma_mapping_error(host_config->buffer)) {
printk(KERN_ERR dev_err(hostdata->dev, "dma_mapping error getting host config\n");
"ibmvscsi: dma_mapping error " "getting host config\n");
free_event_struct(&hostdata->pool, evt_struct); free_event_struct(&hostdata->pool, evt_struct);
return -1; return -1;
} }
...@@ -1556,7 +1530,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) ...@@ -1556,7 +1530,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
driver_template.can_queue = max_requests; driver_template.can_queue = max_requests;
host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); host = scsi_host_alloc(&driver_template, sizeof(*hostdata));
if (!host) { if (!host) {
printk(KERN_ERR "ibmvscsi: couldn't allocate host data\n"); dev_err(&vdev->dev, "couldn't allocate host data\n");
goto scsi_host_alloc_failed; goto scsi_host_alloc_failed;
} }
...@@ -1570,11 +1544,11 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id) ...@@ -1570,11 +1544,11 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_requests); rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_requests);
if (rc != 0 && rc != H_RESOURCE) { if (rc != 0 && rc != H_RESOURCE) {
printk(KERN_ERR "ibmvscsi: couldn't initialize crq\n"); dev_err(&vdev->dev, "couldn't initialize crq. rc=%d\n", rc);
goto init_crq_failed; goto init_crq_failed;
} }
if (initialize_event_pool(&hostdata->pool, max_requests, hostdata) != 0) { if (initialize_event_pool(&hostdata->pool, max_requests, hostdata) != 0) {
printk(KERN_ERR "ibmvscsi: couldn't initialize event pool\n"); dev_err(&vdev->dev, "couldn't initialize event pool\n");
goto init_pool_failed; goto init_pool_failed;
} }
......
...@@ -177,7 +177,7 @@ static void set_adapter_info(struct ibmvscsi_host_data *hostdata) ...@@ -177,7 +177,7 @@ static void set_adapter_info(struct ibmvscsi_host_data *hostdata)
memset(&hostdata->madapter_info, 0x00, memset(&hostdata->madapter_info, 0x00,
sizeof(hostdata->madapter_info)); sizeof(hostdata->madapter_info));
printk(KERN_INFO "rpa_vscsi: SPR_VERSION: %s\n", SRP_VERSION); dev_info(hostdata->dev, "SRP_VERSION: %s\n", SRP_VERSION);
strcpy(hostdata->madapter_info.srp_version, SRP_VERSION); strcpy(hostdata->madapter_info.srp_version, SRP_VERSION);
strncpy(hostdata->madapter_info.partition_name, partition_name, strncpy(hostdata->madapter_info.partition_name, partition_name,
...@@ -232,25 +232,24 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue, ...@@ -232,25 +232,24 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
if (rc == 2) { if (rc == 2) {
/* Adapter is good, but other end is not ready */ /* Adapter is good, but other end is not ready */
printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n"); dev_warn(hostdata->dev, "Partner adapter not ready\n");
retrc = 0; retrc = 0;
} else if (rc != 0) { } else if (rc != 0) {
printk(KERN_WARNING "ibmvscsi: Error %d opening adapter\n", rc); dev_warn(hostdata->dev, "Error %d opening adapter\n", rc);
goto reg_crq_failed; goto reg_crq_failed;
} }
if (request_irq(vdev->irq, if (request_irq(vdev->irq,
ibmvscsi_handle_event, ibmvscsi_handle_event,
0, "ibmvscsi", (void *)hostdata) != 0) { 0, "ibmvscsi", (void *)hostdata) != 0) {
printk(KERN_ERR "ibmvscsi: couldn't register irq 0x%x\n", dev_err(hostdata->dev, "couldn't register irq 0x%x\n",
vdev->irq); vdev->irq);
goto req_irq_failed; goto req_irq_failed;
} }
rc = vio_enable_interrupts(vdev); rc = vio_enable_interrupts(vdev);
if (rc != 0) { if (rc != 0) {
printk(KERN_ERR "ibmvscsi: Error %d enabling interrupts!!!\n", dev_err(hostdata->dev, "Error %d enabling interrupts!!!\n", rc);
rc);
goto req_irq_failed; goto req_irq_failed;
} }
...@@ -294,7 +293,7 @@ int ibmvscsi_reenable_crq_queue(struct crq_queue *queue, ...@@ -294,7 +293,7 @@ int ibmvscsi_reenable_crq_queue(struct crq_queue *queue,
} while ((rc == H_IN_PROGRESS) || (rc == H_BUSY) || (H_IS_LONG_BUSY(rc))); } while ((rc == H_IN_PROGRESS) || (rc == H_BUSY) || (H_IS_LONG_BUSY(rc)));
if (rc) if (rc)
printk(KERN_ERR "ibmvscsi: Error %d enabling adapter\n", rc); dev_err(hostdata->dev, "Error %d enabling adapter\n", rc);
return rc; return rc;
} }
...@@ -327,10 +326,9 @@ int ibmvscsi_reset_crq_queue(struct crq_queue *queue, ...@@ -327,10 +326,9 @@ int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
queue->msg_token, PAGE_SIZE); queue->msg_token, PAGE_SIZE);
if (rc == 2) { if (rc == 2) {
/* Adapter is good, but other end is not ready */ /* Adapter is good, but other end is not ready */
printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n"); dev_warn(hostdata->dev, "Partner adapter not ready\n");
} else if (rc != 0) { } else if (rc != 0) {
printk(KERN_WARNING dev_warn(hostdata->dev, "couldn't register crq--rc 0x%x\n", rc);
"ibmvscsi: couldn't register crq--rc 0x%x\n", rc);
} }
return rc; return rc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment