public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: "sven@svenpeter.dev" <sven@svenpeter.dev>
Cc: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [PATCHv2] nvme: use ctrl state accessor
Date: Fri, 26 Jan 2024 07:20:39 +0000	[thread overview]
Message-ID: <6286227a-1169-4068-8a44-1bd856be37d6@nvidia.com> (raw)
In-Reply-To: <20240125155213.3727106-1-kbusch@meta.com>

Sven,

On 1/25/24 07:52, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The ctrl->state value is updated in another thread using WRITE_ONCE, so
> ensure all the readers use the appropriate accessor.
>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>

Based on this patch nvme/host/apple.c might need something like this, please
have a look at [1].

-ck

[1] Only use for discussion, don't apply or use this patch :-

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index 596bb11eeba5..2524c9a13ad7 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -797,6 +797,7 @@ static int apple_nvme_init_request(struct 
blk_mq_tag_set *set,

  static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)
  {
+       enum nvme_ctrl_state state = nvme_ctrl_state(&anv->ctrl);
         u32 csts = readl(anv->mmio_nvme + NVME_REG_CSTS);
         bool dead = false, freeze = false;
         unsigned long flags;
@@ -808,8 +809,7 @@ static void apple_nvme_disable(struct apple_nvme 
*anv, bool shutdown)
         if (csts & NVME_CSTS_CFS)
                 dead = true;

-       if (anv->ctrl.state == NVME_CTRL_LIVE ||
-           anv->ctrl.state == NVME_CTRL_RESETTING) {
+       if (state == NVME_CTRL_LIVE || state == NVME_CTRL_RESETTING) {
                 freeze = true;
                 nvme_start_freeze(&anv->ctrl);
         }
@@ -881,7 +881,7 @@ static enum blk_eh_timer_return 
apple_nvme_timeout(struct request *req)
         unsigned long flags;
         u32 csts = readl(anv->mmio_nvme + NVME_REG_CSTS);

-       if (anv->ctrl.state != NVME_CTRL_LIVE) {
+       if (nvme_ctrl_state(&anv->ctrl) != NVME_CTRL_LIVE) {
                 /*
                  * From rdma.c:
                  * If we are resetting, connecting or deleting we should
@@ -985,10 +985,11 @@ static void apple_nvme_reset_work(struct 
work_struct *work)
         u32 boot_status, aqa;
         struct apple_nvme *anv =
                 container_of(work, struct apple_nvme, ctrl.reset_work);
+       enum nvme_ctrl_state state = nvme_ctrl_state(&anv->ctrl);

-       if (anv->ctrl.state != NVME_CTRL_RESETTING) {
+       if (state != NVME_CTRL_RESETTING) {
                 dev_warn(anv->dev, "ctrl state %d is not RESETTING\n",
-                        anv->ctrl.state);
+                        state);
                 ret = -ENODEV;
                 goto out;
         }

  reply	other threads:[~2024-01-26  7:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 15:52 [PATCHv2] nvme: use ctrl state accessor Keith Busch
2024-01-26  7:20 ` Chaitanya Kulkarni [this message]
2024-02-05 17:00   ` Sven Peter
2024-01-26  8:25 ` Chaitanya Kulkarni
2024-01-26 16:30   ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6286227a-1169-4068-8a44-1bd856be37d6@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sven@svenpeter.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox