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) {