Skip to content

Commit

Permalink
Merge branch 'nvme-4.13' of git://git.infradead.org/nvme into for-linus
Browse files Browse the repository at this point in the history
Pull NVMe fixes from Christoph:

"A few more small fixes - the fc/lpfc update is the biggest by far."
  • Loading branch information
axboe committed Aug 11, 2017
2 parents d4acf36 + a082b42 commit 4a8b53b
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 51 deletions.
35 changes: 25 additions & 10 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int nvme_get_stream_params(struct nvme_ctrl *ctrl,

c.directive.opcode = nvme_admin_directive_recv;
c.directive.nsid = cpu_to_le32(nsid);
c.directive.numd = cpu_to_le32(sizeof(*s));
c.directive.numd = cpu_to_le32((sizeof(*s) >> 2) - 1);
c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM;
c.directive.dtype = NVME_DIR_STREAMS;

Expand Down Expand Up @@ -1509,7 +1509,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
blk_queue_write_cache(q, vwc, vwc);
}

static void nvme_configure_apst(struct nvme_ctrl *ctrl)
static int nvme_configure_apst(struct nvme_ctrl *ctrl)
{
/*
* APST (Autonomous Power State Transition) lets us program a
Expand Down Expand Up @@ -1538,16 +1538,16 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
* then don't do anything.
*/
if (!ctrl->apsta)
return;
return 0;

if (ctrl->npss > 31) {
dev_warn(ctrl->device, "NPSS is invalid; not using APST\n");
return;
return 0;
}

table = kzalloc(sizeof(*table), GFP_KERNEL);
if (!table)
return;
return 0;

if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) {
/* Turn off APST. */
Expand Down Expand Up @@ -1629,6 +1629,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret);

kfree(table);
return ret;
}

static void nvme_set_latency_tolerance(struct device *dev, s32 val)
Expand Down Expand Up @@ -1835,13 +1836,16 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
* In fabrics we need to verify the cntlid matches the
* admin connect
*/
if (ctrl->cntlid != le16_to_cpu(id->cntlid))
if (ctrl->cntlid != le16_to_cpu(id->cntlid)) {
ret = -EINVAL;
goto out_free;
}

if (!ctrl->opts->discovery_nqn && !ctrl->kas) {
dev_err(ctrl->device,
"keep-alive support is mandatory for fabrics\n");
ret = -EINVAL;
goto out_free;
}
} else {
ctrl->cntlid = le16_to_cpu(id->cntlid);
Expand All @@ -1856,11 +1860,20 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
else if (!ctrl->apst_enabled && prev_apst_enabled)
dev_pm_qos_hide_latency_tolerance(ctrl->device);

nvme_configure_apst(ctrl);
nvme_configure_directives(ctrl);
ret = nvme_configure_apst(ctrl);
if (ret < 0)
return ret;

ret = nvme_configure_directives(ctrl);
if (ret < 0)
return ret;

ctrl->identified = true;

return 0;

out_free:
kfree(id);
return ret;
}
EXPORT_SYMBOL_GPL(nvme_init_identify);
Expand Down Expand Up @@ -2004,9 +2017,11 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
if (memchr_inv(ns->eui, 0, sizeof(ns->eui)))
return sprintf(buf, "eui.%8phN\n", ns->eui);

while (ctrl->serial[serial_len - 1] == ' ')
while (serial_len > 0 && (ctrl->serial[serial_len - 1] == ' ' ||
ctrl->serial[serial_len - 1] == '\0'))
serial_len--;
while (ctrl->model[model_len - 1] == ' ')
while (model_len > 0 && (ctrl->model[model_len - 1] == ' ' ||
ctrl->model[model_len - 1] == '\0'))
model_len--;

return sprintf(buf, "nvme.%04x-%*phN-%*phN-%08x\n", ctrl->vid,
Expand Down
18 changes: 7 additions & 11 deletions drivers/nvme/host/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1558,11 +1558,9 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
if (dev->cmb) {
iounmap(dev->cmb);
dev->cmb = NULL;
if (dev->cmbsz) {
sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
&dev_attr_cmb.attr, NULL);
dev->cmbsz = 0;
}
sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
&dev_attr_cmb.attr, NULL);
dev->cmbsz = 0;
}
}

Expand Down Expand Up @@ -1953,16 +1951,14 @@ static int nvme_pci_enable(struct nvme_dev *dev)

/*
* CMBs can currently only exist on >=1.2 PCIe devices. We only
* populate sysfs if a CMB is implemented. Note that we add the
* CMB attribute to the nvme_ctrl kobj which removes the need to remove
* it on exit. Since nvme_dev_attrs_group has no name we can pass
* NULL as final argument to sysfs_add_file_to_group.
* populate sysfs if a CMB is implemented. Since nvme_dev_attrs_group
* has no name we can pass NULL as final argument to
* sysfs_add_file_to_group.
*/

if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) {
dev->cmb = nvme_map_cmb(dev);

if (dev->cmbsz) {
if (dev->cmb) {
if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
&dev_attr_cmb.attr, NULL))
dev_warn(dev->ctrl.device,
Expand Down
Loading

0 comments on commit 4a8b53b

Please sign in to comment.