Skip to content

Commit d64fd5f

Browse files
committed
Merge tag 'nvme-6.13-2024-12-05' of git://git.infradead.org/nvme into block-6.13
Pull NVMe fixess from Keith: "nvme fixes for Linux 6.13 - Target fix using incorrect zero buffer (Nilay) - Device specifc deallocate quirk fixes (Christoph, Keith) - Fabrics fix for handling max command target bugs (Maurizio) - Cocci fix usage for kzalloc (Yu-Chen) - DMA size fix for host memory buffer feature (Christoph) - Fabrics queue cleanup fixes (Chunguang)" * tag 'nvme-6.13-2024-12-05' of git://git.infradead.org/nvme: nvme-tcp: simplify nvme_tcp_teardown_io_queues() nvme-tcp: no need to quiesce admin_q in nvme_tcp_teardown_io_queues() nvme-rdma: unquiesce admin_q before destroy it nvme-tcp: fix the memleak while create new ctrl failed nvme-pci: don't use dma_alloc_noncontiguous with 0 merge boundary nvmet: replace kmalloc + memset with kzalloc for data allocation nvme-fabrics: handle zero MAXCMD without closing the connection nvme-pci: remove two deallocate zeroes quirks nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported nvmet: use kzalloc instead of ZERO_PAGE in nvme_execute_identify_ns_nvm()
2 parents 7678abe + b4e12f5 commit d64fd5f

File tree

6 files changed

+22
-30
lines changed

6 files changed

+22
-30
lines changed

drivers/nvme/host/core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
20712071
lim->physical_block_size = min(phys_bs, atomic_bs);
20722072
lim->io_min = phys_bs;
20732073
lim->io_opt = io_opt;
2074-
if (ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
2074+
if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
2075+
(ns->ctrl->oncs & NVME_CTRL_ONCS_DSM))
20752076
lim->max_write_zeroes_sectors = UINT_MAX;
20762077
else
20772078
lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors;
@@ -3260,8 +3261,9 @@ static int nvme_check_ctrl_fabric_info(struct nvme_ctrl *ctrl, struct nvme_id_ct
32603261
}
32613262

32623263
if (!ctrl->maxcmd) {
3263-
dev_err(ctrl->device, "Maximum outstanding commands is 0\n");
3264-
return -EINVAL;
3264+
dev_warn(ctrl->device,
3265+
"Firmware bug: maximum outstanding commands is 0\n");
3266+
ctrl->maxcmd = ctrl->sqsize + 1;
32653267
}
32663268

32673269
return 0;

drivers/nvme/host/pci.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,7 @@ static int nvme_alloc_host_mem_multi(struct nvme_dev *dev, u64 preferred,
21722172

21732173
static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
21742174
{
2175+
unsigned long dma_merge_boundary = dma_get_merge_boundary(dev->dev);
21752176
u64 min_chunk = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
21762177
u64 hmminds = max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2);
21772178
u64 chunk_size;
@@ -2180,7 +2181,7 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
21802181
* If there is an IOMMU that can merge pages, try a virtually
21812182
* non-contiguous allocation for a single segment first.
21822183
*/
2183-
if (!(PAGE_SIZE & dma_get_merge_boundary(dev->dev))) {
2184+
if (dma_merge_boundary && (PAGE_SIZE & dma_merge_boundary) == 0) {
21842185
if (!nvme_alloc_host_mem_single(dev, preferred))
21852186
return 0;
21862187
}
@@ -3588,12 +3589,10 @@ static const struct pci_device_id nvme_id_table[] = {
35883589
NVME_QUIRK_DEALLOCATE_ZEROES, },
35893590
{ PCI_VDEVICE(INTEL, 0x0a54), /* Intel P4500/P4600 */
35903591
.driver_data = NVME_QUIRK_STRIPE_SIZE |
3591-
NVME_QUIRK_DEALLOCATE_ZEROES |
35923592
NVME_QUIRK_IGNORE_DEV_SUBNQN |
35933593
NVME_QUIRK_BOGUS_NID, },
35943594
{ PCI_VDEVICE(INTEL, 0x0a55), /* Dell Express Flash P4600 */
3595-
.driver_data = NVME_QUIRK_STRIPE_SIZE |
3596-
NVME_QUIRK_DEALLOCATE_ZEROES, },
3595+
.driver_data = NVME_QUIRK_STRIPE_SIZE, },
35973596
{ PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
35983597
.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
35993598
NVME_QUIRK_MEDIUM_PRIO_SQ |

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,13 +1091,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
10911091
}
10921092
destroy_admin:
10931093
nvme_stop_keep_alive(&ctrl->ctrl);
1094-
nvme_quiesce_admin_queue(&ctrl->ctrl);
1095-
blk_sync_queue(ctrl->ctrl.admin_q);
1096-
nvme_rdma_stop_queue(&ctrl->queues[0]);
1097-
nvme_cancel_admin_tagset(&ctrl->ctrl);
1098-
if (new)
1099-
nvme_remove_admin_tag_set(&ctrl->ctrl);
1100-
nvme_rdma_destroy_admin_queue(ctrl);
1094+
nvme_rdma_teardown_admin_queue(ctrl, new);
11011095
return ret;
11021096
}
11031097

