From patchwork Tue Dec 8 00:48:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 7793221 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2115BEEE1 for ; Tue, 8 Dec 2015 01:30:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6B6220553 for ; Tue, 8 Dec 2015 01:30:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF54420544 for ; Tue, 8 Dec 2015 01:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932759AbbLHB3z (ORCPT ); Mon, 7 Dec 2015 20:29:55 -0500 Received: from mx0b-0016ce01.pphosted.com ([67.231.156.153]:48783 "EHLO mx0b-0016ce01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932614AbbLHB3e (ORCPT ); Mon, 7 Dec 2015 20:29:34 -0500 Received: from pps.filterd (m0085408.ppops.net [127.0.0.1]) by mx0b-0016ce01.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id tB81R5h2005714; Mon, 7 Dec 2015 17:29:32 -0800 Received: from avcashub1.qlogic.com (avcashub1.qlogic.com [198.70.193.115]) by mx0b-0016ce01.pphosted.com with ESMTP id 1ykystkquc-5 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Mon, 07 Dec 2015 17:29:32 -0800 Received: from dut6217.mv.qlogic.com (172.29.56.217) by qlc.com (10.1.4.190) with Microsoft SMTP Server id 14.3.235.1; Mon, 7 Dec 2015 17:29:29 -0800 Received: by dut6217.mv.qlogic.com (Postfix, from userid 0) id 794B052213A; Mon, 7 Dec 2015 19:49:08 -0500 (EST) From: Himanshu Madhani To: , CC: , , Subject: [PATCH 11/20] qla2xxx: Add TAS detection for kernel 3.15 n newer Date: Mon, 7 Dec 2015 19:48:58 -0500 Message-ID: <1449535747-2850-12-git-send-email-himanshu.madhani@qlogic.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1449535747-2850-1-git-send-email-himanshu.madhani@qlogic.com> References: <1449535747-2850-1-git-send-email-himanshu.madhani@qlogic.com> MIME-Version: 1.0 disclaimer: bypass X-Proofpoint-Virus-Version: vendor=nai engine=5700 definitions=8008 signatures=670664 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1507310000 definitions=main-1512080026 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran For kernel 3.15 and newer with TCM API change, add detection for TCM support of TAS. Instead of default command terminate for LUN/TARGET reset error handling, allow SCSI status to go out if we know sequece Initiative is own by FW (cmd_sent_to_fw=0) Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke --- drivers/scsi/qla2xxx/qla_target.c | 36 +++++++++++++++++------------------- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 4d42b79..5fca846 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3239,36 +3239,34 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd) struct qla_tgt *tgt = cmd->tgt; struct scsi_qla_host *vha = tgt->vha; struct se_cmd *se_cmd = &cmd->se_cmd; - unsigned long flags,refcount; + unsigned long flags, refcount; ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014, "qla_target(%d): terminating exchange for aborted cmd=%p " "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd, se_cmd->tag); - spin_lock_irqsave(&cmd->cmd_lock, flags); - if (cmd->aborted) { - spin_unlock_irqrestore(&cmd->cmd_lock, flags); + spin_lock_irqsave(&cmd->cmd_lock, flags); - /* It's normal to see 2 calls in this path: - * 1) XFER Rdy completion + CMD_T_ABORT - * 2) TCM TMR - drain_state_list - */ - refcount = atomic_read(&cmd->se_cmd.cmd_kref.refcount); - ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, - "multiple abort. %p refcount %lx" - "transport_state %x, t_state %x, se_cmd_flags %x \n", - cmd, refcount,cmd->se_cmd.transport_state, - cmd->se_cmd.t_state,cmd->se_cmd.se_cmd_flags); + if (cmd->aborted) { + spin_unlock_irqrestore(&cmd->cmd_lock, flags); + /* It's normal to see 2 calls in this path: + * 1) XFER Rdy completion + CMD_T_ABORT + * 2) TCM TMR - drain_state_list + */ + refcount = atomic_read(&cmd->se_cmd.cmd_kref.refcount); + ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, + "multiple abort. %p refcount %lx" + "transport_state %x, t_state %x, se_cmd_flags %x \n", + cmd, refcount, cmd->se_cmd.transport_state, + cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); - return EIO; - } + return EIO; + } cmd->aborted = 1; cmd->cmd_flags |= BIT_6; - spin_unlock_irqrestore(&cmd->cmd_lock, flags); - - qlt_send_term_exchange(vha, cmd, &cmd->atio, 0, 1); + spin_unlock_irqrestore(&cmd->cmd_lock, flags); return 0; } diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 842fcca..2e9c194 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -617,6 +617,26 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) struct qla_tgt_cmd, se_cmd); int xmit_type = QLA_TGT_XMIT_STATUS; + if (se_cmd->transport_state & CMD_T_ABORTED) { + /* For TCM TAS support n kernel >= 3.15: + * This cmd is attempting to respond with "Task Aborted Status". + */ + if (cmd->aborted) { + return 0; + } else if ((cmd->state == QLA_TGT_STATE_NEED_DATA) && + cmd->cmd_sent_to_fw) { + qlt_abort_cmd(cmd); + return 0; + } else if (cmd->state == QLA_TGT_STATE_PROCESSED) { + if (cmd->cmd_sent_to_fw) { + qlt_abort_cmd(cmd); + return 0; + } else { /* about to be free */ + return 0; + } + } + } + cmd->bufflen = se_cmd->data_length; cmd->sg = NULL; cmd->sg_cnt = 0;