Skip to content

Commit 8a61cb6

Browse files
committed
Merge tag 'block-6.14-20250221' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - FC controller state check fixes (Daniel) - PCI Endpoint fixes (Damien) - TCP connection failure fixe (Caleb) - TCP handling C2HTermReq PDU (Maurizio) - RDMA queue state check (Ruozhu) - Apple controller fixes (Hector) - Target crash on disbaled namespace (Hannes) - MD pull request via Yu: - Fix queue limits error handling for raid0, raid1 and raid10 - Fix for a NULL pointer deref in request data mapping - Code cleanup for request merging * tag 'block-6.14-20250221' of git://git.kernel.dk/linux: nvme: only allow entering LIVE from CONNECTING state nvme-fc: rely on state transitions to handle connectivity loss apple-nvme: Support coprocessors left idle apple-nvme: Release power domains when probe fails nvmet: Use enum definitions instead of hardcoded values nvme: Cleanup the definition of the controller config register fields nvme/ioctl: add missing space in err message nvme-tcp: fix connect failure on receiving partial ICResp PDU nvme: tcp: Fix compilation warning with W=1 nvmet: pci-epf: Avoid RCU stalls under heavy workload nvmet: pci-epf: Do not uselessly write the CSTS register nvmet: pci-epf: Correctly initialize CSTS when enabling the controller nvmet-rdma: recheck queue state is LIVE in state lock in recv done nvmet: Fix crash when a namespace is disabled nvme-tcp: add basic support for the C2HTermReq PDU nvme-pci: quirk Acer FA100 for non-uniqueue identifiers block: fix NULL pointer dereferenced within __blk_rq_map_sg block/merge: remove unnecessary min() with UINT_MAX md/raid*: Fix the set_queue_limits implementations
2 parents f679ebf + 7055044 commit 8a61cb6

File tree

16 files changed

+216
-150
lines changed

16 files changed

+216
-150
lines changed

block/blk-merge.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static bool bvec_split_segs(const struct queue_limits *lim,
270270
const struct bio_vec *bv, unsigned *nsegs, unsigned *bytes,
271271
unsigned max_segs, unsigned max_bytes)
272272
{
273-
unsigned max_len = min(max_bytes, UINT_MAX) - *bytes;
273+
unsigned max_len = max_bytes - *bytes;
274274
unsigned len = min(bv->bv_len, max_len);
275275
unsigned total_len = 0;
276276
unsigned seg_size = 0;
@@ -556,11 +556,14 @@ int __blk_rq_map_sg(struct request_queue *q, struct request *rq,
556556
{
557557
struct req_iterator iter = {
558558
.bio = rq->bio,
559-
.iter = rq->bio->bi_iter,
560559
};
561560
struct phys_vec vec;
562561
int nsegs = 0;
563562

563+
/* the internal flush request may not have bio attached */
564+
if (iter.bio)
565+
iter.iter = iter.bio->bi_iter;
566+
564567
while (blk_map_iter_next(rq, &iter, &vec)) {
565568
*last_sg = blk_next_sg(last_sg, sglist);
566569
sg_set_page(*last_sg, phys_to_page(vec.paddr), vec.len,

drivers/md/raid0.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,8 @@ static int raid0_set_limits(struct mddev *mddev)
386386
lim.io_opt = lim.io_min * mddev->raid_disks;
387387
lim.features |= BLK_FEAT_ATOMIC_WRITES;
388388
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
389-
if (err) {
390-
queue_limits_cancel_update(mddev->gendisk->queue);
389+
if (err)
391390
return err;
392-
}
393391
return queue_limits_set(mddev->gendisk->queue, &lim);
394392
}
395393

drivers/md/raid1.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3219,10 +3219,8 @@ static int raid1_set_limits(struct mddev *mddev)
32193219
lim.max_write_zeroes_sectors = 0;
32203220
lim.features |= BLK_FEAT_ATOMIC_WRITES;
32213221
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
3222-
if (err) {
3223-
queue_limits_cancel_update(mddev->gendisk->queue);
3222+
if (err)
32243223
return err;
3225-
}
32263224
return queue_limits_set(mddev->gendisk->queue, &lim);
32273225
}
32283226

drivers/md/raid10.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -4020,10 +4020,8 @@ static int raid10_set_queue_limits(struct mddev *mddev)
40204020
lim.io_opt = lim.io_min * raid10_nr_stripes(conf);
40214021
lim.features |= BLK_FEAT_ATOMIC_WRITES;
40224022
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
4023-
if (err) {
4024-
queue_limits_cancel_update(mddev->gendisk->queue);
4023+
if (err)
40254024
return err;
4026-
}
40274025
return queue_limits_set(mddev->gendisk->queue, &lim);
40284026
}
40294027

drivers/nvme/host/apple.c

+38-17
Original file line numberDiff line numberDiff line change
@@ -1011,25 +1011,37 @@ static void apple_nvme_reset_work(struct work_struct *work)
10111011
ret = apple_rtkit_shutdown(anv->rtk);
10121012
if (ret)
10131013
goto out;
1014+
1015+
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
10141016
}
10151017

1016-
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1018+
/*
1019+
* Only do the soft-reset if the CPU is not running, which means either we
1020+
* or the previous stage shut it down cleanly.
1021+
*/
1022+
if (!(readl(anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL) &
1023+
APPLE_ANS_COPROC_CPU_CONTROL_RUN)) {
10171024

1018-
ret = reset_control_assert(anv->reset);
1019-
if (ret)
1020-
goto out;
1025+
ret = reset_control_assert(anv->reset);
1026+
if (ret)
1027+
goto out;
10211028

1022-
ret = apple_rtkit_reinit(anv->rtk);
1023-
if (ret)
1024-
goto out;
1029+
ret = apple_rtkit_reinit(anv->rtk);
1030+
if (ret)
1031+
goto out;
10251032

1026-
ret = reset_control_deassert(anv->reset);
1027-
if (ret)
1028-
goto out;
1033+
ret = reset_control_deassert(anv->reset);
1034+
if (ret)
1035+
goto out;
1036+
1037+
writel(APPLE_ANS_COPROC_CPU_CONTROL_RUN,
1038+
anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1039+
1040+
ret = apple_rtkit_boot(anv->rtk);
1041+
} else {
1042+
ret = apple_rtkit_wake(anv->rtk);
1043+
}
10291044

1030-
writel(APPLE_ANS_COPROC_CPU_CONTROL_RUN,
1031-
anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1032-
ret = apple_rtkit_boot(anv->rtk);
10331045
if (ret) {
10341046
dev_err(anv->dev, "ANS did not boot");
10351047
goto out;
@@ -1516,6 +1528,7 @@ static struct apple_nvme *apple_nvme_alloc(struct platform_device *pdev)
15161528

15171529
return anv;
15181530
put_dev:
1531+
apple_nvme_detach_genpd(anv);
15191532
put_device(anv->dev);
15201533
return ERR_PTR(ret);
15211534
}
@@ -1549,6 +1562,7 @@ static int apple_nvme_probe(struct platform_device *pdev)
15491562
nvme_uninit_ctrl(&anv->ctrl);
15501563
out_put_ctrl:
15511564
nvme_put_ctrl(&anv->ctrl);
1565+
apple_nvme_detach_genpd(anv);
15521566
return ret;
15531567
}
15541568

@@ -1563,9 +1577,12 @@ static void apple_nvme_remove(struct platform_device *pdev)
15631577
apple_nvme_disable(anv, true);
15641578
nvme_uninit_ctrl(&anv->ctrl);
15651579

1566-
if (apple_rtkit_is_running(anv->rtk))
1580+
if (apple_rtkit_is_running(anv->rtk)) {
15671581
apple_rtkit_shutdown(anv->rtk);
15681582

1583+
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1584+
}
1585+
15691586
apple_nvme_detach_genpd(anv);
15701587
}
15711588

@@ -1574,8 +1591,11 @@ static void apple_nvme_shutdown(struct platform_device *pdev)
15741591
struct apple_nvme *anv = platform_get_drvdata(pdev);
15751592

15761593
apple_nvme_disable(anv, true);
1577-
if (apple_rtkit_is_running(anv->rtk))
1594+
if (apple_rtkit_is_running(anv->rtk)) {
15781595
apple_rtkit_shutdown(anv->rtk);
1596+
1597+
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1598+
}
15791599
}
15801600

15811601
static int apple_nvme_resume(struct device *dev)
@@ -1592,10 +1612,11 @@ static int apple_nvme_suspend(struct device *dev)
15921612

15931613
apple_nvme_disable(anv, true);
15941614

1595-
if (apple_rtkit_is_running(anv->rtk))
1615+
if (apple_rtkit_is_running(anv->rtk)) {
15961616
ret = apple_rtkit_shutdown(anv->rtk);
15971617

1598-
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1618+
writel(0, anv->mmio_coproc + APPLE_ANS_COPROC_CPU_CONTROL);
1619+
}
15991620

16001621
return ret;
16011622
}

drivers/nvme/host/core.c

-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,6 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
564564
switch (new_state) {
565565
case NVME_CTRL_LIVE:
566566
switch (old_state) {
567-
case NVME_CTRL_NEW:
568-
case NVME_CTRL_RESETTING:
569567
case NVME_CTRL_CONNECTING:
570568
changed = true;
571569
fallthrough;

drivers/nvme/host/fc.c

+6-61
Original file line numberDiff line numberDiff line change
@@ -781,61 +781,12 @@ nvme_fc_abort_lsops(struct nvme_fc_rport *rport)
781781
static void
782782
nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl)
783783
{
784-
enum nvme_ctrl_state state;
785-
unsigned long flags;
786-
787784
dev_info(ctrl->ctrl.device,
788785
"NVME-FC{%d}: controller connectivity lost. Awaiting "
789786
"Reconnect", ctrl->cnum);
790787

791-
spin_lock_irqsave(&ctrl->lock, flags);
792788
set_bit(ASSOC_FAILED, &ctrl->flags);
793-
state = nvme_ctrl_state(&ctrl->ctrl);
794-
spin_unlock_irqrestore(&ctrl->lock, flags);
795-
796-
switch (state) {
797-
case NVME_CTRL_NEW:
798-
case NVME_CTRL_LIVE:
799-
/*
800-
* Schedule a controller reset. The reset will terminate the
801-
* association and schedule the reconnect timer. Reconnects
802-
* will be attempted until either the ctlr_loss_tmo
803-
* (max_retries * connect_delay) expires or the remoteport's
804-
* dev_loss_tmo expires.
805-
*/
806-
if (nvme_reset_ctrl(&ctrl->ctrl)) {
807-
dev_warn(ctrl->ctrl.device,
808-
"NVME-FC{%d}: Couldn't schedule reset.\n",
809-
ctrl->cnum);
810-
nvme_delete_ctrl(&ctrl->ctrl);
811-
}
812-
break;
813-
814-
case NVME_CTRL_CONNECTING:
815-
/*
816-
* The association has already been terminated and the
817-
* controller is attempting reconnects. No need to do anything
818-
* futher. Reconnects will be attempted until either the
819-
* ctlr_loss_tmo (max_retries * connect_delay) expires or the
820-
* remoteport's dev_loss_tmo expires.
821-
*/
822-
break;
823-
824-
case NVME_CTRL_RESETTING:
825-
/*
826-
* Controller is already in the process of terminating the
827-
* association. No need to do anything further. The reconnect
828-
* step will kick in naturally after the association is
829-
* terminated.
830-
*/
831-
break;
832-
833-
case NVME_CTRL_DELETING:
834-
case NVME_CTRL_DELETING_NOIO:
835-
default:
836-
/* no action to take - let it delete */
837-
break;
838-
}
789+
nvme_reset_ctrl(&ctrl->ctrl);
839790
}
840791

841792
/**
@@ -3071,7 +3022,6 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
30713022
struct nvmefc_ls_rcv_op *disls = NULL;
30723023
unsigned long flags;
30733024
int ret;
3074-
bool changed;
30753025

30763026
++ctrl->ctrl.nr_reconnects;
30773027

@@ -3177,23 +3127,18 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
31773127
else
31783128
ret = nvme_fc_recreate_io_queues(ctrl);
31793129
}
3130+
if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags))
3131+
ret = -EIO;
31803132
if (ret)
31813133
goto out_term_aen_ops;
31823134

3183-
spin_lock_irqsave(&ctrl->lock, flags);
3184-
if (!test_bit(ASSOC_FAILED, &ctrl->flags))
3185-
changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
3186-
else
3135+
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE)) {
31873136
ret = -EIO;
3188-
spin_unlock_irqrestore(&ctrl->lock, flags);
3189-
3190-
if (ret)
31913137
goto out_term_aen_ops;
3138+
}
31923139

31933140
ctrl->ctrl.nr_reconnects = 0;
3194-
3195-
if (changed)
3196-
nvme_start_ctrl(&ctrl->ctrl);
3141+
nvme_start_ctrl(&ctrl->ctrl);
31973142

31983143
return 0; /* Success */
31993144

drivers/nvme/host/ioctl.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ static bool nvme_validate_passthru_nsid(struct nvme_ctrl *ctrl,
283283
{
284284
if (ns && nsid != ns->head->ns_id) {
285285
dev_err(ctrl->device,
286-
"%s: nsid (%u) in cmd does not match nsid (%u)"
287-
"of namespace\n",
286+
"%s: nsid (%u) in cmd does not match nsid (%u) of namespace\n",
288287
current->comm, nsid, ns->head->ns_id);
289288
return false;
290289
}

drivers/nvme/host/pci.c

+2
Original file line numberDiff line numberDiff line change
@@ -3706,6 +3706,8 @@ static const struct pci_device_id nvme_id_table[] = {
37063706
.driver_data = NVME_QUIRK_BOGUS_NID, },
37073707
{ PCI_DEVICE(0x1cc1, 0x5350), /* ADATA XPG GAMMIX S50 */
37083708
.driver_data = NVME_QUIRK_BOGUS_NID, },
3709+
{ PCI_DEVICE(0x1dbe, 0x5216), /* Acer/INNOGRIT FA100/5216 NVMe SSD */
3710+
.driver_data = NVME_QUIRK_BOGUS_NID, },
37093711
{ PCI_DEVICE(0x1dbe, 0x5236), /* ADATA XPG GAMMIX S70 */
37103712
.driver_data = NVME_QUIRK_BOGUS_NID, },
37113713
{ PCI_DEVICE(0x1e49, 0x0021), /* ZHITAI TiPro5000 NVMe SSD */

drivers/nvme/host/tcp.c

+48-2
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,40 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,
763763
return 0;
764764
}
765765

766+
static void nvme_tcp_handle_c2h_term(struct nvme_tcp_queue *queue,
767+
struct nvme_tcp_term_pdu *pdu)
768+
{
769+
u16 fes;
770+
const char *msg;
771+
u32 plen = le32_to_cpu(pdu->hdr.plen);
772+
773+
static const char * const msg_table[] = {
774+
[NVME_TCP_FES_INVALID_PDU_HDR] = "Invalid PDU Header Field",
775+
[NVME_TCP_FES_PDU_SEQ_ERR] = "PDU Sequence Error",
776+
[NVME_TCP_FES_HDR_DIGEST_ERR] = "Header Digest Error",
777+
[NVME_TCP_FES_DATA_OUT_OF_RANGE] = "Data Transfer Out Of Range",
778+
[NVME_TCP_FES_R2T_LIMIT_EXCEEDED] = "R2T Limit Exceeded",
779+
[NVME_TCP_FES_UNSUPPORTED_PARAM] = "Unsupported Parameter",
780+
};
781+
782+
if (plen < NVME_TCP_MIN_C2HTERM_PLEN ||
783+
plen > NVME_TCP_MAX_C2HTERM_PLEN) {
784+
dev_err(queue->ctrl->ctrl.device,
785+
"Received a malformed C2HTermReq PDU (plen = %u)\n",
786+
plen);
787+
return;
788+
}
789+
790+
fes = le16_to_cpu(pdu->fes);
791+
if (fes && fes < ARRAY_SIZE(msg_table))
792+
msg = msg_table[fes];
793+
else
794+
msg = "Unknown";
795+
796+
dev_err(queue->ctrl->ctrl.device,
797+
"Received C2HTermReq (FES = %s)\n", msg);
798+
}
799+
766800
static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
767801
unsigned int *offset, size_t *len)
768802
{
@@ -784,6 +818,15 @@ static int nvme_tcp_recv_pdu(struct nvme_tcp_queue *queue, struct sk_buff *skb,
784818
return 0;
785819

786820
hdr = queue->pdu;
821+
if (unlikely(hdr->type == nvme_tcp_c2h_term)) {
822+
/*
823+
* C2HTermReq never includes Header or Data digests.
824+
* Skip the checks.
825+
*/
826+
nvme_tcp_handle_c2h_term(queue, (void *)queue->pdu);
827+
return -EINVAL;
828+
}
829+
787830
if (queue->hdr_digest) {
788831
ret = nvme_tcp_verify_hdgst(queue, queue->pdu, hdr->hlen);
789832
if (unlikely(ret))
@@ -1449,11 +1492,14 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
14491492
msg.msg_control = cbuf;
14501493
msg.msg_controllen = sizeof(cbuf);
14511494
}
1495+
msg.msg_flags = MSG_WAITALL;
14521496
ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
14531497
iov.iov_len, msg.msg_flags);
1454-
if (ret < 0) {
1498+
if (ret < sizeof(*icresp)) {
14551499
pr_warn("queue %d: failed to receive icresp, error %d\n",
14561500
nvme_tcp_queue_id(queue), ret);
1501+
if (ret >= 0)
1502+
ret = -ECONNRESET;
14571503
goto free_icresp;
14581504
}
14591505
ret = -ENOTCONN;
@@ -1565,7 +1611,7 @@ static bool nvme_tcp_poll_queue(struct nvme_tcp_queue *queue)
15651611
ctrl->io_queues[HCTX_TYPE_POLL];
15661612
}
15671613

1568-
/**
1614+
/*
15691615
* Track the number of queues assigned to each cpu using a global per-cpu
15701616
* counter and select the least used cpu from the mq_map. Our goal is to spread
15711617
* different controllers I/O threads across different cpu cores.

0 commit comments

Comments
 (0)