Skip to content

Commit ac30cd3

Browse files
johnpgarrykeithbusch
authored andcommitted
nvme: stop using AWUPF
As described at [0], much of the atomic write parts of the specification are lacking. For now, there is nothing which we can do in software about the lack of a dedicated NVMe write atomic command. As for reading the atomic write limits, it is felt that the per-namespace values are mostly properly specified and it is assumed that they are properly implemented. The specification of NAWUPF is quite clear. However the specification of NABSPF is less clear. The lack of clarity in NABSPF comes from deciding whether NABSPF applies when NSABP is 0 - it is assumed that NSABPF does not apply when NSABP is 0. As for the per-controller AWUPF, how this value applies to shared namespaces is missing in the specification. Furthermore, the value is in terms of logical blocks, which is an NS entity. Since AWUPF is so poorly defined, stop using it already together. Hopefully this will force vendors to implement NAWUPF support always. Note that AWUPF not only effects atomic write support, but also the physical block size reported for the device. To help users know this restriction, log an info message per NS. [0] https://lore.kernel.org/linux-nvme/20250707141834.GA30198@lst.de/ Tested-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent ddfb8b3 commit ac30cd3

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

drivers/nvme/host/core.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,14 +2045,10 @@ static u32 nvme_configure_atomic_write(struct nvme_ns *ns,
20452045
if (id->nabspf)
20462046
boundary = (le16_to_cpu(id->nabspf) + 1) * bs;
20472047
} else {
2048-
/*
2049-
* Use the controller wide atomic write unit. This sucks
2050-
* because the limit is defined in terms of logical blocks while
2051-
* namespaces can have different formats, and because there is
2052-
* no clear language in the specification prohibiting different
2053-
* values for different controllers in the subsystem.
2054-
*/
2055-
atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs;
2048+
if (ns->ctrl->awupf)
2049+
dev_info_once(ns->ctrl->device,
2050+
"AWUPF ignored, only NAWUPF accepted\n");
2051+
atomic_bs = bs;
20562052
}
20572053

20582054
lim->atomic_write_hw_max = atomic_bs;
@@ -3221,7 +3217,6 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
32213217
memcpy(subsys->model, id->mn, sizeof(subsys->model));
32223218
subsys->vendor_id = le16_to_cpu(id->vid);
32233219
subsys->cmic = id->cmic;
3224-
subsys->awupf = le16_to_cpu(id->awupf);
32253220

32263221
/* Versions prior to 1.4 don't necessarily report a valid type */
32273222
if (id->cntrltype == NVME_CTRL_DISC ||
@@ -3654,6 +3649,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
36543649
dev_pm_qos_expose_latency_tolerance(ctrl->device);
36553650
else if (!ctrl->apst_enabled && prev_apst_enabled)
36563651
dev_pm_qos_hide_latency_tolerance(ctrl->device);
3652+
ctrl->awupf = le16_to_cpu(id->awupf);
36573653
out_free:
36583654
kfree(id);
36593655
return ret;

drivers/nvme/host/nvme.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ struct nvme_ctrl {
464464

465465
enum nvme_ctrl_type cntrltype;
466466
enum nvme_dctype dctype;
467+
468+
u16 awupf; /* 0's based value. */
467469
};
468470

469471
static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)
@@ -496,7 +498,6 @@ struct nvme_subsystem {
496498
u8 cmic;
497499
enum nvme_subsys_type subtype;
498500
u16 vendor_id;
499-
u16 awupf; /* 0's based value. */
500501
struct ida ns_ida;
501502
#ifdef CONFIG_NVME_MULTIPATH
502503
enum nvme_iopolicy iopolicy;

0 commit comments

Comments
 (0)