Skip to content

Commit 5f63a49

Browse files
committed
Merge tag 'nvme-6.8-2023-02-08' of git://git.infradead.org/nvme into block-6.8
Pull NVMe fixes from Keith: "nvme fixes for Linux 6.8 - Update a potentially stale firmware attribute (Maurizio) - Fixes for the recent verbose error logging (Keith, Chaitanya) - Protection information payload size fix for passthrough (Francis)" * tag 'nvme-6.8-2023-02-08' of git://git.infradead.org/nvme: nvme: use ns->head->pi_size instead of t10_pi_tuple structure size nvme-core: fix comment to reflect right functions nvme: move passthrough logging attribute to head nvme-host: fix the updating of the firmware version
2 parents 4ce6e2d + 4054705 commit 5f63a49

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

drivers/nvme/host/core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ void nvme_init_request(struct request *req, struct nvme_command *cmd)
713713
if (req->q->queuedata) {
714714
struct nvme_ns *ns = req->q->disk->private_data;
715715

716-
logging_enabled = ns->passthru_err_log_enabled;
716+
logging_enabled = ns->head->passthru_err_log_enabled;
717717
req->timeout = NVME_IO_TIMEOUT;
718718
} else { /* no queuedata implies admin queue */
719719
logging_enabled = nr->ctrl->passthru_err_log_enabled;
@@ -3696,7 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
36963696

36973697
ns->disk = disk;
36983698
ns->queue = disk->queue;
3699-
ns->passthru_err_log_enabled = false;
37003699

37013700
if (ctrl->opts && ctrl->opts->data_digest)
37023701
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
@@ -3762,8 +3761,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
37623761

37633762
/*
37643763
* Set ns->disk->device->driver_data to ns so we can access
3765-
* ns->logging_enabled in nvme_passthru_err_log_enabled_store() and
3766-
* nvme_passthru_err_log_enabled_show().
3764+
* ns->head->passthru_err_log_enabled in
3765+
* nvme_io_passthru_err_log_enabled_[store | show]().
37673766
*/
37683767
dev_set_drvdata(disk_to_dev(ns->disk), ns);
37693768

@@ -4191,6 +4190,7 @@ static bool nvme_ctrl_pp_status(struct nvme_ctrl *ctrl)
41914190
static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
41924191
{
41934192
struct nvme_fw_slot_info_log *log;
4193+
u8 next_fw_slot, cur_fw_slot;
41944194

41954195
log = kmalloc(sizeof(*log), GFP_KERNEL);
41964196
if (!log)
@@ -4202,13 +4202,15 @@ static void nvme_get_fw_slot_info(struct nvme_ctrl *ctrl)
42024202
goto out_free_log;
42034203
}
42044204

4205-
if (log->afi & 0x70 || !(log->afi & 0x7)) {
4205+
cur_fw_slot = log->afi & 0x7;
4206+
next_fw_slot = (log->afi & 0x70) >> 4;
4207+
if (!cur_fw_slot || (next_fw_slot && (cur_fw_slot != next_fw_slot))) {
42064208
dev_info(ctrl->device,
42074209
"Firmware is activated after next Controller Level Reset\n");
42084210
goto out_free_log;
42094211
}
42104212

4211-
memcpy(ctrl->subsys->firmware_rev, &log->frs[(log->afi & 0x7) - 1],
4213+
memcpy(ctrl->subsys->firmware_rev, &log->frs[cur_fw_slot - 1],
42124214
sizeof(ctrl->subsys->firmware_rev));
42134215

42144216
out_free_log:

drivers/nvme/host/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
228228
length = (io.nblocks + 1) << ns->head->lba_shift;
229229

230230
if ((io.control & NVME_RW_PRINFO_PRACT) &&
231-
ns->head->ms == sizeof(struct t10_pi_tuple)) {
231+
(ns->head->ms == ns->head->pi_size)) {
232232
/*
233233
* Protection information is stripped/inserted by the
234234
* controller.

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ struct nvme_ns_head {
455455
struct list_head entry;
456456
struct kref ref;
457457
bool shared;
458+
bool passthru_err_log_enabled;
458459
int instance;
459460
struct nvme_effects_log *effects;
460461
u64 nuse;
@@ -523,7 +524,6 @@ struct nvme_ns {
523524
struct device cdev_device;
524525

525526
struct nvme_fault_inject fault_inject;
526-
bool passthru_err_log_enabled;
527527
};
528528

529529
/* NVMe ns supports metadata actions by the controller (generate/strip) */

drivers/nvme/host/sysfs.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
4848
struct device_attribute *attr, const char *buf, size_t count)
4949
{
5050
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
51-
int err;
5251
bool passthru_err_log_enabled;
52+
int err;
5353

5454
err = kstrtobool(buf, &passthru_err_log_enabled);
5555
if (err)
@@ -60,25 +60,34 @@ static ssize_t nvme_adm_passthru_err_log_enabled_store(struct device *dev,
6060
return count;
6161
}
6262

63+
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
64+
{
65+
struct gendisk *disk = dev_to_disk(dev);
66+
67+
if (nvme_disk_is_ns_head(disk))
68+
return disk->private_data;
69+
return nvme_get_ns_from_dev(dev)->head;
70+
}
71+
6372
static ssize_t nvme_io_passthru_err_log_enabled_show(struct device *dev,
6473
struct device_attribute *attr, char *buf)
6574
{
66-
struct nvme_ns *n = dev_get_drvdata(dev);
75+
struct nvme_ns_head *head = dev_to_ns_head(dev);
6776

68-
return sysfs_emit(buf, n->passthru_err_log_enabled ? "on\n" : "off\n");
77+
return sysfs_emit(buf, head->passthru_err_log_enabled ? "on\n" : "off\n");
6978
}
7079

7180
static ssize_t nvme_io_passthru_err_log_enabled_store(struct device *dev,
7281
struct device_attribute *attr, const char *buf, size_t count)
7382
{
74-
struct nvme_ns *ns = dev_get_drvdata(dev);
75-
int err;
83+
struct nvme_ns_head *head = dev_to_ns_head(dev);
7684
bool passthru_err_log_enabled;
85+
int err;
7786

7887
err = kstrtobool(buf, &passthru_err_log_enabled);
7988
if (err)
8089
return -EINVAL;
81-
ns->passthru_err_log_enabled = passthru_err_log_enabled;
90+
head->passthru_err_log_enabled = passthru_err_log_enabled;
8291

8392
return count;
8493
}
@@ -91,15 +100,6 @@ static struct device_attribute dev_attr_io_passthru_err_log_enabled = \
91100
__ATTR(passthru_err_log_enabled, S_IRUGO | S_IWUSR, \
92101
nvme_io_passthru_err_log_enabled_show, nvme_io_passthru_err_log_enabled_store);
93102

94-
static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
95-
{
96-
struct gendisk *disk = dev_to_disk(dev);
97-
98-
if (nvme_disk_is_ns_head(disk))
99-
return disk->private_data;
100-
return nvme_get_ns_from_dev(dev)->head;
101-
}
102-
103103
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
104104
char *buf)
105105
{

0 commit comments

Comments
 (0)