Skip to content

Commit c266ae7

Browse files
committed
Merge tag 'nvme-6.6-2023-09-14' of git://git.infradead.org/nvme into block-6.6
Pull NVMe fixes from Keith: "nvme fixes for Linux 6.6 - nvme-tcp iov len fix (Varun) - nvme-hwmon const qualifier for safety (Krzysztof) - nvme-fc null pointer checks (Nigel) - nvme-pci no numa node fix (Pratyush) - nvme timeout fix for non-compliant controllers (Keith)" * tag 'nvme-6.6-2023-09-14' of git://git.infradead.org/nvme: nvme: avoid bogus CRTO values nvme-pci: do not set the NUMA node of device if it has none nvme-fc: Prevent null pointer dereference in nvme_fc_io_getuuid() nvme: host: hwmon: constify pointers to hwmon_channel_info nvmet-tcp: pass iov_len instead of sg->length to bvec_set_page()
2 parents 29ee7a4 + 6cc834b commit c266ae7

File tree

5 files changed

+38
-25
lines changed

5 files changed

+38
-25
lines changed

drivers/nvme/host/core.c

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,25 +2245,8 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
22452245
else
22462246
ctrl->ctrl_config = NVME_CC_CSS_NVM;
22472247

2248-
if (ctrl->cap & NVME_CAP_CRMS_CRWMS) {
2249-
u32 crto;
2250-
2251-
ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CRTO, &crto);
2252-
if (ret) {
2253-
dev_err(ctrl->device, "Reading CRTO failed (%d)\n",
2254-
ret);
2255-
return ret;
2256-
}
2257-
2258-
if (ctrl->cap & NVME_CAP_CRMS_CRIMS) {
2259-
ctrl->ctrl_config |= NVME_CC_CRIME;
2260-
timeout = NVME_CRTO_CRIMT(crto);
2261-
} else {
2262-
timeout = NVME_CRTO_CRWMT(crto);
2263-
}
2264-
} else {
2265-
timeout = NVME_CAP_TIMEOUT(ctrl->cap);
2266-
}
2248+
if (ctrl->cap & NVME_CAP_CRMS_CRWMS && ctrl->cap & NVME_CAP_CRMS_CRIMS)
2249+
ctrl->ctrl_config |= NVME_CC_CRIME;
22672250

22682251
ctrl->ctrl_config |= (NVME_CTRL_PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
22692252
ctrl->ctrl_config |= NVME_CC_AMS_RR | NVME_CC_SHN_NONE;
@@ -2277,6 +2260,39 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
22772260
if (ret)
22782261
return ret;
22792262

2263+
/* CAP value may change after initial CC write */
2264+
ret = ctrl->ops->reg_read64(ctrl, NVME_REG_CAP, &ctrl->cap);
2265+
if (ret)
2266+
return ret;
2267+
2268+
timeout = NVME_CAP_TIMEOUT(ctrl->cap);
2269+
if (ctrl->cap & NVME_CAP_CRMS_CRWMS) {
2270+
u32 crto, ready_timeout;
2271+
2272+
ret = ctrl->ops->reg_read32(ctrl, NVME_REG_CRTO, &crto);
2273+
if (ret) {
2274+
dev_err(ctrl->device, "Reading CRTO failed (%d)\n",
2275+
ret);
2276+
return ret;
2277+
}
2278+
2279+
/*
2280+
* CRTO should always be greater or equal to CAP.TO, but some
2281+
* devices are known to get this wrong. Use the larger of the
2282+
* two values.
2283+
*/
2284+
if (ctrl->ctrl_config & NVME_CC_CRIME)
2285+
ready_timeout = NVME_CRTO_CRIMT(crto);
2286+
else
2287+
ready_timeout = NVME_CRTO_CRWMT(crto);
2288+
2289+
if (ready_timeout < timeout)
2290+
dev_warn_once(ctrl->device, "bad crto:%x cap:%llx\n",
2291+
crto, ctrl->cap);
2292+
else
2293+
timeout = ready_timeout;
2294+
}
2295+
22802296
ctrl->ctrl_config |= NVME_CC_ENABLE;
22812297
ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
22822298
if (ret)

drivers/nvme/host/fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ char *nvme_fc_io_getuuid(struct nvmefc_fcp_req *req)
19241924
struct nvme_fc_fcp_op *op = fcp_req_to_fcp_op(req);
19251925
struct request *rq = op->rq;
19261926

1927-
if (!IS_ENABLED(CONFIG_BLK_CGROUP_FC_APPID) || !rq->bio)
1927+
if (!IS_ENABLED(CONFIG_BLK_CGROUP_FC_APPID) || !rq || !rq->bio)
19281928
return NULL;
19291929
return blkcg_get_fc_appid(rq->bio);
19301930
}

drivers/nvme/host/hwmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
187187
return 0;
188188
}
189189

190-
static const struct hwmon_channel_info *nvme_hwmon_info[] = {
190+
static const struct hwmon_channel_info *const nvme_hwmon_info[] = {
191191
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
192192
HWMON_CHANNEL_INFO(temp,
193193
HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MIN |

drivers/nvme/host/pci.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,9 +2916,6 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
29162916
struct nvme_dev *dev;
29172917
int ret = -ENOMEM;
29182918

2919-
if (node == NUMA_NO_NODE)
2920-
set_dev_node(&pdev->dev, first_memory_node);
2921-
29222919
dev = kzalloc_node(sizeof(*dev), GFP_KERNEL, node);
29232920
if (!dev)
29242921
return ERR_PTR(-ENOMEM);

drivers/nvme/target/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static void nvmet_tcp_build_pdu_iovec(struct nvmet_tcp_cmd *cmd)
348348
while (length) {
349349
u32 iov_len = min_t(u32, length, sg->length - sg_offset);
350350

351-
bvec_set_page(iov, sg_page(sg), sg->length,
351+
bvec_set_page(iov, sg_page(sg), iov_len,
352352
sg->offset + sg_offset);
353353

354354
length -= iov_len;

0 commit comments

Comments
 (0)