From patchwork Tue Jul 31 05:35:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 10549885 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 0D545157D for ; Tue, 31 Jul 2018 05:35:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E556C22B27 for ; Tue, 31 Jul 2018 05:35:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6C132A729; Tue, 31 Jul 2018 05:35: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=-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 B16D422B27 for ; Tue, 31 Jul 2018 05:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727147AbeGaHOK (ORCPT ); Tue, 31 Jul 2018 03:14:10 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:42917 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbeGaHOK (ORCPT ); Tue, 31 Jul 2018 03:14:10 -0400 Received: by mail-qk0-f196.google.com with SMTP id 26-v6so9449642qks.9 for ; Mon, 30 Jul 2018 22:35:41 -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=UD6X0RQbQhJWrIRMw5umYrl2bm8i+kCxIiT84Ki8Emvu1AG0E6tF+Krh8FDC1+HlRC +XLSn+E+CorRi8w39HLjf4exsgPreOuE3nmxVbMCJz9Mro5tzu5HUuKvKntELgGGgmyA g2DW8dYyyl5PzVWRtUCqY78K8lHusaAJy3y6o= 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=ddKqDEpedAi1vMr5ZxUQNMnfPEyQ3TEb5NS/lqt0eRo00vToBOvUuaRqAnoELbDf9V RDPtqS83Z28199COA70lsLwG3rpml9rDeRiUKb9Xbsemz+snCQUM/9sylLzsE6VbSoAm 6nXzxhub4sQ6p7Q58TLtJDqixUMzKeTZq5FURQnmDWZJ+LAgnKbuJhxRYAxw1lPszT1J CYj2uT0SFkSOjk27YL6PROk7koxOGHGF2B82DTUV0kPTAm9uPNITEHH5uUIpA06gj5X/ 3fDQU6Hm75OEDJVYxq9/+z2z8V6WQbVhWqc1aFDUrz879u8A+5JyAHjkZ+jCdD0rF7mV l+rg== X-Gm-Message-State: AOUpUlGwSkszLemjJj1OHlzhgQuqVqMT29bGRyxDVXfxazjpWHkKZhdv 0A22cwEt/S3Oleqy9J7OLQDF5Q== X-Google-Smtp-Source: AAOMgpeJ1C4/Ee+d9jqYBRTFIOz6M1UBxjib2Bx5DI/Ox5BQqw/alUf/7f/OyP58yfIryjs5YMtTCg== X-Received: by 2002:a37:b91:: with SMTP id 139-v6mr18574892qkl.429.1533015341130; Mon, 30 Jul 2018 22:35:41 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d2-v6sm9881306qkj.76.2018.07.30.22.35.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 22:35:40 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, sathya.prakash@broadcom.com, thenzl@redhat.com, davem@davemloft.net, Sreekanth Reddy Subject: [PATCH v1] mpt3sas: correct reset of smid while clearing scsi tracker Date: Tue, 31 Jul 2018 01:35:28 -0400 Message-Id: <1533015328-10260-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; } /**