Skip to content

Commit 9754d6c

Browse files
committed
Merge tag 'nvme-5.9-2020-09-24' of git://git.infradead.org/nvme into block-5.9
Pull NVMe fixes from Christoph: "nvme fixes for 5.9 - fix error during controller probe that cause double free irqs (Keith Busch) - FC connection establishment fix (James Smart) - properly handle completions for invalid tags (Xianting Tian) - pass the correct nsid to the command effects and supported log (Chaitanya Kulkarni)" * tag 'nvme-5.9-2020-09-24' of git://git.infradead.org/nvme: nvme-core: don't use NVME_NSID_ALL for command effects and supported log nvme-fc: fail new connections to a deleted host or remote port nvme-pci: fix NULL req in completion handler nvme: return errors for hwmon init
2 parents 4a2dd2c + 46d2613 commit 9754d6c

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

drivers/nvme/host/core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,7 +3041,7 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
30413041
if (!cel)
30423042
return -ENOMEM;
30433043

3044-
ret = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_CMD_EFFECTS, 0, csi,
3044+
ret = nvme_get_log(ctrl, 0x00, NVME_LOG_CMD_EFFECTS, 0, csi,
30453045
&cel->log, sizeof(cel->log), 0);
30463046
if (ret) {
30473047
kfree(cel);
@@ -3236,8 +3236,11 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
32363236
if (ret < 0)
32373237
return ret;
32383238

3239-
if (!ctrl->identified)
3240-
nvme_hwmon_init(ctrl);
3239+
if (!ctrl->identified) {
3240+
ret = nvme_hwmon_init(ctrl);
3241+
if (ret < 0)
3242+
return ret;
3243+
}
32413244

32423245
ctrl->identified = true;
32433246

drivers/nvme/host/fc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,12 +3671,14 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts)
36713671
spin_lock_irqsave(&nvme_fc_lock, flags);
36723672
list_for_each_entry(lport, &nvme_fc_lport_list, port_list) {
36733673
if (lport->localport.node_name != laddr.nn ||
3674-
lport->localport.port_name != laddr.pn)
3674+
lport->localport.port_name != laddr.pn ||
3675+
lport->localport.port_state != FC_OBJSTATE_ONLINE)
36753676
continue;
36763677

36773678
list_for_each_entry(rport, &lport->endp_list, endp_list) {
36783679
if (rport->remoteport.node_name != raddr.nn ||
3679-
rport->remoteport.port_name != raddr.pn)
3680+
rport->remoteport.port_name != raddr.pn ||
3681+
rport->remoteport.port_state != FC_OBJSTATE_ONLINE)
36803682
continue;
36813683

36823684
/* if fail to get reference fall through. Will error */

drivers/nvme/host/hwmon.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,
5959

6060
static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data)
6161
{
62-
int ret;
63-
64-
ret = nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
62+
return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
6563
NVME_CSI_NVM, &data->log, sizeof(data->log), 0);
66-
67-
return ret <= 0 ? ret : -EIO;
6864
}
6965

7066
static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
@@ -225,7 +221,7 @@ static const struct hwmon_chip_info nvme_hwmon_chip_info = {
225221
.info = nvme_hwmon_info,
226222
};
227223

228-
void nvme_hwmon_init(struct nvme_ctrl *ctrl)
224+
int nvme_hwmon_init(struct nvme_ctrl *ctrl)
229225
{
230226
struct device *dev = ctrl->dev;
231227
struct nvme_hwmon_data *data;
@@ -234,7 +230,7 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl)
234230

235231
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
236232
if (!data)
237-
return;
233+
return 0;
238234

239235
data->ctrl = ctrl;
240236
mutex_init(&data->read_lock);
@@ -244,7 +240,7 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl)
244240
dev_warn(ctrl->device,
245241
"Failed to read smart log (error %d)\n", err);
246242
devm_kfree(dev, data);
247-
return;
243+
return err;
248244
}
249245

250246
hwmon = devm_hwmon_device_register_with_info(dev, "nvme", data,
@@ -254,4 +250,6 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl)
254250
dev_warn(dev, "Failed to instantiate hwmon device\n");
255251
devm_kfree(dev, data);
256252
}
253+
254+
return 0;
257255
}

drivers/nvme/host/nvme.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,12 @@ static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
827827
}
828828

829829
#ifdef CONFIG_NVME_HWMON
830-
void nvme_hwmon_init(struct nvme_ctrl *ctrl);
830+
int nvme_hwmon_init(struct nvme_ctrl *ctrl);
831831
#else
832-
static inline void nvme_hwmon_init(struct nvme_ctrl *ctrl) { }
832+
static inline int nvme_hwmon_init(struct nvme_ctrl *ctrl)
833+
{
834+
return 0;
835+
}
833836
#endif
834837

835838
u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,

drivers/nvme/host/pci.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,6 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
940940
struct nvme_completion *cqe = &nvmeq->cqes[idx];
941941
struct request *req;
942942

943-
if (unlikely(cqe->command_id >= nvmeq->q_depth)) {
944-
dev_warn(nvmeq->dev->ctrl.device,
945-
"invalid id %d completed on queue %d\n",
946-
cqe->command_id, le16_to_cpu(cqe->sq_id));
947-
return;
948-
}
949-
950943
/*
951944
* AEN requests are special as they don't time out and can
952945
* survive any kind of queue freeze and often don't respond to
@@ -960,6 +953,13 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
960953
}
961954

962955
req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id);
956+
if (unlikely(!req)) {
957+
dev_warn(nvmeq->dev->ctrl.device,
958+
"invalid id %d completed on queue %d\n",
959+
cqe->command_id, le16_to_cpu(cqe->sq_id));
960+
return;
961+
}
962+
963963
trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
964964
if (!nvme_try_complete_req(req, cqe->status, cqe->result))
965965
nvme_pci_complete_rq(req);

0 commit comments

Comments
 (0)