From patchwork Wed Apr 17 21:44:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A20817E6 for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D5B2873E for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 796EF2867C; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17B4B2873E for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387907AbfDQVo6 (ORCPT ); Wed, 17 Apr 2019 17:44:58 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33398 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387756AbfDQVo4 (ORCPT ); Wed, 17 Apr 2019 17:44:56 -0400 Received: by mail-pf1-f195.google.com with SMTP id h5so92795pfo.0 for ; Wed, 17 Apr 2019 14:44:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sdOUShQ6AoeFT0CkgLVINj1bmuVaYYs3TLoQhdjvjWU=; b=MVtizrUDavq4Zb7ZxM0iCYtFZMSupKiMSzwv7fxZVM+mLnCxkClQ8EboV2ghKW/DUF e/jT/SN130tGfMd1KMp0Qz5FEmfs6PXymztGJiDSF6M0ArH5APx6oo9Vr8AlSTpthHni oRyhkFG3Qcg7ZmCeEqBNE4fKB3ujGV8/8qOzFc+4rlv89GLd3vZgM9E+Jsz5dTZ3ZSrp lfS0QG75ZL8QiX4vVmh1IhUjB4U8O0QboYkFq/MSOgJimkuJamHCLSD+soT3w5dMJbQD 333NaOVDfevI18isCPj9x7atebwdKXBqIr3xUFqFsT9pPQBMMtROJA/Jwce972sFgmT2 difA== X-Gm-Message-State: APjAAAV73BI+6DUnayxQfWBSwV66/c8pqMxEC0Ltp99mwmDcfoRuwvU0 ldxVTqF6Z5E8JTA7rlkkGQnpkQH1 X-Google-Smtp-Source: APXvYqwKwBYjnjCIU5PgcSNOfFxheutvets4E6QoERDo0mfTToO2aCIkSDgjkAMzJp2V50ZX9RnVXw== X-Received: by 2002:aa7:86ce:: with SMTP id h14mr93018098pfo.84.1555537495440; Wed, 17 Apr 2019 14:44:55 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.44.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:44:54 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 01/34] qla2xxx: Update two source code comments Date: Wed, 17 Apr 2019 14:44:10 -0700 Message-Id: <20190417214443.243152-2-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change one occurrence of "*(" into "()" and change one occurrence of "lcoate" into "locate". Fix the reference to qla_tgt_handle_cmd_for_atio(): there has never been a function with that name. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: 75f8c1f693ee ("[SCSI] tcm_qla2xxx: Add >= 24xx series fabric module for target-core") # v3.5. Fixes: 2d70c103fd2a ("[SCSI] qla2xxx: Add LLD target-mode infrastructure for >= 24xx series") # v3.5. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 2 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 57cdd762230d..4afab9d338b3 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -4246,7 +4246,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd) if (ret != 0) goto out_term; /* - * Drop extra session reference from qla_tgt_handle_cmd_for_atio*( + * Drop extra session reference from qlt_handle_cmd_for_atio(). */ spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 7f9d5461023a..eb19ad845bc9 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -1482,7 +1482,7 @@ static int tcm_qla2xxx_check_initiator_node_acl( */ tpg = lport->tpg_1; if (!tpg) { - pr_err("Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n"); + pr_err("Unable to locate struct tcm_qla2xxx_lport->tpg_1\n"); return -EINVAL; } /* From patchwork Wed Apr 17 21:44:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5D2D17E0 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFD1B28A93 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3C2C28A96; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F18228BA9 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387693AbfDQVo6 (ORCPT ); Wed, 17 Apr 2019 17:44:58 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45285 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387758AbfDQVo5 (ORCPT ); Wed, 17 Apr 2019 17:44:57 -0400 Received: by mail-pl1-f194.google.com with SMTP id bf11so100562plb.12 for ; Wed, 17 Apr 2019 14:44:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XynsbGbRtkW5+qbzMrlSHzphnFgzcqd1gKjGjn2l2+I=; b=ipdDwBjzVEUdOqMKEPXjVhz7D1e8FQVPoPhYlKxLc1kcurH6IMQBobY/0E9OwC1KDR 14Uuw8y7La4a7pZtvbD/hXAt8RCPyPBNtsV3CWwrycfN0bxcyD/9r+4P1cX+YamnGgEl c4FTrkfpSjUgr2qsy/EnfbuEqtTgqnM7UYE6wK5a7rGfheK+daMoOPJf7LblLDnuZLR9 cRT1oFTPIhE4aCEDrmm/yvw5uTRtNdZmtaeUgmUroQlPO6dzsWtKijkiITqn7pwBOq3s hTG083g+qq0k9vUhlws2aPBUwAKzIPlmjS9xIMBqRR6Lg8ytD6YF2k2MEceI+5KIiTNt LxLw== X-Gm-Message-State: APjAAAUJ1IGnqPL1d4wDOiL+8nSOBYhvd5YKtLwklNzTYwWe5WwB+7rp YHuBLYkflaGQo62/5VnzCTw= X-Google-Smtp-Source: APXvYqxZdBly6zhmjVXwY0mhVX6Wr9MAV6mHtrdLCHhun/WMhhTcPY6aYx2iH6m0Tz/kVP9DJ6dFNg== X-Received: by 2002:a17:902:70c8:: with SMTP id l8mr92471859plt.177.1555537496761; Wed, 17 Apr 2019 14:44:56 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.44.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:44:56 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 02/34] qla2xxx: Fix a format specifier Date: Wed, 17 Apr 2019 14:44:11 -0700 Message-Id: <20190417214443.243152-3-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since mcmd->sess->port_name is eight bytes long, use %8phC to format that port name instead of %phC. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery") # v4.11. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 4afab9d338b3..e5707ffdaefe 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -2391,7 +2391,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd) case ELS_PRLO: case ELS_TPRLO: ql_dbg(ql_dbg_disc, vha, 0x2106, - "TM response logo %phC status %#x state %#x", + "TM response logo %8phC status %#x state %#x", mcmd->sess->port_name, mcmd->fc_tm_rsp, mcmd->flags); qlt_schedule_sess_for_deletion(mcmd->sess); From patchwork Wed Apr 17 21:44:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF7B517E0 for ; Wed, 17 Apr 2019 21:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6CCA28A93 for ; Wed, 17 Apr 2019 21:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 969B728BAB; Wed, 17 Apr 2019 21:45:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ABEB28A93 for ; Wed, 17 Apr 2019 21:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387769AbfDQVpK (ORCPT ); Wed, 17 Apr 2019 17:45:10 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40157 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387760AbfDQVo6 (ORCPT ); Wed, 17 Apr 2019 17:44:58 -0400 Received: by mail-pf1-f194.google.com with SMTP id c207so76377pfc.7 for ; Wed, 17 Apr 2019 14:44:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lIt4MnniGUXt5HFFwY7RsZQVGXWVFQnn03GMAZMv05w=; b=pQjPWYZ8KQCukcKogIRBUq835T9hN2vazVLb7Rs7jXrYnLCQqJcQTImf2swZwkSD6s MXWeLjkmrSzmgQx0QLpebogeXm67gfzCJUwCb+flvX+ol+VmyH9IDZXlEgKHTs/OJLBJ 9gz47h5HJg0AEyyWzDkKyJwX6k8k1U83M68M6JH4jnpPKuTuIFHgwuTTOOpyAUDM3az5 SRHZGqOg61JTxaIx4VxWG8fmGukc5UeZ25DCViAHOOrOQ9fdjp6jqliTL9FX4rr0s8eC E4nSfttFPSIcsIQLrrp4U/r2Si6tS3dgAyAHh6bxGZ/1ns7gdjGQEAZvFwOkCdSplWkC hbHg== X-Gm-Message-State: APjAAAU2Vu6X3vnSlBnnh9QOHEDx55yOVAGEzx4Wj/jHPkDJErd6rdpU +sR7vpG4VPAfqA7ES8g1Vlk= X-Google-Smtp-Source: APXvYqw7lqINSjXOr7XNWFUCd4Io302IHtcEKDLnngyoPgw4e/WJ7BKMjP/vlxz3VjaPABuwOn9otA== X-Received: by 2002:a65:625a:: with SMTP id q26mr86247481pgv.68.1555537497867; Wed, 17 Apr 2019 14:44:57 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.44.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:44:57 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 03/34] qla2xxx: Move qla2x00_set_reserved_loop_ids() definition Date: Wed, 17 Apr 2019 14:44:12 -0700 Message-Id: <20190417214443.243152-4-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since qla2x00_set_reserved_loop_ids() only has a single caller, move it into the source file from where it is called. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_inline.h | 14 -------------- drivers/scsi/qla2xxx/qla_os.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 7a67169d94a2..d6808d3e0ccb 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -90,20 +90,6 @@ host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize) *odest++ = cpu_to_le32(*isrc); } -static inline void -qla2x00_set_reserved_loop_ids(struct qla_hw_data *ha) -{ - int i; - - if (IS_FWI2_CAPABLE(ha)) - return; - - for (i = 0; i < SNS_FIRST_LOOP_ID; i++) - set_bit(i, ha->loop_id_map); - set_bit(MANAGEMENT_SERVER, ha->loop_id_map); - set_bit(BROADCAST, ha->loop_id_map); -} - static inline int qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id) { diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 466aa35d10cc..a3561e461aa5 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3984,6 +3984,19 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) } } +static void qla2x00_set_reserved_loop_ids(struct qla_hw_data *ha) +{ + int i; + + if (IS_FWI2_CAPABLE(ha)) + return; + + for (i = 0; i < SNS_FIRST_LOOP_ID; i++) + set_bit(i, ha->loop_id_map); + set_bit(MANAGEMENT_SERVER, ha->loop_id_map); + set_bit(BROADCAST, ha->loop_id_map); +} + /* * qla2x00_mem_alloc * Allocates adapter memory. From patchwork Wed Apr 17 21:44:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E837517E0 for ; Wed, 17 Apr 2019 21:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEE932867C for ; Wed, 17 Apr 2019 21:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFAA4287C8; Wed, 17 Apr 2019 21:45:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A3252867C for ; Wed, 17 Apr 2019 21:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387919AbfDQVpA (ORCPT ); Wed, 17 Apr 2019 17:45:00 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44016 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfDQVpA (ORCPT ); Wed, 17 Apr 2019 17:45:00 -0400 Received: by mail-pl1-f196.google.com with SMTP id n8so106066plp.10 for ; Wed, 17 Apr 2019 14:44:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BTVDSEoCQnj984xC3RsloCv0YmRe1xZCWqn9kcLbPO8=; b=TXh4YoAZmkxN4mjsQqK2oHs1EO3DwMidgsExQq10Km7chrIPBiykXUvHLBOs9111rM VPA/TR6ddLkelfoHsddI9Sr0yTrfKXtO98NC0bPv7zvpeUEjcSHlV73hVGi+QGFSToCc gHJNr2ss4jYwKHK9rqevlxq6+ZFmXWdqq0Dag0whJUUbnzxAkRGZgtVrdpMyem5dso/z nJElh4z+U7f3Jz/HLyJ5g0GlWBinUJGlj5CgsQC7qPv5ZoAJuxcViUA60g2gRHJspr2F ZJbZQ5m4dNyESrUHtpJZA4VazD0wgOHL7WtnLNmWqyOwK6PzK1AiSA7f2AELVWNrJQJD EDcA== X-Gm-Message-State: APjAAAXfn0rfolVJG9FdiWaw0c3zG9UI1xKzUfMr2gwNXsHflTO6az/l VCCT+7B/jJAI5bMg+Xh+rHVeDB8l X-Google-Smtp-Source: APXvYqze2TFDZq6TVZwHvPX3+G456vAtRSB4WFvk3/gxCjTqTw4swWAjoPea/M4fXavvyNPL0yty0Q== X-Received: by 2002:a17:902:4643:: with SMTP id o61mr80927860pld.249.1555537499151; Wed, 17 Apr 2019 14:44:59 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.44.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:44:58 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 04/34] qla2xxx: Declare qla2x00_find_new_loop_id() static Date: Wed, 17 Apr 2019 14:44:13 -0700 Message-Id: <20190417214443.243152-5-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since all qla2x00_find_new_loop_id() calls occur in the same source file as the definition of this function, move that function to just before its first caller and declare it static. Convert the header above this function into kernel-doc format. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_gbl.h | 2 - drivers/scsi/qla2xxx/qla_init.c | 92 +++++++++++++++------------------ 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 034cfc152336..97be390e027d 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -39,8 +39,6 @@ extern int qla81xx_load_risc(scsi_qla_host_t *, uint32_t *); extern int qla2x00_perform_loop_resync(scsi_qla_host_t *); extern int qla2x00_loop_resync(scsi_qla_host_t *); -extern int qla2x00_find_new_loop_id(scsi_qla_host_t *, fc_port_t *); - extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *); extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 948f20805111..14edf3614614 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -514,6 +514,49 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, return rval; } +/** + * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID + * @vha: adapter state pointer. + * @dev: port structure pointer. + * + * Returns: + * qla2x00 local function return status code. + * + * Context: + * Kernel context. + */ +static int qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) +{ + int rval; + struct qla_hw_data *ha = vha->hw; + unsigned long flags = 0; + + rval = QLA_SUCCESS; + + spin_lock_irqsave(&ha->vport_slock, flags); + + dev->loop_id = find_first_zero_bit(ha->loop_id_map, LOOPID_MAP_SIZE); + if (dev->loop_id >= LOOPID_MAP_SIZE || + qla2x00_is_reserved_id(vha, dev->loop_id)) { + dev->loop_id = FC_NO_LOOP_ID; + rval = QLA_FUNCTION_FAILED; + } else { + set_bit(dev->loop_id, ha->loop_id_map); + } + spin_unlock_irqrestore(&ha->vport_slock, flags); + + if (rval == QLA_SUCCESS) + ql_dbg(ql_dbg_disc, dev->vha, 0x2086, + "Assigning new loopid=%x, portid=%x.\n", + dev->loop_id, dev->d_id.b24); + else + ql_log(ql_log_warn, dev->vha, 0x2087, + "No loop_id's available, portid=%x.\n", + dev->d_id.b24); + + return rval; +} + static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, struct event_arg *ea) { @@ -5886,55 +5929,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha) return (rval); } -/* - * qla2x00_find_new_loop_id - * Scan through our port list and find a new usable loop ID. - * - * Input: - * ha: adapter state pointer. - * dev: port structure pointer. - * - * Returns: - * qla2x00 local function return status code. - * - * Context: - * Kernel context. - */ -int -qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) -{ - int rval; - struct qla_hw_data *ha = vha->hw; - unsigned long flags = 0; - - rval = QLA_SUCCESS; - - spin_lock_irqsave(&ha->vport_slock, flags); - - dev->loop_id = find_first_zero_bit(ha->loop_id_map, - LOOPID_MAP_SIZE); - if (dev->loop_id >= LOOPID_MAP_SIZE || - qla2x00_is_reserved_id(vha, dev->loop_id)) { - dev->loop_id = FC_NO_LOOP_ID; - rval = QLA_FUNCTION_FAILED; - } else - set_bit(dev->loop_id, ha->loop_id_map); - - spin_unlock_irqrestore(&ha->vport_slock, flags); - - if (rval == QLA_SUCCESS) - ql_dbg(ql_dbg_disc, dev->vha, 0x2086, - "Assigning new loopid=%x, portid=%x.\n", - dev->loop_id, dev->d_id.b24); - else - ql_log(ql_log_warn, dev->vha, 0x2087, - "No loop_id's available, portid=%x.\n", - dev->d_id.b24); - - return (rval); -} - - /* FW does not set aside Loop id for MGMT Server/FFFFFAh */ int qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha) From patchwork Wed Apr 17 21:44:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 610C117E0 for ; Wed, 17 Apr 2019 21:45:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DC1B2867C for ; Wed, 17 Apr 2019 21:45:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4280B287C8; Wed, 17 Apr 2019 21:45:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB9412873E for ; Wed, 17 Apr 2019 21:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387626AbfDQVpC (ORCPT ); Wed, 17 Apr 2019 17:45:02 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39695 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387920AbfDQVpA (ORCPT ); Wed, 17 Apr 2019 17:45:00 -0400 Received: by mail-pl1-f193.google.com with SMTP id a96so113907pla.6 for ; Wed, 17 Apr 2019 14:45:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tiqoKFdJXX9dSUq6uSa6Y4r+5PbLMXG+MMMoD5jRZ+w=; b=KsQCsJesyVSN2nfPWs1CUgI6SwMK+wLLMZK7Ajy+wBCtDl0U7qYj7+Sc2dsYEW6arq aunAHxfBlATNAI52bsCr/772GG9U13/pn4E5fo3pBlP8OvQBzH0RL+t9E5UweUkRNNZl H24mpd+4L1ugdhnSstrSfpXfjl/kx8P0cxxS8t3tGCL4xna+0hXHW2m8ANRjdn6HhHfc 8rRMOiyEGqKV5GljIqqRME0/u3rRDiaheouFIGVboySAMkYBPnZlbgQRp591Yor5i50W SFwvN/1NItwaTxt/FwOGdcuyXd6JawwTELTU6qIMW8mirPs835T0Q50ykOxMUPeyebtN sxSA== X-Gm-Message-State: APjAAAWYpJQKBqz+UpPX9gp1ZV+AnQ1oADkue/9f3zI0LDd43cL/GfJB a5lQtstpYWyUI8lQ734ZIwP6tRPF X-Google-Smtp-Source: APXvYqyq8fo06P/vQWcNJHJlKUxvP0eBl7/lvjYE+A41eAAMUnHacw1gD1b4qVHww/46RbD8pPAdGQ== X-Received: by 2002:a17:902:b78c:: with SMTP id e12mr39493368pls.29.1555537500243; Wed, 17 Apr 2019 14:45:00 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.44.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:44:59 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 05/34] qla2xxx: Remove a set-but-not-used variable Date: Wed, 17 Apr 2019 14:44:14 -0700 Message-Id: <20190417214443.243152-6-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_iocb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 5ec975e110c5..e753ab35c6d2 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -3004,7 +3004,6 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) scsi_qla_host_t *vha = sp->vha; struct qla_hw_data *ha = vha->hw; struct bsg_job *bsg_job = sp->u.bsg_job; - int loop_iterartion = 0; int entry_count = 1; memset(ct_iocb, 0, sizeof(ms_iocb_entry_t)); @@ -3062,7 +3061,6 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); - loop_iterartion++; avail_dsds--; } ct_iocb->entry_count = entry_count; From patchwork Wed Apr 17 21:44:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5232D17E6 for ; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FAAE2867C for ; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 343E5287C8; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA7912867C for ; Wed, 17 Apr 2019 21:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387924AbfDQVpG (ORCPT ); Wed, 17 Apr 2019 17:45:06 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44720 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387577AbfDQVpC (ORCPT ); Wed, 17 Apr 2019 17:45:02 -0400 Received: by mail-pg1-f193.google.com with SMTP id i2so138705pgj.11 for ; Wed, 17 Apr 2019 14:45:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z5wjEFF2B1Zxm+xyOqUNa2TxiH5hEKW7xMB/C+pftkA=; b=Ede68FybtNgZoN2tsvEo+KtzzPiUyLFflDbTWF2O+zNGK6g5VgzmXiCCoL20SMUp9r MYIahNNlAiNvMB6bkden64bH15YT4EYXMaRSWOuqFmmvxJpFOcw7AJNQRZW57wcDB/o9 DPE/0+AFPcdhdTNMMtkW8V4WEs3mpXFV0EfeIw/RGZ0N6vDAUFz7C2sRfWJeJ/CAvQkN 9avDo8/StMS+sNh7fR8IgVh9GBuaZtMuAD4OGLMz0Y6hvRmSnEUJeg3qisnNZnV2NTBP OaB7Bub5PI/lvvxeOhmiboB5t7kyJZ0v5sZtA5odSgf/qgRmdGIJnG0k7J3DQ62DzP9n Odug== X-Gm-Message-State: APjAAAXlXn4GOSvNvFu8IXf0ni05PbAwlKksZCVntQI6RbDkgCPsJFWb E1vA4RgTkDvSF9I5mqIYGFw= X-Google-Smtp-Source: APXvYqxn5H4nGH0rGtBoHz/1rgWv6J2yY/HphutEetS9S2S/zLfXf5HCKwZk6TDviHM5fyAedll1aQ== X-Received: by 2002:a62:2587:: with SMTP id l129mr92472926pfl.151.1555537501436; Wed, 17 Apr 2019 14:45:01 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:00 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 06/34] qla2xxx: Move qla2x00_clear_loop_id() from qla_inline.h into qla_init.c Date: Wed, 17 Apr 2019 14:44:15 -0700 Message-Id: <20190417214443.243152-7-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since qla2x00_clear_loop_id() is not in the hot path, uninline it. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_init.c | 12 ++++++++++++ drivers/scsi/qla2xxx/qla_inline.h | 12 ------------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 97be390e027d..3275c86087c4 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -38,6 +38,7 @@ extern int qla81xx_load_risc(scsi_qla_host_t *, uint32_t *); extern int qla2x00_perform_loop_resync(scsi_qla_host_t *); extern int qla2x00_loop_resync(scsi_qla_host_t *); +extern void qla2x00_clear_loop_id(fc_port_t *fcport); extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *); extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 14edf3614614..bba37820d226 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -557,6 +557,18 @@ static int qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) return rval; } +void qla2x00_clear_loop_id(fc_port_t *fcport) +{ + struct qla_hw_data *ha = fcport->vha->hw; + + if (fcport->loop_id == FC_NO_LOOP_ID || + qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) + return; + + clear_bit(fcport->loop_id, ha->loop_id_map); + fcport->loop_id = FC_NO_LOOP_ID; +} + static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, struct event_arg *ea) { diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index d6808d3e0ccb..57b7e38e3056 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -101,18 +101,6 @@ qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id) loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST); } -static inline void -qla2x00_clear_loop_id(fc_port_t *fcport) { - struct qla_hw_data *ha = fcport->vha->hw; - - if (fcport->loop_id == FC_NO_LOOP_ID || - qla2x00_is_reserved_id(fcport->vha, fcport->loop_id)) - return; - - clear_bit(fcport->loop_id, ha->loop_id_map); - fcport->loop_id = FC_NO_LOOP_ID; -} - static inline void qla2x00_clean_dsd_pool(struct qla_hw_data *ha, struct crc_context *ctx) { From patchwork Wed Apr 17 21:44:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DECB817E0 for ; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC0342867C for ; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0D9A287C8; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69CEC2867C for ; Wed, 17 Apr 2019 21:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387923AbfDQVpF (ORCPT ); Wed, 17 Apr 2019 17:45:05 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37807 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387767AbfDQVpD (ORCPT ); Wed, 17 Apr 2019 17:45:03 -0400 Received: by mail-pf1-f195.google.com with SMTP id 8so83563pfr.4 for ; Wed, 17 Apr 2019 14:45:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PJmOr0xcRv8xSnNsDGeocx7CfB1IFlxtegRSdGV+bUc=; b=hOJjGyTi2x538YnkrHv06xPuLU5PIZkkNC+he0cLYjqRT5xHG43jouy620z4XJPB7p j7E2mkGOy/a99E/VL4kicn4Fp8zI25o6fN0wKCvMx0tFUm+8098OpaY+q8Q1aFYmiZO3 XlJsL715Q1475vtDvFGEG25xWru3DzyTA1/gQ6mELR1zVQif20VsozUvRlLNuI4xeMIu oAN4qVEsV3J/H7CU9MWZ7Q02m1l3X+rOILbzaEw4yIw6VVq8hpsPVM4u+bj0XDG/Aiw4 5mS/MhX0Agxw58I6wIo21MxoRS0wpnpmOG6h4A+JKv0aOIYoMVl+rdV0J3Idk8Ripid6 HaYw== X-Gm-Message-State: APjAAAVY5z1OAxbTTxMslUZd0ItRfvMorU2SFmkHvJWn8cJVVxvIrSCI 1VctV26dYqGJjArwydafuXzAlvA5 X-Google-Smtp-Source: APXvYqw+IzzTklv/PDgKN9cLn4EAaWJSaV6F214fzITT8gS+MIQzTgMc0bZ5JIwZ7ulZBPDEb+eakQ== X-Received: by 2002:a63:7f0b:: with SMTP id a11mr1251936pgd.234.1555537502577; Wed, 17 Apr 2019 14:45:02 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:01 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 07/34] qla2xxx: Move qla2x00_is_reserved_id() from qla_inline.h into qla_init.c Date: Wed, 17 Apr 2019 14:44:16 -0700 Message-Id: <20190417214443.243152-8-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The previous patch moved all qla2x00_is_reserved_id() callers into qla_init.c. Hence also move the qla2x00_is_reserved_id() definition into qla_init.c. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_init.c | 11 +++++++++++ drivers/scsi/qla2xxx/qla_inline.h | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index bba37820d226..241ff5ae26f0 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -514,6 +514,17 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, return rval; } +static bool qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id) +{ + struct qla_hw_data *ha = vha->hw; + + if (IS_FWI2_CAPABLE(ha)) + return loop_id > NPH_LAST_HANDLE; + + return (loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || + loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST; +} + /** * qla2x00_find_new_loop_id - scan through our port list and find a new usable loop ID * @vha: adapter state pointer. diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 57b7e38e3056..cf34df8807ff 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -90,17 +90,6 @@ host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize) *odest++ = cpu_to_le32(*isrc); } -static inline int -qla2x00_is_reserved_id(scsi_qla_host_t *vha, uint16_t loop_id) -{ - struct qla_hw_data *ha = vha->hw; - if (IS_FWI2_CAPABLE(ha)) - return (loop_id > NPH_LAST_HANDLE); - - return ((loop_id > ha->max_loop_id && loop_id < SNS_FIRST_LOOP_ID) || - loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST); -} - static inline void qla2x00_clean_dsd_pool(struct qla_hw_data *ha, struct crc_context *ctx) { From patchwork Wed Apr 17 21:44:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C36641390 for ; Wed, 17 Apr 2019 21:45:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5212867C for ; Wed, 17 Apr 2019 21:45:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2744287C8; Wed, 17 Apr 2019 21:45:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4138E2867C for ; Wed, 17 Apr 2019 21:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387922AbfDQVpF (ORCPT ); Wed, 17 Apr 2019 17:45:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34327 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387753AbfDQVpE (ORCPT ); Wed, 17 Apr 2019 17:45:04 -0400 Received: by mail-pf1-f193.google.com with SMTP id b3so90133pfd.1 for ; Wed, 17 Apr 2019 14:45:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=krlv9oByY3GEE6cVQjIpWzRdjVRGH25D1bUkGKASo18=; b=NUl4AGsoi+L0nSMXBfVL3GzKdJXyoWEXpwT64UbmUAUvxCfOf2dmvanGIVAH+UNueV ZYXpWWx0pZGPCvHCEhBLUCGbw0Casev7SFiDUZjh1kFVX8Vhq/k9krVPSUJy2e4hdLl5 TEL/SN7A5wlyUbMy0V8/bNU5PhUjUBRQmt+j93N0xY5TpCFBvjuglgBjV0GR1872vxGR GNvrBj2/mXGU0l1cQf0BNGtUJ6ufzdNcYJ+ttpZEUPztvfb+fBoHbjypQRkBuB8ErAB0 Sd7EXhXC9q91vn7GZMNvgeEk+FvE/AFnmUDGenn4CSnlXeWfnvcs4wQNGS2/dmiPu+Sn qCvw== X-Gm-Message-State: APjAAAWGHaTsCvXsc4RzGj/oCCLr9i2X9RpnuHD5G9FfizJmICpEweeG p849Aq4sg92t9nTYruH8/Mc= X-Google-Smtp-Source: APXvYqxqYVGTAmyRtktA5R5P52kFTPcWqoWkGyWfF5rbJpbvpufji0ZfWkO9B3ppr3B5RFQ5hG1tTA== X-Received: by 2002:aa7:8edd:: with SMTP id b29mr2320365pfr.241.1555537503856; Wed, 17 Apr 2019 14:45:03 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:02 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 08/34] qla2xxx: Uninline qla2x00_init_timer() Date: Wed, 17 Apr 2019 14:44:17 -0700 Message-Id: <20190417214443.243152-9-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since qla2x00_init_timer() is not used for I/O commands there is no need to inline this function. Hence uninline this function. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_inline.h | 12 ------------ drivers/scsi/qla2xxx/qla_iocb.c | 11 +++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 3275c86087c4..ac3d418e3990 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -281,6 +281,7 @@ extern int qla2x00_start_sp(srb_t *); extern int qla24xx_dif_start_scsi(srb_t *); extern int qla2x00_start_bidir(srb_t *, struct scsi_qla_host *, uint32_t); extern int qla2xxx_dif_start_scsi_mq(srb_t *); +extern void qla2x00_init_timer(srb_t *sp, unsigned long tmo); extern unsigned long qla2x00_get_async_timeout(struct scsi_qla_host *); extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *); diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index cf34df8807ff..bf063c664352 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -219,18 +219,6 @@ qla2x00_rel_sp(srb_t *sp) qla2xxx_rel_qpair_sp(sp->qpair, sp); } -static inline void -qla2x00_init_timer(srb_t *sp, unsigned long tmo) -{ - timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); - sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; - sp->free = qla2x00_sp_free; - init_completion(&sp->comp); - if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD)) - init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); - add_timer(&sp->u.iocb_cmd.timer); -} - static inline int qla2x00_gid_list_size(struct qla_hw_data *ha) { diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index e753ab35c6d2..7ab157c079ca 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2565,6 +2565,17 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk) } } +void qla2x00_init_timer(srb_t *sp, unsigned long tmo) +{ + timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); + sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; + sp->free = qla2x00_sp_free; + init_completion(&sp->comp); + if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD) + init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); + add_timer(&sp->u.iocb_cmd.timer); +} + static void qla2x00_els_dcmd_sp_free(void *data) { From patchwork Wed Apr 17 21:44:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCDAA17E0 for ; Wed, 17 Apr 2019 21:45:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A89A92867C for ; Wed, 17 Apr 2019 21:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D4AA287E5; Wed, 17 Apr 2019 21:45:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1272867C for ; Wed, 17 Apr 2019 21:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387926AbfDQVpH (ORCPT ); Wed, 17 Apr 2019 17:45:07 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40013 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387921AbfDQVpF (ORCPT ); Wed, 17 Apr 2019 17:45:05 -0400 Received: by mail-pg1-f195.google.com with SMTP id d31so148178pgl.7 for ; Wed, 17 Apr 2019 14:45:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wovk3eG2reJUvsCdEpO16z+YWx2eFLzYVwwM6g35epc=; b=LSiBN7QQ26u/Q3MalzBkQ9Crp3N0AxFx57vdZShDqGipARNZ7ZF707lZKuyqAcMsuO C6XezJIR76SRC5N8FELATqcJ901UZajQZut/tghzHQDbPrJQ6IUQqKyYIsjqr8b5quFV AG3ZP7SfkObmu+HXLp3QGywawrQ9RB5znYZYMPBU6C7AbDjASabXJJjBNcrkcHIoWeyq kkdaDcFRXYW/VP5ftzuq2Q7Runf65mV3GLI69KTCn7PWszFAxrQytEEvhhOiIUHVptEh CL1758ozYgkRZNSJAEgUA6+hJ62WvonwGWQ9BtjRqXO2ioCKkJYWAyhfqH7okLJkwfyf TMww== X-Gm-Message-State: APjAAAXCEn4pHN3BPrIolA+NOO9+BnMEcDOg1WD9gcfU6ZuTaia40OOU 8+VKyUit3hQFpVooKicy7Cc= X-Google-Smtp-Source: APXvYqxnXcntS9s+q5nbsu1gkjKRJjbXdMaRWiA11AQ4anmA5ye+SYWoaKbE8T4i4ZxuVsAbB2YHSQ== X-Received: by 2002:a63:f707:: with SMTP id x7mr86151794pgh.343.1555537505110; Wed, 17 Apr 2019 14:45:05 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:04 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 09/34] qla2xxx: Remove the fcport test from qla_nvme_abort_work() Date: Wed, 17 Apr 2019 14:44:18 -0700 Message-Id: <20190417214443.243152-10-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Testing whether a pointer is not NULL after it has been dereferenced is not useful. Hence remove the if (fcport) test. This was detected by Coverity. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 8dd6220857d4..5d9191278f41 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -186,10 +186,9 @@ static void qla_nvme_abort_work(struct work_struct *work) struct qla_hw_data *ha = fcport->vha->hw; int rval; - if (fcport) - ql_dbg(ql_dbg_io, fcport->vha, 0xffff, - "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n", - __func__, sp, sp->handle, fcport, fcport->deleted); + ql_dbg(ql_dbg_io, fcport->vha, 0xffff, + "%s called for sp=%p, hndl=%x on fcport=%p deleted=%d\n", + __func__, sp, sp->handle, fcport, fcport->deleted); if (!ha->flags.fw_started && (fcport && fcport->deleted)) return; From patchwork Wed Apr 17 21:44:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 747891390 for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61B142867C for ; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55F5428818; Wed, 17 Apr 2019 21:45:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA1AE2867C for ; Wed, 17 Apr 2019 21:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387927AbfDQVpI (ORCPT ); Wed, 17 Apr 2019 17:45:08 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37465 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387577AbfDQVpH (ORCPT ); Wed, 17 Apr 2019 17:45:07 -0400 Received: by mail-pg1-f194.google.com with SMTP id e6so155184pgc.4 for ; Wed, 17 Apr 2019 14:45:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XprVmq3TTMZOtRS9jGDhC+TKlXs+IlZcKHfOr2E3Goo=; b=FOu74IGULPy75QrVseP+gjcEIywDRMttmJD9WNonQ+8j7crPPrwtlMeMZ60yrk8+ej qK4cfEZZrnumQQYujXtIt2snKcKAeYZwZRmYGd4BXpKeqiOCEuyoFzxKQ6MmVoM5xXxd m+jaEmQAJQ6RQpDd0yz2ZXpXukRfnlsr9psDSETy9C3nH/nNHnpO3Hvc1/Bd/s/Vu5UW jKHGyh0yWBghX7AUR/NtjMLncY+p/6ejS5iMONwa1MJq6ovn37oF+NN7J4yDgCaajSEg 03uq3TVRt+QcvMv3lYqEGc4M+LlkVSH6civFjN40aRjvo9VFDEoKTwPYOqMkaYy1uwtA B04Q== X-Gm-Message-State: APjAAAXgxgTE1RUcWYiHPPJx/7roklY6GwbNRIwmqkZVdM8zfHRZN0ZW QktOMy7+GlETbONnxHJfxV8= X-Google-Smtp-Source: APXvYqx0FVtEQKpipid7i0zHyZCyeS1PlMZsiaRd0DAUMsDBMSq9hO9PBE5Xrhru+/Ll8Jane5iFOg== X-Received: by 2002:a62:4554:: with SMTP id s81mr63962692pfa.66.1555537506236; Wed, 17 Apr 2019 14:45:06 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 10/34] qla2xxx: Avoid that Coverity complains about dereferencing a NULL rport pointer Date: Wed, 17 Apr 2019 14:44:19 -0700 Message-Id: <20190417214443.243152-11-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since Coverity cannot know that rport != NULL in qla2xxx_queuecommand() and since there is code in that function that dereferences the rport pointer, modify qla2xxx_queuecommand() such that it fails SCSI commands if rport == NULL. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a3561e461aa5..5cfdf0cc3846 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -859,7 +859,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) uint32_t tag; uint16_t hwq; - if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { + if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)) || + WARN_ON_ONCE(!rport)) { cmd->result = DID_NO_CONNECT << 16; goto qc24_fail_command; } @@ -982,7 +983,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, srb_t *sp; int rval; - rval = fc_remote_port_chkready(rport); + rval = rport ? fc_remote_port_chkready(rport) : FC_PORTSTATE_OFFLINE; if (rval) { cmd->result = rval; ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, From patchwork Wed Apr 17 21:44:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DB8F1390 for ; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A6728A96 for ; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DF3B28BAA; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B06828BA9 for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387646AbfDQVpQ (ORCPT ); Wed, 17 Apr 2019 17:45:16 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39703 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387921AbfDQVpI (ORCPT ); Wed, 17 Apr 2019 17:45:08 -0400 Received: by mail-pl1-f194.google.com with SMTP id a96so114020pla.6 for ; Wed, 17 Apr 2019 14:45:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KjX4Qkmu49rFY0OmVSTsm6XGNnxUmdvCcA5PxODqy9Q=; b=LwoE+kgWwLWNI0eApFhOW7cr2uy4oQJSpohFPhm+zF0DjHGMKndonCVF+yvH/mulWr hWgFfEat9Q4pqM6xEY+mmQawJjknRAbzXVI38TXhas/JHx8qchKy3bksi1wreubb+FaF Tt97ZdPniT1l4XzXSnO3+DiN3yBO15DNb2FWVHxQ2HcJaZw2ByT+E5qmCU/rRGVKj7LO 0m8jtMKAtlGgo+ihhCid3wym7TxHu27EUnG3HIUDm/y/pHmVhCuwgkgIipYHSSu1He+/ fAh3Swx8pm7dImOVZ/+CHlrLixxdrADNZ4lJv98hvBmOFYmDqOZPmEjQt8u9J4+KRO7j YkvQ== X-Gm-Message-State: APjAAAUbVIfRXfBY6uyP/QtKO1kT75ye0Qzrvpa3/cwbaEQRtTULqiGy OJDmpEvmizWWFYb2r7QvIMQfa6gj X-Google-Smtp-Source: APXvYqyq2yXlZNC0U7tFYGror34EI9S2TxIGIlkzJu1TYTIrjr9XqYYzRI4uwTFcao4N1YSjhmCAvg== X-Received: by 2002:a17:902:1602:: with SMTP id g2mr2193919plg.325.1555537507600; Wed, 17 Apr 2019 14:45:07 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:06 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 11/34] qla2xxx: Log the status code if a firmware command fails Date: Wed, 17 Apr 2019 14:44:20 -0700 Message-Id: <20190417214443.243152-12-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is important to know why a firmware command failed. Hence log 'rval' together with the values of the mailbox registers if a firwmare command fails. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_mbx.c | 4 ++-- drivers/scsi/qla2xxx/qla_mr.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 682a26157311..133f5f6270ff 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -567,9 +567,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) mcp->mb[0]); } else if (rval) { if (ql2xextended_error_logging & (ql_dbg_disc|ql_dbg_mbx)) { - pr_warn("%s [%s]-%04x:%ld: **** Failed", QL_MSGHDR, + pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR, dev_name(&ha->pdev->dev), 0x1020+0x800, - vha->host_no); + vha->host_no, rval); mboxes = mcp->in_mb; cnt = 4; for (i = 0; i < ha->mbx_count && cnt; i++, mboxes >>= 1) diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index 505936e3ec28..783f24db89f7 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -273,9 +273,9 @@ qlafx00_mailbox_command(scsi_qla_host_t *vha, struct mbx_cmd_32 *mcp) if (rval) { ql_log(ql_log_warn, base_vha, 0x1163, - "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, " - "mb[3]=%x, cmd=%x ****.\n", - mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], command); + "**** Failed=%x mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n", + rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], + command); } else { ql_dbg(ql_dbg_mbx, base_vha, 0x1164, "Done %s.\n", __func__); } From patchwork Wed Apr 17 21:44:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF1D317E6 for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC18228A96 for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD7D628BB0; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C886028A96 for ; Wed, 17 Apr 2019 21:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387930AbfDQVpP (ORCPT ); Wed, 17 Apr 2019 17:45:15 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41992 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387564AbfDQVpJ (ORCPT ); Wed, 17 Apr 2019 17:45:09 -0400 Received: by mail-pl1-f196.google.com with SMTP id cv12so107205plb.9 for ; Wed, 17 Apr 2019 14:45:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xUvuSWWNU0dv9WWwbLZDcuhLrweaG0JkwgMwzhLnhDQ=; b=GfRPAvc2t8Jzb7o59ll64ti0vvzwQfGP9T3P2UHfVhz6wXIdVQ6LQhY37iaaCPyT1Z JXYyyhOzi4TpFHIs64IlrWKMtqD+vHugoKcF2nF6PUYJCP3SBeuI0r56TLJnXE+4Rb8k afGNsKk0eKdAVfdE4UpzARQERnwF4BE6eFaeDdniTeQQ2BOlmlbe0OzX78zE5HYhHfQ5 E7jYcppN1WbPiUnjgmeAL1mKYqdTH9Xtn4kBWtRYGH06W+kX3Pm1IN7yoiEV5lu3U2YD uFeV9hmESM6b99QXxjcV9XoGWGUdY6473mv85J7Z5OtTkmp9RUji0Z5vC8dnJ5plmOPV adyg== X-Gm-Message-State: APjAAAWnKbLnoiOgT1D6JCub3MPKEnrTTfLCn1/I7zSa8FSz721pD1Os EjurkCdVrv28n+oGmUb2PgY= X-Google-Smtp-Source: APXvYqwy9O7DJDYM93C6hV1RPhnEuAJLP4fhVRvBeKeuY0SvR954mqMiz1NQ1HzR2Xbs+MeSR44blA== X-Received: by 2002:a17:902:bc47:: with SMTP id t7mr66935935plz.122.1555537509069; Wed, 17 Apr 2019 14:45:09 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:07 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 12/34] qla2xxx: Increase the size of the mailbox arrays from 4 to 8 Date: Wed, 17 Apr 2019 14:44:21 -0700 Message-Id: <20190417214443.243152-13-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch avoids that Coverity complains that qla2x00_async_event() writes outside the bounds of the mb[] arrays (MBA_IDC_AEN case). Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_isr.c | 4 ++-- drivers/scsi/qla2xxx/qla_nx.c | 6 +++--- drivers/scsi/qla2xxx/qla_nx2.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 8432ef05f20b..b781e8a47f43 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -49,7 +49,7 @@ qla2100_intr_handler(int irq, void *dev_id) int status; unsigned long iter; uint16_t hccr; - uint16_t mb[4]; + uint16_t mb[8]; struct rsp_que *rsp; unsigned long flags; @@ -168,7 +168,7 @@ qla2300_intr_handler(int irq, void *dev_id) unsigned long iter; uint32_t stat; uint16_t hccr; - uint16_t mb[4]; + uint16_t mb[8]; struct rsp_que *rsp; struct qla_hw_data *ha; unsigned long flags; diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index df1612b19f67..c12db16c3cf4 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -2039,7 +2039,7 @@ qla82xx_intr_handler(int irq, void *dev_id) unsigned long flags; unsigned long iter; uint32_t stat = 0; - uint16_t mb[4]; + uint16_t mb[8]; rsp = (struct rsp_que *) dev_id; if (!rsp) { @@ -2123,7 +2123,7 @@ qla82xx_msix_default(int irq, void *dev_id) unsigned long flags; uint32_t stat = 0; uint32_t host_int = 0; - uint16_t mb[4]; + uint16_t mb[8]; rsp = (struct rsp_que *) dev_id; if (!rsp) { @@ -2219,7 +2219,7 @@ qla82xx_poll(int irq, void *dev_id) int status = 0; uint32_t stat; uint32_t host_int = 0; - uint16_t mb[4]; + uint16_t mb[8]; unsigned long flags; rsp = (struct rsp_que *) dev_id; diff --git a/drivers/scsi/qla2xxx/qla_nx2.c b/drivers/scsi/qla2xxx/qla_nx2.c index 1adc4f3febe8..369ac04d0454 100644 --- a/drivers/scsi/qla2xxx/qla_nx2.c +++ b/drivers/scsi/qla2xxx/qla_nx2.c @@ -3895,7 +3895,7 @@ qla8044_intr_handler(int irq, void *dev_id) unsigned long flags; unsigned long iter; uint32_t stat; - uint16_t mb[4]; + uint16_t mb[8]; uint32_t leg_int_ptr = 0, pf_bit; rsp = (struct rsp_que *) dev_id; From patchwork Wed Apr 17 21:44:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB97B17E0 for ; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C674528BA9 for ; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B809C28A93; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB6428A93 for ; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387751AbfDQVpP (ORCPT ); Wed, 17 Apr 2019 17:45:15 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44952 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387656AbfDQVpL (ORCPT ); Wed, 17 Apr 2019 17:45:11 -0400 Received: by mail-pl1-f194.google.com with SMTP id g12so102426pll.11 for ; Wed, 17 Apr 2019 14:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ccHCb8byTWen+AtqpBNRiioYmSuHrRFsx6GoF0f5yw8=; b=Fm4DlLu0fekW7UGTBlWPMZmmxC+0qBRof8TYxOSSdZ9Fv7so8gYq7J0Evz0uC072C7 8s5NK84+5cPEzxseCaLzpucfYRwPi7dEAFu1CLQDBNeJdtUhZvbH5Z0HybhWanOFqf9q ol+eRD706ERCj7bfyW+y4T5zKdRFJwQv9pV7ZOYBep3iVHnQAwaWb+Ip9IGNJ1CFRfXm 0cW3wim3sWdRqxupD8eNdNJnQRBcCOzlCirTXOUd7nPvodEU/RMdYPQVY06wnFwbMp1B rvLobqRmY3otfiBVb4zIjJVfCbw+gEn+srmxtI8Tc1S/u5a3n4GrlD2SMbSlj7WhR4NS YEvg== X-Gm-Message-State: APjAAAXs07uRXWf66aVRgb5Z086/YtomTH4b8NCE46vKlgSBGDut90Rd KVBT7zJ7XDIX/W08SJIwE3c= X-Google-Smtp-Source: APXvYqxP3m9UuMAOEBjty1BeJcGTxB761as31nXBdOHIsvmcg2jvkheVuHRAN56Wd0jUY6PRdqo5qQ== X-Received: by 2002:a17:902:e182:: with SMTP id cd2mr9875659plb.240.1555537510393; Wed, 17 Apr 2019 14:45:10 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:09 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 13/34] qla2xxx: Make qla2x00_mem_free() easier to verify Date: Wed, 17 Apr 2019 14:44:22 -0700 Message-Id: <20190417214443.243152-14-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of clearing all freed pointers at the end of qla2x00_mem_free(), clear freed pointers immediately after having freed the memory these pointers point at. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 61 ++++++++++++++----------------- drivers/scsi/qla2xxx/qla_target.c | 3 ++ 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 5cfdf0cc3846..b90eed1c989e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4680,28 +4680,37 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->mctp_dump) dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, ha->mctp_dump_dma); + ha->mctp_dump = NULL; mempool_destroy(ha->srb_mempool); + ha->srb_mempool = NULL; if (ha->dcbx_tlv) dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, ha->dcbx_tlv, ha->dcbx_tlv_dma); + ha->dcbx_tlv = NULL; if (ha->xgmac_data) dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, ha->xgmac_data, ha->xgmac_data_dma); + ha->xgmac_data = NULL; if (ha->sns_cmd) dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), ha->sns_cmd, ha->sns_cmd_dma); + ha->sns_cmd = NULL; + ha->sns_cmd_dma = 0; if (ha->ct_sns) dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma); + ha->ct_sns = NULL; + ha->ct_sns_dma = 0; if (ha->sfp_data) dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->sfp_data, ha->sfp_data_dma); + ha->sfp_data = NULL; if (ha->flt) dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, @@ -4709,19 +4718,28 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->ms_iocb) dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); + ha->ms_iocb = NULL; + ha->ms_iocb_dma = 0; if (ha->ex_init_cb) dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); + ha->ex_init_cb = NULL; + ha->ex_init_cb_dma = 0; if (ha->async_pd) dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); + ha->async_pd = NULL; + ha->async_pd_dma = 0; dma_pool_destroy(ha->s_dma_pool); + ha->s_dma_pool = NULL; if (ha->gid_list) dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), ha->gid_list, ha->gid_list_dma); + ha->gid_list = NULL; + ha->gid_list_dma = 0; if (IS_QLA82XX(ha)) { if (!list_empty(&ha->gbl_dsd_list)) { @@ -4739,10 +4757,13 @@ qla2x00_mem_free(struct qla_hw_data *ha) } dma_pool_destroy(ha->dl_dma_pool); + ha->dl_dma_pool = NULL; dma_pool_destroy(ha->fcp_cmnd_dma_pool); + ha->fcp_cmnd_dma_pool = NULL; mempool_destroy(ha->ctx_mempool); + ha->ctx_mempool = NULL; if (ql2xenabledif) { struct dsd_dma *dsd, *nxt; @@ -4775,47 +4796,19 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->init_cb) dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, ha->init_cb_dma); + ha->init_cb = NULL; + ha->init_cb_dma = 0; vfree(ha->optrom_buffer); + ha->optrom_buffer = NULL; kfree(ha->nvram); + ha->nvram = NULL; kfree(ha->npiv_info); + ha->npiv_info = NULL; kfree(ha->swl); + ha->swl = NULL; kfree(ha->loop_id_map); - - ha->srb_mempool = NULL; - ha->ctx_mempool = NULL; - ha->sns_cmd = NULL; - ha->sns_cmd_dma = 0; - ha->ct_sns = NULL; - ha->ct_sns_dma = 0; - ha->ms_iocb = NULL; - ha->ms_iocb_dma = 0; - ha->init_cb = NULL; - ha->init_cb_dma = 0; - ha->ex_init_cb = NULL; - ha->ex_init_cb_dma = 0; - ha->async_pd = NULL; - ha->async_pd_dma = 0; ha->loop_id_map = NULL; - ha->npiv_info = NULL; - ha->optrom_buffer = NULL; - ha->swl = NULL; - ha->nvram = NULL; - ha->mctp_dump = NULL; - ha->dcbx_tlv = NULL; - ha->xgmac_data = NULL; - ha->sfp_data = NULL; - - ha->s_dma_pool = NULL; - ha->dl_dma_pool = NULL; - ha->fcp_cmnd_dma_pool = NULL; - - ha->gid_list = NULL; - ha->gid_list_dma = 0; - - ha->tgt.atio_ring = NULL; - ha->tgt.atio_dma = 0; - ha->tgt.tgt_vp_map = NULL; } struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index e5707ffdaefe..f25535fb30f5 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -7347,7 +7347,10 @@ qlt_mem_free(struct qla_hw_data *ha) sizeof(struct atio_from_isp), ha->tgt.atio_ring, ha->tgt.atio_dma); } + ha->tgt.atio_ring = NULL; + ha->tgt.atio_dma = 0; kfree(ha->tgt.tgt_vp_map); + ha->tgt.tgt_vp_map = NULL; } /* vport_slock to be held by the caller */ From patchwork Wed Apr 17 21:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E5621390 for ; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AD6028A93 for ; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F53728BAA; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21BA628A93 for ; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387931AbfDQVpN (ORCPT ); Wed, 17 Apr 2019 17:45:13 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43396 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387928AbfDQVpM (ORCPT ); Wed, 17 Apr 2019 17:45:12 -0400 Received: by mail-pg1-f193.google.com with SMTP id z9so141254pgu.10 for ; Wed, 17 Apr 2019 14:45:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G+W1R4QhuYvCkvm9QmQ0c7+um7CKrbU5VKvEfoFqdko=; b=tVgtaHK3lO+OrP8igDOGXaIoHHZNIouIOuYRRsyEJTAityImsK8PuZPr49UJk12Zit RBtSBsgKT5CcdK2pV/W6o6dSaBMe/xPTFb7R5jbLCG/h9kbCq6ROEtksFSdUyWqd67Nf boeZSk/rX7+3r8GZBS5pJvTOd7946nW0We3p0/WKM8GvNI9pPyY56fX0jwSLjdb4EYVb b4RW8Sd8Ugbt9klnpSRA408/G8Cz/Wd0GW9w/DvXDD135TZDfOIsvdTVS0IFlsQ7d7rN O7vlNFYZxoeIotPYNTqZAQIWU4ztMlTQlg5jzEadqtWtKBUhF3awPww6RjSeLm7XMkGU U3Dw== X-Gm-Message-State: APjAAAVQSeFn8kJqQjcK2eAVzT9srH6F7aWpNZxA+axSTjuhOWZKgx5h VG+dZKcUUxiun4zeYOqOklcgH0uw X-Google-Smtp-Source: APXvYqxzxCAgi1KbN3zuzYgEC3AyuQPVoWM+/J+uuEhZha+FxnyOsLInteUJOiMa62MrmAHEhb4lug== X-Received: by 2002:a65:5682:: with SMTP id v2mr86278429pgs.100.1555537511521; Wed, 17 Apr 2019 14:45:11 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:10 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 14/34] qla2xxx: Avoid that qla2x00_mem_free() crashes if called twice Date: Wed, 17 Apr 2019 14:44:23 -0700 Message-Id: <20190417214443.243152-15-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clear each pointer after having freed memory such that it becomes safe to call qla2x00_mem_free() twice. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b90eed1c989e..6d5dfe12760e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4715,6 +4715,8 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->flt) dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE, ha->flt, ha->flt_dma); + ha->flt = NULL; + ha->flt_dma = 0; if (ha->ms_iocb) dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); @@ -4790,6 +4792,7 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->dif_bundl_pool) dma_pool_destroy(ha->dif_bundl_pool); + ha->dif_bundl_pool = NULL; qlt_mem_free(ha); From patchwork Wed Apr 17 21:44:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CA8E17E0 for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5867E28BA9 for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CEB528BAB; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F11528BA9 for ; Wed, 17 Apr 2019 21:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387933AbfDQVpO (ORCPT ); Wed, 17 Apr 2019 17:45:14 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36384 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387930AbfDQVpN (ORCPT ); Wed, 17 Apr 2019 17:45:13 -0400 Received: by mail-pf1-f194.google.com with SMTP id z5so85793pfn.3 for ; Wed, 17 Apr 2019 14:45:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XKaokxoVqlt5goo8vGv5KMc+20acV1pgBEpTlqDpgRM=; b=qEomINi7eSqaXz0rll0obj4miHPx5XuqnyFrNMZp831zZBzE7uQetlaLzsQnIILod2 kQvWJTMlXmTV6DSqViJkfYsA1+NTaRJ5opKzcphH4+5xHw1z2VuOb6KYC2SUr/Rc9b18 Zff6M9wUmZBVze5Zlms8Llm3HhLYq3crIn9l9SOnp1KKh6Bmq8uxrUitJgCtZlxKGQw2 s1mmhrkxvMEYyv99HQnD5mudaWNVSHy1bUri78gnJXvPwCqkk7QIJrnLT4qnJn2nFiRd s0MBdUnoOAZMwq6M4+3ufiGi7WMSCDYhEynah6Kp+A7Trp5Lltv7oBJLVOmvycdLOS2A QZ7Q== X-Gm-Message-State: APjAAAUt7f2vNPBYnjXQM7KCfMjIusmrVMvynbWQr15r52gFEp24Dm+0 XrM6ZYCjGl3XbJmOeFlzs8Y= X-Google-Smtp-Source: APXvYqxOIvk43Knm9yqIs+lkf4HHF/J+QzzQtauiGZY2f4lonQKzACsjWcJYcEfDvvc8tbcSrrfmmg== X-Received: by 2002:a63:5b24:: with SMTP id p36mr40394975pgb.84.1555537512743; Wed, 17 Apr 2019 14:45:12 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:11 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 15/34] qla2xxx: Fix a qla24xx_enable_msix() error path Date: Wed, 17 Apr 2019 14:44:24 -0700 Message-Id: <20190417214443.243152-16-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure that the allocated interrupts are freed if allocating memory for the msix_entries array fails. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_isr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index b781e8a47f43..b015b405fdd9 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -3499,7 +3499,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) ql_log(ql_log_fatal, vha, 0x00c8, "Failed to allocate memory for ha->msix_entries.\n"); ret = -ENOMEM; - goto msix_out; + goto free_irqs; } ha->flags.msix_enabled = 1; @@ -3582,6 +3582,10 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) msix_out: return ret; + +free_irqs: + pci_free_irq_vectors(ha->pdev); + goto msix_out; } int From patchwork Wed Apr 17 21:44:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3914A17E6 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22B2428A93 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 174B128BA9; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACB7928A96 for ; Wed, 17 Apr 2019 21:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387921AbfDQVpS (ORCPT ); Wed, 17 Apr 2019 17:45:18 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38514 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387932AbfDQVpO (ORCPT ); Wed, 17 Apr 2019 17:45:14 -0400 Received: by mail-pl1-f196.google.com with SMTP id f36so117237plb.5 for ; Wed, 17 Apr 2019 14:45:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b++NJig8e+kc5pKOfWUnELU6TXGMORE5rsZuVwS+rTk=; b=kuBxQX0AU+tBHKpQHwv90+CugP5mqqWgXLgL0pEmwFfO0B+TEIGmSftiuqWr9S9jxp WgmeX+qqEJ+AgwQJZYNsEdOsOeIgMRoxec4xMbwUGKaK6t2IwGreZVMLW/lPDe+V4u7B uylT9aGONuTkAnWOAt/MO5plaYEMORWRP4XmYfHdLoyL+3+MUj0PvMV66uEwtFiJF49n vdHsaUfl6aQ1whNGRyMFuB1jRqL8/vq8zffBlCh7oLOzOa8s+5Wc9+82HysTVovq7aaD V5Lqes8wOFSj8egK2dvHJ2UJi8Grnexd/cUYYlpTyBs5pVzVhNVVVLhPhKHMHBmsI+iM xGPg== X-Gm-Message-State: APjAAAWScrmHexP9dz4iOtDwRHOISi3dWq6VcnznFX9i5faQJgj2D94T t62+mMDDxrR3DxJrpGRSGeqWnqw/ X-Google-Smtp-Source: APXvYqx6JuAadTMQ7aiADYA+GHsjNpkN9pCftGwW+KZ6nJwizJttO010pZLmUCYLemsgEtppvG9BHQ== X-Received: by 2002:a17:902:a583:: with SMTP id az3mr92153752plb.205.1555537513921; Wed, 17 Apr 2019 14:45:13 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:13 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 16/34] qla2xxx: Fix use-after-free issues in qla2xxx_qpair_sp_free_dma() Date: Wed, 17 Apr 2019 14:44:25 -0700 Message-Id: <20190417214443.243152-17-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current order for freeing memory is as follows: - struct crc_context itself. - struct crc_context member pointers. Change the freeing order into the following: - struct crc_context member pointers. - struct crc_context itself. Detected by Coverity. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: 50b812755e97 ("scsi: qla2xxx: Fix DMA error when the DIF sg buffer crosses 4GB boundary") # v5.1-rc1. Fixes: d74595278f4a ("scsi: qla2xxx: Add multiple queue pair functionality.") # v4.10. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 6d5dfe12760e..4fc1474c5a26 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -764,25 +764,8 @@ qla2xxx_qpair_sp_free_dma(void *ptr) sp->flags &= ~SRB_CRC_CTX_DSD_VALID; } - if (sp->flags & SRB_CRC_CTX_DMA_VALID) { - struct crc_context *ctx0 = ctx; - - dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); - sp->flags &= ~SRB_CRC_CTX_DMA_VALID; - } - - if (sp->flags & SRB_FCP_CMND_DMA_VALID) { - struct ct6_dsd *ctx1 = ctx; - dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, - ctx1->fcp_cmnd_dma); - list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); - ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; - ha->gbl_dsd_avail += ctx1->dsd_use_cnt; - mempool_free(ctx1, ha->ctx_mempool); - sp->flags &= ~SRB_FCP_CMND_DMA_VALID; - } if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) { - struct crc_context *difctx = sp->u.scmd.ctx; + struct crc_context *difctx = ctx; struct dsd_dma *dif_dsd, *nxt_dsd; list_for_each_entry_safe(dif_dsd, nxt_dsd, @@ -816,6 +799,25 @@ qla2xxx_qpair_sp_free_dma(void *ptr) } sp->flags &= ~SRB_DIF_BUNDL_DMA_VALID; } + + if (sp->flags & SRB_FCP_CMND_DMA_VALID) { + struct ct6_dsd *ctx1 = ctx; + + dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, + ctx1->fcp_cmnd_dma); + list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); + ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; + ha->gbl_dsd_avail += ctx1->dsd_use_cnt; + mempool_free(ctx1, ha->ctx_mempool); + sp->flags &= ~SRB_FCP_CMND_DMA_VALID; + } + + if (sp->flags & SRB_CRC_CTX_DMA_VALID) { + struct crc_context *ctx0 = ctx; + + dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); + sp->flags &= ~SRB_CRC_CTX_DMA_VALID; + } } void From patchwork Wed Apr 17 21:44:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A4B71390 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45DB428A93 for ; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39F9D28BAB; Wed, 17 Apr 2019 21:45:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6008D28BAC for ; Wed, 17 Apr 2019 21:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387667AbfDQVpQ (ORCPT ); Wed, 17 Apr 2019 17:45:16 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41267 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387635AbfDQVpP (ORCPT ); Wed, 17 Apr 2019 17:45:15 -0400 Received: by mail-pl1-f196.google.com with SMTP id d1so109641plj.8 for ; Wed, 17 Apr 2019 14:45:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tbyMkZxJBbvz4bqMG98IB6XToDHzHvJi/lZkfpKAJaE=; b=A+pMEt6eyNY5k8xI+hRIjKa5FC81CZ1uHsB/yCIZx6a0Ch7ommUg4kRCKVCeJgQYaT SwfLzkRn+pLiXwldYS9N6k/h6ePCynkfbNICW3nWYo6GwQQkXPZ68dTrId7n7OW+niYi nfuFP91LUtq1hTt6Ac4mvNFjEVDnH7rlREiEaATvwU1WgIv1+Mih5PQS6gjLqSIZgj0Q R1TelTgpN4PXN1mdHw4Z/kcjBjqZE/1AYFFix7Jg5NfPlU2/DoLqQ5phrHHb7Xj78NRC iN1TLs6GTn0BMLSdipl3jKpq5wJHa2325m7SwuqUMF8FR4X9X5wywLrVHx0GHVoicqEE MC5g== X-Gm-Message-State: APjAAAX4BiqGiuCyCAATtmh6b9SAVepUn+W9IvpGZGr8X4rYpVV3Umk0 Ipz4azgSfyYhMQGMR2hNFOw= X-Google-Smtp-Source: APXvYqxcOte9HYJs+sbjDrZaxjlGAOsaEmLJ9E35Z2DZNZnr2gZFDprlpnRfJOLFlJKsOmFCwiS7GQ== X-Received: by 2002:a17:902:1621:: with SMTP id g30mr59040428plg.168.1555537515058; Wed, 17 Apr 2019 14:45:15 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:14 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 17/34] qla2xxx: Simplify qlt_send_term_imm_notif() Date: Wed, 17 Apr 2019 14:44:26 -0700 Message-Id: <20190417214443.243152-18-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All qlt_send_term_imm_notif() callers pass '1' as second argument to this function. Hence remove the (broken) code that depends on that second argument having another value. Add a pr_debug() statement that prints rc to avoid that the compiler would complain that rc has been set but is not used. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index f25535fb30f5..69fc29d7e59d 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3651,33 +3651,11 @@ static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha, static void qlt_send_term_imm_notif(struct scsi_qla_host *vha, struct imm_ntfy_from_isp *imm, int ha_locked) { - unsigned long flags = 0; int rc; - if (ha_locked) { - rc = __qlt_send_term_imm_notif(vha, imm); - -#if 0 /* Todo */ - if (rc == -ENOMEM) - qlt_alloc_qfull_cmd(vha, imm, 0, 0); -#else - if (rc) { - } -#endif - goto done; - } - - spin_lock_irqsave(&vha->hw->hardware_lock, flags); + WARN_ON_ONCE(!ha_locked); rc = __qlt_send_term_imm_notif(vha, imm); - -#if 0 /* Todo */ - if (rc == -ENOMEM) - qlt_alloc_qfull_cmd(vha, imm, 0, 0); -#endif - -done: - if (!ha_locked) - spin_unlock_irqrestore(&vha->hw->hardware_lock, flags); + pr_debug("rc = %d\n", rc); } /* From patchwork Wed Apr 17 21:44:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11BA01390 for ; Wed, 17 Apr 2019 21:45:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B6B28A93 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E62A628BAC; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C3528A96 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387791AbfDQVpT (ORCPT ); Wed, 17 Apr 2019 17:45:19 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33656 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387761AbfDQVpR (ORCPT ); Wed, 17 Apr 2019 17:45:17 -0400 Received: by mail-pg1-f194.google.com with SMTP id k19so164670pgh.0 for ; Wed, 17 Apr 2019 14:45:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lugG6B8yBp/cm6LJRo01MraCQrLx2xInxC7bC//5+Mk=; b=tYv9Z0n8gZHoWmnYhlOIbVWxGofBXgl2au61luZNYsUVAHcYSRdQz2xn9rQXPaCmK2 8dVSLrjUkNBtT1Wyv/Gorc4hiMTg7ADwocjBV58Kr41+JxU9mHNtwVWp78KVrlbZoaWL 80Al5t48j+RE7ohPjY3XEMIQVAyHxHWDHmbS1N66IsiUJjA6Pr/4TDG2n8kajFsruBPG RfJwys2VXylbNBH77wZoHGo3b8ZvPPhEpY7diHJhw05BWv3nMp80LigfBmqZHrROJsNx nhRZXmFDbkHOdHUi4jJ+i4YP3vCU8fCUzMtIWQDiB8h9CBkzinmPtmHcv1HBIqBzucy8 fSAw== X-Gm-Message-State: APjAAAVFxGL5f3K7JGbtfbTllk5SHrrRiQ/PFZqZE5TGuG+r6Yecwi7v O/r5LVAsPYRuCrBJMsuiDuQ= X-Google-Smtp-Source: APXvYqxiiPebHiF8uzZ/q+Ouh+iNOp5S/h+WuG/JjEyW3RzisDTJX9MROCfPIBccfRK5F5T9cIL/ng== X-Received: by 2002:aa7:9389:: with SMTP id t9mr93312769pfe.60.1555537516365; Wed, 17 Apr 2019 14:45:16 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:15 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 18/34] qla2xxx: Fix error handling in qlt_alloc_qfull_cmd() Date: Wed, 17 Apr 2019 14:44:27 -0700 Message-Id: <20190417214443.243152-19-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test "if (!cmd)" is not useful because it is guaranteed that cmd != NULL. Instead of testing the cmd pointer, rely on the tag to decide whether or not command allocation failed. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: 33e799775593 ("qla2xxx: Add support for QFull throttling and Term Exchange retry") # v3.18. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 69fc29d7e59d..144bdec9ddd2 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -5481,11 +5481,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha, se_sess = sess->se_sess; tag = sbitmap_queue_get(&se_sess->sess_tag_pool, &cpu); - if (tag < 0) - return; - - cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag]; - if (!cmd) { + if (tag < 0) { ql_dbg(ql_dbg_io, vha, 0x3009, "qla_target(%d): %s: Allocation of cmd failed\n", vha->vp_idx, __func__); @@ -5500,6 +5496,7 @@ qlt_alloc_qfull_cmd(struct scsi_qla_host *vha, return; } + cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag]; memset(cmd, 0, sizeof(struct qla_tgt_cmd)); qlt_incr_num_pend_cmds(vha); From patchwork Wed Apr 17 21:44:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EF0E17E0 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BDAD28A93 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 004E928BA9; Wed, 17 Apr 2019 21:45:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3E6028A93 for ; Wed, 17 Apr 2019 21:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387932AbfDQVpT (ORCPT ); Wed, 17 Apr 2019 17:45:19 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38789 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387771AbfDQVpS (ORCPT ); Wed, 17 Apr 2019 17:45:18 -0400 Received: by mail-pg1-f194.google.com with SMTP id j26so153296pgl.5 for ; Wed, 17 Apr 2019 14:45:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3DKIuX7PsnJet2S2kE8Dp1GCUf5mU3cMtRQjfCZYUaU=; b=YS0KqJYeBwF8zVfgI/lo3Si7/lplP9/VZ8TRkwvgQXbFpKXIE38ZYlvs1j7NczwsH7 tQQeh515RBSvYPRCqxfBPPpZyiJLWEIq9SCU9CyQZFT6eTH0qSoB/fQVwyhLgUf4K+CL hlVqQlMy5HCVJhniOi6QadRbXWKHzFzvMUwvOE6yE1isZhUJaPo2CXK0lns4Z1V7Lhg9 P8qon+jb1rqUxcI6tOsQUlgqPlgEx+wjrwJXW7qenwE8sgEzAoQRqRZC7qN6P4GV9KbL PwPgxxoyHA/qMq8jSu5/4Y8I43pOxdvNs8BCurM9lbf+z3DhTRU+0YEtWL+ScJRzNJsw rMPw== X-Gm-Message-State: APjAAAVUAa4m0ompnziDfwXHwLBGNWPQkWuoIdUyVId4aEqHB5SN7g9f 2GVY7w13w3sUW3qAv7lpgGQ= X-Google-Smtp-Source: APXvYqz2zf+1CeYypKEC/27IcY8qSWg4c5Uzw40qXYcLkLcwvcZ+kn+jUUvIrgF6IJ28f//Mq7VYeg== X-Received: by 2002:a62:5f84:: with SMTP id t126mr91758531pfb.185.1555537517479; Wed, 17 Apr 2019 14:45:17 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:16 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 19/34] qla2xxx: Fix abort handling in tcm_qla2xxx_write_pending() Date: Wed, 17 Apr 2019 14:44:28 -0700 Message-Id: <20190417214443.243152-20-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implementations of the .write_pending() callback functions must guarantee that an approprite LIO core callback function will be called immediately or at a later time. Make sure that this guarantee is met for aborted SCSI commands. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: 694833ee00c4 ("scsi: tcm_qla2xxx: Do not allow aborted cmd to advance.") # v4.13. Fixes: a07100e00ac4 ("qla2xxx: Fix TMR ABORT interaction issue between qla2xxx and TCM") # v4.5. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index eb19ad845bc9..0ef332cfb112 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -394,6 +394,8 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd) cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); + transport_generic_request_failure(&cmd->se_cmd, + TCM_CHECK_CONDITION_ABORT_CMD); return 0; } cmd->trc_flags |= TRC_XFR_RDY; From patchwork Wed Apr 17 21:44:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F044E17E0 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8F2728BA9 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD61028BAA; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4441D28A93 for ; Wed, 17 Apr 2019 21:45:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387935AbfDQVpU (ORCPT ); Wed, 17 Apr 2019 17:45:20 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36908 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387783AbfDQVpT (ORCPT ); Wed, 17 Apr 2019 17:45:19 -0400 Received: by mail-pl1-f196.google.com with SMTP id w23so119817ply.4 for ; Wed, 17 Apr 2019 14:45:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SEA3bqOntzYKdpeU67w6LXWdrPobZIUJAcapkMnPRdU=; b=gtqCq6X0A5kUBBoDGJIzFOXdBLiM2TPV3BxQMj31T4OYFzdghquffFZixyOMPuNOCO 7y88uEyc31u5iq3sH9e4DxwevxIn9zCE0925M3pnIgzrdMqrRbvryT/EhY0BSejQWYTE oxPcvqioXfhIcjG19J70h9JcfDHlTQ57gEy1MPJM6GnmWvvDSDysryPY/qgG7H6683z2 7TeBL54unZfBnYL2W9k16SuhhXrCzzNH+r+ExKuH0O80sKpMd8YGnQ4FcIAIjNr4hnZS yEW/enZA97uEYpKGzxXstoqBm3fH7IXtznX/ElusnSuson8b9OHagO47rTypiEPgdbXk lf+g== X-Gm-Message-State: APjAAAV/jdi9TobcRHXnFE5H/lM4LkGn4utOU5B0kBOyThkDMiuPk26t AicV6AGPFQMTmhx0XNxwLJc= X-Google-Smtp-Source: APXvYqwcjzfTILGa+t1vpkyALXMHdaF2ranRgCYPETVb0w2WSB4CATg9mHBbrDH3NFtZGkr6auuybA== X-Received: by 2002:a17:902:7b97:: with SMTP id w23mr2264147pll.335.1555537518773; Wed, 17 Apr 2019 14:45:18 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:18 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Arun Easi , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 20/34] qla2xxx, target: Fix offline port handling and host reset handling Date: Wed, 17 Apr 2019 14:44:29 -0700 Message-Id: <20190417214443.243152-21-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the function qlt_abort_cmd_on_host_reset() because it can do the following, all of which can cause a kernel crash: - DMA unmapping while DMA is in progress. - Call target_execute_cmd() while DMA is in progress. - Call transport_generic_free_cmd() while the LIO core owns a command. Instead of trying to abort a command asynchronously, set the 'aborted' flag and handle the abort after the hardware has passed control back to the tcm_qla2xxx driver. Cc: Arun Easi Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: c0cb44967b4a ("qla2xxx: Add Host reset handling in target mode.") # v3.18. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 9 ++----- drivers/scsi/qla2xxx/qla_target.c | 41 +++--------------------------- drivers/scsi/qla2xxx/qla_target.h | 11 +++++--- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 3 ++- 4 files changed, 16 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 4fc1474c5a26..a41aaf071b52 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1837,15 +1837,10 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) continue; } cmd = (struct qla_tgt_cmd *)sp; - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); + cmd->aborted = 1; break; case TYPE_TGT_TMCMD: - /* - * Currently, only ABTS response gets on the - * outstanding_cmds[] - */ - ha->tgt.tgt_ops->free_mcmd( - (struct qla_tgt_mgmt_cmd *)sp); + /* Skip task management functions. */ break; default: break; diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 144bdec9ddd2..72d12286e6ce 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3268,7 +3268,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || (cmd->sess && cmd->sess->deleted)) { cmd->state = QLA_TGT_STATE_PROCESSED; - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); return 0; } @@ -3297,7 +3296,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, * previous life, just abort the processing. */ cmd->state = QLA_TGT_STATE_PROCESSED; - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); ql_dbg_qp(ql_dbg_async, qpair, 0xe101, "RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n", vha->flags.online, qla2x00_reset_active(vha), @@ -3438,8 +3436,10 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) * Either the port is not online or this request was from * previous life, just abort the processing. */ - cmd->state = QLA_TGT_STATE_NEED_DATA; - qlt_abort_cmd_on_host_reset(cmd->vha, cmd); + cmd->aborted = 1; + cmd->write_data_transferred = 0; + cmd->state = QLA_TGT_STATE_DATA_IN; + vha->hw->tgt.tgt_ops->handle_data(cmd); ql_dbg_qp(ql_dbg_async, qpair, 0xe102, "RESET-XFR online/active/old-count/new-count = %d/%d/%d/%d.\n", vha->flags.online, qla2x00_reset_active(vha), @@ -3961,39 +3961,6 @@ static void *qlt_ctio_to_cmd(struct scsi_qla_host *vha, return cmd; } -/* hardware_lock should be held by caller. */ -void -qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd) -{ - struct qla_hw_data *ha = vha->hw; - - if (cmd->sg_mapped) - qlt_unmap_sg(vha, cmd); - - /* TODO: fix debug message type and ids. */ - if (cmd->state == QLA_TGT_STATE_PROCESSED) { - ql_dbg(ql_dbg_io, vha, 0xff00, - "HOST-ABORT: state=PROCESSED.\n"); - } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) { - cmd->write_data_transferred = 0; - cmd->state = QLA_TGT_STATE_DATA_IN; - - ql_dbg(ql_dbg_io, vha, 0xff01, - "HOST-ABORT: state=DATA_IN.\n"); - - ha->tgt.tgt_ops->handle_data(cmd); - return; - } else { - ql_dbg(ql_dbg_io, vha, 0xff03, - "HOST-ABORT: state=BAD(%d).\n", - cmd->state); - dump_stack(); - } - - cmd->trc_flags |= TRC_FLUSH; - ha->tgt.tgt_ops->free_cmd(cmd); -} - /* * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire */ diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 727dd52963c2..8fb197a4d740 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -889,9 +889,16 @@ struct qla_tgt_cmd { unsigned int term_exchg:1; unsigned int cmd_sent_to_fw:1; unsigned int cmd_in_wq:1; - unsigned int aborted:1; unsigned int released:1; + /* + * This variable may be set from outside the LIO and I/O completion + * callback functions. Do not declare this member variable as a + * bitfield to avoid a read-modify-write operation when this variable + * is set. + */ + unsigned int aborted; + struct scatterlist *sg; /* cmd data buffer SG vector */ int sg_cnt; /* SG segments count */ int bufflen; /* cmd buffer length */ @@ -1101,7 +1108,5 @@ extern void qlt_do_generation_tick(struct scsi_qla_host *, int *); void qlt_send_resp_ctio(struct qla_qpair *, struct qla_tgt_cmd *, uint8_t, uint8_t, uint8_t, uint8_t); -extern void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *, - struct qla_tgt_cmd *); #endif /* __QLA_TARGET_H */ diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 0ef332cfb112..38eaee6be127 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -505,7 +505,8 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) if (cmd->aborted) { spin_unlock_irqrestore(&cmd->cmd_lock, flags); - tcm_qla2xxx_free_cmd(cmd); + transport_generic_request_failure(&cmd->se_cmd, + TCM_CHECK_CONDITION_ABORT_CMD); return; } spin_unlock_irqrestore(&cmd->cmd_lock, flags); From patchwork Wed Apr 17 21:44:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CEBB1390 for ; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6809C28A93 for ; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C5AE28BA9; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A88A28A93 for ; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387942AbfDQVpZ (ORCPT ); Wed, 17 Apr 2019 17:45:25 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38220 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387936AbfDQVpU (ORCPT ); Wed, 17 Apr 2019 17:45:20 -0400 Received: by mail-pf1-f196.google.com with SMTP id 10so81926pfo.5 for ; Wed, 17 Apr 2019 14:45:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RUXS3QJeHlU6u83GrujViMiZrlRAsTS9n7kot8UwBoQ=; b=FjA62bWlp9Q/XM2CewMHBRtm5SLaqIKvfonkmT1ebvaikUsP0ZrGkjTwX+aXfzfoud ltxzEVpHpKUUJpUhnp3rvIrDmZTfm9u+KY1kWc/qgxTzFGzr0m6DY3ddo6dVVAtCZvOK URmZyLOwSWe/sRuGkpso8XevhVQOKHA1JtMZlUVuFRygGdY/bXqxQobVUHtrKwvjfy8W B8u5BlBwXObY5a0F38WI5tzyFdqXDw4PtA0lxQbLgB7dnnvURXU9KLhPZjlfr0Th7HIQ OWZ02/Gmr8b6AbAl5HwAhcfmKYTA3NxfU8BJxytA2mrxk909yZxgwzZhapshsVoPnp3E TAiw== X-Gm-Message-State: APjAAAUdCb3/+pgTgwweMGvn3oKaPx99rBTJUpCGM5AnrPCZYLEGFijy /uQWUcQomzJ0J05iip6dmWc= X-Google-Smtp-Source: APXvYqx1rDnEea1x/VKzDJjd8Wn0FrRtO+9cNSk759nG06b9GeSXbSD5YqiC+q4NbyrCDd3L3N1nVw== X-Received: by 2002:a62:6ec6:: with SMTP id j189mr10505103pfc.195.1555537520091; Wed, 17 Apr 2019 14:45:20 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:19 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 21/34] qla2xxx: Complain if a command is released that is owned by the firmware Date: Wed, 17 Apr 2019 14:44:30 -0700 Message-Id: <20190417214443.243152-22-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The previous patch guarantees that a command is only released after the firmware has finished processing it. Hence complain if a command is released that is owned by the firmware. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 38eaee6be127..4fcae1af2d63 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -321,7 +321,6 @@ static int tcm_qla2xxx_check_stop_free(struct se_cmd *se_cmd) static void tcm_qla2xxx_release_cmd(struct se_cmd *se_cmd) { struct qla_tgt_cmd *cmd; - unsigned long flags; if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) { struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd, @@ -331,14 +330,10 @@ static void tcm_qla2xxx_release_cmd(struct se_cmd *se_cmd) } cmd = container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - spin_lock_irqsave(&cmd->cmd_lock, flags); - if (cmd->cmd_sent_to_fw) { - cmd->released = 1; - spin_unlock_irqrestore(&cmd->cmd_lock, flags); - } else { - spin_unlock_irqrestore(&cmd->cmd_lock, flags); - qlt_free_cmd(cmd); - } + if (WARN_ON(cmd->cmd_sent_to_fw)) + return; + + qlt_free_cmd(cmd); } static void tcm_qla2xxx_release_session(struct kref *kref) From patchwork Wed Apr 17 21:44:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CFC817E6 for ; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 080F628A93 for ; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F044128BA9; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 940CA28A93 for ; Wed, 17 Apr 2019 21:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387940AbfDQVpY (ORCPT ); Wed, 17 Apr 2019 17:45:24 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35441 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387790AbfDQVpV (ORCPT ); Wed, 17 Apr 2019 17:45:21 -0400 Received: by mail-pf1-f196.google.com with SMTP id t21so88350pfh.2 for ; Wed, 17 Apr 2019 14:45:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gARxyKpfYyRwj7cmkjcfDh93vFm/0nbvIPOSrb8vVHc=; b=bY4CyDzpS4hjuO3uXAnZ5jnaEuikt2YPO01kllHsnBjk1eIu1D6ZByUbCHkwLLLAc4 brc6TtPuUZYu/yhfIe3q1J/eb0WUuoMhVSmBJIQi4VXKKWmmLbpocx9R8fOAaaO+2DcX 9yavK+py+mLSfhocV04kK96o/A/vh8QlPwr7YdohisxtXM2vsQO8M2V8rxrWT/b/LFoB jytU+4jI/v4pxTIhWI5BXVgF/9fEgmcmjviNx7SomClYCtipVZph0MdOFEQ32Vuvx/FK quLtY+n/FF4hHxlD/UlPM2ZwRF945vsbXqFh7B6grW3mwZz/PFen0D9US8jomBL07bnP WWpg== X-Gm-Message-State: APjAAAVhlVoSlX7eA3L0NLy7fGXbTdq6z+V7c2TEwSiZnLxsM+hpzM7w V7d5DQGfxvyNRJJTEmiDpK8= X-Google-Smtp-Source: APXvYqxsb/gmodedoWXlgFVR1KCexWz32V7Er9Sm24bV+aOik0UfwjzX8rdre2iRlz+NslRi/QmLsQ== X-Received: by 2002:a65:64c8:: with SMTP id t8mr84230809pgv.248.1555537521192; Wed, 17 Apr 2019 14:45:21 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:20 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 22/34] qla2xxx: Remove qla_tgt_cmd.released Date: Wed, 17 Apr 2019 14:44:31 -0700 Message-Id: <20190417214443.243152-23-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the previous patch removed the only statement that sets qla_tgt_cmd.released, remove the code that depends on that member variable being set and the member variable itself. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.h | 1 - drivers/scsi/qla2xxx/tcm_qla2xxx.c | 15 +-------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 8fb197a4d740..262fc33fb473 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -889,7 +889,6 @@ struct qla_tgt_cmd { unsigned int term_exchg:1; unsigned int cmd_sent_to_fw:1; unsigned int cmd_in_wq:1; - unsigned int released:1; /* * This variable may be set from outside the LIO and I/O completion diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 4fcae1af2d63..f6797eed320a 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -262,7 +262,6 @@ static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd) static void tcm_qla2xxx_complete_free(struct work_struct *work) { struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work); - bool released = false; unsigned long flags; cmd->cmd_in_wq = 0; @@ -273,14 +272,9 @@ static void tcm_qla2xxx_complete_free(struct work_struct *work) cmd->qpair->tgt_counters.qla_core_ret_sta_ctio++; cmd->trc_flags |= TRC_CMD_FREE; cmd->cmd_sent_to_fw = 0; - if (cmd->released) - released = true; spin_unlock_irqrestore(&cmd->cmd_lock, flags); - if (released) - qlt_free_cmd(cmd); - else - transport_generic_free_cmd(&cmd->se_cmd, 0); + transport_generic_free_cmd(&cmd->se_cmd, 0); } /* @@ -490,13 +484,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) spin_lock_irqsave(&cmd->cmd_lock, flags); cmd->cmd_sent_to_fw = 0; - - if (cmd->released) { - spin_unlock_irqrestore(&cmd->cmd_lock, flags); - qlt_free_cmd(cmd); - return; - } - if (cmd->aborted) { spin_unlock_irqrestore(&cmd->cmd_lock, flags); From patchwork Wed Apr 17 21:44:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2FEE1390 for ; Wed, 17 Apr 2019 21:45:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADCF728A93 for ; Wed, 17 Apr 2019 21:45:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1EE428BA9; Wed, 17 Apr 2019 21:45:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B3D228A93 for ; Wed, 17 Apr 2019 21:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387939AbfDQVpY (ORCPT ); Wed, 17 Apr 2019 17:45:24 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34304 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387937AbfDQVpW (ORCPT ); Wed, 17 Apr 2019 17:45:22 -0400 Received: by mail-pg1-f194.google.com with SMTP id v12so163157pgq.1 for ; Wed, 17 Apr 2019 14:45:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mo3Jfu6woa52VRyMK0S1W04I0Iw9wUnWj0BdgcjiCZk=; b=JkZ5DZ4BFFdMpfgLAEzgO66+N7GVomis3qlkJAzOXOMkVEXBUgh5wHg6qcZqAChKn3 If+vJ9/yym5FCy7KAh3ur8FiYhl5Q3JtyYHz5YxYfHvrxmC+XtWx/0rJgVoBBV79xBqP 2Zy0Ss+Yf+nwKzWYqLkhJ/pwJDq00iD3t8lpEgR1Y5nLhFaPyxijcCbb0pWlaBXH2YWk gO60yfute2HjkYn9yhVc82tK8m5VkV+4rRJfs6hXSw4eJTqLVRkab4V8oiWhcvXdYFaE xLI+2f4ZNXHJ4/gNM+KIWeBgDrcNrPsmx8JOPbWjckJUQ+32j54sYomBjkNGfVAtcpsz UF1A== X-Gm-Message-State: APjAAAUOCTv9cLy8IHdNv/jLs8dmNNb91qPfUZZRdoRX4c25VuJ2JKlk Gub0pbhjxd2cQ/ZltSvZ7oOv4FHl X-Google-Smtp-Source: APXvYqwl7w1gPEY9GcvC3rp9o2ubrh/kgzKdsB0Z8F2a/y8h/8b6f4DNfQmDb2s0Vs+qW/pydQOvqA== X-Received: by 2002:a63:e20b:: with SMTP id q11mr86787634pgh.263.1555537522175; Wed, 17 Apr 2019 14:45:22 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:21 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 23/34] qla2xxx: Remove unnecessary locking from the target code Date: Wed, 17 Apr 2019 14:44:32 -0700 Message-Id: <20190417214443.243152-24-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All callbacks from the target core into the qla2xxx driver and also all I/O completion functions are serialized per command. Since .cmd_sent_to_fw and .trc_flags are only modified from inside these functions it is not necessary to protect it with locking. Remove the superfluous locking. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 4 ---- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 10 +--------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 72d12286e6ce..1ced494d8673 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3387,9 +3387,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, cmd->state = QLA_TGT_STATE_PROCESSED; /* Mid-level is done processing */ - spin_lock(&cmd->cmd_lock); cmd->cmd_sent_to_fw = 1; - spin_unlock(&cmd->cmd_lock); cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); /* Memory Barrier */ @@ -3470,9 +3468,7 @@ int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd) qlt_load_data_segments(&prm); cmd->state = QLA_TGT_STATE_NEED_DATA; - spin_lock(&cmd->cmd_lock); cmd->cmd_sent_to_fw = 1; - spin_unlock(&cmd->cmd_lock); cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); /* Memory Barrier */ diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index f6797eed320a..6334fb9ee2a4 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -262,17 +262,15 @@ static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd) static void tcm_qla2xxx_complete_free(struct work_struct *work) { struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work); - unsigned long flags; cmd->cmd_in_wq = 0; WARN_ON(cmd->trc_flags & TRC_CMD_FREE); - spin_lock_irqsave(&cmd->cmd_lock, flags); + /* To do: protect all tgt_counters manipulations with proper locking. */ cmd->qpair->tgt_counters.qla_core_ret_sta_ctio++; cmd->trc_flags |= TRC_CMD_FREE; cmd->cmd_sent_to_fw = 0; - spin_unlock_irqrestore(&cmd->cmd_lock, flags); transport_generic_free_cmd(&cmd->se_cmd, 0); } @@ -474,24 +472,18 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd, static void tcm_qla2xxx_handle_data_work(struct work_struct *work) { struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work); - unsigned long flags; /* * Ensure that the complete FCP WRITE payload has been received. * Otherwise return an exception via CHECK_CONDITION status. */ cmd->cmd_in_wq = 0; - - spin_lock_irqsave(&cmd->cmd_lock, flags); cmd->cmd_sent_to_fw = 0; if (cmd->aborted) { - spin_unlock_irqrestore(&cmd->cmd_lock, flags); - transport_generic_request_failure(&cmd->se_cmd, TCM_CHECK_CONDITION_ABORT_CMD); return; } - spin_unlock_irqrestore(&cmd->cmd_lock, flags); cmd->qpair->tgt_counters.qla_core_ret_ctio++; if (!cmd->write_data_transferred) { From patchwork Wed Apr 17 21:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C47B517E0 for ; Wed, 17 Apr 2019 21:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AECFC28A93 for ; Wed, 17 Apr 2019 21:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B6C28BA9; Wed, 17 Apr 2019 21:45:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ACDC28A93 for ; Wed, 17 Apr 2019 21:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387943AbfDQVp1 (ORCPT ); Wed, 17 Apr 2019 17:45:27 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42798 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387771AbfDQVpY (ORCPT ); Wed, 17 Apr 2019 17:45:24 -0400 Received: by mail-pg1-f196.google.com with SMTP id p6so144196pgh.9 for ; Wed, 17 Apr 2019 14:45:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nr918DFAKUsYOXDm0ErNkhOiGcjnhJgM06RNssXI7JY=; b=X0PpnmtFGkzcvyiDWGjByGxFW5s3Nkhj/GWyG8eHkDjD6zsz/91RDsCZKL22NLKjCo QFJh5b7iSfYbvyZQkiRqpg6GAf4fnBWqCJ6Dlet/JmiPzb2vRDAk4YtznJKckX3Jg+90 iWTEyAOqNL6dfYcbY1CjrHUXXiA/XRjcQ6T8fndq9N+CR3FFOQXhSByFo37HrEF2+qTS T502bUsv5DErmBCnW3M6naeWyIE2sk5UycocrBW3lc0PNIFhp4MUI/l0wy+q6mDkGr+j VffT2hXZhlbmFTq6Sw9LayJk/zDmvKRlroTlCiquG97ec+GvQGvQwHYYevgTmqDLVbKV gW+Q== X-Gm-Message-State: APjAAAXbl9aKQxflESR38bQEAIeHj0EF8uLJYFQTMPApoRtzCLkvWfci PpjkS6qR7qinL3EOQl+pf/0= X-Google-Smtp-Source: APXvYqzpSAgWPe9eQGNrtFCUUJBHIdO4h3DrX0RhnGoXkrVc/MiYHJ0Jknlkq47jRE1UZupRZ2oX0g== X-Received: by 2002:a63:3284:: with SMTP id y126mr580018pgy.424.1555537523271; Wed, 17 Apr 2019 14:45:23 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:22 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 24/34] qla2xxx: Make qla24xx_async_abort_cmd() static Date: Wed, 17 Apr 2019 14:44:33 -0700 Message-Id: <20190417214443.243152-25-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since qla24xx_async_abort_cmd() is only called from inside qla_init.c, declare that function static. Reorder a few functions to avoid that any forward declarations are needed. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_gbl.h | 1 - drivers/scsi/qla2xxx/qla_init.c | 149 ++++++++++++++++---------------- 2 files changed, 73 insertions(+), 77 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index ac3d418e3990..9c7fbd4da9b8 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -220,7 +220,6 @@ extern void qla24xx_sched_upd_fcport(fc_port_t *); void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *, uint16_t *); int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *); -int qla24xx_async_abort_cmd(srb_t *, bool); int qla24xx_post_relogin_work(struct scsi_qla_host *vha); void qla2x00_wait_for_sess_deletion(scsi_qla_host_t *); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 241ff5ae26f0..8945278ff0be 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -95,6 +95,79 @@ qla2x00_get_async_timeout(struct scsi_qla_host *vha) return tmo; } +static void qla24xx_abort_iocb_timeout(void *data) +{ + srb_t *sp = data; + struct srb_iocb *abt = &sp->u.iocb_cmd; + + abt->u.abt.comp_status = CS_TIMEOUT; + sp->done(sp, QLA_FUNCTION_TIMEOUT); +} + +static void qla24xx_abort_sp_done(void *ptr, int res) +{ + srb_t *sp = ptr; + struct srb_iocb *abt = &sp->u.iocb_cmd; + + if (del_timer(&sp->u.iocb_cmd.timer)) { + if (sp->flags & SRB_WAKEUP_ON_COMP) + complete(&abt->u.abt.comp); + else + sp->free(sp); + } +} + +static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) +{ + scsi_qla_host_t *vha = cmd_sp->vha; + struct srb_iocb *abt_iocb; + srb_t *sp; + int rval = QLA_FUNCTION_FAILED; + + sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, + GFP_ATOMIC); + if (!sp) + goto done; + + abt_iocb = &sp->u.iocb_cmd; + sp->type = SRB_ABT_CMD; + sp->name = "abort"; + sp->qpair = cmd_sp->qpair; + if (wait) + sp->flags = SRB_WAKEUP_ON_COMP; + + abt_iocb->timeout = qla24xx_abort_iocb_timeout; + init_completion(&abt_iocb->u.abt.comp); + /* FW can send 2 x ABTS's timeout/20s */ + qla2x00_init_timer(sp, 42); + + abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; + abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); + + sp->done = qla24xx_abort_sp_done; + + ql_dbg(ql_dbg_async, vha, 0x507c, + "Abort command issued - hdl=%x, type=%x\n", cmd_sp->handle, + cmd_sp->type); + + rval = qla2x00_start_sp(sp); + if (rval != QLA_SUCCESS) + goto done_free_sp; + + if (wait) { + wait_for_completion(&abt_iocb->u.abt.comp); + rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? + QLA_SUCCESS : QLA_FUNCTION_FAILED; + } else { + goto done; + } + +done_free_sp: + sp->free(sp); +done: + return rval; +} + void qla2x00_async_iocb_timeout(void *data) { @@ -1785,82 +1858,6 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, return rval; } -static void -qla24xx_abort_iocb_timeout(void *data) -{ - srb_t *sp = data; - struct srb_iocb *abt = &sp->u.iocb_cmd; - - abt->u.abt.comp_status = CS_TIMEOUT; - sp->done(sp, QLA_FUNCTION_TIMEOUT); -} - -static void -qla24xx_abort_sp_done(void *ptr, int res) -{ - srb_t *sp = ptr; - struct srb_iocb *abt = &sp->u.iocb_cmd; - - if (del_timer(&sp->u.iocb_cmd.timer)) { - if (sp->flags & SRB_WAKEUP_ON_COMP) - complete(&abt->u.abt.comp); - else - sp->free(sp); - } -} - -int -qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait) -{ - scsi_qla_host_t *vha = cmd_sp->vha; - struct srb_iocb *abt_iocb; - srb_t *sp; - int rval = QLA_FUNCTION_FAILED; - - sp = qla2xxx_get_qpair_sp(cmd_sp->vha, cmd_sp->qpair, cmd_sp->fcport, - GFP_ATOMIC); - if (!sp) - goto done; - - abt_iocb = &sp->u.iocb_cmd; - sp->type = SRB_ABT_CMD; - sp->name = "abort"; - sp->qpair = cmd_sp->qpair; - if (wait) - sp->flags = SRB_WAKEUP_ON_COMP; - - abt_iocb->timeout = qla24xx_abort_iocb_timeout; - init_completion(&abt_iocb->u.abt.comp); - /* FW can send 2 x ABTS's timeout/20s */ - qla2x00_init_timer(sp, 42); - - abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; - abt_iocb->u.abt.req_que_no = cpu_to_le16(cmd_sp->qpair->req->id); - - sp->done = qla24xx_abort_sp_done; - - ql_dbg(ql_dbg_async, vha, 0x507c, - "Abort command issued - hdl=%x, type=%x\n", - cmd_sp->handle, cmd_sp->type); - - rval = qla2x00_start_sp(sp); - if (rval != QLA_SUCCESS) - goto done_free_sp; - - if (wait) { - wait_for_completion(&abt_iocb->u.abt.comp); - rval = abt_iocb->u.abt.comp_status == CS_COMPLETE ? - QLA_SUCCESS : QLA_FUNCTION_FAILED; - } else { - goto done; - } - -done_free_sp: - sp->free(sp); -done: - return rval; -} - int qla24xx_async_abort_command(srb_t *sp) { From patchwork Wed Apr 17 21:44:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C512B1390 for ; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C5C28A93 for ; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4E4628BA9; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 431FC28A93 for ; Wed, 17 Apr 2019 21:45:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387936AbfDQVpZ (ORCPT ); Wed, 17 Apr 2019 17:45:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34352 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387941AbfDQVpZ (ORCPT ); Wed, 17 Apr 2019 17:45:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id b3so90507pfd.1 for ; Wed, 17 Apr 2019 14:45:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GIpobrlfPJwI22wRVOJtPkh5AvQSRQEkpL4S7hL4XRY=; b=LFDfast4wccwmvzZ/52VfbSpQirgwPGB6FJXqP9uVddAoOzScVcg+YlaE61qmiwF2J OPwMhsurrm2ZZb7lL1xtmvTebN6y6lkokj9zl7dscp069rKB45HTuQPH9rUA42/HboOs +uGCKitPqWcBJJgDXHK08w3QwYoScRHNlhzE0tlosf1+Rqe5tSU+scGYbs6uA8nV/YUh p17iOOXCeyVinQn6iWGEH0Vt5BTd9P4a0MfZNgxM4pIzeDtUEuYP11FVM5TK1Z073hVi 9tbrdtl3ldm8EilxMmzNcY22WQDkO0ol9ryW79vd8ZSTOLPmRymoiiMlrpb/2fmrr2uf F7+Q== X-Gm-Message-State: APjAAAWaBh651lK5OzSzVcofH4BQq5OIWUSltsMHDYnWIJrQ0bOH20a+ 2UtdzT1niJY/bq+vByPVbck= X-Google-Smtp-Source: APXvYqzjyC+GNwfCmaZfhSj4iqvCo2p4viZCQLG3Ong4nVA7XqNjoxK4xM82dtqi8fmCY62pgEYrzw== X-Received: by 2002:a63:1043:: with SMTP id 3mr84674107pgq.283.1555537524397; Wed, 17 Apr 2019 14:45:24 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:23 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 25/34] qla2xxx: Use an on-stack completion in qla24xx_control_vp() Date: Wed, 17 Apr 2019 14:44:34 -0700 Message-Id: <20190417214443.243152-26-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch reduces the size of struct srb. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 1 - drivers/scsi/qla2xxx/qla_mid.c | 9 +++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index c9f0169b21ea..6dd2d41713c9 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -545,7 +545,7 @@ typedef struct srb { u32 gen2; /* scratch */ int rc; int retry_count; - struct completion comp; + struct completion *comp; wait_queue_head_t *cwaitq; union { struct srb_iocb iocb_cmd; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 7ab157c079ca..60f6685cb342 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2570,7 +2570,6 @@ void qla2x00_init_timer(srb_t *sp, unsigned long tmo) timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; sp->free = qla2x00_sp_free; - init_completion(&sp->comp); if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD) init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); add_timer(&sp->u.iocb_cmd.timer); diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 099d8e9851cb..b2977e49356b 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -905,7 +905,8 @@ static void qla_ctrlvp_sp_done(void *s, int res) { struct srb *sp = s; - complete(&sp->comp); + if (sp->comp) + complete(sp->comp); /* don't free sp here. Let the caller do the free */ } @@ -922,6 +923,7 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) struct qla_hw_data *ha = vha->hw; int vp_index = vha->vp_idx; struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); + DECLARE_COMPLETION_ONSTACK(comp); srb_t *sp; ql_dbg(ql_dbg_vport, vha, 0x10c1, @@ -936,6 +938,7 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) sp->type = SRB_CTRL_VP; sp->name = "ctrl_vp"; + sp->comp = ∁ sp->done = qla_ctrlvp_sp_done; sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); @@ -953,7 +956,9 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n", sp->name, sp->handle); - wait_for_completion(&sp->comp); + wait_for_completion(&comp); + sp->comp = NULL; + rval = sp->rc; switch (rval) { case QLA_FUNCTION_TIMEOUT: From patchwork Wed Apr 17 21:44:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 618741390 for ; Wed, 17 Apr 2019 21:45:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AF4728A93 for ; Wed, 17 Apr 2019 21:45:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F54F28BAA; Wed, 17 Apr 2019 21:45:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3244A28A93 for ; Wed, 17 Apr 2019 21:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387945AbfDQVp2 (ORCPT ); Wed, 17 Apr 2019 17:45:28 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33142 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387938AbfDQVp0 (ORCPT ); Wed, 17 Apr 2019 17:45:26 -0400 Received: by mail-pl1-f196.google.com with SMTP id t16so127669plo.0 for ; Wed, 17 Apr 2019 14:45:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UtmdIRODeu3qXvxP0xDdDdkGRl7LhU+nYs6Tp55kPm0=; b=tBHng+QVfC+8DH4MxR6u4HXMKFXwnNgDelONeT3Dj3MIAXF/8jQcniiaorapXj0ZAS 9O/u3VYenfJmGarw6i+djM3XfN4iCdsf4M++wbhkDawrf1Q7sTgPb14/4Ip0aC0+32e4 ZHXyXDHYGNc23uwz6cuVTgnRhPyQbZu/XT6khFeThGZs6wmt1jaRB9czGEL6rB6CqAIF KaohhEC+nXx+sr8akUHYJA3JbZQsLhFCaHDy9WmPS7oT9UL52FJifDAtyp5TrxZ3NMrr 60TbhHmFiAQDoe6Uu8RCStE/QQzG+p+qx88gd2SKkF/ErfLZaGJzXSdoJzTdNoF36Gk0 Ai7w== X-Gm-Message-State: APjAAAXwAkMFSKoyurISPKFWIQhfDNmCazQVWFKlc6VJofEv2GIecm9l Zny/e65J2QSqGOtqW+cbGH4= X-Google-Smtp-Source: APXvYqxr6S7DiXG/HhYxaQ8R+vHuERplmo5Imov8mkPeKclDdNUfVuIaXWRIR0cyxyiPbrpZhYlPow== X-Received: by 2002:a17:902:b78c:: with SMTP id e12mr39495234pls.29.1555537525683; Wed, 17 Apr 2019 14:45:25 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:24 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 26/34] qla2xxx: Fix race conditions in the code for aborting SCSI commands Date: Wed, 17 Apr 2019 14:44:35 -0700 Message-Id: <20190417214443.243152-27-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the *_done() functions, instead of returning early if sp->ref_count >= 2, only decrement sp->ref_count. In qla2xxx_eh_abort(), instead of deciding what to do based on the value of sp->ref_count, decide which action to take depending on the completion status of the firmware abort. Remove srb.cwaitq and use srb.comp instead. In qla2x00_abort_srb(), call isp_ops->abort_command() directly instead of calling qla2xxx_eh_abort(). Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 34 +------- drivers/scsi/qla2xxx/qla_nvme.h | 1 - drivers/scsi/qla2xxx/qla_os.c | 150 +++++++++++--------------------- 4 files changed, 55 insertions(+), 131 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 6dd2d41713c9..8acaeba98da1 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -546,7 +546,6 @@ typedef struct srb { int rc; int retry_count; struct completion *comp; - wait_queue_head_t *cwaitq; union { struct srb_iocb iocb_cmd; struct bsg_job *bsg_job; diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 5d9191278f41..0829ab7f0d54 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -137,8 +137,7 @@ static void qla_nvme_sp_ls_done(void *ptr, int res) return; } - if (!atomic_dec_and_test(&sp->ref_count)) - return; + atomic_dec(&sp->ref_count); if (res) res = -EINVAL; @@ -161,8 +160,7 @@ static void qla_nvme_sp_done(void *ptr, int res) nvme = &sp->u.iocb_cmd; fd = nvme->u.nvme.desc; - if (!atomic_dec_and_test(&sp->ref_count)) - return; + atomic_dec(&sp->ref_count); if (res == QLA_SUCCESS) { fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; @@ -599,34 +597,6 @@ static struct nvme_fc_port_template qla_nvme_fc_transport = { .fcprqst_priv_sz = sizeof(struct nvme_private), }; -#define NVME_ABORT_POLLING_PERIOD 2 -static int qla_nvme_wait_on_command(srb_t *sp) -{ - int ret = QLA_SUCCESS; - - wait_event_timeout(sp->nvme_ls_waitq, (atomic_read(&sp->ref_count) > 1), - NVME_ABORT_POLLING_PERIOD*HZ); - - if (atomic_read(&sp->ref_count) > 1) - ret = QLA_FUNCTION_FAILED; - - return ret; -} - -void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res) -{ - int rval; - - if (ha->flags.fw_started) { - rval = ha->isp_ops->abort_command(sp); - if (!rval && !qla_nvme_wait_on_command(sp)) - ql_log(ql_log_warn, NULL, 0x2112, - "timed out waiting on sp=%p\n", sp); - } else { - sp->done(sp, res); - } -} - static void qla_nvme_unregister_remote_port(struct work_struct *work) { struct fc_port *fcport = container_of(work, struct fc_port, diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h index da8dad5ad693..0db04f0a4d5d 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.h +++ b/drivers/scsi/qla2xxx/qla_nvme.h @@ -145,7 +145,6 @@ struct pt_ls4_rx_unsol { int qla_nvme_register_hba(struct scsi_qla_host *); int qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *); void qla_nvme_delete(struct scsi_qla_host *); -void qla_nvme_abort(struct qla_hw_data *, struct srb *sp, int res); void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *, struct req_que *); void qla24xx_async_gffid_sp_done(void *, int); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a41aaf071b52..35f62f171b20 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -714,7 +714,7 @@ qla2x00_sp_compl(void *ptr, int res) { srb_t *sp = ptr; struct scsi_cmnd *cmd = GET_CMD_SP(sp); - wait_queue_head_t *cwaitq = sp->cwaitq; + struct completion *comp = sp->comp; if (atomic_read(&sp->ref_count) == 0) { ql_dbg(ql_dbg_io, sp->vha, 0x3015, @@ -724,15 +724,15 @@ qla2x00_sp_compl(void *ptr, int res) WARN_ON(atomic_read(&sp->ref_count) == 0); return; } - if (!atomic_dec_and_test(&sp->ref_count)) - return; + + atomic_dec(&sp->ref_count); sp->free(sp); cmd->result = res; CMD_SP(cmd) = NULL; cmd->scsi_done(cmd); - if (cwaitq) - wake_up(cwaitq); + if (comp) + complete(comp); qla2x00_rel_sp(sp); } @@ -825,7 +825,7 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) { srb_t *sp = ptr; struct scsi_cmnd *cmd = GET_CMD_SP(sp); - wait_queue_head_t *cwaitq = sp->cwaitq; + struct completion *comp = sp->comp; if (atomic_read(&sp->ref_count) == 0) { ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, @@ -835,15 +835,15 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) WARN_ON(atomic_read(&sp->ref_count) == 0); return; } - if (!atomic_dec_and_test(&sp->ref_count)) - return; + + atomic_dec(&sp->ref_count); sp->free(sp); cmd->result = res; CMD_SP(cmd) = NULL; cmd->scsi_done(cmd); - if (cwaitq) - wake_up(cwaitq); + if (comp) + complete(comp); qla2xxx_rel_qpair_sp(sp->qpair, sp); } @@ -1286,7 +1286,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) unsigned int id; uint64_t lun; unsigned long flags; - int rval, wait = 0; + int rval; struct qla_hw_data *ha = vha->hw; struct qla_qpair *qpair; @@ -1299,7 +1299,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) ret = fc_block_scsi_eh(cmd); if (ret != 0) return ret; - ret = SUCCESS; sp = (srb_t *) CMD_SP(cmd); if (!sp) @@ -1310,7 +1309,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) return SUCCESS; spin_lock_irqsave(qpair->qp_lock_ptr, flags); - if (!CMD_SP(cmd)) { + if (sp->type != SRB_SCSI_CMD || GET_CMD_SP(sp) != cmd) { /* there's a chance an interrupt could clear the ptr as part of done & free */ spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); @@ -1331,66 +1330,31 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", vha->host_no, id, lun, sp, cmd, sp->handle); - /* Get a reference to the sp and drop the lock.*/ rval = ha->isp_ops->abort_command(sp); - if (rval) { - if (rval == QLA_FUNCTION_PARAMETER_ERROR) - ret = SUCCESS; - else - ret = FAILED; - - ql_dbg(ql_dbg_taskm, vha, 0x8003, - "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); - } else { - ql_dbg(ql_dbg_taskm, vha, 0x8004, - "Abort command mbx success cmd=%p.\n", cmd); - wait = 1; - } + ql_dbg(ql_dbg_taskm, vha, 0x8003, + "Abort command mbx cmd=%p, rval=%x.\n", cmd, rval); - spin_lock_irqsave(qpair->qp_lock_ptr, flags); - - /* - * Releasing of the SRB and associated command resources - * is managed through ref_count. - * Whether we need to wait for the abort completion or complete - * the abort handler should be based on the ref_count. - */ - if (atomic_read(&sp->ref_count) > 1) { + switch (rval) { + case QLA_SUCCESS: /* - * The command is not yet completed. We need to wait for either - * command completion or abort completion. + * The command has been aborted. That means that the firmware + * won't report a completion. */ - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(eh_waitq); - uint32_t ratov = ha->r_a_tov/10; - - /* Go ahead and release the extra ref_count obtained earlier */ - sp->done(sp, DID_RESET << 16); - sp->cwaitq = &eh_waitq; - - if (!wait_event_lock_irq_timeout(eh_waitq, - CMD_SP(cmd) == NULL, *qpair->qp_lock_ptr, - msecs_to_jiffies(4 * ratov * 1000))) { - /* - * The abort got dropped, LOGO will be sent and the - * original command will be completed with CS_TIMEOUT - * completion - */ - ql_dbg(ql_dbg_taskm, vha, 0xffff, - "%s: Abort wait timer (4 * R_A_TOV[%d]) expired\n", - __func__, ha->r_a_tov); - sp->cwaitq = NULL; - ret = FAILED; - goto end; - } - } else { - /* Command completed while processing the abort */ - sp->done(sp, DID_RESET << 16); + sp->done(sp, DID_ABORT << 16); + ret = SUCCESS; + break; + default: + /* + * Either abort failed or abort and completion raced. Let + * the SCSI core retry the abort in the former case. + */ + ret = FAILED; + break; } -end: - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + ql_log(ql_log_info, vha, 0x801c, - "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", - vha->host_no, id, lun, wait, ret); + "Abort command issued nexus=%ld:%d:%llu -- %x.\n", + vha->host_no, id, lun, ret); return ret; } @@ -1766,42 +1730,34 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, __releases(qp->qp_lock_ptr) __acquires(qp->qp_lock_ptr) { + DECLARE_COMPLETION_ONSTACK(comp); scsi_qla_host_t *vha = qp->vha; struct qla_hw_data *ha = vha->hw; + int rval; - if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) { - if (!sp_get(sp)) { - /* got sp */ - spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); - qla_nvme_abort(ha, sp, res); - spin_lock_irqsave(qp->qp_lock_ptr, *flags); - } - } else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy && - !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && - !qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) { - /* - * Don't abort commands in adapter during EEH recovery as it's - * not accessible/responding. - * - * Get a reference to the sp and drop the lock. The reference - * ensures this sp->done() call and not the call in - * qla2xxx_eh_abort() ends the SCSI cmd (with result 'res'). - */ - if (!sp_get(sp)) { - int status; + if (sp_get(sp)) + return; - spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); - status = qla2xxx_eh_abort(GET_CMD_SP(sp)); - spin_lock_irqsave(qp->qp_lock_ptr, *flags); - /* - * Get rid of extra reference caused - * by early exit from qla2xxx_eh_abort - */ - if (status == FAST_IO_FAIL) - atomic_dec(&sp->ref_count); + if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS || + (sp->type == SRB_SCSI_CMD && !ha->flags.eeh_busy && + !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && + !qla2x00_isp_reg_stat(ha))) { + sp->comp = ∁ + rval = ha->isp_ops->abort_command(sp); + spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); + + switch (rval) { + case QLA_SUCCESS: + sp->done(sp, res); + break; + case QLA_FUNCTION_PARAMETER_ERROR: + wait_for_completion(&comp); + break; } + + spin_lock_irqsave(qp->qp_lock_ptr, *flags); + sp->comp = NULL; } - sp->done(sp, res); } static void From patchwork Wed Apr 17 21:44:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAC0C1390 for ; Wed, 17 Apr 2019 21:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D679628A93 for ; Wed, 17 Apr 2019 21:45:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB25428BA9; Wed, 17 Apr 2019 21:45:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EFEE28A93 for ; Wed, 17 Apr 2019 21:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387946AbfDQVpa (ORCPT ); Wed, 17 Apr 2019 17:45:30 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37834 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387539AbfDQVp1 (ORCPT ); Wed, 17 Apr 2019 17:45:27 -0400 Received: by mail-pf1-f196.google.com with SMTP id 8so84007pfr.4 for ; Wed, 17 Apr 2019 14:45:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mkb4hVWFHkNHGFxpBTHQY5E3+UAPRXX87pgy6wMcgX0=; b=Gxb7/lN6i9InPdO2+YJ8mY/bCxYVFtCAQvoIB2xkInmwSboYCo007KL/Ft9SkBmnNj vMnaA7fq5JrTmrd/HWED5IvECbTbn1isBWH/+sFokBa1bgvgYEVntTuhS7FFA1vAJpsk AClwfzCqvDqVfgG/YATpkF362zYm2EsXXVgdIXkWQ7ipjcYQVeNCBV8lId+gRMwvaJ6z jkKzmfUFLKtBeS94BHKRg6YCwnd94oPF3QiUO+LDh49QBlpNXIF7563miPOpzXEpt51P 1TfoG17N9B0rvsdxo2EKZs102ZniKwgjUHKYAS6J1xCSZ7pV5fJ9fa6grkfxjiboGPum 9/ig== X-Gm-Message-State: APjAAAXphHvKX1F0bJwePtC3ConQQAUJOAfaLX9wDkVN5tCDWnmlBvoa NfyWSYEZbcFi233wUR6g2nU= X-Google-Smtp-Source: APXvYqxLXeJplyC7JE0kYh+JsTIhFcKkU+4nUrTggVZQCUnL80qekKecor7hQX7ntu7ysilPgDEtBg== X-Received: by 2002:a63:c302:: with SMTP id c2mr86166058pgd.235.1555537526732; Wed, 17 Apr 2019 14:45:26 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:26 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 27/34] qla2xxx: Pass little-endian values to the firmware Date: Wed, 17 Apr 2019 14:44:36 -0700 Message-Id: <20190417214443.243152-28-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Pass dsd_list_len in little endian format to the firmware instead of in CPU endian format. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_iocb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 60f6685cb342..19eb18be2316 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -973,7 +973,7 @@ qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp, /* add new list to cmd iocb or last list */ *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = dsd_list_len; + *cur_dsd++ = cpu_to_le32(dsd_list_len); cur_dsd = (uint32_t *)next_dsd; } *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); @@ -1072,7 +1072,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, /* add new list to cmd iocb or last list */ *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = dsd_list_len; + *cur_dsd++ = cpu_to_le32(dsd_list_len); cur_dsd = (uint32_t *)next_dsd; } sle_dma = sg_dma_address(sg); @@ -1317,7 +1317,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = dsd_list_len; + *cur_dsd++ = cpu_to_le32(dsd_list_len); cur_dsd = dsd_ptr->dsd_addr; } *cur_dsd++ = cpu_to_le32(LSD(dif_dsd->dsd_list_dma)); @@ -1378,7 +1378,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = dsd_list_len; + *cur_dsd++ = cpu_to_le32(dsd_list_len); cur_dsd = dsd_ptr->dsd_addr; } sle_dma = sg_dma_address(sg); From patchwork Wed Apr 17 21:44:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DA1F17E0 for ; Wed, 17 Apr 2019 21:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17F2428A93 for ; Wed, 17 Apr 2019 21:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C82928BA9; Wed, 17 Apr 2019 21:45:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E84928A93 for ; Wed, 17 Apr 2019 21:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387662AbfDQVp3 (ORCPT ); Wed, 17 Apr 2019 17:45:29 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35258 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387944AbfDQVp2 (ORCPT ); Wed, 17 Apr 2019 17:45:28 -0400 Received: by mail-pl1-f196.google.com with SMTP id w24so124184plp.2 for ; Wed, 17 Apr 2019 14:45:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i88QiyauPagUAxtqYaHzd33ActREZAUKql9V//pBqzA=; b=EWcswTD2KCHPnPmHKRT6Zu0Oxp8lyiKgPvZZcTzXqltGUmN1F6nvtvJETT6V0b2zzk 64AYtLO9XugPYYuZPh0PZ1i1/8FBabCGHKgZS+rGm1MKv6fDwLb1DlPWliAL8aLxj0J9 WSmzV/aOTxz2ex0Eh62LuIq5QSxSbBEbNXHMgjES7Fxsa1gocIQEX+I2HckkTPBk2lBQ O2DqzhKcPEyJwaIoBel/zAHq67x43UNXhXnz2O7Q703/RrGXY5y7DhRdQhDahRkLdhpH ruIbTdA6I+4fFkdjRuJeQWsG5jrf/aX6rK2SK+P7K1HKbr5iNoZWvSD6s7PfXDZgm9Mc xkzA== X-Gm-Message-State: APjAAAVFMd3KKvtNv//l3f0PKRROfwZAK+M9L7TOqF/R6+6Cq5m04Dv9 pOOo+upazS93IzjpG/B0W9FE0zt7 X-Google-Smtp-Source: APXvYqzltuw5+AeHz+bgDvWHUTSKA6iflwHFA+/S4GCh/XIWwHvazmGoSkFUqzUmZQbvcsnpAsl1lw== X-Received: by 2002:a17:902:42:: with SMTP id 60mr53532632pla.79.1555537527964; Wed, 17 Apr 2019 14:45:27 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:27 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 28/34] qla2xxx: Check the size of firmware data structures at compile time Date: Wed, 17 Apr 2019 14:44:37 -0700 Message-Id: <20190417214443.243152-29-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the next patch will modify several firmware data structures, add compile time checks that verify that these structures have the correct size. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_os.c | 24 ++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_target.c | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 35f62f171b20..73ddd02d1a39 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -7285,6 +7285,30 @@ qla2x00_module_init(void) { int ret = 0; + BUILD_BUG_ON(sizeof(cmd_entry_t) != 64); + BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64); + BUILD_BUG_ON(sizeof(cont_entry_t) != 64); + BUILD_BUG_ON(sizeof(init_cb_t) != 96); + BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64); + BUILD_BUG_ON(sizeof(request_t) != 64); + BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64); + BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64); + BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64); + BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64); + BUILD_BUG_ON(sizeof(struct cmd_type_7) != 64); + BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64); + BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64); + BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64); + BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64); + BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64); + BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64); + BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128); + BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128); + BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64); + BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064); + BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64); + BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56); + /* Allocate cache for SRBs. */ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, SLAB_HWCACHE_ALIGN, NULL); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 1ced494d8673..b3f741cfe6ed 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -7372,6 +7372,9 @@ int __init qlt_init(void) { int ret; + BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64); + BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64); + if (!qlt_parse_ini_mode()) { ql_log(ql_log_fatal, NULL, 0xe06b, "qlt_parse_ini_mode() failed\n"); From patchwork Wed Apr 17 21:44:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 841DE17E6 for ; Wed, 17 Apr 2019 21:45:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 693D528A93 for ; Wed, 17 Apr 2019 21:45:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CEEC28A96; Wed, 17 Apr 2019 21:45:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DFD728BAA for ; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387600AbfDQVpm (ORCPT ); Wed, 17 Apr 2019 17:45:42 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40038 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387604AbfDQVpa (ORCPT ); Wed, 17 Apr 2019 17:45:30 -0400 Received: by mail-pg1-f194.google.com with SMTP id d31so148603pgl.7 for ; Wed, 17 Apr 2019 14:45:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DE65EWHDHpOvL90Oad2UGaakG25Go11tAuE1lE+s4Aw=; b=s/ZBTcyCXAMfaj8msf102R0hu1wqKzAqMxG9d4D7d9CrPbq0xCSeGzUW8ePmr4ec7w UKeyjRkAYz4OwlfQf8wqcXo5QItioczTZFNWmtpUXpDmiK4rLgWVbtOdtoPHi3tMsXT4 8/iFPaEn0WQHr1PFydOkc0wLeD/Sz/qZ0w0TL26fkualgSUUd4/dQmD7uB6oRcGWCj1a G/WGSPbs3wTMmo7G8F0CMxh+Ewd4a7aRYdIFStz/8E1bVSncZJVE+wLhrWfiXjGveuWW QA8nIQuxxqiaSWQjlgWOyHcFwZpUkTwZDkp1rf/NQe1L7TmQHzurZxV5UGQrAmiCQoXw gIBQ== X-Gm-Message-State: APjAAAWdaEK04CGgxW+DFSWk+2x/jS+gef1K7Vp4rIupGx+VP9/J3tj7 2SbyR+OSulhJGKdKf21iKew= X-Google-Smtp-Source: APXvYqwY/feDIufKsjBDEzCBw/vCr9oPCSJpt8ohz7xaJE9UMtPcrhrgKuzZkCwYs4L57PCdXHR82g== X-Received: by 2002:aa7:8208:: with SMTP id k8mr93357004pfi.69.1555537529073; Wed, 17 Apr 2019 14:45:29 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:28 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 29/34] qla2xxx: Introduce the dsd32 and dsd64 data structures Date: Wed, 17 Apr 2019 14:44:38 -0700 Message-Id: <20190417214443.243152-30-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce two structures for the (DMA address, length) combination instead of using separate structure members for the DMA address and length. This patch fixes several Coverity complaints about 'cur_dsd' being used to write outside the bounds of structure members. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_bsg.c | 10 +- drivers/scsi/qla2xxx/qla_def.h | 58 ++----- drivers/scsi/qla2xxx/qla_dsd.h | 30 ++++ drivers/scsi/qla2xxx/qla_fw.h | 22 +-- drivers/scsi/qla2xxx/qla_gbl.h | 6 +- drivers/scsi/qla2xxx/qla_gs.c | 44 +++--- drivers/scsi/qla2xxx/qla_iocb.c | 255 ++++++++++++------------------ drivers/scsi/qla2xxx/qla_mr.c | 57 +++---- drivers/scsi/qla2xxx/qla_mr.h | 11 +- drivers/scsi/qla2xxx/qla_nvme.c | 14 +- drivers/scsi/qla2xxx/qla_nvme.h | 9 +- drivers/scsi/qla2xxx/qla_target.c | 37 ++--- drivers/scsi/qla2xxx/qla_target.h | 13 +- 13 files changed, 221 insertions(+), 345 deletions(-) create mode 100644 drivers/scsi/qla2xxx/qla_dsd.h diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 45f26ea5f9d9..5441557b424b 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1056,9 +1056,8 @@ qla84xx_updatefw(struct bsg_job *bsg_job) mn->fw_ver = cpu_to_le32(fw_ver); mn->fw_size = cpu_to_le32(data_len); mn->fw_seq_size = cpu_to_le32(data_len); - mn->dseg_address[0] = cpu_to_le32(LSD(fw_dma)); - mn->dseg_address[1] = cpu_to_le32(MSD(fw_dma)); - mn->dseg_length = cpu_to_le32(data_len); + put_unaligned_le64(fw_dma, &mn->dsd.address); + mn->dsd.length = cpu_to_le32(data_len); mn->data_seg_cnt = cpu_to_le16(1); rval = qla2x00_issue_iocb_timeout(vha, mn, mn_dma, 0, 120); @@ -1237,9 +1236,8 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job) if (ql84_mgmt->mgmt.cmd != QLA84_MGMT_CHNG_CONFIG) { mn->total_byte_cnt = cpu_to_le32(ql84_mgmt->mgmt.len); mn->dseg_count = cpu_to_le16(1); - mn->dseg_address[0] = cpu_to_le32(LSD(mgmt_dma)); - mn->dseg_address[1] = cpu_to_le32(MSD(mgmt_dma)); - mn->dseg_length = cpu_to_le32(ql84_mgmt->mgmt.len); + put_unaligned_le64(mgmt_dma, &mn->dsd.address); + mn->dsd.length = cpu_to_le32(ql84_mgmt->mgmt.len); } rval = qla2x00_issue_iocb(vha, mn, mn_dma, 0); diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 8acaeba98da1..502a4812bf51 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -35,6 +35,7 @@ #include #include "qla_bsg.h" +#include "qla_dsd.h" #include "qla_nx.h" #include "qla_nx2.h" #include "qla_nvme.h" @@ -1754,12 +1755,10 @@ typedef struct { uint16_t dseg_count; /* Data segment count. */ uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */ uint32_t byte_count; /* Total byte count. */ - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ + union { + struct dsd32 dsd32[3]; + struct dsd64 dsd64[2]; + }; } cmd_entry_t; /* @@ -1780,10 +1779,7 @@ typedef struct { uint16_t dseg_count; /* Data segment count. */ uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */ uint32_t byte_count; /* Total byte count. */ - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ + struct dsd64 dsd[2]; } cmd_a64_entry_t, request_t; /* @@ -1796,20 +1792,7 @@ typedef struct { uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ uint32_t reserved; - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ - uint32_t dseg_4_address; /* Data segment 4 address. */ - uint32_t dseg_4_length; /* Data segment 4 length. */ - uint32_t dseg_5_address; /* Data segment 5 address. */ - uint32_t dseg_5_length; /* Data segment 5 length. */ - uint32_t dseg_6_address; /* Data segment 6 address. */ - uint32_t dseg_6_length; /* Data segment 6 length. */ + struct dsd32 dsd[7]; } cont_entry_t; /* @@ -1821,16 +1804,7 @@ typedef struct { uint8_t entry_count; /* Entry count. */ uint8_t sys_define; /* System defined. */ uint8_t entry_status; /* Entry Status. */ - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address [2]; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ - uint32_t dseg_3_address[2]; /* Data segment 3 address. */ - uint32_t dseg_3_length; /* Data segment 3 length. */ - uint32_t dseg_4_address[2]; /* Data segment 4 address. */ - uint32_t dseg_4_length; /* Data segment 4 length. */ + struct dsd64 dsd[5]; } cont_a64_entry_t; #define PO_MODE_DIF_INSERT 0 @@ -1874,8 +1848,7 @@ struct crc_context { uint16_t reserved_2; uint16_t reserved_3; uint32_t reserved_4; - uint32_t data_address[2]; - uint32_t data_length; + struct dsd64 data_dsd; uint32_t reserved_5[2]; uint32_t reserved_6; } nobundling; @@ -1885,11 +1858,8 @@ struct crc_context { uint16_t reserved_1; __le16 dseg_count; /* Data segment count */ uint32_t reserved_2; - uint32_t data_address[2]; - uint32_t data_length; - uint32_t dif_address[2]; - uint32_t dif_length; /* Data segment 0 - * length */ + struct dsd64 data_dsd; + struct dsd64 dif_dsd; } bundling; } u; @@ -2088,10 +2058,8 @@ typedef struct { uint32_t handle2; uint32_t rsp_bytecount; uint32_t req_bytecount; - uint32_t dseg_req_address[2]; /* Data segment 0 address. */ - uint32_t dseg_req_length; /* Data segment 0 length. */ - uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */ - uint32_t dseg_rsp_length; /* Data segment 1 length. */ + struct dsd64 req_dsd; + struct dsd64 rsp_dsd; } ms_iocb_entry_t; diff --git a/drivers/scsi/qla2xxx/qla_dsd.h b/drivers/scsi/qla2xxx/qla_dsd.h new file mode 100644 index 000000000000..7479924ba422 --- /dev/null +++ b/drivers/scsi/qla2xxx/qla_dsd.h @@ -0,0 +1,30 @@ +#ifndef _QLA_DSD_H_ +#define _QLA_DSD_H_ + +/* 32-bit data segment descriptor (8 bytes) */ +struct dsd32 { + __le32 address; + __le32 length; +}; + +static inline void append_dsd32(struct dsd32 **dsd, struct scatterlist *sg) +{ + put_unaligned_le32(sg_dma_address(sg), &(*dsd)->address); + put_unaligned_le32(sg_dma_len(sg), &(*dsd)->length); + (*dsd)++; +} + +/* 64-bit data segment descriptor (12 bytes) */ +struct dsd64 { + __le64 address; + __le32 length; +} __packed; + +static inline void append_dsd64(struct dsd64 **dsd, struct scatterlist *sg) +{ + put_unaligned_le64(sg_dma_address(sg), &(*dsd)->address); + put_unaligned_le32(sg_dma_len(sg), &(*dsd)->length); + (*dsd)++; +} + +#endif diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h index d53cd7875a85..604eb4682ac0 100644 --- a/drivers/scsi/qla2xxx/qla_fw.h +++ b/drivers/scsi/qla2xxx/qla_fw.h @@ -10,6 +10,8 @@ #include #include +#include "qla_dsd.h" + #define MBS_CHECKSUM_ERROR 0x4010 #define MBS_INVALID_PRODUCT_KEY 0x4020 @@ -463,8 +465,7 @@ struct cmd_bidir { uint8_t port_id[3]; /* PortID of destination port.*/ uint8_t vp_index; - uint32_t fcp_data_dseg_address[2]; /* Data segment address. */ - uint16_t fcp_data_dseg_len; /* Data segment length. */ + struct dsd64 fcp_dsd; }; #define COMMAND_TYPE_6 0x48 /* Command Type 6 entry */ @@ -501,8 +502,7 @@ struct cmd_type_6 { uint8_t port_id[3]; /* PortID of destination port. */ uint8_t vp_index; - uint32_t fcp_data_dseg_address[2]; /* Data segment address. */ - uint32_t fcp_data_dseg_len; /* Data segment length. */ + struct dsd64 fcp_dsd; }; #define COMMAND_TYPE_7 0x18 /* Command Type 7 entry */ @@ -548,8 +548,7 @@ struct cmd_type_7 { uint8_t port_id[3]; /* PortID of destination port. */ uint8_t vp_index; - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_len; /* Data segment 0 length. */ + struct dsd64 dsd; }; #define COMMAND_TYPE_CRC_2 0x6A /* Command Type CRC_2 (Type 6) @@ -717,10 +716,7 @@ struct ct_entry_24xx { uint32_t rsp_byte_count; uint32_t cmd_byte_count; - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_len; /* Data segment 0 length. */ - uint32_t dseg_1_address[2]; /* Data segment 1 address. */ - uint32_t dseg_1_len; /* Data segment 1 length. */ + struct dsd64 dsd[2]; }; /* @@ -1606,8 +1602,7 @@ struct verify_chip_entry_84xx { uint32_t fw_seq_size; uint32_t relative_offset; - uint32_t dseg_address[2]; - uint32_t dseg_length; + struct dsd64 dsd; }; struct verify_chip_rsp_84xx { @@ -1664,8 +1659,7 @@ struct access_chip_84xx { uint32_t total_byte_cnt; uint32_t reserved4; - uint32_t dseg_address[2]; - uint32_t dseg_length; + struct dsd64 dsd; }; struct access_chip_rsp_84xx { diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 9c7fbd4da9b8..bbe69ab5cf3f 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -287,11 +287,11 @@ extern void *qla2x00_alloc_iocbs(struct scsi_qla_host *, srb_t *); extern void *__qla2x00_alloc_iocbs(struct qla_qpair *, srb_t *); extern int qla2x00_issue_marker(scsi_qla_host_t *, int); extern int qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *, srb_t *, - uint32_t *, uint16_t, struct qla_tc_param *); + struct dsd64 *, uint16_t, struct qla_tc_param *); extern int qla24xx_walk_and_build_sglist(struct qla_hw_data *, srb_t *, - uint32_t *, uint16_t, struct qla_tc_param *); + struct dsd64 *, uint16_t, struct qla_tc_param *); extern int qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *, srb_t *, - uint32_t *, uint16_t, struct qla_tgt_cmd *); + struct dsd64 *, uint16_t, struct qla_tgt_cmd *); extern int qla24xx_get_one_block_sg(uint32_t, struct qla2_sgx *, uint32_t *); extern int qla24xx_configure_prot_mode(srb_t *, uint16_t *); diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 4235769ec4cc..e2653bbc117d 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -45,13 +45,11 @@ qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, struct ct_arg *arg) ms_pkt->rsp_bytecount = cpu_to_le32(arg->rsp_size); ms_pkt->req_bytecount = cpu_to_le32(arg->req_size); - ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(arg->req_dma)); - ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(arg->req_dma)); - ms_pkt->dseg_req_length = ms_pkt->req_bytecount; + put_unaligned_le64(arg->req_dma, &ms_pkt->req_dsd.address); + ms_pkt->req_dsd.length = ms_pkt->req_bytecount; - ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(arg->rsp_dma)); - ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(arg->rsp_dma)); - ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; + put_unaligned_le64(arg->rsp_dma, &ms_pkt->rsp_dsd.address); + ms_pkt->rsp_dsd.length = ms_pkt->rsp_bytecount; vha->qla_stats.control_requests++; @@ -83,13 +81,11 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, struct ct_arg *arg) ct_pkt->rsp_byte_count = cpu_to_le32(arg->rsp_size); ct_pkt->cmd_byte_count = cpu_to_le32(arg->req_size); - ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(arg->req_dma)); - ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(arg->req_dma)); - ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; + put_unaligned_le64(arg->req_dma, &ct_pkt->dsd[0].address); + ct_pkt->dsd[0].length = ct_pkt->cmd_byte_count; - ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(arg->rsp_dma)); - ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(arg->rsp_dma)); - ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; + put_unaligned_le64(arg->rsp_dma, &ct_pkt->dsd[1].address); + ct_pkt->dsd[1].length = ct_pkt->rsp_byte_count; ct_pkt->vp_index = vha->vp_idx; vha->qla_stats.control_requests++; @@ -1438,13 +1434,11 @@ qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size, ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); ms_pkt->req_bytecount = cpu_to_le32(req_size); - ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); - ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); - ms_pkt->dseg_req_length = ms_pkt->req_bytecount; + put_unaligned_le64(ha->ct_sns_dma, &ms_pkt->req_dsd.address); + ms_pkt->req_dsd.length = ms_pkt->req_bytecount; - ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); - ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); - ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; + put_unaligned_le64(ha->ct_sns_dma, &ms_pkt->rsp_dsd.address); + ms_pkt->rsp_dsd.length = ms_pkt->rsp_bytecount; return ms_pkt; } @@ -1476,13 +1470,11 @@ qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size, ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); ct_pkt->cmd_byte_count = cpu_to_le32(req_size); - ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); - ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); - ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; + put_unaligned_le64(ha->ct_sns_dma, &ct_pkt->dsd[0].address); + ct_pkt->dsd[0].length = ct_pkt->cmd_byte_count; - ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); - ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); - ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; + put_unaligned_le64(ha->ct_sns_dma, &ct_pkt->dsd[1].address); + ct_pkt->dsd[1].length = ct_pkt->rsp_byte_count; ct_pkt->vp_index = vha->vp_idx; return ct_pkt; @@ -1497,10 +1489,10 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size) if (IS_FWI2_CAPABLE(ha)) { ct_pkt->cmd_byte_count = cpu_to_le32(req_size); - ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; + ct_pkt->dsd[0].length = ct_pkt->cmd_byte_count; } else { ms_pkt->req_bytecount = cpu_to_le32(req_size); - ms_pkt->dseg_req_length = ms_pkt->req_bytecount; + ms_pkt->req_dsd.length = ms_pkt->req_bytecount; } return ms_pkt; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 19eb18be2316..ef895e1142c9 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -192,7 +192,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt, uint16_t tot_dsds) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd32 *cur_dsd; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; struct scatterlist *sg; @@ -213,8 +213,8 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt, cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); /* Three DSDs are available in the Command Type 2 IOCB */ - avail_dsds = 3; - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; + avail_dsds = ARRAY_SIZE(cmd_pkt->dsd32); + cur_dsd = cmd_pkt->dsd32; /* Load data segments */ scsi_for_each_sg(cmd, sg, tot_dsds, i) { @@ -227,12 +227,11 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt, * Type 0 IOCB. */ cont_pkt = qla2x00_prep_cont_type0_iocb(vha); - cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address; - avail_dsds = 7; + cur_dsd = cont_pkt->dsd; + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); } - *cur_dsd++ = cpu_to_le32(sg_dma_address(sg)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd32(&cur_dsd, sg); avail_dsds--; } } @@ -249,7 +248,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt, uint16_t tot_dsds) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; struct scatterlist *sg; @@ -270,12 +269,11 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt, cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); /* Two DSDs are available in the Command Type 3 IOCB */ - avail_dsds = 2; - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; + avail_dsds = ARRAY_SIZE(cmd_pkt->dsd64); + cur_dsd = cmd_pkt->dsd64; /* Load data segments */ scsi_for_each_sg(cmd, sg, tot_dsds, i) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets? */ @@ -285,14 +283,11 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt, * Type 1 IOCB. */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; - avail_dsds = 5; + cur_dsd = cont_pkt->dsd; + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } } @@ -578,13 +573,11 @@ static inline int qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, uint16_t tot_dsds) { - uint32_t *cur_dsd = NULL; + struct dsd64 *cur_dsd = NULL, *next_dsd; scsi_qla_host_t *vha; struct qla_hw_data *ha; struct scsi_cmnd *cmd; struct scatterlist *cur_seg; - uint32_t *dsd_seg; - void *next_dsd; uint8_t avail_dsds; uint8_t first_iocb = 1; uint32_t dsd_list_len; @@ -636,32 +629,27 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, if (first_iocb) { first_iocb = 0; - dsd_seg = (uint32_t *)&cmd_pkt->fcp_data_dseg_address; - *dsd_seg++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *dsd_seg++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - cmd_pkt->fcp_data_dseg_len = cpu_to_le32(dsd_list_len); + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cmd_pkt->fcp_dsd.address); + cmd_pkt->fcp_dsd.length = cpu_to_le32(dsd_list_len); } else { - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(dsd_list_len); + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(dsd_list_len); + cur_dsd++; } - cur_dsd = (uint32_t *)next_dsd; + cur_dsd = next_dsd; while (avail_dsds) { - dma_addr_t sle_dma; - - sle_dma = sg_dma_address(cur_seg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(cur_seg)); + append_dsd64(&cur_dsd, cur_seg); cur_seg = sg_next(cur_seg); avail_dsds--; } } /* Null termination */ - *cur_dsd++ = 0; - *cur_dsd++ = 0; - *cur_dsd++ = 0; + cur_dsd->address = 0; + cur_dsd->length = 0; + cur_dsd++; cmd_pkt->control_flags |= CF_DATA_SEG_DESCR_ENABLE; return 0; } @@ -700,7 +688,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt, uint16_t tot_dsds, struct req_que *req) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; struct scatterlist *sg; @@ -732,12 +720,11 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt, /* One DSD is available in the Command Type 3 IOCB */ avail_dsds = 1; - cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address; + cur_dsd = &cmd_pkt->dsd; /* Load data segments */ scsi_for_each_sg(cmd, sg, tot_dsds, i) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets? */ @@ -747,14 +734,11 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt, * Type 1 IOCB. */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, req); - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; - avail_dsds = 5; + cur_dsd = cont_pkt->dsd; + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } } @@ -890,14 +874,14 @@ qla24xx_get_one_block_sg(uint32_t blk_sz, struct qla2_sgx *sgx, int qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp, - uint32_t *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) + struct dsd64 *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) { void *next_dsd; uint8_t avail_dsds = 0; uint32_t dsd_list_len; struct dsd_dma *dsd_ptr; struct scatterlist *sg_prot; - uint32_t *cur_dsd = dsd; + struct dsd64 *cur_dsd = dsd; uint16_t used_dsds = tot_dsds; uint32_t prot_int; /* protection interval */ uint32_t partial; @@ -971,14 +955,14 @@ qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp, /* add new list to cmd iocb or last list */ - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(dsd_list_len); - cur_dsd = (uint32_t *)next_dsd; + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(dsd_list_len); + cur_dsd = next_dsd; } - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sle_dma_len); + put_unaligned_le64(sle_dma, &cur_dsd->address); + cur_dsd->length = cpu_to_le32(sle_dma_len); + cur_dsd++; avail_dsds--; if (partial == 0) { @@ -997,22 +981,22 @@ qla24xx_walk_and_build_sglist_no_difb(struct qla_hw_data *ha, srb_t *sp, } } /* Null termination */ - *cur_dsd++ = 0; - *cur_dsd++ = 0; - *cur_dsd++ = 0; + cur_dsd->address = 0; + cur_dsd->length = 0; + cur_dsd++; return 0; } int -qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, - uint16_t tot_dsds, struct qla_tc_param *tc) +qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, + struct dsd64 *dsd, uint16_t tot_dsds, struct qla_tc_param *tc) { void *next_dsd; uint8_t avail_dsds = 0; uint32_t dsd_list_len; struct dsd_dma *dsd_ptr; struct scatterlist *sg, *sgl; - uint32_t *cur_dsd = dsd; + struct dsd64 *cur_dsd = dsd; int i; uint16_t used_dsds = tot_dsds; struct scsi_cmnd *cmd; @@ -1029,8 +1013,6 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, for_each_sg(sgl, sg, tot_dsds, i) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? @@ -1070,29 +1052,25 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp, uint32_t *dsd, } /* add new list to cmd iocb or last list */ - *cur_dsd++ = cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(dsd_list_len); - cur_dsd = (uint32_t *)next_dsd; + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(dsd_list_len); + cur_dsd = next_dsd; } - sle_dma = sg_dma_address(sg); - - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } /* Null termination */ - *cur_dsd++ = 0; - *cur_dsd++ = 0; - *cur_dsd++ = 0; + cur_dsd->address = 0; + cur_dsd->length = 0; + cur_dsd++; return 0; } int qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, - uint32_t *cur_dsd, uint16_t tot_dsds, struct qla_tgt_cmd *tc) + struct dsd64 *cur_dsd, uint16_t tot_dsds, struct qla_tgt_cmd *tc) { struct dsd_dma *dsd_ptr = NULL, *dif_dsd, *nxt_dsd; struct scatterlist *sg, *sgl; @@ -1313,16 +1291,15 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, } /* add new list to cmd iocb or last list */ - *cur_dsd++ = - cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = - cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(dsd_list_len); + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(dsd_list_len); cur_dsd = dsd_ptr->dsd_addr; } - *cur_dsd++ = cpu_to_le32(LSD(dif_dsd->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(MSD(dif_dsd->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(sglen); + put_unaligned_le64(dif_dsd->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(sglen); + cur_dsd++; avail_dsds--; difctx->dif_bundl_len -= sglen; track_difbundl_buf--; @@ -1333,8 +1310,6 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, difctx->no_ldif_dsd, difctx->no_dif_bundl); } else { for_each_sg(sgl, sg, tot_dsds, i) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? @@ -1374,24 +1349,19 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, } /* add new list to cmd iocb or last list */ - *cur_dsd++ = - cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = - cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); - *cur_dsd++ = cpu_to_le32(dsd_list_len); + put_unaligned_le64(dsd_ptr->dsd_list_dma, + &cur_dsd->address); + cur_dsd->length = cpu_to_le32(dsd_list_len); cur_dsd = dsd_ptr->dsd_addr; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } } /* Null termination */ - *cur_dsd++ = 0; - *cur_dsd++ = 0; - *cur_dsd++ = 0; + cur_dsd->address = 0; + cur_dsd->length = 0; + cur_dsd++; return 0; } /** @@ -1408,7 +1378,8 @@ static inline int qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, uint16_t tot_dsds, uint16_t tot_prot_dsds, uint16_t fw_prot_opts) { - uint32_t *cur_dsd, *fcp_dl; + struct dsd64 *cur_dsd; + uint32_t *fcp_dl; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; uint32_t total_bytes = 0; @@ -1547,7 +1518,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, } if (!bundling) { - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.nobundling.data_address; + cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd; } else { /* * Configure Bundling if we need to fetch interlaving @@ -1557,7 +1528,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds - tot_prot_dsds); - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.data_address; + cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd; } /* Finish the common fields of CRC pkt */ @@ -1590,7 +1561,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, if (bundling && tot_prot_dsds) { /* Walks dif segments */ cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; + cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd, tot_prot_dsds, NULL)) goto crc_queuing_error; @@ -3007,7 +2978,7 @@ static void qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; struct scatterlist *sg; int index; uint16_t tot_dsds; @@ -3033,25 +3004,20 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) ct_iocb->rsp_bytecount = cpu_to_le32(bsg_job->reply_payload.payload_len); - ct_iocb->dseg_req_address[0] = cpu_to_le32(LSD(sg_dma_address - (bsg_job->request_payload.sg_list))); - ct_iocb->dseg_req_address[1] = cpu_to_le32(MSD(sg_dma_address - (bsg_job->request_payload.sg_list))); - ct_iocb->dseg_req_length = ct_iocb->req_bytecount; + ct_iocb->req_dsd.address = + cpu_to_le64(sg_dma_address(bsg_job->request_payload.sg_list)); + ct_iocb->req_dsd.length = ct_iocb->req_bytecount; - ct_iocb->dseg_rsp_address[0] = cpu_to_le32(LSD(sg_dma_address - (bsg_job->reply_payload.sg_list))); - ct_iocb->dseg_rsp_address[1] = cpu_to_le32(MSD(sg_dma_address - (bsg_job->reply_payload.sg_list))); - ct_iocb->dseg_rsp_length = ct_iocb->rsp_bytecount; + ct_iocb->rsp_dsd.address = + cpu_to_le64(sg_dma_address(bsg_job->reply_payload.sg_list)); + ct_iocb->rsp_dsd.length = ct_iocb->rsp_bytecount; avail_dsds = 1; - cur_dsd = (uint32_t *)ct_iocb->dseg_rsp_address; + cur_dsd = &ct_iocb->rsp_dsd; index = 0; tot_dsds = bsg_job->reply_payload.sg_cnt; for_each_sg(bsg_job->reply_payload.sg_list, sg, tot_dsds, index) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets? */ @@ -3062,15 +3028,12 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->hw->req_q_map[0]); - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; + cur_dsd = cont_pkt->dsd; avail_dsds = 5; entry_count++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } ct_iocb->entry_count = entry_count; @@ -3082,7 +3045,7 @@ static void qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; struct scatterlist *sg; int index; uint16_t cmd_dsds, rsp_dsds; @@ -3111,12 +3074,10 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) cpu_to_le32(bsg_job->request_payload.payload_len); avail_dsds = 2; - cur_dsd = (uint32_t *)ct_iocb->dseg_0_address; + cur_dsd = ct_iocb->dsd; index = 0; for_each_sg(bsg_job->request_payload.sg_list, sg, cmd_dsds, index) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { /* @@ -3125,23 +3086,18 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) */ cont_pkt = qla2x00_prep_cont_type1_iocb( vha, ha->req_q_map[0]); - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; + cur_dsd = cont_pkt->dsd; avail_dsds = 5; entry_count++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } index = 0; for_each_sg(bsg_job->reply_payload.sg_list, sg, rsp_dsds, index) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { /* @@ -3150,15 +3106,12 @@ qla24xx_ct_iocb(srb_t *sp, struct ct_entry_24xx *ct_iocb) */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, ha->req_q_map[0]); - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; + cur_dsd = cont_pkt->dsd; avail_dsds = 5; entry_count++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } ct_iocb->entry_count = entry_count; @@ -3599,15 +3552,13 @@ qla_nvme_ls(srb_t *sp, struct pt_ls4_request *cmd_pkt) cmd_pkt->tx_dseg_count = 1; cmd_pkt->tx_byte_count = nvme->u.nvme.cmd_len; - cmd_pkt->dseg0_len = nvme->u.nvme.cmd_len; - cmd_pkt->dseg0_address[0] = cpu_to_le32(LSD(nvme->u.nvme.cmd_dma)); - cmd_pkt->dseg0_address[1] = cpu_to_le32(MSD(nvme->u.nvme.cmd_dma)); + cmd_pkt->dsd[0].length = nvme->u.nvme.cmd_len; + put_unaligned_le64(nvme->u.nvme.cmd_dma, &cmd_pkt->dsd[0].address); cmd_pkt->rx_dseg_count = 1; cmd_pkt->rx_byte_count = nvme->u.nvme.rsp_len; - cmd_pkt->dseg1_len = nvme->u.nvme.rsp_len; - cmd_pkt->dseg1_address[0] = cpu_to_le32(LSD(nvme->u.nvme.rsp_dma)); - cmd_pkt->dseg1_address[1] = cpu_to_le32(MSD(nvme->u.nvme.rsp_dma)); + cmd_pkt->dsd[1].length = nvme->u.nvme.rsp_len; + put_unaligned_le64(nvme->u.nvme.rsp_dma, &cmd_pkt->dsd[1].address); return rval; } @@ -3746,7 +3697,7 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, struct cmd_bidir *cmd_pkt, uint32_t tot_dsds) { uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; uint32_t req_data_len = 0; uint32_t rsp_data_len = 0; struct scatterlist *sg; @@ -3781,13 +3732,12 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, * are bundled in continuation iocb */ avail_dsds = 1; - cur_dsd = (uint32_t *)&cmd_pkt->fcp_data_dseg_address; + cur_dsd = &cmd_pkt->fcp_dsd; index = 0; for_each_sg(bsg_job->request_payload.sg_list, sg, bsg_job->request_payload.sg_cnt, index) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets */ @@ -3796,14 +3746,11 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, * 5 DSDS */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; + cur_dsd = cont_pkt->dsd; avail_dsds = 5; entry_count++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } /* For read request DSD will always goes to continuation IOCB @@ -3813,7 +3760,6 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, */ for_each_sg(bsg_job->reply_payload.sg_list, sg, bsg_job->reply_payload.sg_cnt, index) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets */ @@ -3822,14 +3768,11 @@ qla25xx_build_bidir_iocb(srb_t *sp, struct scsi_qla_host *vha, * 5 DSDS */ cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); - cur_dsd = (uint32_t *) cont_pkt->dseg_0_address; + cur_dsd = cont_pkt->dsd; avail_dsds = 5; entry_count++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } /* This value should be same as number of IOCB required for this cmd */ diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index 783f24db89f7..a08d83dbcece 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -2993,7 +2993,7 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, uint16_t tot_dsds, struct cmd_type_7_fx00 *lcmd_pkt) { uint16_t avail_dsds; - __le32 *cur_dsd; + struct dsd64 *cur_dsd; scsi_qla_host_t *vha; struct scsi_cmnd *cmd; struct scatterlist *sg; @@ -3029,12 +3029,10 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, /* One DSD is available in the Command Type 3 IOCB */ avail_dsds = 1; - cur_dsd = (__le32 *)&lcmd_pkt->dseg_0_address; + cur_dsd = &lcmd_pkt->dsd; /* Load data segments */ scsi_for_each_sg(cmd, sg, tot_dsds, i) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { /* @@ -3044,15 +3042,12 @@ qlafx00_build_scsi_iocbs(srb_t *sp, struct cmd_type_7_fx00 *cmd_pkt, memset(&lcont_pkt, 0, REQUEST_ENTRY_SIZE); cont_pkt = qlafx00_prep_cont_type1_iocb(req, &lcont_pkt); - cur_dsd = (__le32 *)lcont_pkt.dseg_0_address; + cur_dsd = lcont_pkt.dsd; avail_dsds = 5; cont = 1; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; if (avail_dsds == 0 && cont == 1) { cont = 0; @@ -3283,11 +3278,9 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.req_dsdcnt = cpu_to_le16(1); fx_iocb.req_xfrcnt = cpu_to_le16(fxio->u.fxiocb.req_len); - fx_iocb.dseg_rq_address[0] = - cpu_to_le32(LSD(fxio->u.fxiocb.req_dma_handle)); - fx_iocb.dseg_rq_address[1] = - cpu_to_le32(MSD(fxio->u.fxiocb.req_dma_handle)); - fx_iocb.dseg_rq_len = + fx_iocb.dseg_rq.address = + cpu_to_le64(fxio->u.fxiocb.req_dma_handle); + fx_iocb.dseg_rq.length = cpu_to_le32(fxio->u.fxiocb.req_len); } @@ -3295,11 +3288,9 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.rsp_dsdcnt = cpu_to_le16(1); fx_iocb.rsp_xfrcnt = cpu_to_le16(fxio->u.fxiocb.rsp_len); - fx_iocb.dseg_rsp_address[0] = - cpu_to_le32(LSD(fxio->u.fxiocb.rsp_dma_handle)); - fx_iocb.dseg_rsp_address[1] = - cpu_to_le32(MSD(fxio->u.fxiocb.rsp_dma_handle)); - fx_iocb.dseg_rsp_len = + fx_iocb.dseg_rsp.address = + cpu_to_le64(fxio->u.fxiocb.rsp_dma_handle); + fx_iocb.dseg_rsp.length = cpu_to_le32(fxio->u.fxiocb.rsp_len); } @@ -3329,19 +3320,17 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) int avail_dsds, tot_dsds; cont_a64_entry_t lcont_pkt; cont_a64_entry_t *cont_pkt = NULL; - __le32 *cur_dsd; + struct dsd64 *cur_dsd; int index = 0, cont = 0; fx_iocb.req_dsdcnt = cpu_to_le16(bsg_job->request_payload.sg_cnt); tot_dsds = bsg_job->request_payload.sg_cnt; - cur_dsd = (__le32 *)&fx_iocb.dseg_rq_address[0]; + cur_dsd = &fx_iocb.dseg_rq; avail_dsds = 1; for_each_sg(bsg_job->request_payload.sg_list, sg, tot_dsds, index) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { /* @@ -3353,17 +3342,13 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) cont_pkt = qlafx00_prep_cont_type1_iocb( sp->vha->req, &lcont_pkt); - cur_dsd = (__le32 *) - lcont_pkt.dseg_0_address; + cur_dsd = lcont_pkt.dsd; avail_dsds = 5; cont = 1; entry_cnt++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; if (avail_dsds == 0 && cont == 1) { @@ -3391,19 +3376,17 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) int avail_dsds, tot_dsds; cont_a64_entry_t lcont_pkt; cont_a64_entry_t *cont_pkt = NULL; - __le32 *cur_dsd; + struct dsd64 *cur_dsd; int index = 0, cont = 0; fx_iocb.rsp_dsdcnt = cpu_to_le16(bsg_job->reply_payload.sg_cnt); tot_dsds = bsg_job->reply_payload.sg_cnt; - cur_dsd = (__le32 *)&fx_iocb.dseg_rsp_address[0]; + cur_dsd = &fx_iocb.dseg_rsp; avail_dsds = 1; for_each_sg(bsg_job->reply_payload.sg_list, sg, tot_dsds, index) { - dma_addr_t sle_dma; - /* Allocate additional continuation packets? */ if (avail_dsds == 0) { /* @@ -3415,17 +3398,13 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) cont_pkt = qlafx00_prep_cont_type1_iocb( sp->vha->req, &lcont_pkt); - cur_dsd = (__le32 *) - lcont_pkt.dseg_0_address; + cur_dsd = lcont_pkt.dsd; avail_dsds = 5; cont = 1; entry_cnt++; } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; if (avail_dsds == 0 && cont == 1) { diff --git a/drivers/scsi/qla2xxx/qla_mr.h b/drivers/scsi/qla2xxx/qla_mr.h index aeaa1b40b1fc..4567f0c42486 100644 --- a/drivers/scsi/qla2xxx/qla_mr.h +++ b/drivers/scsi/qla2xxx/qla_mr.h @@ -7,6 +7,8 @@ #ifndef __QLA_MR_H #define __QLA_MR_H +#include "qla_dsd.h" + /* * The PCI VendorID and DeviceID for our board. */ @@ -46,8 +48,7 @@ struct cmd_type_7_fx00 { uint8_t fcp_cdb[MAX_CMDSZ]; /* SCSI command words. */ __le32 byte_count; /* Total byte count. */ - uint32_t dseg_0_address[2]; /* Data segment 0 address. */ - uint32_t dseg_0_len; /* Data segment 0 length. */ + struct dsd64 dsd; }; #define STATUS_TYPE_FX00 0x01 /* Status entry. */ @@ -176,10 +177,8 @@ struct fxdisc_entry_fx00 { uint8_t flags; uint8_t reserved_1; - __le32 dseg_rq_address[2]; /* Data segment 0 address. */ - __le32 dseg_rq_len; /* Data segment 0 length. */ - __le32 dseg_rsp_address[2]; /* Data segment 1 address. */ - __le32 dseg_rsp_len; /* Data segment 1 length. */ + struct dsd64 dseg_rq; + struct dsd64 dseg_rsp; __le32 dataword; __le32 adapid; diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 0829ab7f0d54..29b30df97c58 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -305,7 +305,7 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) uint16_t req_cnt; uint16_t tot_dsds; uint16_t avail_dsds; - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; struct req_que *req = NULL; struct scsi_qla_host *vha = sp->fcport->vha; struct qla_hw_data *ha = vha->hw; @@ -423,12 +423,11 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) /* One DSD is available in the Command Type NVME IOCB */ avail_dsds = 1; - cur_dsd = (uint32_t *)&cmd_pkt->nvme_data_dseg_address[0]; + cur_dsd = &cmd_pkt->nvme_dsd; sgl = fd->first_sgl; /* Load data segments */ for_each_sg(sgl, sg, tot_dsds, i) { - dma_addr_t sle_dma; cont_a64_entry_t *cont_pkt; /* Allocate additional continuation packets? */ @@ -450,14 +449,11 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) put_unaligned_le32(CONTINUE_A64_TYPE, &cont_pkt->entry_type); - cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; - avail_dsds = 5; + cur_dsd = cont_pkt->dsd; + avail_dsds = ARRAY_SIZE(cont_pkt->dsd); } - sle_dma = sg_dma_address(sg); - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); + append_dsd64(&cur_dsd, sg); avail_dsds--; } diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h index 0db04f0a4d5d..b67aa271f6cc 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.h +++ b/drivers/scsi/qla2xxx/qla_nvme.h @@ -13,6 +13,7 @@ #include #include "qla_def.h" +#include "qla_dsd.h" /* default dev loss time (seconds) before transport tears down ctrl */ #define NVME_FC_DEV_LOSS_TMO 30 @@ -72,8 +73,7 @@ struct cmd_nvme { uint8_t port_id[3]; /* PortID of destination port. */ uint8_t vp_index; - uint32_t nvme_data_dseg_address[2]; /* Data segment address. */ - uint32_t nvme_data_dseg_len; /* Data segment length. */ + struct dsd64 nvme_dsd; }; #define PT_LS4_REQUEST 0x89 /* Link Service pass-through IOCB (request) */ @@ -101,10 +101,7 @@ struct pt_ls4_request { uint32_t rsvd3; uint32_t rx_byte_count; uint32_t tx_byte_count; - uint32_t dseg0_address[2]; - uint32_t dseg0_len; - uint32_t dseg1_address[2]; - uint32_t dseg1_len; + struct dsd64 dsd[2]; }; #define PT_LS4_UNSOL 0x56 /* pass-up unsolicited rec FC-NVMe request */ diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index b3f741cfe6ed..c121a8d9e783 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -2640,7 +2640,7 @@ static int qlt_24xx_build_ctio_pkt(struct qla_qpair *qpair, static void qlt_load_cont_data_segments(struct qla_tgt_prm *prm) { int cnt; - uint32_t *dword_ptr; + struct dsd64 *cur_dsd; /* Build continuation packets */ while (prm->seg_cnt > 0) { @@ -2661,19 +2661,13 @@ static void qlt_load_cont_data_segments(struct qla_tgt_prm *prm) cont_pkt64->sys_define = 0; cont_pkt64->entry_type = CONTINUE_A64_TYPE; - dword_ptr = (uint32_t *)&cont_pkt64->dseg_0_address; + cur_dsd = cont_pkt64->dsd; /* Load continuation entry data segments */ for (cnt = 0; cnt < QLA_TGT_DATASEGS_PER_CONT_24XX && prm->seg_cnt; cnt++, prm->seg_cnt--) { - *dword_ptr++ = - cpu_to_le32(lower_32_bits - (sg_dma_address(prm->sg))); - *dword_ptr++ = cpu_to_le32(upper_32_bits - (sg_dma_address(prm->sg))); - *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); - + append_dsd64(&cur_dsd, prm->sg); prm->sg = sg_next(prm->sg); } } @@ -2686,13 +2680,13 @@ static void qlt_load_cont_data_segments(struct qla_tgt_prm *prm) static void qlt_load_data_segments(struct qla_tgt_prm *prm) { int cnt; - uint32_t *dword_ptr; + struct dsd64 *cur_dsd; struct ctio7_to_24xx *pkt24 = (struct ctio7_to_24xx *)prm->pkt; pkt24->u.status0.transfer_length = cpu_to_le32(prm->cmd->bufflen); /* Setup packet address segment pointer */ - dword_ptr = pkt24->u.status0.dseg_0_address; + cur_dsd = &pkt24->u.status0.dsd; /* Set total data segment count */ if (prm->seg_cnt) @@ -2700,8 +2694,8 @@ static void qlt_load_data_segments(struct qla_tgt_prm *prm) if (prm->seg_cnt == 0) { /* No data transfer */ - *dword_ptr++ = 0; - *dword_ptr = 0; + cur_dsd->address = 0; + cur_dsd->length = 0; return; } @@ -2711,14 +2705,7 @@ static void qlt_load_data_segments(struct qla_tgt_prm *prm) for (cnt = 0; (cnt < QLA_TGT_DATASEGS_PER_CMD_24XX) && prm->seg_cnt; cnt++, prm->seg_cnt--) { - *dword_ptr++ = - cpu_to_le32(lower_32_bits(sg_dma_address(prm->sg))); - - *dword_ptr++ = cpu_to_le32(upper_32_bits( - sg_dma_address(prm->sg))); - - *dword_ptr++ = cpu_to_le32(sg_dma_len(prm->sg)); - + append_dsd64(&cur_dsd, prm->sg); prm->sg = sg_next(prm->sg); } @@ -3042,7 +3029,7 @@ qla_tgt_set_dif_tags(struct qla_tgt_cmd *cmd, struct crc_context *ctx, static inline int qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) { - uint32_t *cur_dsd; + struct dsd64 *cur_dsd; uint32_t transfer_length = 0; uint32_t data_bytes; uint32_t dif_bytes; @@ -3193,7 +3180,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) pkt->crc_context_len = CRC_CONTEXT_LEN_FW; if (!bundling) { - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.nobundling.data_address; + cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd; } else { /* * Configure Bundling if we need to fetch interlaving @@ -3203,7 +3190,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(prm->tot_dsds - prm->prot_seg_cnt); - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.data_address; + cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd; } /* Finish the common fields of CRC pkt */ @@ -3236,7 +3223,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) /* Walks dif segments */ pkt->add_flags |= CTIO_CRC2_AF_DIF_DSD_ENA; - cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; + cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; if (qla24xx_walk_and_build_prot_sglist(ha, NULL, cur_dsd, prm->prot_seg_cnt, cmd)) goto crc_queuing_error; diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 262fc33fb473..b09a9232b817 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -29,6 +29,7 @@ #define __QLA_TARGET_H #include "qla_def.h" +#include "qla_dsd.h" /* * Must be changed on any change in any initiator visible interfaces or @@ -224,12 +225,7 @@ struct ctio_to_2xxx { uint16_t reserved_1[3]; uint16_t scsi_status; uint32_t transfer_length; - uint32_t dseg_0_address; /* Data segment 0 address. */ - uint32_t dseg_0_length; /* Data segment 0 length. */ - uint32_t dseg_1_address; /* Data segment 1 address. */ - uint32_t dseg_1_length; /* Data segment 1 length. */ - uint32_t dseg_2_address; /* Data segment 2 address. */ - uint32_t dseg_2_length; /* Data segment 2 length. */ + struct dsd32 dsd[3]; } __packed; #define ATIO_PATH_INVALID 0x07 #define ATIO_CANT_PROV_CAP 0x16 @@ -429,10 +425,7 @@ struct ctio7_to_24xx { uint32_t reserved2; uint32_t transfer_length; uint32_t reserved3; - /* Data segment 0 address. */ - uint32_t dseg_0_address[2]; - /* Data segment 0 length. */ - uint32_t dseg_0_length; + struct dsd64 dsd; } status0; struct { uint16_t sense_length; From patchwork Wed Apr 17 21:44:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD9AF1390 for ; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 927E428A93 for ; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86E5128BA9; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E3F328A96 for ; Wed, 17 Apr 2019 21:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387627AbfDQVpl (ORCPT ); Wed, 17 Apr 2019 17:45:41 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42015 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387539AbfDQVpb (ORCPT ); Wed, 17 Apr 2019 17:45:31 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so107538plb.9 for ; Wed, 17 Apr 2019 14:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C8qB8F7QwIML2KyzbOK8KQYwMbe68rY3iRQ64eOTtRY=; b=KtRHflHZfFYPJFiK0FJGD0uJ6mh0UqjGgoH9+kOJn2nvw3iCS3IJ+UhFleWclBzoyw cZ+DGxe0mWnq3zQRyi37VngbHoHJZQZBe97cI4Dawhn5mtgAR31JC8KDLW1HVScPl4fi PUP4vVRa/fsENel51K5kCowHuh8UEDxKxuNb7waPbvsnhn2jW1xacrYBbH3XkU/7AZUq Cj5gRRppQ2X3PmbGHpnd337Jhap/GqUkrBu/AbRmpmCQ2g5FGhq8NhcHCGGUV3IP+ozH 2qRxxqhtRLudBwmu0V+1N4ir+v+PC7AvCcFQ9gTWMwbeKvZU2rwqJNXomdLFQ+xHwFJo FMpA== X-Gm-Message-State: APjAAAUOjoHE4wgXTMt0GwCFRfyJ5I3wdf6dWe684P5Ene5mOwM8we2X dyzCHgggmZbUQ6KCRx+KcTl/Tt2j X-Google-Smtp-Source: APXvYqwo/D3jYgdiKPNCX6yyvR2xsciSRtgZKonO6Pse347oK4I5fGuD4fqPY/63dVssJ3xmUdgw0A== X-Received: by 2002:a17:902:eb0f:: with SMTP id cw15mr2185759plb.314.1555537530039; Wed, 17 Apr 2019 14:45:30 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:29 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 30/34] qla2xxx: Use __le64 instead of uint32_t[2] for sending DMA addresses to firmware Date: Wed, 17 Apr 2019 14:44:39 -0700 Message-Id: <20190417214443.243152-31-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes the code easier to read and more compact. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_def.h | 6 ++-- drivers/scsi/qla2xxx/qla_fw.h | 45 ++++++++++++------------ drivers/scsi/qla2xxx/qla_gs.c | 3 +- drivers/scsi/qla2xxx/qla_init.c | 15 +++----- drivers/scsi/qla2xxx/qla_iocb.c | 57 +++++++++++-------------------- drivers/scsi/qla2xxx/qla_mr.c | 8 ++--- drivers/scsi/qla2xxx/qla_nvme.c | 6 ++-- drivers/scsi/qla2xxx/qla_nvme.h | 4 +-- drivers/scsi/qla2xxx/qla_nx.c | 6 ++-- drivers/scsi/qla2xxx/qla_target.c | 3 +- drivers/scsi/qla2xxx/qla_target.h | 4 +-- 11 files changed, 65 insertions(+), 92 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 502a4812bf51..1a4095c56eee 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -1329,8 +1329,8 @@ typedef struct { uint16_t response_q_inpointer; uint16_t request_q_length; uint16_t response_q_length; - uint32_t request_q_address[2]; - uint32_t response_q_address[2]; + __le64 request_q_address __packed; + __le64 response_q_address __packed; uint16_t lun_enables; uint8_t command_resource_count; @@ -3031,7 +3031,7 @@ struct sns_cmd_pkt { struct { uint16_t buffer_length; uint16_t reserved_1; - uint32_t buffer_address[2]; + __le64 buffer_address __packed; uint16_t subcommand_length; uint16_t reserved_2; uint16_t subcommand; diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h index 604eb4682ac0..df079a8c2b33 100644 --- a/drivers/scsi/qla2xxx/qla_fw.h +++ b/drivers/scsi/qla2xxx/qla_fw.h @@ -341,9 +341,9 @@ struct init_cb_24xx { uint16_t prio_request_q_length; - uint32_t request_q_address[2]; - uint32_t response_q_address[2]; - uint32_t prio_request_q_address[2]; + __le64 request_q_address __packed; + __le64 response_q_address __packed; + __le64 prio_request_q_address __packed; uint16_t msix; uint16_t msix_atio; @@ -351,7 +351,7 @@ struct init_cb_24xx { uint16_t atio_q_inpointer; uint16_t atio_q_length; - uint32_t atio_q_address[2]; + __le64 atio_q_address __packed; uint16_t interrupt_delay_timer; /* 100us increments. */ uint16_t login_timeout; @@ -455,7 +455,7 @@ struct cmd_bidir { #define BD_WRITE_DATA BIT_0 uint16_t fcp_cmnd_dseg_len; /* Data segment length. */ - uint32_t fcp_cmnd_dseg_address[2]; /* Data segment address. */ + __le64 fcp_cmnd_dseg_address __packed;/* Data segment address. */ uint16_t reserved[2]; /* Reserved */ @@ -492,10 +492,11 @@ struct cmd_type_6 { #define CF_READ_DATA BIT_1 #define CF_WRITE_DATA BIT_0 - uint16_t fcp_cmnd_dseg_len; /* Data segment length. */ - uint32_t fcp_cmnd_dseg_address[2]; /* Data segment address. */ - - uint32_t fcp_rsp_dseg_address[2]; /* Data segment address. */ + uint16_t fcp_cmnd_dseg_len; /* Data segment length. */ + /* Data segment address. */ + __le64 fcp_cmnd_dseg_address __packed; + /* Data segment address. */ + __le64 fcp_rsp_dseg_address __packed; uint32_t byte_count; /* Total byte count. */ @@ -572,17 +573,17 @@ struct cmd_type_crc_2 { uint16_t control_flags; /* Control flags. */ - uint16_t fcp_cmnd_dseg_len; /* Data segment length. */ - uint32_t fcp_cmnd_dseg_address[2]; /* Data segment address. */ - - uint32_t fcp_rsp_dseg_address[2]; /* Data segment address. */ + uint16_t fcp_cmnd_dseg_len; /* Data segment length. */ + __le64 fcp_cmnd_dseg_address __packed; + /* Data segment address. */ + __le64 fcp_rsp_dseg_address __packed; uint32_t byte_count; /* Total byte count. */ uint8_t port_id[3]; /* PortID of destination port. */ uint8_t vp_index; - uint32_t crc_context_address[2]; /* Data segment address. */ + __le64 crc_context_address __packed; /* Data segment address. */ uint16_t crc_context_len; /* Data segment length. */ uint16_t reserved_1; /* MUST be set to 0. */ }; @@ -763,9 +764,9 @@ struct els_entry_24xx { uint32_t rx_byte_count; uint32_t tx_byte_count; - uint32_t tx_address[2]; /* Data segment 0 address. */ + __le64 tx_address __packed; /* Data segment 0 address. */ uint32_t tx_len; /* Data segment 0 length. */ - uint32_t rx_address[2]; /* Data segment 1 address. */ + __le64 rx_address __packed; /* Data segment 1 address. */ uint32_t rx_len; /* Data segment 1 length. */ }; @@ -1418,9 +1419,9 @@ struct vf_evfp_entry_24xx { uint16_t control_flags; uint32_t io_parameter_0; uint32_t io_parameter_1; - uint32_t tx_address[2]; /* Data segment 0 address. */ + __le64 tx_address __packed; /* Data segment 0 address. */ uint32_t tx_len; /* Data segment 0 length. */ - uint32_t rx_address[2]; /* Data segment 1 address. */ + __le64 rx_address __packed; /* Data segment 1 address. */ uint32_t rx_len; /* Data segment 1 length. */ }; @@ -1927,15 +1928,15 @@ struct init_cb_81xx { uint16_t prio_request_q_length; - uint32_t request_q_address[2]; - uint32_t response_q_address[2]; - uint32_t prio_request_q_address[2]; + __le64 request_q_address __packed; + __le64 response_q_address __packed; + __le64 prio_request_q_address __packed; uint8_t reserved_4[8]; uint16_t atio_q_inpointer; uint16_t atio_q_length; - uint32_t atio_q_address[2]; + __le64 atio_q_address __packed; uint16_t interrupt_delay_timer; /* 100us increments. */ uint16_t login_timeout; diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index e2653bbc117d..9f58e591666d 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -996,8 +996,7 @@ qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len, memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt)); wc = data_size / 2; /* Size in 16bit words. */ sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc); - sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma)); - sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma)); + put_unaligned_le64(ha->sns_cmd_dma, &sns_cmd->p.cmd.buffer_address); sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len); sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd); wc = (data_size - 16) / 4; /* Size in 32bit words. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 8945278ff0be..54772d4c377f 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3941,10 +3941,8 @@ qla2x00_config_rings(struct scsi_qla_host *vha) ha->init_cb->response_q_inpointer = cpu_to_le16(0); ha->init_cb->request_q_length = cpu_to_le16(req->length); ha->init_cb->response_q_length = cpu_to_le16(rsp->length); - ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); - ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); - ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); - ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); + put_unaligned_le64(req->dma, &ha->init_cb->request_q_address); + put_unaligned_le64(rsp->dma, &ha->init_cb->response_q_address); WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); @@ -3971,16 +3969,13 @@ qla24xx_config_rings(struct scsi_qla_host *vha) icb->response_q_inpointer = cpu_to_le16(0); icb->request_q_length = cpu_to_le16(req->length); icb->response_q_length = cpu_to_le16(rsp->length); - icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); - icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); - icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); - icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); + put_unaligned_le64(req->dma, &icb->request_q_address); + put_unaligned_le64(rsp->dma, &icb->response_q_address); /* Setup ATIO queue dma pointers for target mode */ icb->atio_q_inpointer = cpu_to_le16(0); icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length); - icb->atio_q_address[0] = cpu_to_le32(LSD(ha->tgt.atio_dma)); - icb->atio_q_address[1] = cpu_to_le32(MSD(ha->tgt.atio_dma)); + put_unaligned_le64(ha->tgt.atio_dma, &icb->atio_q_address); if (IS_SHADOW_REG_CAPABLE(ha)) icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29); diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index ef895e1142c9..9312b19ed708 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1445,8 +1445,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, qla24xx_set_t10dif_tags(sp, (struct fw_dif_context *) &crc_ctx_pkt->ref_tag, tot_prot_dsds); - cmd_pkt->crc_context_address[0] = cpu_to_le32(LSD(crc_ctx_dma)); - cmd_pkt->crc_context_address[1] = cpu_to_le32(MSD(crc_ctx_dma)); + put_unaligned_le64(crc_ctx_dma, &cmd_pkt->crc_context_address); cmd_pkt->crc_context_len = CRC_CONTEXT_LEN_FW; /* Determine SCSI command length -- align to 4 byte boundary */ @@ -1473,10 +1472,8 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, int_to_scsilun(cmd->device->lun, &fcp_cmnd->lun); memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); - cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32( - LSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); - cmd_pkt->fcp_cmnd_dseg_address[1] = cpu_to_le32( - MSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); + put_unaligned_le64(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF, + &cmd_pkt->fcp_cmnd_dseg_address); fcp_cmnd->task_management = 0; fcp_cmnd->task_attribute = TSK_SIMPLE; @@ -2707,18 +2704,13 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) { els_iocb->tx_byte_count = els_iocb->tx_len = sizeof(struct els_plogi_payload); - els_iocb->tx_address[0] = - cpu_to_le32(LSD(elsio->u.els_plogi.els_plogi_pyld_dma)); - els_iocb->tx_address[1] = - cpu_to_le32(MSD(elsio->u.els_plogi.els_plogi_pyld_dma)); - + put_unaligned_le64(elsio->u.els_plogi.els_plogi_pyld_dma, + &els_iocb->tx_address); els_iocb->rx_dsd_count = 1; els_iocb->rx_byte_count = els_iocb->rx_len = sizeof(struct els_plogi_payload); - els_iocb->rx_address[0] = - cpu_to_le32(LSD(elsio->u.els_plogi.els_resp_pyld_dma)); - els_iocb->rx_address[1] = - cpu_to_le32(MSD(elsio->u.els_plogi.els_resp_pyld_dma)); + put_unaligned_le64(elsio->u.els_plogi.els_resp_pyld_dma, + &els_iocb->rx_address); ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3073, "PLOGI ELS IOCB:\n"); @@ -2726,15 +2718,12 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) (uint8_t *)els_iocb, 0x70); } else { els_iocb->tx_byte_count = sizeof(struct els_logo_payload); - els_iocb->tx_address[0] = - cpu_to_le32(LSD(elsio->u.els_logo.els_logo_pyld_dma)); - els_iocb->tx_address[1] = - cpu_to_le32(MSD(elsio->u.els_logo.els_logo_pyld_dma)); + put_unaligned_le64(elsio->u.els_logo.els_logo_pyld_dma, + &els_iocb->tx_address); els_iocb->tx_len = cpu_to_le32(sizeof(struct els_logo_payload)); els_iocb->rx_byte_count = 0; - els_iocb->rx_address[0] = 0; - els_iocb->rx_address[1] = 0; + els_iocb->rx_address = 0; els_iocb->rx_len = 0; } @@ -2957,17 +2946,13 @@ qla24xx_els_iocb(srb_t *sp, struct els_entry_24xx *els_iocb) els_iocb->tx_byte_count = cpu_to_le32(bsg_job->request_payload.payload_len); - els_iocb->tx_address[0] = cpu_to_le32(LSD(sg_dma_address - (bsg_job->request_payload.sg_list))); - els_iocb->tx_address[1] = cpu_to_le32(MSD(sg_dma_address - (bsg_job->request_payload.sg_list))); + put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), + &els_iocb->tx_address); els_iocb->tx_len = cpu_to_le32(sg_dma_len (bsg_job->request_payload.sg_list)); - els_iocb->rx_address[0] = cpu_to_le32(LSD(sg_dma_address - (bsg_job->reply_payload.sg_list))); - els_iocb->rx_address[1] = cpu_to_le32(MSD(sg_dma_address - (bsg_job->reply_payload.sg_list))); + put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), + &els_iocb->rx_address); els_iocb->rx_len = cpu_to_le32(sg_dma_len (bsg_job->reply_payload.sg_list)); @@ -3004,12 +2989,12 @@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entry_t *ct_iocb) ct_iocb->rsp_bytecount = cpu_to_le32(bsg_job->reply_payload.payload_len); - ct_iocb->req_dsd.address = - cpu_to_le64(sg_dma_address(bsg_job->request_payload.sg_list)); + put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), + &ct_iocb->req_dsd.address); ct_iocb->req_dsd.length = ct_iocb->req_bytecount; - ct_iocb->rsp_dsd.address = - cpu_to_le64(sg_dma_address(bsg_job->reply_payload.sg_list)); + put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), + &ct_iocb->rsp_dsd.address); ct_iocb->rsp_dsd.length = ct_iocb->rsp_bytecount; avail_dsds = 1; @@ -3332,10 +3317,8 @@ qla82xx_start_scsi(srb_t *sp) *fcp_dl = htonl((uint32_t)scsi_bufflen(cmd)); cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len); - cmd_pkt->fcp_cmnd_dseg_address[0] = - cpu_to_le32(LSD(ctx->fcp_cmnd_dma)); - cmd_pkt->fcp_cmnd_dseg_address[1] = - cpu_to_le32(MSD(ctx->fcp_cmnd_dma)); + put_unaligned_le64(ctx->fcp_cmnd_dma, + &cmd_pkt->fcp_cmnd_dseg_address); sp->flags |= SRB_FCP_CMND_DMA_VALID; cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index a08d83dbcece..942ee13b96a4 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -3278,8 +3278,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.req_dsdcnt = cpu_to_le16(1); fx_iocb.req_xfrcnt = cpu_to_le16(fxio->u.fxiocb.req_len); - fx_iocb.dseg_rq.address = - cpu_to_le64(fxio->u.fxiocb.req_dma_handle); + put_unaligned_le64(fxio->u.fxiocb.req_dma_handle, + &fx_iocb.dseg_rq.address); fx_iocb.dseg_rq.length = cpu_to_le32(fxio->u.fxiocb.req_len); } @@ -3288,8 +3288,8 @@ qlafx00_fxdisc_iocb(srb_t *sp, struct fxdisc_entry_fx00 *pfxiocb) fx_iocb.rsp_dsdcnt = cpu_to_le16(1); fx_iocb.rsp_xfrcnt = cpu_to_le16(fxio->u.fxiocb.rsp_len); - fx_iocb.dseg_rsp.address = - cpu_to_le64(fxio->u.fxiocb.rsp_dma_handle); + put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle, + &fx_iocb.dseg_rsp.address); fx_iocb.dseg_rsp.length = cpu_to_le32(fxio->u.fxiocb.rsp_len); } diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 29b30df97c58..4c1112107e88 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -410,13 +410,11 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) /* NVME RSP IU */ cmd_pkt->nvme_rsp_dsd_len = cpu_to_le16(fd->rsplen); - cmd_pkt->nvme_rsp_dseg_address[0] = cpu_to_le32(LSD(fd->rspdma)); - cmd_pkt->nvme_rsp_dseg_address[1] = cpu_to_le32(MSD(fd->rspdma)); + put_unaligned_le64(fd->rspdma, &cmd_pkt->nvme_rsp_dseg_address); /* NVME CNMD IU */ cmd_pkt->nvme_cmnd_dseg_len = cpu_to_le16(fd->cmdlen); - cmd_pkt->nvme_cmnd_dseg_address[0] = cpu_to_le32(LSD(fd->cmddma)); - cmd_pkt->nvme_cmnd_dseg_address[1] = cpu_to_le32(MSD(fd->cmddma)); + cmd_pkt->nvme_cmnd_dseg_address = cpu_to_le64(fd->cmddma); cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); cmd_pkt->byte_count = cpu_to_le32(fd->payload_length); diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h index b67aa271f6cc..d3b8a6440113 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.h +++ b/drivers/scsi/qla2xxx/qla_nvme.h @@ -65,8 +65,8 @@ struct cmd_nvme { #define CF_WRITE_DATA BIT_0 uint16_t nvme_cmnd_dseg_len; /* Data segment length. */ - uint32_t nvme_cmnd_dseg_address[2]; /* Data segment address. */ - uint32_t nvme_rsp_dseg_address[2]; /* Data segment address. */ + __le64 nvme_cmnd_dseg_address __packed;/* Data segment address. */ + __le64 nvme_rsp_dseg_address __packed; /* Data segment address. */ uint32_t byte_count; /* Total byte count. */ diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index c12db16c3cf4..c760ae354174 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -1788,10 +1788,8 @@ void qla82xx_config_rings(struct scsi_qla_host *vha) icb->response_q_inpointer = cpu_to_le16(0); icb->request_q_length = cpu_to_le16(req->length); icb->response_q_length = cpu_to_le16(rsp->length); - icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); - icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); - icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); - icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); + put_unaligned_le64(req->dma, &icb->request_q_address); + put_unaligned_le64(rsp->dma, &icb->response_q_address); WRT_REG_DWORD(®->req_q_out[0], 0); WRT_REG_DWORD(®->rsp_q_in[0], 0); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index c121a8d9e783..b1a355f8cf2a 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3175,8 +3175,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm) qla_tgt_set_dif_tags(cmd, crc_ctx_pkt, &fw_prot_opts); - pkt->crc_context_address[0] = cpu_to_le32(LSD(crc_ctx_dma)); - pkt->crc_context_address[1] = cpu_to_le32(MSD(crc_ctx_dma)); + put_unaligned_le64(crc_ctx_dma, &pkt->crc_context_address); pkt->crc_context_len = CRC_CONTEXT_LEN_FW; if (!bundling) { diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index b09a9232b817..89ceffa7d4fd 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -519,10 +519,10 @@ struct ctio_crc2_to_fw { uint32_t reserved5; __le32 transfer_length; /* total fc transfer length */ uint32_t reserved6; - __le32 crc_context_address[2];/* Data segment address. */ + __le64 crc_context_address __packed; /* Data segment address. */ uint16_t crc_context_len; /* Data segment length. */ uint16_t reserved_1; /* MUST be set to 0. */ -} __packed; +}; /* CTIO Type CRC_x Status IOCB */ struct ctio_crc_from_fw { From patchwork Wed Apr 17 21:44:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DABD17E0 for ; Wed, 17 Apr 2019 21:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 685ED28A93 for ; Wed, 17 Apr 2019 21:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D0DF28BA9; Wed, 17 Apr 2019 21:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F301628A93 for ; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387556AbfDQVpl (ORCPT ); Wed, 17 Apr 2019 17:45:41 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36859 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387600AbfDQVpb (ORCPT ); Wed, 17 Apr 2019 17:45:31 -0400 Received: by mail-pl1-f195.google.com with SMTP id ck15so120401plb.3 for ; Wed, 17 Apr 2019 14:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0sISpMETIoFW4aa7wZzd//XMlizWjNwapA9loNGUa+w=; b=h/NvuAniTjy8Nci/r5VYg6W9oH0A6lBFliRZGipopLbYZCM1m/u9bEdAO8BE64IRPs p2T6fLYRA6R7QGcppXdmlJ30DZobsBRErlrer5fplSr9bM2wnxqDFfk2sJU6hpHGKDEL h2Q6b6BiPgQHYHND+HEgh+7nk/B7kym6zOIdM8FCBVo5sCuKACi6xz09jJyCDSpKC34r loH4AoaobFtn51tvkx7fXwR3l3EEfNTKp4jrgUG7r1T8ROGEjI27p3wQuZbYLtvZU4Pe 64SOQoZ+4tJsT0VzUwOGMxmDFE5d2uk+1+xEwoPEBV8MltsXT1XBw6xZleraUZJudjtl VQzQ== X-Gm-Message-State: APjAAAWKyevLQvi/0GZzvoaCpTnO/fQYlYa692UgcfnmtzVrrCrazIxe L9ed3WMUiyYatVKR3F6bvGw= X-Google-Smtp-Source: APXvYqwUn5nKu1zJeBUjBSNkr1kM+37vmxaejL6tRnY1y9MK9Zs7r6HgNjEhbNVaWFPoJzbKNRRxFQ== X-Received: by 2002:a17:902:1602:: with SMTP id g2mr2195737plg.325.1555537531095; Wed, 17 Apr 2019 14:45:31 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:30 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 31/34] qla2xxx: Complain loudly about reference count underflow Date: Wed, 17 Apr 2019 14:44:40 -0700 Message-Id: <20190417214443.243152-32-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A reference count underflow is a severe bug. Hence complain loudly if a reference count underflow happens. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nvme.c | 15 +++++---------- drivers/scsi/qla2xxx/qla_os.c | 16 ++-------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 4c1112107e88..22e3fba28e51 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -131,11 +131,8 @@ static void qla_nvme_sp_ls_done(void *ptr, int res) struct nvmefc_ls_req *fd; struct nvme_private *priv; - if (atomic_read(&sp->ref_count) == 0) { - ql_log(ql_log_warn, sp->fcport->vha, 0x2123, - "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count); @@ -160,6 +157,9 @@ static void qla_nvme_sp_done(void *ptr, int res) nvme = &sp->u.iocb_cmd; fd = nvme->u.nvme.desc; + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) + return; + atomic_dec(&sp->ref_count); if (res == QLA_SUCCESS) { @@ -199,13 +199,8 @@ static void qla_nvme_abort_work(struct work_struct *work) return; } - if (atomic_read(&sp->ref_count) == 0) { - WARN_ON(1); - ql_log(ql_log_info, fcport->vha, 0xffff, - "%s: command already aborted on sp: %p\n", - __func__, sp); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } rval = ha->isp_ops->abort_command(sp); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 73ddd02d1a39..e1c82a0a9745 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -716,14 +716,8 @@ qla2x00_sp_compl(void *ptr, int res) struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct completion *comp = sp->comp; - if (atomic_read(&sp->ref_count) == 0) { - ql_dbg(ql_dbg_io, sp->vha, 0x3015, - "SP reference-count to ZERO -- sp=%p cmd=%p.\n", - sp, GET_CMD_SP(sp)); - if (ql2xextended_error_logging & ql_dbg_io) - WARN_ON(atomic_read(&sp->ref_count) == 0); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count); @@ -827,14 +821,8 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct completion *comp = sp->comp; - if (atomic_read(&sp->ref_count) == 0) { - ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, - "SP reference-count to ZERO -- sp=%p cmd=%p.\n", - sp, GET_CMD_SP(sp)); - if (ql2xextended_error_logging & ql_dbg_io) - WARN_ON(atomic_read(&sp->ref_count) == 0); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count); From patchwork Wed Apr 17 21:44:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DAA61390 for ; Wed, 17 Apr 2019 21:45:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53BF428A96 for ; Wed, 17 Apr 2019 21:45:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4711728A93; Wed, 17 Apr 2019 21:45:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F0C828A93 for ; Wed, 17 Apr 2019 21:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387967AbfDQVph (ORCPT ); Wed, 17 Apr 2019 17:45:37 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46805 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387959AbfDQVpd (ORCPT ); Wed, 17 Apr 2019 17:45:33 -0400 Received: by mail-pg1-f196.google.com with SMTP id q1so134374pgv.13 for ; Wed, 17 Apr 2019 14:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a88GWmqIR2vvfR57CC62kejQv8YpZBFWo80TPUZqf3o=; b=rigrU4tWgHP8H7MFt/OioeKrmjFkZBEE2LvZ1f4JzwGaf3RiqxgPPSR66YI9yJZByw C4Ch/JXL+s7p2UiEEMuT9MKKgs08KyHn77IbGla3XkO5eorEhhkIOr7Y0blVwGFTdDhk hnXdi1z/qa5piJ/ksupQ2d9XWSR69+lqGarru9dgHrap8d7H3i+OU7RDt03JeOS+lBiG A9xvzeDZDbPnkC36RBZMx64nC/Rq7S1JOXtekgQTvyS1JBriNE5lsQjnrwVTvogH1JlC XfNmeePINQW1trFQvjH6RkWALf10S8JqkiHcS+SvJOXNIT8jX8p/gvYzMgwlYwhNpxob +fCA== X-Gm-Message-State: APjAAAVdlUICMppG0xvFnkdhbzRbP1KEfr6/QatwFd15eVxqPufBQxWr wVNg2KU5NLgV4N3O26rW7aM= X-Google-Smtp-Source: APXvYqxsiHxGwaqzKf6/2fiOujem2AYIA6AEsZhmZFwFZySvsQvOVwaCAq4AiyHfINiWYUQrfFI49Q== X-Received: by 2002:a63:af0a:: with SMTP id w10mr59901380pge.67.1555537532135; Wed, 17 Apr 2019 14:45:32 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:31 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 32/34] qla2xxx: Fix hardirq-unsafe locking Date: Wed, 17 Apr 2019 14:44:41 -0700 Message-Id: <20190417214443.243152-33-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since fc_remote_port_delete() must be called with interrupts enabled, do not disable interrupts when calling that function. Remove the lockin calls from around the put_sess() call. This is safe because the function that is called when the final reference is dropped, qlt_unreg_sess(), grabs the proper locks. This patch avoids that lockdep reports the following: WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected kworker/2:1/62 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire: 0000000009e679b3 (&(&k->k_lock)->rlock){+.+.}, at: klist_next+0x43/0x1d0 and this task is already holding: 00000000a033b71c (&(&ha->tgt.sess_lock)->rlock){-...}, at: qla24xx_delete_sess_fn+0x55/0xf0 [qla2xxx_scst] which would create a new lock dependency: (&(&ha->tgt.sess_lock)->rlock){-...} -> (&(&k->k_lock)->rlock){+.+.} but this new dependency connects a HARDIRQ-irq-safe lock: (&(&ha->tgt.sess_lock)->rlock){-...} ... which became HARDIRQ-irq-safe at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst] qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x2a8/0x320 secondary_startup_64+0xa4/0xb0 to a HARDIRQ-irq-unsafe lock: (&(&k->k_lock)->rlock){+.+.} ... which became HARDIRQ-irq-unsafe at: ... lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7e1/0xb50 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 other info that might help us debug this: Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&(&k->k_lock)->rlock); local_irq_disable(); lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&k->k_lock)->rlock); lock(&(&ha->tgt.sess_lock)->rlock); *** DEADLOCK *** 3 locks held by kworker/2:1/62: #0: 00000000a4319c16 ((wq_completion)"qla2xxx_wq"){+.+.}, at: process_one_work+0x437/0xa80 #1: 00000000ffa34c42 ((work_completion)(&sess->del_work)){+.+.}, at: process_one_work+0x437/0xa80 #2: 00000000a033b71c (&(&ha->tgt.sess_lock)->rlock){-...}, at: qla24xx_delete_sess_fn+0x55/0xf0 [qla2xxx_scst] the dependencies between HARDIRQ-irq-safe lock and the holding lock: -> (&(&ha->tgt.sess_lock)->rlock){-...} ops: 8 { IN-HARDIRQ-W at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst] qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x2a8/0x320 secondary_startup_64+0xa4/0xb0 INITIAL USE at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla24xx_report_id_acquisition+0xa69/0xe30 [qla2xxx_scst] qla24xx_process_response_queue+0x69e/0x1270 [qla2xxx_scst] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx_scst] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x2a8/0x320 secondary_startup_64+0xa4/0xb0 } ... key at: [] __key.85462+0x0/0xfffffffffff7df80 [qla2xxx_scst] ... acquired at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst] qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst] qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst] process_one_work+0x511/0xa80 worker_thread+0x67/0x5b0 kthread+0x1d2/0x1f0 ret_from_fork+0x3a/0x50 the dependencies between the lock to be acquired and HARDIRQ-irq-unsafe lock: -> (&(&k->k_lock)->rlock){+.+.} ops: 13831 { HARDIRQ-ON-W at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7e1/0xb50 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 SOFTIRQ-ON-W at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7e1/0xb50 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 INITIAL USE at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7e1/0xb50 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 } ... key at: [] __key.15491+0x0/0x40 ... acquired at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst] qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst] qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst] process_one_work+0x511/0xa80 worker_thread+0x67/0x5b0 kthread+0x1d2/0x1f0 ret_from_fork+0x3a/0x50 stack backtrace: CPU: 2 PID: 62 Comm: kworker/2:1 Tainted: G O 5.0.7-dbg+ #8 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: qla2xxx_wq qla24xx_delete_sess_fn [qla2xxx_scst] Call Trace: dump_stack+0x86/0xca check_usage.cold.52+0x473/0x563 __lock_acquire+0x11c0/0x23e0 lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0xa0b/0xa30 [qla2xxx_scst] qlt_unreg_sess+0x1c6/0x380 [qla2xxx_scst] qla24xx_delete_sess_fn+0xe6/0xf0 [qla2xxx_scst] process_one_work+0x511/0xa80 worker_thread+0x67/0x5b0 kthread+0x1d2/0x1f0 ret_from_fork+0x3a/0x50 Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 25 ++++++++----------------- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 -- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index b1a355f8cf2a..302bc43cc061 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -682,7 +682,6 @@ int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport, void qla24xx_do_nack_work(struct scsi_qla_host *vha, struct qla_work_evt *e) { fc_port_t *t; - unsigned long flags; switch (e->u.nack.type) { case SRB_NACK_PRLI: @@ -695,10 +694,8 @@ void qla24xx_do_nack_work(struct scsi_qla_host *vha, struct qla_work_evt *e) if (t) { ql_log(ql_log_info, vha, 0xd034, "%s create sess success %p", __func__, t); - spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); /* create sess has an extra kref */ vha->hw->tgt.tgt_ops->put_sess(e->u.nack.fcport); - spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); } break; } @@ -710,9 +707,6 @@ void qla24xx_delete_sess_fn(struct work_struct *work) { fc_port_t *fcport = container_of(work, struct fc_port, del_work); struct qla_hw_data *ha = fcport->vha->hw; - unsigned long flags; - - spin_lock_irqsave(&ha->tgt.sess_lock, flags); if (fcport->se_sess) { ha->tgt.tgt_ops->shutdown_sess(fcport); @@ -720,7 +714,6 @@ void qla24xx_delete_sess_fn(struct work_struct *work) } else { qlt_unreg_sess(fcport); } - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); } /* @@ -789,8 +782,9 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) fcport->port_name, sess->loop_id); sess->local = 0; } - ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + + ha->tgt.tgt_ops->put_sess(sess); } /* @@ -4175,9 +4169,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd) /* * Drop extra session reference from qlt_handle_cmd_for_atio(). */ - spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); return; out_term: @@ -4194,9 +4186,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd) target_free_tag(sess->se_sess, &cmd->se_cmd); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); } static void qlt_do_work(struct work_struct *work) @@ -4405,9 +4395,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, if (!cmd) { ql_dbg(ql_dbg_io, vha, 0x3062, "qla_target(%d): Allocation of cmd failed\n", vha->vp_idx); - spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); return -EBUSY; } @@ -6258,17 +6246,19 @@ static void qlt_abort_work(struct qla_tgt *tgt, } rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess); - ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); + ha->tgt.tgt_ops->put_sess(sess); + if (rc != 0) goto out_term; return; out_term2: + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); + if (sess) ha->tgt.tgt_ops->put_sess(sess); - spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); out_term: spin_lock_irqsave(&ha->hardware_lock, flags); @@ -6326,9 +6316,10 @@ static void qlt_tmr_work(struct qla_tgt *tgt, scsilun_to_int((struct scsi_lun *)&a->u.isp24.fcp_cmnd.lun); rc = qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0); - ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + ha->tgt.tgt_ops->put_sess(sess); + if (rc != 0) goto out_term; return; diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 6334fb9ee2a4..03b58fd60598 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -341,7 +341,6 @@ static void tcm_qla2xxx_put_sess(struct fc_port *sess) if (!sess) return; - assert_spin_locked(&sess->vha->hw->tgt.sess_lock); kref_put(&sess->sess_kref, tcm_qla2xxx_release_session); } @@ -799,7 +798,6 @@ static void tcm_qla2xxx_clear_nacl_from_fcport_map(struct fc_port *sess) static void tcm_qla2xxx_shutdown_sess(struct fc_port *sess) { - assert_spin_locked(&sess->vha->hw->tgt.sess_lock); target_sess_cmd_list_set_waiting(sess->se_sess); } From patchwork Wed Apr 17 21:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EA7017E0 for ; Wed, 17 Apr 2019 21:45:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69D5428A93 for ; Wed, 17 Apr 2019 21:45:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E54028BA9; Wed, 17 Apr 2019 21:45:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07E7F28A93 for ; Wed, 17 Apr 2019 21:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387963AbfDQVpe (ORCPT ); Wed, 17 Apr 2019 17:45:34 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35450 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387962AbfDQVpe (ORCPT ); Wed, 17 Apr 2019 17:45:34 -0400 Received: by mail-pf1-f194.google.com with SMTP id t21so88580pfh.2 for ; Wed, 17 Apr 2019 14:45:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ATXzuJAeM11DHVbKy+mLtJ4hzU63/8FkCHfSVCsvUbI=; b=HWlZmGWxEEjem/FsGNr5iKDaWsOxYdkHQptTmFWPeWt4IlNvIcYcKXzxI3espFRNB9 0lkscTCxusYJ92MgIAMEXbVJAFSeqIrMWQD2x3h9itp9fZhaM1PGM632uMNt6XPO8xRK ri39QKE5mnIqgNfzPHU7cfu740+vZHtmSkzodHv1VCvo6Lf0CS3CkSTrXmv2uU8c2lgv kYbs0D/SwG+qfWaKfc1rsAaoMEe0qYfuqImtBiuqn5nswwr0en7v8pNKI3wt5H/YI+wu +Hj3aOuxNthLGzszAHKNstdflGI1k+FtM1wBsZ+r4vUZXSVj7NrTPBDlSnU+2lTEz3K0 DOrQ== X-Gm-Message-State: APjAAAVSeZcJ2p4IQEufgZIP4C/hyTDTtTr1zL4cMne8OJlAS7QuQoP7 Dao0jrg9P2B2XdvNZH4u+uIklQOs X-Google-Smtp-Source: APXvYqzonyRVZg4TBg21mxA/RXitNZNNMnAPPuRo10W4+EO9MHRv37FbKitYkOp71vAXo7k6cXBzrQ== X-Received: by 2002:a63:f707:: with SMTP id x7mr86153881pgh.343.1555537533392; Wed, 17 Apr 2019 14:45:33 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:32 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 33/34] qla2xxx: Avoid that qlt_send_resp_ctio() corrupts memory Date: Wed, 17 Apr 2019 14:44:42 -0700 Message-Id: <20190417214443.243152-34-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "(&ctio->u.status1.sense_data)[i]" where i >= 0 expressions in qlt_send_resp_ctio() are probably typos and should have been "(&ctio->u.status1.sense_data[4 * i])" instead. Instead of only fixing these typos, modify the code for storing sense data such that it becomes easy to read. This patch fixes a Coverity complaint about accessing an array outside its bounds. Cc: Himanshu Madhani Cc: Giridhar Malavali Fixes: be25152c0d9e ("qla2xxx: Improve T10-DIF/PI handling in driver.") # v4.11. Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_target.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 302bc43cc061..ed02ac51183d 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -2329,14 +2329,14 @@ void qlt_send_resp_ctio(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd, ctio->u.status1.scsi_status |= cpu_to_le16(SS_RESIDUAL_UNDER); - /* Response code and sense key */ - put_unaligned_le32(((0x70 << 24) | (sense_key << 8)), - (&ctio->u.status1.sense_data)[0]); + /* Fixed format sense data. */ + ctio->u.status1.sense_data[0] = 0x70; + ctio->u.status1.sense_data[2] = sense_key; /* Additional sense length */ - put_unaligned_le32(0x0a, (&ctio->u.status1.sense_data)[1]); + ctio->u.status1.sense_data[7] = 0xa; /* ASC and ASCQ */ - put_unaligned_le32(((asc << 24) | (ascq << 16)), - (&ctio->u.status1.sense_data)[3]); + ctio->u.status1.sense_data[12] = asc; + ctio->u.status1.sense_data[13] = ascq; /* Memory Barrier */ wmb(); From patchwork Wed Apr 17 21:44:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 404DE17E0 for ; Wed, 17 Apr 2019 21:45:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278D628A93 for ; Wed, 17 Apr 2019 21:45:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BDE428A96; Wed, 17 Apr 2019 21:45:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B9328BAA for ; Wed, 17 Apr 2019 21:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387807AbfDQVpj (ORCPT ); Wed, 17 Apr 2019 17:45:39 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42812 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387962AbfDQVpf (ORCPT ); Wed, 17 Apr 2019 17:45:35 -0400 Received: by mail-pg1-f194.google.com with SMTP id p6so144382pgh.9 for ; Wed, 17 Apr 2019 14:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7qSjarsi8tMyUgKT4lwZDCZH4a6mmn0gHj6+xBxp/OY=; b=PRycsMX/Bbhzrd9356PI0V2Pf376TRMObf7yf5MT/wIzX2sSAXjh202ljswqJNpGMc 497n+PHMpKMnk/qmb64FnS4XQqSGrhq32L1o4rBWMPCKVQLwU2oRosDTipgh4QttKeu6 Ml+dQGuY2sIMxBCqRTIV/z8lL8MWSPOKANcEuOaFOUOCWdSpkGLtdGfsq5Nt/DEPmSK5 9HJXnM+C1NRH6ocIJug+1vbWDQabUPMLsax+6xpKFqgBHKGSyy8ftA7funfs1ffTNWqa 8eH6+2EPNfSH5l2anbUOKsWoTMz28MHxYHa1HuYpCJo8UQ14ARCHE9dtzhQIrmmph+pr hhSw== X-Gm-Message-State: APjAAAXWC4/ttT4sMzIar5BeEkoHeYh7nUNNuiHd/3PjtdASYDL5VHm7 pV5utDh5nGCSPhz5gYgaEzo= X-Google-Smtp-Source: APXvYqxwqHOeS7p2EU5a+S7qZ0yoCDhdLkMm2ZQxkvXGmk25SkofJPCqPXtnRMcaZP7depxypFV/wA== X-Received: by 2002:a65:614e:: with SMTP id o14mr6396354pgv.196.1555537534555; Wed, 17 Apr 2019 14:45:34 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:33 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 34/34] qla2xxx: Avoid that lockdep complains about unsafe locking in tcm_qla2xxx_close_session() Date: Wed, 17 Apr 2019 14:44:43 -0700 Message-Id: <20190417214443.243152-35-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch avoids that lockdep reports the following warning: ===================================================== WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected 5.1.0-rc1-dbg+ #11 Tainted: G W ----------------------------------------------------- rmdir/1478 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire: 00000000e7ac4607 (&(&k->k_lock)->rlock){+.+.}, at: klist_next+0x43/0x1d0 and this task is already holding: 00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx] which would create a new lock dependency: (&(&ha->tgt.sess_lock)->rlock){-...} -> (&(&k->k_lock)->rlock){+.+.} but this new dependency connects a HARDIRQ-irq-safe lock: (&(&ha->tgt.sess_lock)->rlock){-...} ... which became HARDIRQ-irq-safe at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx] qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx] qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x24d/0x2d0 secondary_startup_64+0xa4/0xb0 to a HARDIRQ-irq-unsafe lock: (&(&k->k_lock)->rlock){+.+.} ... which became HARDIRQ-irq-unsafe at: ... lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7f4/0xb60 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 other info that might help us debug this: Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&(&k->k_lock)->rlock); local_irq_disable(); lock(&(&ha->tgt.sess_lock)->rlock); lock(&(&k->k_lock)->rlock); lock(&(&ha->tgt.sess_lock)->rlock); *** DEADLOCK *** 4 locks held by rmdir/1478: #0: 000000002c7f1ba4 (sb_writers#10){.+.+}, at: mnt_want_write+0x32/0x70 #1: 00000000c85eb147 (&default_group_class[depth - 1]#2/1){+.+.}, at: do_rmdir+0x217/0x2d0 #2: 000000002b164d6f (&sb->s_type->i_mutex_key#13){++++}, at: vfs_rmdir+0x7e/0x1d0 #3: 00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx] the dependencies between HARDIRQ-irq-safe lock and the holding lock: -> (&(&ha->tgt.sess_lock)->rlock){-...} ops: 127 { IN-HARDIRQ-W at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx] qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx] qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x24d/0x2d0 secondary_startup_64+0xa4/0xb0 INITIAL USE at: lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla2x00_loop_resync+0xb3d/0x2690 [qla2xxx] qla2x00_do_dpc+0xcee/0xf30 [qla2xxx] kthread+0x1d2/0x1f0 ret_from_fork+0x3a/0x50 } ... key at: [] __key.62804+0x0/0xfffffffffff7e900 [qla2xxx] ... acquired at: __lock_acquire+0x11ed/0x1b60 lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx] qlt_unreg_sess+0x104/0x2c0 [qla2xxx] tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx] target_shutdown_sessions+0x17b/0x190 [target_core_mod] core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod] target_fabric_nacl_base_release+0x25/0x30 [target_core_mod] config_item_release+0x9f/0x120 [configfs] config_item_put+0x29/0x2b [configfs] configfs_rmdir+0x3d2/0x520 [configfs] vfs_rmdir+0xb3/0x1d0 do_rmdir+0x25c/0x2d0 __x64_sys_rmdir+0x24/0x30 do_syscall_64+0x77/0x220 entry_SYSCALL_64_after_hwframe+0x49/0xbe the dependencies between the lock to be acquired and HARDIRQ-irq-unsafe lock: -> (&(&k->k_lock)->rlock){+.+.} ops: 14568 { HARDIRQ-ON-W at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7f4/0xb60 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 SOFTIRQ-ON-W at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7f4/0xb60 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 INITIAL USE at: lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7f4/0xb60 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50 } ... key at: [] __key.15805+0x0/0x40 ... acquired at: __lock_acquire+0x11ed/0x1b60 lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx] qlt_unreg_sess+0x104/0x2c0 [qla2xxx] tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx] target_shutdown_sessions+0x17b/0x190 [target_core_mod] core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod] target_fabric_nacl_base_release+0x25/0x30 [target_core_mod] config_item_release+0x9f/0x120 [configfs] config_item_put+0x29/0x2b [configfs] configfs_rmdir+0x3d2/0x520 [configfs] vfs_rmdir+0xb3/0x1d0 do_rmdir+0x25c/0x2d0 __x64_sys_rmdir+0x24/0x30 do_syscall_64+0x77/0x220 entry_SYSCALL_64_after_hwframe+0x49/0xbe stack backtrace: CPU: 7 PID: 1478 Comm: rmdir Tainted: G W 5.1.0-rc1-dbg+ #11 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x86/0xca check_usage.cold.59+0x473/0x563 check_prev_add.constprop.43+0x1f1/0x1170 __lock_acquire+0x11ed/0x1b60 lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 klist_next+0x43/0x1d0 device_for_each_child+0x96/0x110 scsi_target_block+0x3c/0x40 [scsi_mod] fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc] qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx] qlt_unreg_sess+0x104/0x2c0 [qla2xxx] tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx] target_shutdown_sessions+0x17b/0x190 [target_core_mod] core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod] target_fabric_nacl_base_release+0x25/0x30 [target_core_mod] config_item_release+0x9f/0x120 [configfs] config_item_put+0x29/0x2b [configfs] configfs_rmdir+0x3d2/0x520 [configfs] vfs_rmdir+0xb3/0x1d0 do_rmdir+0x25c/0x2d0 __x64_sys_rmdir+0x24/0x30 do_syscall_64+0x77/0x220 entry_SYSCALL_64_after_hwframe+0x49/0xbe Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 03b58fd60598..e99cc03f85bd 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -355,8 +355,9 @@ static void tcm_qla2xxx_close_session(struct se_session *se_sess) spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); target_sess_cmd_list_set_waiting(se_sess); - tcm_qla2xxx_put_sess(sess); spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); + + tcm_qla2xxx_put_sess(sess); } static u32 tcm_qla2xxx_sess_get_index(struct se_session *se_sess)