From patchwork Fri Jul 20 12:26:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 10537401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71D276053F for ; Fri, 20 Jul 2018 12:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 565A128703 for ; Fri, 20 Jul 2018 12:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479C5294B7; Fri, 20 Jul 2018 12:59: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 6BFE828703 for ; Fri, 20 Jul 2018 12:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732087AbeGTNOx (ORCPT ); Fri, 20 Jul 2018 09:14:53 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34347 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731336AbeGTNOw (ORCPT ); Fri, 20 Jul 2018 09:14:52 -0400 Received: by mail-qt0-f194.google.com with SMTP id m13-v6so10059448qth.1 for ; Fri, 20 Jul 2018 05:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=rZbgGWSeHDE50V8M/a2xOWQ0TO7WX6j3fGsH6juJfWY=; b=Rg2kaSWJNik/RIlPUIhp8af1QyAWZupGQR/zWWgiu+Hcyge1pVH/S7vuoqcgICeHah LGZvX6R32ojwb5H4IjNhPq5H6nyjIWRsWQc110mhyp763AqqrCo2QSoGrsg2ye7uWaLI sVME5MfWfPFqxDKhhQMCsUcJVIfUFvfAQSVbA= 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; bh=rZbgGWSeHDE50V8M/a2xOWQ0TO7WX6j3fGsH6juJfWY=; b=Qpf0tSPziWx7o/qkshsYewvC03kNBVKBEOwqXwdMzG3LtdLEA8p0ytfmmXPdvCoP/i NzuxBZLr5WDMjA+DwDyrs6rR0c5geK1Q3KGD+XiR/QaPkytvMUzNzoWj0sxTt/sRMf48 Rqbk/F7nNAIDfbw+82jfWvRujeDO+mi+YrtxqsQTkCtOq0SUU7OWEvJXmug1D/h5fj9P UFGIMfaZy6VDgKmDXe2yG+N+QYI0H9MpiTHxe3iGpsFgfmUJzJ/f+R+OFUHQWkW4Sxn1 cEeopAdS3ziTgeYfoOgyVJ9mPoIanoVl26JhW5WVO4D7MEYVzaQw3mkEqHEApBEUNv2s aaqA== X-Gm-Message-State: AOUpUlG94PuqZ6juyWvcUKMMIA8ZosqzCqwl/y8J8FFzSrTg28lcau/y 6+ZjBoaZ5vcWH1oVuvv4A1eptQ== X-Google-Smtp-Source: AAOMgpdE3XV8GhPMXEiuRC8yWOxaGnynv9RprBCogQYCu85CYUiRnrRZu5GR98p54aSQwfz/EAZoEg== X-Received: by 2002:ac8:611c:: with SMTP id a28-v6mr1658721qtm.130.1532089612124; Fri, 20 Jul 2018 05:26:52 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c10-v6sm930106qtn.90.2018.07.20.05.26.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 05:26:51 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, sathya.prakash@broadcom.com, thenzl@redhat.com, Sreekanth Reddy Subject: [PATCH] mpt3sas: correct reset of smid while clearing scsi tracker Date: Fri, 20 Jul 2018 08:26:39 -0400 Message-Id: <1532089599-39863-1-git-send-email-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 1.8.3.1 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 mpt3sas_base_clear_st() function smid value is reseted in wrong line, i.e. driver should reset smid value to zero after decrementing chain_offset counter in chain_lookup table but in current code, driver is resetting smid value before decrementing the chain_offset counter. which we are correcting with this patch. v1 changelog: Added memory barriers before & after atomic_set() API. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 902610d..94359d8 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -1702,6 +1702,8 @@ static int mpt3sas_remove_dead_ioc_func(void *arg) return NULL; chain_req = &ioc->chain_lookup[smid - 1].chains_per_smid[chain_offset]; + /* Adding memory barrier before atomic operation. */ + smp_mb__before_atomic(); atomic_inc(&ioc->chain_lookup[smid - 1].chain_offset); return chain_req; } @@ -3283,8 +3285,12 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc, return; st->cb_idx = 0xFF; st->direct_io = 0; - st->smid = 0; + /* Adding memory barrier before atomic operation. */ + smp_mb__before_atomic(); atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0); + /* Adding memory barrier after atomic operation. */ + smp_mb__after_atomic(); + st->smid = 0; } /**