From nobody Mon Jun 8 06:36:57 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08C853F4DDF for ; Wed, 3 Jun 2026 07:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471414; cv=none; b=kGXoulO4T8eBRseBgXkWxLJTQmVi9929LwKbSsFnuJQBhcjgo7j66MfN/72PWbwUlQO76+Zjx4iyassmFbIHiLxioOOrGu4LYahNoY9w8RsJFrDN0N6ZlRIcZHCMXKvsK/d/bVMmHcuyP0CQY3pSeHRXCkNQUxb6lGiYE/+mi4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780471414; c=relaxed/simple; bh=eNUZGu4Ul5z/qEG7X8KpOIA6vn2VIxBs/pdo4daS/CM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=KmSETS8+kp7TKVIxGtPEbA+AIt7v8qLvCtukjPHjxtEauGygoQILMUwsRApbWpXPSpRPe9JkglnUCPtSV9sEil/wuU7BAnoPcKehNtJzz3sEFZHH7i0CzzIW5ksWhYXGfMK5kNqH9jdc24ZjeSH7pAI+ZwyFvHDcm7LKJvNLCks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k7alyWQV; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k7alyWQV" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2c0bd02d97eso40158655ad.2 for ; Wed, 03 Jun 2026 00:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780471412; x=1781076212; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3LmA3WaTMG7OAWRgeiXus9O8phC2OkjC2j8xyhgOD/Y=; b=k7alyWQVQHXFEgWa77C8N4Ed5H19n0J0pTmNDPoksyMj8s223tb/6krpifdlfz6TpQ rA8g4MscVwdYWfGe7OghdXdN+RUAV+PS1wLz3w02inGta/jn/adTc+USqV7Frsc9xL42 63NgUJZZToMuryNOdgjejF/jm0F//17slPC7rR3Wjl4/CAPCjOxdng+4NEJkBDU2CpQT Er4Q2YfcTK/1Td/DvqV84COQVsNvrRyZQ2AnYqFOt3R2mMwlVSxbjBg8AzEfogNTD+vI PcTuPtp6v9OQGCcoIOrc9p80O0mKEk97A+PQda5L85Gw+KMZrvtmUOVD+QinHQD+tCP1 TfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780471412; x=1781076212; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3LmA3WaTMG7OAWRgeiXus9O8phC2OkjC2j8xyhgOD/Y=; b=ZrO+5NkoKVGjpHGCrnoORtHAhds2mZi2moL79LD+LM1gaYqluaKJ9kdX5JVDf92a9L WOHrZFhVLjSGF1C1kOXWSLF6j42y3+z/qw0S/eysp25q4Fq00BymxUKcZyAWNHiP+CUj 19cTPesHtarzfFTQZBgXTC4DfKqdtK/N9XPTAvzj9YDtJODXNkL/zJq1T7yiHJKEZPdh J6oQ6WS5hSUsxbmdfUIpeSi+RztZcyzMG3BY8uSzMGmb6CL3yfuhBcB5MKx3REN2qz4Q +3ZR25J+7PRxNgYAvE3ad84PdUZNYNdPpDroyuQtaoPq0cssklicgoz4px8RpY3OLH9U 3q9w== X-Forwarded-Encrypted: i=1; AFNElJ+qbTKliU5TDxowkU+oRUQfy2u6snanRuyqWGP09r68YcOcAwpON+xfVAeWYcZ99xjI9VJ6hzMFIIXpfwc=@vger.kernel.org X-Gm-Message-State: AOJu0Yya0R057++cIw/YV5wq0uOhFO7knwmItzmRJlgN0Yzw7gbNKALJ EyFq/KrJPAjlaI1hBG6iFlNEDk1F0mx2T2E+KykC/cJ69xF/9J+Fw49TW6cuzc2m X-Gm-Gg: Acq92OEZroMtfzKMuON3VajexThRmD7wH8iVNKjaRhh1f+5dh+Lq91hU7UAOaBzyRkC x9hTj2cjoqX11Eq1l1Kp5EH4BjjY/7z0DumpnTDYwxNLVm1/7QU57pzwujDZyj/XE59D1uWQK8s Edsxcn8Znaa3eE4Su16wX2tZIAccbdBwpPyOdzE1HqxTU7QJOFClKRaDZ7xdrQI3s0Vo8aYzxxN HJnjAlel7gka7N8wzxCI2QGHoeZYEbEE70V9rlY9mb1nJmGg5kHRf8eT4fy1ya6JxNy3aDW8Kpl Lqx+iToenBCLPRXbmWxs/wxOBivNlmKNhLzzXCBpW07dPLoo/5oaEJcam4AsZG3q5Z+eI2hT1dh +xe7vaPEB6d8ZX9h5ouuld+CJdk8I9etNCbyGFvrZXfYpfsWRwIgvoaKFqzgBH6TuzQfG90ulBq Yl4vemu5sGE0xULIohNgwFA39ql4KA9O4D5qnu3sQpxpaMh9Eq9qwmHj5cXECOYanEpv7N/w8Yz Psirrcp5Zv34FoXAil+rV4q6tcy6ToK/1a64QsKl9vn1stUCxBpMnQFRAtOLGNy6Cfi5esEdWYU 9+8= X-Received: by 2002:a17:902:7b85:b0:2bd:8395:fed8 with SMTP id d9443c01a7336-2c1641b148dmr13579975ad.27.1780471412125; Wed, 03 Jun 2026 00:23:32 -0700 (PDT) Received: from bass-virtual-machine.. ([111.202.175.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164fa072asm14750055ad.34.2026.06.03.00.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 00:23:31 -0700 (PDT) From: Gui-Dong Han To: sven@kernel.org, kbusch@kernel.org, linux-nvme@lists.infradead.org Cc: axboe@kernel.dk, hch@lst.de, sagi@grimberg.me, j@jannau.net, neal@gompa.dev, asahi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, baijiaju1990@gmail.com, Gui-Dong Han Subject: [PATCH] nvme-apple: Use acquire/release for queue enabled state Date: Wed, 3 Jun 2026 15:22:05 +0800 Message-Id: <20260603072205.3291888-1-hanguidong02@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" apple_nvme_init_queue() initializes queue state and then marks the queue enabled. The interrupt and request paths check enabled before using that queue state. The existing wmb() after WRITE_ONCE(enabled, true) orders the enabled store before later queue use, but it does not publish the earlier initialization before enabled becomes visible. Use a release store when enabling the queue and acquire loads when testing it. Keep the existing wmb() in place for the store-before-later-use ordering. Fixes: 5bd2927aceba ("nvme-apple: Add initial Apple SoC NVMe driver") Signed-off-by: Gui-Dong Han --- Found by auditing READ_ONCE() used for synchronization. A similar fix can be found in 8df672bfe3ec. --- drivers/nvme/host/apple.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index c692fc73babf..fcaf8f230b19 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -151,6 +151,18 @@ struct apple_nvme_queue { bool enabled; }; =20 +static inline bool apple_nvme_queue_enabled(struct apple_nvme_queue *q) +{ + /* Pair with apple_nvme_enable_queue(). */ + return smp_load_acquire(&q->enabled); +} + +static inline void apple_nvme_enable_queue(struct apple_nvme_queue *q) +{ + /* Publish queue initialization before setting q->enabled. */ + smp_store_release(&q->enabled, true); +} + /* * The apple_nvme_iod describes the data in an I/O. * @@ -677,7 +689,7 @@ static bool apple_nvme_handle_cq(struct apple_nvme_queu= e *q, bool force) bool found; DEFINE_IO_COMP_BATCH(iob); =20 - if (!READ_ONCE(q->enabled) && !force) + if (!apple_nvme_queue_enabled(q) && !force) return false; =20 found =3D apple_nvme_poll_cq(q, &iob); @@ -780,7 +792,7 @@ static blk_status_t apple_nvme_queue_rq(struct blk_mq_h= w_ctx *hctx, * We should not need to do this, but we're still using this to * ensure we can drain requests on a dying queue. */ - if (unlikely(!READ_ONCE(q->enabled))) + if (unlikely(!apple_nvme_queue_enabled(q))) return BLK_STS_IOERR; =20 if (!nvme_check_ready(&anv->ctrl, req, true)) @@ -1016,7 +1028,7 @@ static void apple_nvme_init_queue(struct apple_nvme_q= ueue *q) memset(q->tcbs, 0, anv->hw->max_queue_depth * sizeof(struct apple_nvmmu_tcb)); memset(q->cqes, 0, depth * sizeof(struct nvme_completion)); - WRITE_ONCE(q->enabled, true); + apple_nvme_enable_queue(q); wmb(); /* ensure the first interrupt sees the initialization */ } =20 --=20 2.34.1