提交 9122e991 编写于 作者: J Jitendra Bhivare 提交者: Martin K. Petersen

scsi: be2iscsi: Fix checks for HBA in error state

Save ue_detected and fw_timeout errors in state field of beiscsi_hba.
BEISCSI_HBA_RUNNING
BEISCSI_HBA_LINK_UP
BEISCSI_HBA_BOOT_FOUND
BEISCSI_HBA_PCI_ERR
BEISCSI_HBA_FW_TIMEOUT
BEISCSI_HBA_IN_UE

Make sure no PCI transaction happens once in error state.
Add checks in IO path to detect HBA in error.

Skip hwi_purge_eq step which can't be done in error state.
Signed-off-by: NJitendra Bhivare <jitendra.bhivare@broadcom.com>
Reviewed-by: NHannes Reinecke <hare@suse.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 a3095016
...@@ -152,8 +152,11 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba, ...@@ -152,8 +152,11 @@ int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
struct be_cmd_resp_hdr *mbx_resp_hdr; struct be_cmd_resp_hdr *mbx_resp_hdr;
struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
if (beiscsi_error(phba)) if (beiscsi_hba_in_error(phba)) {
return -EPERM; clear_bit(MCC_TAG_STATE_RUNNING,
&phba->ctrl.ptag_state[tag].tag_state);
return -EIO;
}
/* wait for the mccq completion */ /* wait for the mccq completion */
rc = wait_event_interruptible_timeout( rc = wait_event_interruptible_timeout(
...@@ -315,13 +318,16 @@ static void beiscsi_process_async_link(struct beiscsi_hba *phba, ...@@ -315,13 +318,16 @@ static void beiscsi_process_async_link(struct beiscsi_hba *phba,
* This has been newly introduced in SKH-R Firmware 10.0.338.45. * This has been newly introduced in SKH-R Firmware 10.0.338.45.
**/ **/
if (evt->port_link_status & BE_ASYNC_LINK_UP_MASK) { if (evt->port_link_status & BE_ASYNC_LINK_UP_MASK) {
phba->state = BE_ADAPTER_LINK_UP | BE_ADAPTER_CHECK_BOOT;
phba->get_boot = BE_GET_BOOT_RETRIES; phba->get_boot = BE_GET_BOOT_RETRIES;
/* first this needs to be visible to worker thread */
wmb();
set_bit(BEISCSI_HBA_LINK_UP | BEISCSI_HBA_BOOT_FOUND,
&phba->state);
__beiscsi_log(phba, KERN_ERR, __beiscsi_log(phba, KERN_ERR,
"BC_%d : Link Up on Port %d tag 0x%x\n", "BC_%d : Link Up on Port %d tag 0x%x\n",
evt->physical_port, evt->event_tag); evt->physical_port, evt->event_tag);
} else { } else {
phba->state = BE_ADAPTER_LINK_DOWN; clear_bit(BEISCSI_HBA_LINK_UP, &phba->state);
__beiscsi_log(phba, KERN_ERR, __beiscsi_log(phba, KERN_ERR,
"BC_%d : Link Down on Port %d tag 0x%x\n", "BC_%d : Link Down on Port %d tag 0x%x\n",
evt->physical_port, evt->event_tag); evt->physical_port, evt->event_tag);
...@@ -406,8 +412,10 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba, ...@@ -406,8 +412,10 @@ void beiscsi_process_async_event(struct beiscsi_hba *phba,
beiscsi_process_async_link(phba, compl); beiscsi_process_async_link(phba, compl);
break; break;
case ASYNC_EVENT_CODE_ISCSI: case ASYNC_EVENT_CODE_ISCSI:
phba->state |= BE_ADAPTER_CHECK_BOOT;
phba->get_boot = BE_GET_BOOT_RETRIES; phba->get_boot = BE_GET_BOOT_RETRIES;
/* first this needs to be visible to worker thread */
wmb();
set_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state);
sev = KERN_ERR; sev = KERN_ERR;
break; break;
case ASYNC_EVENT_CODE_SLI: case ASYNC_EVENT_CODE_SLI:
...@@ -504,7 +512,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag) ...@@ -504,7 +512,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag)
return 0; return 0;
} }
for (i = 0; i < mcc_timeout; i++) { for (i = 0; i < mcc_timeout; i++) {
if (beiscsi_error(phba)) if (beiscsi_hba_in_error(phba))
return -EIO; return -EIO;
beiscsi_process_mcc_cq(phba); beiscsi_process_mcc_cq(phba);
...@@ -522,7 +530,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag) ...@@ -522,7 +530,7 @@ int be_mcc_compl_poll(struct beiscsi_hba *phba, unsigned int tag)
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : FW Timed Out\n"); "BC_%d : FW Timed Out\n");
phba->fw_timeout = true; set_bit(BEISCSI_HBA_FW_TIMEOUT, &phba->state);
beiscsi_ue_detect(phba); beiscsi_ue_detect(phba);
return -EBUSY; return -EBUSY;
} }
...@@ -566,7 +574,7 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl) ...@@ -566,7 +574,7 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
*/ */
timeout = jiffies + msecs_to_jiffies(BEISCSI_MBX_RDY_BIT_TIMEOUT); timeout = jiffies + msecs_to_jiffies(BEISCSI_MBX_RDY_BIT_TIMEOUT);
do { do {
if (beiscsi_error(phba)) if (beiscsi_hba_in_error(phba))
return -EIO; return -EIO;
ready = ioread32(db); ready = ioread32(db);
...@@ -586,10 +594,8 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl) ...@@ -586,10 +594,8 @@ static int be_mbox_db_ready_poll(struct be_ctrl_info *ctrl)
beiscsi_log(phba, KERN_ERR, beiscsi_log(phba, KERN_ERR,
BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BC_%d : FW Timed Out\n"); "BC_%d : FW Timed Out\n");
set_bit(BEISCSI_HBA_FW_TIMEOUT, &phba->state);
phba->fw_timeout = true;
beiscsi_ue_detect(phba); beiscsi_ue_detect(phba);
return -EBUSY; return -EBUSY;
} }
......
...@@ -52,22 +52,20 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, ...@@ -52,22 +52,20 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep,
if (!ep) { if (!ep) {
printk(KERN_ERR pr_err("beiscsi_session_create: invalid ep\n");
"beiscsi_session_create: invalid ep\n");
return NULL; return NULL;
} }
beiscsi_ep = ep->dd_data; beiscsi_ep = ep->dd_data;
phba = beiscsi_ep->phba; phba = beiscsi_ep->phba;
if (phba->state & BE_ADAPTER_PCI_ERR) { if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : PCI_ERROR Recovery\n");
return NULL;
} else {
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_session_create\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
return NULL;
} }
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_session_create\n");
if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Cannot handle %d cmds." "BS_%d : Cannot handle %d cmds."
...@@ -436,9 +434,9 @@ int beiscsi_iface_set_param(struct Scsi_Host *shost, ...@@ -436,9 +434,9 @@ int beiscsi_iface_set_param(struct Scsi_Host *shost,
uint32_t rm_len = dt_len; uint32_t rm_len = dt_len;
int ret; int ret;
if (phba->state & BE_ADAPTER_PCI_ERR) { if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
return -EBUSY; return -EBUSY;
} }
...@@ -579,9 +577,9 @@ int beiscsi_iface_get_param(struct iscsi_iface *iface, ...@@ -579,9 +577,9 @@ int beiscsi_iface_get_param(struct iscsi_iface *iface,
if (param_type != ISCSI_NET_PARAM) if (param_type != ISCSI_NET_PARAM)
return 0; return 0;
if (phba->state & BE_ADAPTER_PCI_ERR) { if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
return -EBUSY; return -EBUSY;
} }
...@@ -737,7 +735,7 @@ static void beiscsi_get_port_state(struct Scsi_Host *shost) ...@@ -737,7 +735,7 @@ static void beiscsi_get_port_state(struct Scsi_Host *shost)
struct beiscsi_hba *phba = iscsi_host_priv(shost); struct beiscsi_hba *phba = iscsi_host_priv(shost);
struct iscsi_cls_host *ihost = shost->shost_data; struct iscsi_cls_host *ihost = shost->shost_data;
ihost->port_state = (phba->state & BE_ADAPTER_LINK_UP) ? ihost->port_state = test_bit(BEISCSI_HBA_LINK_UP, &phba->state) ?
ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN; ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN;
} }
...@@ -789,16 +787,13 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, ...@@ -789,16 +787,13 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
struct beiscsi_hba *phba = iscsi_host_priv(shost); struct beiscsi_hba *phba = iscsi_host_priv(shost);
int status = 0; int status = 0;
if (beiscsi_hba_in_error(phba)) {
if (phba->state & BE_ADAPTER_PCI_ERR) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n");
return -EBUSY;
} else {
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_get_host_param," "BS_%d : HBA in error 0x%lx\n", phba->state);
" param = %d\n", param); return -EBUSY;
} }
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_get_host_param, param = %d\n", param);
switch (param) { switch (param) {
case ISCSI_HOST_PARAM_HWADDRESS: case ISCSI_HOST_PARAM_HWADDRESS:
...@@ -940,15 +935,13 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) ...@@ -940,15 +935,13 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn)
phba = ((struct beiscsi_conn *)conn->dd_data)->phba; phba = ((struct beiscsi_conn *)conn->dd_data)->phba;
if (phba->state & BE_ADAPTER_PCI_ERR) { if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
return -EBUSY; return -EBUSY;
} else {
beiscsi_log(beiscsi_conn->phba, KERN_INFO,
BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_conn_start\n");
} }
beiscsi_log(beiscsi_conn->phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_conn_start\n");
memset(&params, 0, sizeof(struct beiscsi_offload_params)); memset(&params, 0, sizeof(struct beiscsi_offload_params));
beiscsi_ep = beiscsi_conn->ep; beiscsi_ep = beiscsi_conn->ep;
...@@ -1165,28 +1158,20 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, ...@@ -1165,28 +1158,20 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
struct iscsi_endpoint *ep; struct iscsi_endpoint *ep;
int ret; int ret;
if (shost) if (!shost) {
phba = iscsi_host_priv(shost);
else {
ret = -ENXIO; ret = -ENXIO;
printk(KERN_ERR pr_err("beiscsi_ep_connect shost is NULL\n");
"beiscsi_ep_connect shost is NULL\n");
return ERR_PTR(ret); return ERR_PTR(ret);
} }
if (beiscsi_error(phba)) { phba = iscsi_host_priv(shost);
if (beiscsi_hba_in_error(phba)) {
ret = -EIO; ret = -EIO;
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : The FW state Not Stable!!!\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
if (!test_bit(BEISCSI_HBA_LINK_UP, &phba->state)) {
if (phba->state & BE_ADAPTER_PCI_ERR) {
ret = -EBUSY;
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : In PCI_ERROR Recovery\n");
return ERR_PTR(ret);
} else if (phba->state & BE_ADAPTER_LINK_DOWN) {
ret = -EBUSY; ret = -EBUSY;
beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
"BS_%d : The Adapter Port state is Down!!!\n"); "BS_%d : The Adapter Port state is Down!!!\n");
...@@ -1340,9 +1325,9 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) ...@@ -1340,9 +1325,9 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
tcp_upload_flag = CONNECTION_UPLOAD_ABORT; tcp_upload_flag = CONNECTION_UPLOAD_ABORT;
} }
if (phba->state & BE_ADAPTER_PCI_ERR) { if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : PCI_ERROR Recovery\n"); "BS_%d : HBA in error 0x%lx\n", phba->state);
goto free_ep; goto free_ep;
} }
......
...@@ -2017,6 +2017,9 @@ void beiscsi_process_mcc_cq(struct beiscsi_hba *phba) ...@@ -2017,6 +2017,9 @@ void beiscsi_process_mcc_cq(struct beiscsi_hba *phba)
mcc_compl = queue_tail_node(mcc_cq); mcc_compl = queue_tail_node(mcc_cq);
mcc_compl->flags = le32_to_cpu(mcc_compl->flags); mcc_compl->flags = le32_to_cpu(mcc_compl->flags);
while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) { while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) {
if (beiscsi_hba_in_error(phba))
return;
if (num_processed >= 32) { if (num_processed >= 32) {
hwi_ring_cq_db(phba, mcc_cq->id, hwi_ring_cq_db(phba, mcc_cq->id,
num_processed, 0); num_processed, 0);
...@@ -2048,7 +2051,8 @@ static void beiscsi_mcc_work(struct work_struct *work) ...@@ -2048,7 +2051,8 @@ static void beiscsi_mcc_work(struct work_struct *work)
phba = pbe_eq->phba; phba = pbe_eq->phba;
beiscsi_process_mcc_cq(phba); beiscsi_process_mcc_cq(phba);
/* rearm EQ for further interrupts */ /* rearm EQ for further interrupts */
hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); if (!beiscsi_hba_in_error(phba))
hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1);
} }
/** /**
...@@ -2079,6 +2083,9 @@ unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget) ...@@ -2079,6 +2083,9 @@ unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget)
while (sol->dw[offsetof(struct amap_sol_cqe, valid) / 32] & while (sol->dw[offsetof(struct amap_sol_cqe, valid) / 32] &
CQE_VALID_MASK) { CQE_VALID_MASK) {
if (beiscsi_hba_in_error(phba))
return 0;
be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); be_dws_le_to_cpu(sol, sizeof(struct sol_cqe));
code = (sol->dw[offsetof(struct amap_sol_cqe, code) / code = (sol->dw[offsetof(struct amap_sol_cqe, code) /
...@@ -2248,12 +2255,16 @@ static int be_iopoll(struct irq_poll *iop, int budget) ...@@ -2248,12 +2255,16 @@ static int be_iopoll(struct irq_poll *iop, int budget)
struct be_eq_entry *eqe = NULL; struct be_eq_entry *eqe = NULL;
struct be_queue_info *eq; struct be_queue_info *eq;
io_events = 0;
pbe_eq = container_of(iop, struct be_eq_obj, iopoll); pbe_eq = container_of(iop, struct be_eq_obj, iopoll);
phba = pbe_eq->phba; phba = pbe_eq->phba;
if (beiscsi_hba_in_error(phba)) {
irq_poll_complete(iop);
return 0;
}
io_events = 0;
eq = &pbe_eq->q; eq = &pbe_eq->q;
eqe = queue_tail_node(eq); eqe = queue_tail_node(eq);
while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] & while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] &
EQE_VALID_MASK) { EQE_VALID_MASK) {
AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
...@@ -2261,7 +2272,6 @@ static int be_iopoll(struct irq_poll *iop, int budget) ...@@ -2261,7 +2272,6 @@ static int be_iopoll(struct irq_poll *iop, int budget)
eqe = queue_tail_node(eq); eqe = queue_tail_node(eq);
io_events++; io_events++;
} }
hwi_ring_eq_db(phba, eq->id, 1, io_events, 0, 1); hwi_ring_eq_db(phba, eq->id, 1, io_events, 0, 1);
ret = beiscsi_process_cq(pbe_eq, budget); ret = beiscsi_process_cq(pbe_eq, budget);
...@@ -2272,7 +2282,8 @@ static int be_iopoll(struct irq_poll *iop, int budget) ...@@ -2272,7 +2282,8 @@ static int be_iopoll(struct irq_poll *iop, int budget)
BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
"BM_%d : rearm pbe_eq->q.id =%d ret %d\n", "BM_%d : rearm pbe_eq->q.id =%d ret %d\n",
pbe_eq->q.id, ret); pbe_eq->q.id, ret);
hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); if (!beiscsi_hba_in_error(phba))
hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1);
} }
return ret; return ret;
} }
...@@ -4633,7 +4644,8 @@ static void beiscsi_cleanup_task(struct iscsi_task *task) ...@@ -4633,7 +4644,8 @@ static void beiscsi_cleanup_task(struct iscsi_task *task)
} }
if (io_task->scsi_cmnd) { if (io_task->scsi_cmnd) {
scsi_dma_unmap(io_task->scsi_cmnd); if (io_task->num_sg)
scsi_dma_unmap(io_task->scsi_cmnd);
io_task->scsi_cmnd = NULL; io_task->scsi_cmnd = NULL;
} }
} else { } else {
...@@ -5112,6 +5124,15 @@ static int beiscsi_task_xmit(struct iscsi_task *task) ...@@ -5112,6 +5124,15 @@ static int beiscsi_task_xmit(struct iscsi_task *task)
int num_sg; int num_sg;
unsigned int writedir = 0, xferlen = 0; unsigned int writedir = 0, xferlen = 0;
phba = io_task->conn->phba;
/**
* HBA in error includes BEISCSI_HBA_FW_TIMEOUT. IO path might be
* operational if FW still gets heartbeat from EP FW. Is management
* path really needed to continue further?
*/
if (beiscsi_hba_in_error(phba))
return -EIO;
if (!io_task->conn->login_in_progress) if (!io_task->conn->login_in_progress)
task->hdr->exp_statsn = 0; task->hdr->exp_statsn = 0;
...@@ -5119,8 +5140,8 @@ static int beiscsi_task_xmit(struct iscsi_task *task) ...@@ -5119,8 +5140,8 @@ static int beiscsi_task_xmit(struct iscsi_task *task)
return beiscsi_mtask(task); return beiscsi_mtask(task);
io_task->scsi_cmnd = sc; io_task->scsi_cmnd = sc;
io_task->num_sg = 0;
num_sg = scsi_dma_map(sc); num_sg = scsi_dma_map(sc);
phba = io_task->conn->phba;
if (num_sg < 0) { if (num_sg < 0) {
beiscsi_log(phba, KERN_ERR, beiscsi_log(phba, KERN_ERR,
BEISCSI_LOG_IO | BEISCSI_LOG_ISCSI, BEISCSI_LOG_IO | BEISCSI_LOG_ISCSI,
...@@ -5131,6 +5152,11 @@ static int beiscsi_task_xmit(struct iscsi_task *task) ...@@ -5131,6 +5152,11 @@ static int beiscsi_task_xmit(struct iscsi_task *task)
return num_sg; return num_sg;
} }
/**
* For scsi cmd task, check num_sg before unmapping in cleanup_task.
* For management task, cleanup_task checks mtask_addr before unmapping.
*/
io_task->num_sg = num_sg;
xferlen = scsi_bufflen(sc); xferlen = scsi_bufflen(sc);
sg = scsi_sglist(sc); sg = scsi_sglist(sc);
if (sc->sc_data_direction == DMA_TO_DEVICE) if (sc->sc_data_direction == DMA_TO_DEVICE)
...@@ -5160,6 +5186,12 @@ static int beiscsi_bsg_request(struct bsg_job *job) ...@@ -5160,6 +5186,12 @@ static int beiscsi_bsg_request(struct bsg_job *job)
shost = iscsi_job_to_shost(job); shost = iscsi_job_to_shost(job);
phba = iscsi_host_priv(shost); phba = iscsi_host_priv(shost);
if (beiscsi_hba_in_error(phba)) {
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BM_%d : HBA in error 0x%lx\n", phba->state);
return -ENXIO;
}
switch (bsg_req->msgcode) { switch (bsg_req->msgcode) {
case ISCSI_BSG_HST_VENDOR: case ISCSI_BSG_HST_VENDOR:
nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
...@@ -5233,12 +5265,10 @@ void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) ...@@ -5233,12 +5265,10 @@ void beiscsi_hba_attrs_init(struct beiscsi_hba *phba)
/* /*
* beiscsi_quiesce()- Cleanup Driver resources * beiscsi_quiesce()- Cleanup Driver resources
* @phba: Instance Priv structure * @phba: Instance Priv structure
* @unload_state:i Clean or EEH unload state
* *
* Free the OS and HW resources held by the driver * Free the OS and HW resources held by the driver
**/ **/
static void beiscsi_quiesce(struct beiscsi_hba *phba, static void beiscsi_quiesce(struct beiscsi_hba *phba)
uint32_t unload_state)
{ {
struct hwi_controller *phwi_ctrlr; struct hwi_controller *phwi_ctrlr;
struct hwi_context_memory *phwi_context; struct hwi_context_memory *phwi_context;
...@@ -5265,21 +5295,22 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba, ...@@ -5265,21 +5295,22 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba,
irq_poll_disable(&pbe_eq->iopoll); irq_poll_disable(&pbe_eq->iopoll);
} }
if (unload_state == BEISCSI_CLEAN_UNLOAD) { /* PCI_ERR is set then check if driver is not unloading */
destroy_workqueue(phba->wq); if (test_bit(BEISCSI_HBA_RUNNING, &phba->state) &&
beiscsi_clean_port(phba); test_bit(BEISCSI_HBA_PCI_ERR, &phba->state)) {
beiscsi_free_mem(phba);
beiscsi_unmap_pci_function(phba);
pci_free_consistent(phba->pcidev,
phba->ctrl.mbox_mem_alloced.size,
phba->ctrl.mbox_mem_alloced.va,
phba->ctrl.mbox_mem_alloced.dma);
} else {
hwi_purge_eq(phba);
hwi_cleanup(phba); hwi_cleanup(phba);
return;
} }
destroy_workqueue(phba->wq);
beiscsi_clean_port(phba);
beiscsi_free_mem(phba);
beiscsi_unmap_pci_function(phba);
pci_free_consistent(phba->pcidev,
phba->ctrl.mbox_mem_alloced.size,
phba->ctrl.mbox_mem_alloced.va,
phba->ctrl.mbox_mem_alloced.dma);
} }
static void beiscsi_remove(struct pci_dev *pcidev) static void beiscsi_remove(struct pci_dev *pcidev)
...@@ -5292,10 +5323,11 @@ static void beiscsi_remove(struct pci_dev *pcidev) ...@@ -5292,10 +5323,11 @@ static void beiscsi_remove(struct pci_dev *pcidev)
return; return;
} }
clear_bit(BEISCSI_HBA_RUNNING, &phba->state);
beiscsi_iface_destroy_default(phba); beiscsi_iface_destroy_default(phba);
iscsi_boot_destroy_kset(phba->boot_kset); iscsi_boot_destroy_kset(phba->boot_kset);
iscsi_host_remove(phba->shost); iscsi_host_remove(phba->shost);
beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD); beiscsi_quiesce(phba);
pci_dev_put(phba->pcidev); pci_dev_put(phba->pcidev);
iscsi_host_free(phba->shost); iscsi_host_free(phba->shost);
pci_disable_pcie_error_reporting(pcidev); pci_disable_pcie_error_reporting(pcidev);
...@@ -5331,6 +5363,9 @@ static void be_eqd_update(struct beiscsi_hba *phba) ...@@ -5331,6 +5363,9 @@ static void be_eqd_update(struct beiscsi_hba *phba)
u32 pps, delta; u32 pps, delta;
unsigned int tag; unsigned int tag;
if (beiscsi_hba_in_error(phba))
return;
phwi_ctrlr = phba->phwi_ctrlr; phwi_ctrlr = phba->phwi_ctrlr;
phwi_context = phwi_ctrlr->phwi_ctxt; phwi_context = phwi_ctrlr->phwi_ctxt;
...@@ -5372,6 +5407,9 @@ static void be_eqd_update(struct beiscsi_hba *phba) ...@@ -5372,6 +5407,9 @@ static void be_eqd_update(struct beiscsi_hba *phba)
static void be_check_boot_session(struct beiscsi_hba *phba) static void be_check_boot_session(struct beiscsi_hba *phba)
{ {
if (beiscsi_hba_in_error(phba))
return;
if (beiscsi_setup_boot_info(phba)) if (beiscsi_setup_boot_info(phba))
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : Could not set up " "BM_%d : Could not set up "
...@@ -5393,13 +5431,13 @@ beiscsi_hw_health_check(struct work_struct *work) ...@@ -5393,13 +5431,13 @@ beiscsi_hw_health_check(struct work_struct *work)
be_eqd_update(phba); be_eqd_update(phba);
if (phba->state & BE_ADAPTER_CHECK_BOOT) { if (test_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state)) {
if ((phba->get_boot > 0) && (!phba->boot_kset)) { if ((phba->get_boot > 0) && (!phba->boot_kset)) {
phba->get_boot--; phba->get_boot--;
if (!(phba->get_boot % BE_GET_BOOT_TO)) if (!(phba->get_boot % BE_GET_BOOT_TO))
be_check_boot_session(phba); be_check_boot_session(phba);
} else { } else {
phba->state &= ~BE_ADAPTER_CHECK_BOOT; clear_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state);
phba->get_boot = 0; phba->get_boot = 0;
} }
} }
...@@ -5417,12 +5455,12 @@ static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, ...@@ -5417,12 +5455,12 @@ static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev,
struct beiscsi_hba *phba = NULL; struct beiscsi_hba *phba = NULL;
phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); phba = (struct beiscsi_hba *)pci_get_drvdata(pdev);
phba->state |= BE_ADAPTER_PCI_ERR; set_bit(BEISCSI_HBA_PCI_ERR, &phba->state);
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : EEH error detected\n"); "BM_%d : EEH error detected\n");
beiscsi_quiesce(phba, BEISCSI_EEH_UNLOAD); beiscsi_quiesce(phba);
if (state == pci_channel_io_perm_failure) { if (state == pci_channel_io_perm_failure) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
...@@ -5554,7 +5592,7 @@ static void beiscsi_eeh_resume(struct pci_dev *pdev) ...@@ -5554,7 +5592,7 @@ static void beiscsi_eeh_resume(struct pci_dev *pdev)
} }
hwi_enable_intr(phba); hwi_enable_intr(phba);
phba->state &= ~BE_ADAPTER_PCI_ERR; clear_bit(BEISCSI_HBA_PCI_ERR, &phba->state);
return; return;
ret_err: ret_err:
...@@ -5597,10 +5635,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -5597,10 +5635,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
/* Initialize Driver configuration Paramters */ /* Initialize Driver configuration Paramters */
beiscsi_hba_attrs_init(phba); beiscsi_hba_attrs_init(phba);
phba->fw_timeout = false;
phba->mac_addr_set = false; phba->mac_addr_set = false;
switch (pcidev->device) { switch (pcidev->device) {
case BE_DEVICE_ID1: case BE_DEVICE_ID1:
case OC_DEVICE_ID1: case OC_DEVICE_ID1:
...@@ -5629,6 +5665,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -5629,6 +5665,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
goto hba_free; goto hba_free;
} }
set_bit(BEISCSI_HBA_RUNNING, &phba->state);
/* /*
* FUNCTION_RESET should clean up any stale info in FW for this fn * FUNCTION_RESET should clean up any stale info in FW for this fn
*/ */
......
...@@ -98,20 +98,9 @@ ...@@ -98,20 +98,9 @@
#define INVALID_SESS_HANDLE 0xFFFFFFFF #define INVALID_SESS_HANDLE 0xFFFFFFFF
/**
* Adapter States
**/
#define BE_ADAPTER_LINK_UP 0x001
#define BE_ADAPTER_LINK_DOWN 0x002
#define BE_ADAPTER_PCI_ERR 0x004
#define BE_ADAPTER_CHECK_BOOT 0x008
#define BEISCSI_CLEAN_UNLOAD 0x01
#define BEISCSI_EEH_UNLOAD 0x02
#define BE_GET_BOOT_RETRIES 45 #define BE_GET_BOOT_RETRIES 45
#define BE_GET_BOOT_TO 20 #define BE_GET_BOOT_TO 20
/** /**
* hardware needs the async PDU buffers to be posted in multiples of 8 * hardware needs the async PDU buffers to be posted in multiples of 8
* So have atleast 8 of them by default * So have atleast 8 of them by default
...@@ -417,11 +406,20 @@ struct beiscsi_hba { ...@@ -417,11 +406,20 @@ struct beiscsi_hba {
unsigned long ulp_supported; unsigned long ulp_supported;
} fw_config; } fw_config;
unsigned int state; unsigned long state;
#define BEISCSI_HBA_RUNNING 0
#define BEISCSI_HBA_LINK_UP 1
#define BEISCSI_HBA_BOOT_FOUND 2
#define BEISCSI_HBA_PCI_ERR 3
#define BEISCSI_HBA_FW_TIMEOUT 4
#define BEISCSI_HBA_IN_UE 5
/* error bits */
#define BEISCSI_HBA_IN_ERR ((1 << BEISCSI_HBA_PCI_ERR) | \
(1 << BEISCSI_HBA_FW_TIMEOUT) | \
(1 << BEISCSI_HBA_IN_UE))
u8 optic_state; u8 optic_state;
int get_boot; int get_boot;
bool fw_timeout;
bool ue_detected;
struct delayed_work beiscsi_hw_check_task; struct delayed_work beiscsi_hw_check_task;
bool mac_addr_set; bool mac_addr_set;
...@@ -445,6 +443,8 @@ struct beiscsi_hba { ...@@ -445,6 +443,8 @@ struct beiscsi_hba {
uint32_t writedir); uint32_t writedir);
}; };
#define beiscsi_hba_in_error(phba) ((phba)->state & BEISCSI_HBA_IN_ERR)
struct beiscsi_session { struct beiscsi_session {
struct pci_pool *bhs_pool; struct pci_pool *bhs_pool;
}; };
...@@ -507,6 +507,7 @@ struct beiscsi_io_task { ...@@ -507,6 +507,7 @@ struct beiscsi_io_task {
struct sgl_handle *psgl_handle; struct sgl_handle *psgl_handle;
struct beiscsi_conn *conn; struct beiscsi_conn *conn;
struct scsi_cmnd *scsi_cmnd; struct scsi_cmnd *scsi_cmnd;
int num_sg;
struct hwi_wrb_context *pwrb_context; struct hwi_wrb_context *pwrb_context;
unsigned int cmd_sn; unsigned int cmd_sn;
unsigned int flags; unsigned int flags;
...@@ -854,11 +855,6 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba, ...@@ -854,11 +855,6 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget); unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget);
void beiscsi_process_mcc_cq(struct beiscsi_hba *phba); void beiscsi_process_mcc_cq(struct beiscsi_hba *phba);
static inline bool beiscsi_error(struct beiscsi_hba *phba)
{
return phba->ue_detected || phba->fw_timeout;
}
struct pdu_nop_out { struct pdu_nop_out {
u32 dw[12]; u32 dw[12];
}; };
......
...@@ -108,9 +108,6 @@ void beiscsi_ue_detect(struct beiscsi_hba *phba) ...@@ -108,9 +108,6 @@ void beiscsi_ue_detect(struct beiscsi_hba *phba)
uint32_t ue_mask_hi = 0, ue_mask_lo = 0; uint32_t ue_mask_hi = 0, ue_mask_lo = 0;
uint8_t i = 0; uint8_t i = 0;
if (phba->ue_detected)
return;
pci_read_config_dword(phba->pcidev, pci_read_config_dword(phba->pcidev,
PCICFG_UE_STATUS_LOW, &ue_lo); PCICFG_UE_STATUS_LOW, &ue_lo);
pci_read_config_dword(phba->pcidev, pci_read_config_dword(phba->pcidev,
...@@ -128,7 +125,7 @@ void beiscsi_ue_detect(struct beiscsi_hba *phba) ...@@ -128,7 +125,7 @@ void beiscsi_ue_detect(struct beiscsi_hba *phba)
if (ue_lo || ue_hi) { if (ue_lo || ue_hi) {
phba->ue_detected = true; set_bit(BEISCSI_HBA_IN_UE, &phba->state);
beiscsi_log(phba, KERN_ERR, beiscsi_log(phba, KERN_ERR,
BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
"BG_%d : Error detected on the adapter\n"); "BG_%d : Error detected on the adapter\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册