Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2206267iof; Tue, 7 Jun 2022 23:11:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc0Gn/2sa98JsiLddYfdgvF8ZLpbvZvgjMNgToq4er3Kmh2V4oNi9/w3/cIfOsZ+dmo9/u X-Received: by 2002:a63:305:0:b0:3fc:7f18:8d7 with SMTP id 5-20020a630305000000b003fc7f1808d7mr28461493pgd.186.1654668680276; Tue, 07 Jun 2022 23:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668680; cv=none; d=google.com; s=arc-20160816; b=e8Wrn+tnXaLXDGO3tMJ7JkljM12FPDmgHaiQYAGs2GKzpiCA0Lrye57fj87yyjZNjX Oy5UT/yTA19RKpv2bEI1uRTehQxR5aqn2po3yC8l3hNVgkvGAwUkMHunH7rm8Zzvjg66 C9k5XqCspYIE6PBr4ax1QEnNlgz8RbaH5xqqCtEQC5oF+5cPfE7WzpJyLLmTDYH4fc+4 cROiKLKld3rIvJ9Yb4hC8tzSxV252JYrZNUNrLqVevacefgFjLCe3Ld94drS/YZlgMy8 jwFw85xxVQcXWW+6dc86xM2dhxHhEJAqP6j/Po9khZJ75ocvJJpOlEeIOcaDgDGGARA+ AAEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j4ThToFSE9ByOXGEp1Fk9dRQwIsWLWHu4TAsnsLIuTo=; b=pJ/DUJ9e2wOJuI9CppdnhB5HZS+dXd4tTTxNGPlawBo7Erl/Ws9e2kb+muei48PqKe zAsj+io8XicUcxuFE3XI9Ls47QdtgpmmEWhtPLRUlMXHEKnDkytYhYtS0JTygdrIJaIz xfVip4ugRud4FhqXSn+FujomVcyzMiOwv6bU/PnBKj4EnUhVwsvOJ7RShDw1ljNXmhgW lZc29gDiwEDC2xwzNUxWOVhe0zFIF7i27DXElxWAS8jHBI3qVWn70xxU4o0HZL08AFin nhfgJBTcfc6/Xs4JoYWBIjXrzDHk57OvWXAVjzWdH8AS3ORycoBlyKYSm4I/uuXKgXVE pEcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="heYNGFK/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q188-20020a6343c5000000b003fc949fa196si26903697pga.866.2022.06.07.23.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:11:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="heYNGFK/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B96751D9B5D; Tue, 7 Jun 2022 22:33:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388777AbiFHBp3 (ORCPT + 99 others); Tue, 7 Jun 2022 21:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383149AbiFGVwU (ORCPT ); Tue, 7 Jun 2022 17:52:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A8F82428E4; Tue, 7 Jun 2022 12:10:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC6B2617D0; Tue, 7 Jun 2022 19:10:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BE8CC385A5; Tue, 7 Jun 2022 19:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629036; bh=mCQHmNsaRFd+gnI4Oto6NcCrMml2VebXVqV8yAX6psg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=heYNGFK/iz1CBgyQKWlxXCoQ3nSvyn1Ab9i6CwlBA1LawyKJ+VgM/wfPCw1VXm9Iu UxSNRRQQaYHurQ3mPc7x+JEaGFz470V6wVKppYhxZs7IJJ3cyT0lRPOtXqCUi77beR miobiP8k1hrnEA5vF+lKM5g1wf63Y2IUXontGBAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yihang Li , John Garry , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.18 505/879] scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() Date: Tue, 7 Jun 2022 19:00:23 +0200 Message-Id: <20220607165017.534549158@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit 6c6ac8b7773f05f93dc4e4044686e059d1f78dea ] The memories for the slot should be observed to be written prior to observing the slot as ready. Prior to commit 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR"), we had a spin_lock() + spin_unlock() immediately before marking the slot as ready. The spin_unlock() - with release semantics - caused the slot memory to be observed to be written. Now that the spin_lock() + spin_unlock() is gone, use a smp_wmb(). Link: https://lore.kernel.org/r/1652774661-12935-1-git-send-email-john.garry@huawei.com Fixes: 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR") Reported-by: Yihang Li Tested-by: Yihang Li Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 86cbfab78dfe..849cc5fc86af 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, return; } + /* Make slot memories observable before marking as ready */ + smp_wmb(); WRITE_ONCE(slot->ready, 1); spin_lock(&dq->lock); -- 2.35.1