@@ -926,6 +926,15 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
ns->pi_type = pi_type;
blk_queue_logical_block_size(ns->queue, bs);
+ /*
+ * Advertisze the maximum atomic write size. Don't bother with the
+ * per-namespace values due to their alignment constraints.
+ */
+ if (ns->ctrl->awupf > 1) {
+ blk_queue_max_atomic_write_sectors(ns->queue,
+ (ns->ctrl->awupf + 1) << (ns->lba_shift - 9));
+ }
+
if (ns->ms && !blk_get_integrity(disk) && !ns->ext)
nvme_init_integrity(ns);
if (ns->ms && !(ns->ms == 8 && ns->pi_type) && !blk_get_integrity(disk))
@@ -1232,6 +1241,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
ctrl->vid = le16_to_cpu(id->vid);
ctrl->oncs = le16_to_cpup(&id->oncs);
+ ctrl->awupf = le16_to_cpu(id->awupf);
atomic_set(&ctrl->abort_limit, id->acl + 1);
ctrl->vwc = id->vwc;
ctrl->cntlid = le16_to_cpup(&id->cntlid);
@@ -143,6 +143,7 @@ struct nvme_ctrl {
u32 vs;
u32 sgls;
u16 kas;
+ u16 awupf;
unsigned int kato;
bool subsystem;
unsigned long quirks;
Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/core.c | 10 ++++++++++ drivers/nvme/host/nvme.h | 1 + 2 files changed, 11 insertions(+)