From patchwork Sun Dec 9 16:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satish Kharat X-Patchwork-Id: 10720145 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 6256F91E for ; Sun, 9 Dec 2018 16:54:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 530402A0C3 for ; Sun, 9 Dec 2018 16:54:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 474F42A0D9; Sun, 9 Dec 2018 16:54: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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 EEB102A0C3 for ; Sun, 9 Dec 2018 16:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726130AbeLIQyJ (ORCPT ); Sun, 9 Dec 2018 11:54:09 -0500 Received: from rcdn-iport-5.cisco.com ([173.37.86.76]:54410 "EHLO rcdn-iport-5.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbeLIQyJ (ORCPT ); Sun, 9 Dec 2018 11:54:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1241; q=dns/txt; s=iport; t=1544374449; x=1545584049; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=pl1j5t84BuGphGIWeRZoC3uMMUb+pOcrw5jdHUpoetM=; b=hPBVLaQdd2uuIJbwADdhm8urKONrH9+oI7WX5vmRtoBVLMR3ostBIy/J trjbEDY+GflCAffQi/8/9IajEfL+v2mhoYXKj0SHkXiiEzHS+ViKc5dOJ 6d6VSqyiuIZx2hy8gCeqS+DXsPeXW8ASN1JLoy6D4Rb+tRt8Ak1pKBiwH 8=; X-IronPort-AV: E=Sophos;i="5.56,335,1539648000"; d="scan'208";a="275391690" Received: from alln-core-11.cisco.com ([173.36.13.133]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2018 16:44:49 +0000 Received: from satish-ini-cisco-com.cisco.com (satish-ini.cisco.com [10.193.101.67]) by alln-core-11.cisco.com (8.15.2/8.15.2) with ESMTP id wB9GiXtF022582; Sun, 9 Dec 2018 16:44:49 GMT From: Satish Kharat To: linux-scsi@vger.kernel.org Cc: Satish Kharat Subject: [PATCH 1/1] scsi : fnic : usign fnic_lock to gaurd fnic->state_flags Date: Sun, 9 Dec 2018 08:38:42 -0800 Message-Id: <20181209163844.48020-8-satishkh@cisco.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181209163844.48020-1-satishkh@cisco.com> References: <20181209163844.48020-1-satishkh@cisco.com> X-Outbound-SMTP-Client: 10.193.101.67, satish-ini.cisco.com X-Outbound-Node: alln-core-11.cisco.com 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 Need to use fnic_lock as well as host lock in that order to set state flags. Signed-off-by: Satish Kharat --- drivers/scsi/fnic/fnic_scsi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 96acfcecd540..94186c4da091 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -180,20 +180,19 @@ void __fnic_set_state_flags(struct fnic *fnic, unsigned long st_flags, unsigned long clearbits) { - struct Scsi_Host *host = fnic->lport->host; - int sh_locked = spin_is_locked(host->host_lock); unsigned long flags = 0; + unsigned long host_lock_flags = 0; - if (!sh_locked) - spin_lock_irqsave(host->host_lock, flags); + spin_lock_irqsave(&fnic->fnic_lock, flags); + spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags); if (clearbits) fnic->state_flags &= ~st_flags; else fnic->state_flags |= st_flags; - if (!sh_locked) - spin_unlock_irqrestore(host->host_lock, flags); + spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); return; }