drivers/nvme/host/tcp.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,14 +2101,6 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
21012101
return ret;
21022102
}
21032103

2104-
static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove)
2105-
{
2106-
nvme_tcp_stop_queue(ctrl, 0);
2107-
if (remove)
2108-
nvme_remove_admin_tag_set(ctrl);
2109-
nvme_tcp_free_admin_queue(ctrl);
2110-
}
2111-
21122104
static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)
21132105
{
21142106
int error;
@@ -2163,9 +2155,11 @@ static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl,
21632155
blk_sync_queue(ctrl->admin_q);
21642156
nvme_tcp_stop_queue(ctrl, 0);
21652157
nvme_cancel_admin_tagset(ctrl);
2166-
if (remove)
2158+
if (remove) {
21672159
nvme_unquiesce_admin_queue(ctrl);
2168-
nvme_tcp_destroy_admin_queue(ctrl, remove);
2160+
nvme_remove_admin_tag_set(ctrl);
2161+
}
2162+
nvme_tcp_free_admin_queue(ctrl);
21692163
if (ctrl->tls_pskid) {
21702164
dev_dbg(ctrl->device, "Wipe negotiated TLS_PSK %08x\n",
21712165
ctrl->tls_pskid);
@@ -2178,7 +2172,6 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
21782172
{
21792173
if (ctrl->queue_count <= 1)
21802174
return;
2181-
nvme_quiesce_admin_queue(ctrl);
21822175
nvme_quiesce_io_queues(ctrl);
21832176
nvme_sync_io_queues(ctrl);
21842177
nvme_tcp_stop_io_queues(ctrl);
@@ -2278,7 +2271,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
22782271
}
22792272
destroy_admin:
22802273
nvme_stop_keep_alive(ctrl);
2281-
nvme_tcp_teardown_admin_queue(ctrl, false);
2274+
nvme_tcp_teardown_admin_queue(ctrl, new);
22822275
return ret;
22832276
}
22842277

drivers/nvme/target/admin-cmd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,13 +902,18 @@ static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req)
902902
static void nvme_execute_identify_ns_nvm(struct nvmet_req *req)
903903
{
904904
u16 status;
905+
struct nvme_id_ns_nvm *id;
905906

906907
status = nvmet_req_find_ns(req);
907908
if (status)
908909
goto out;
909910

910-
status = nvmet_copy_to_sgl(req, 0, ZERO_PAGE(0),
911-
NVME_IDENTIFY_DATA_SIZE);
911+
id = kzalloc(sizeof(*id), GFP_KERNEL);
912+
if (!id) {
913+
status = NVME_SC_INTERNAL;
914+
goto out;
915+
}
916+
status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
912917
out:
913918
nvmet_req_complete(req, status);
914919
}

drivers/nvme/target/pr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,11 @@ static void nvmet_execute_pr_report(struct nvmet_req *req)
828828
goto out;
829829
}
830830

831-
data = kmalloc(num_bytes, GFP_KERNEL);
831+
data = kzalloc(num_bytes, GFP_KERNEL);
832832
if (!data) {
833833
status = NVME_SC_INTERNAL;
834834
goto out;
835835
}
836-
memset(data, 0, num_bytes);
837836
data->gen = cpu_to_le32(atomic_read(&pr->generation));
838837
data->ptpls = 0;
839838
ctrl_eds = data->regctl_eds;

0 commit comments

Comments
 (0)