Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB643482F3 for ; Mon, 11 Dec 2023 14:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a3j+s0Z/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4521C433CC; Mon, 11 Dec 2023 14:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702303317; bh=4k1SaVBa0z2pNpULLs2GouEoUDKokyLPmJyx01TWH5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3j+s0Z/FO583b1b91UdG4K2MAExZZJPpvriW9sfff/oyGyzaMUckqyGIxzThTztA FevWkHIszcw6w/MVBRzDYOMG+4Oc+/U6boj46N5O/4oa5xshyjdsFxJEWFYnZsJoFi RxpPn1q/qXQneltHHUCAHMeVju1wtowyNTMpiVmI2jaXIWSRGuSE9/UuLm5DW8MICF LCubDSQGVJSS262ggVSRm0f+C44iMUHD/TzL/zj1Kl88PpM/qwGSSzNXL+z9QvCYLy KEYMF4/Us0Z3AhJX+HddEI69O4MIRiWaC9BAT2oFiYQpW/ykyRA5bDYGbrEPEC0pTO 11XoxFNBBXwLQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Keith Busch , Sagi Grimberg , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 13/16] nvme: introduce helper function to get ctrl state Date: Mon, 11 Dec 2023 09:00:37 -0500 Message-ID: <20231211140116.391986-13-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211140116.391986-1-sashal@kernel.org> References: <20231211140116.391986-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.203 Content-Transfer-Encoding: 8bit From: Keith Busch [ Upstream commit 5c687c287c46fadb14644091823298875a5216aa ] The controller state is typically written by another CPU, so reading it should ensure no optimizations are taken. This is a repeated pattern in the driver, so start with adding a convenience function that returns the controller state with READ_ONCE(). Reviewed-by: Sagi Grimberg Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/nvme.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index c3e4d9b6f9c0d..1e56fe8e8157c 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -354,6 +354,11 @@ struct nvme_ctrl { struct nvme_fault_inject fault_inject; }; +static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl) +{ + return READ_ONCE(ctrl->state); +} + enum nvme_iopolicy { NVME_IOPOLICY_NUMA, NVME_IOPOLICY_RR, -- 2.42.0