History

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio fixes from Michael Tsirkin: "Some last minute fixes - most of them for regressions" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vdpa_sim_net: complete the initialization before register the device vdpa/mlx5: Add and remove debugfs in setup/teardown driver tools/virtio: fix typo in README instructions vhost-scsi: Fix crash during LUN unmapping vhost-scsi: Fix vhost_scsi struct use after free virtio-blk: fix ZBD probe in kernels without ZBD support virtio-blk: fix to match virtio spec

Linus Torvalds committed 3 years ago

Commit dfc19152 parents c118b59 9da667e6 files · +205 −144Browse files

Unified · Split

6 files
  1. drivers/block/virtio_blk.c +173 −96
  2. drivers/vdpa/mlx5/net/mlx5_vnet.c +6 −2
  3. drivers/vdpa/vdpa_sim/vdpa_sim_net.c +9 −4
  4. drivers/vhost/scsi.c +7 −32
  5. include/uapi/linux/virtio_blk.h +9 −9
  6. tools/virtio/virtio-trace/README +1 −1
drivers/block/virtio_blk.c+173−96
@@ -96,16 +96,14 @@ struct virtblk_req { · 95 unmodified lines
9696
9797 /*
9898 * The zone append command has an extended in header.
99− * The status field in zone_append_in_hdr must have
100− * the same offset in virtblk_req as the non-zoned
101− * status field above.
99+ * The status field in zone_append_in_hdr must always
100+ * be the last byte.
102101 */
103102 struct {
103+ __virtio64 sector;
104104 u8 status;
105− u8 reserved[7];
106− __le64 append_sector;
107− } zone_append_in_hdr;
108− };
105+ } zone_append;
106+ } in_hdr;
109107
110108 size_t in_hdr_len;
111109
@@ -154,7 +152,7 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr) · 42 unmodified lines
154152 sgs[num_out + num_in++] = vbr->sg_table.sgl;
155153 }
156154
157− sg_init_one(&in_hdr, &vbr->status, vbr->in_hdr_len);
155+ sg_init_one(&in_hdr, &vbr->in_hdr.status, vbr->in_hdr_len);
158156 sgs[num_out + num_in++] = &in_hdr;
159157
160158 return virtqueue_add_sgs(vq, sgs, num_out, num_in, vbr, GFP_ATOMIC);
@@ -242,11 +240,14 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev, · 81 unmodified lines
242240 struct request *req,
243241 struct virtblk_req *vbr)
244242 {
245− size_t in_hdr_len = sizeof(vbr->status);
243+ size_t in_hdr_len = sizeof(vbr->in_hdr.status);
246244 bool unmap = false;
247245 u32 type;
248246 u64 sector = 0;
249247
248+ if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) && op_is_zone_mgmt(req_op(req)))
249+ return BLK_STS_NOTSUPP;
250+
250251 /* Set fields for all request types */
251252 vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
252253
@@ -287,7 +288,7 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev, · 34 unmodified lines
287288 case REQ_OP_ZONE_APPEND:
288289 type = VIRTIO_BLK_T_ZONE_APPEND;
289290 sector = blk_rq_pos(req);
290− in_hdr_len = sizeof(vbr->zone_append_in_hdr);
291+ in_hdr_len = sizeof(vbr->in_hdr.zone_append);
291292 break;
292293 case REQ_OP_ZONE_RESET:
293294 type = VIRTIO_BLK_T_ZONE_RESET;
@@ -297,7 +298,10 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev, · 3 unmodified lines
297298 type = VIRTIO_BLK_T_ZONE_RESET_ALL;
298299 break;
299300 case REQ_OP_DRV_IN:
300− /* Out header already filled in, nothing to do */
301+ /*
302+ * Out header has already been prepared by the caller (virtblk_get_id()
303+ * or virtblk_submit_zone_report()), nothing to do here.
304+ */
301305 return 0;
302306 default:
303307 WARN_ON_ONCE(1);
@@ -318,16 +322,28 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev, · 14 unmodified lines
318322 return 0;
319323 }
320324
325+/*
326+ * The status byte is always the last byte of the virtblk request
327+ * in-header. This helper fetches its value for all in-header formats
328+ * that are currently defined.
329+ */
330+static inline u8 virtblk_vbr_status(struct virtblk_req *vbr)
331+{
332+ return *((u8 *)&vbr->in_hdr + vbr->in_hdr_len - 1);
333+}
334+
321335 static inline void virtblk_request_done(struct request *req)
322336 {
323337 struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
324− blk_status_t status = virtblk_result(vbr->status);
338+ blk_status_t status = virtblk_result(virtblk_vbr_status(vbr));
339+ struct virtio_blk *vblk = req->mq_hctx->queue->queuedata;
325340
326341 virtblk_unmap_data(req, vbr);
327342 virtblk_cleanup_cmd(req);
328343
329344 if (req_op(req) == REQ_OP_ZONE_APPEND)
330− req->__sector = le64_to_cpu(vbr->zone_append_in_hdr.append_sector);
345+ req->__sector = virtio64_to_cpu(vblk->vdev,
346+ vbr->in_hdr.zone_append.sector);
331347
332348 blk_mq_end_request(req, status);
333349 }
@@ -355,7 +371,7 @@ static int virtblk_handle_req(struct virtio_blk_vq *vq, · 21 unmodified lines
355371
356372 if (likely(!blk_should_fake_timeout(req->q)) &&
357373 !blk_mq_complete_request_remote(req) &&
358− !blk_mq_add_to_batch(req, iob, vbr->status,
374+ !blk_mq_add_to_batch(req, iob, virtblk_vbr_status(vbr),
359375 virtblk_complete_batch))
360376 virtblk_request_done(req);
361377 req_done++;
@@ -550,7 +566,6 @@ static void virtio_queue_rqs(struct request **rqlist) · 188 unmodified lines
550566 #ifdef CONFIG_BLK_DEV_ZONED
551567 static void *virtblk_alloc_report_buffer(struct virtio_blk *vblk,
552568 unsigned int nr_zones,
553− unsigned int zone_sectors,
554569 size_t *buflen)
555570 {
556571 struct request_queue *q = vblk->disk->queue;
@@ -558,7 +573,7 @@ static void *virtblk_alloc_report_buffer(struct virtio_blk *vblk, · 1 unmodified line
558573 void *buf;
559574
560575 nr_zones = min_t(unsigned int, nr_zones,
561− get_capacity(vblk->disk) >> ilog2(zone_sectors));
576+ get_capacity(vblk->disk) >> ilog2(vblk->zone_sectors));
562577
563578 bufsize = sizeof(struct virtio_blk_zone_report) +
564579 nr_zones * sizeof(struct virtio_blk_zone_descriptor);
@@ -592,7 +607,7 @@ static int virtblk_submit_zone_report(struct virtio_blk *vblk, · 27 unmodified lines
592607 return PTR_ERR(req);
593608
594609 vbr = blk_mq_rq_to_pdu(req);
595− vbr->in_hdr_len = sizeof(vbr->status);
610+ vbr->in_hdr_len = sizeof(vbr->in_hdr.status);
596611 vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_ZONE_REPORT);
597612 vbr->out_hdr.sector = cpu_to_virtio64(vblk->vdev, sector);
598613
@@ -601,7 +616,7 @@ static int virtblk_submit_zone_report(struct virtio_blk *vblk, · 2 unmodified lines
601616 goto out;
602617
603618 blk_execute_rq(req, false);
604− err = blk_status_to_errno(virtblk_result(vbr->status));
619+ err = blk_status_to_errno(virtblk_result(vbr->in_hdr.status));
605620 out:
606621 blk_mq_free_request(req);
607622 return err;
@@ -609,29 +624,72 @@ out: · 1 unmodified line
609624
610625 static int virtblk_parse_zone(struct virtio_blk *vblk,
611626 struct virtio_blk_zone_descriptor *entry,
612− unsigned int idx, unsigned int zone_sectors,
613− report_zones_cb cb, void *data)
627+ unsigned int idx, report_zones_cb cb, void *data)
614628 {
615629 struct blk_zone zone = { };
616630
617− if (entry->z_type != VIRTIO_BLK_ZT_SWR &&
618− entry->z_type != VIRTIO_BLK_ZT_SWP &&
619− entry->z_type != VIRTIO_BLK_ZT_CONV) {
620− dev_err(&vblk->vdev->dev, "invalid zone type %#x\n",
621− entry->z_type);
622− return -EINVAL;
631+ zone.start = virtio64_to_cpu(vblk->vdev, entry->z_start);
632+ if (zone.start + vblk->zone_sectors <= get_capacity(vblk->disk))
633+ zone.len = vblk->zone_sectors;
634+ else
635+ zone.len = get_capacity(vblk->disk) - zone.start;
636+ zone.capacity = virtio64_to_cpu(vblk->vdev, entry->z_cap);
637+ zone.wp = virtio64_to_cpu(vblk->vdev, entry->z_wp);
638+
639+ switch (entry->z_type) {
640+ case VIRTIO_BLK_ZT_SWR:
641+ zone.type = BLK_ZONE_TYPE_SEQWRITE_REQ;
642+ break;
643+ case VIRTIO_BLK_ZT_SWP:
644+ zone.type = BLK_ZONE_TYPE_SEQWRITE_PREF;
645+ break;
646+ case VIRTIO_BLK_ZT_CONV:
647+ zone.type = BLK_ZONE_TYPE_CONVENTIONAL;
648+ break;
649+ default:
650+ dev_err(&vblk->vdev->dev, "zone %llu: invalid type %#x\n",
651+ zone.start, entry->z_type);
652+ return -EIO;
623653 }
624654
625− zone.type = entry->z_type;
626− zone.cond = entry->z_state;
627− zone.len = zone_sectors;
628− zone.capacity = le64_to_cpu(entry->z_cap);
629− zone.start = le64_to_cpu(entry->z_start);
630− if (zone.cond == BLK_ZONE_COND_FULL)
655+ switch (entry->z_state) {
656+ case VIRTIO_BLK_ZS_EMPTY:
657+ zone.cond = BLK_ZONE_COND_EMPTY;
658+ break;
659+ case VIRTIO_BLK_ZS_CLOSED:
660+ zone.cond = BLK_ZONE_COND_CLOSED;
661+ break;
662+ case VIRTIO_BLK_ZS_FULL:
663+ zone.cond = BLK_ZONE_COND_FULL;
631664 zone.wp = zone.start + zone.len;
632− else
633− zone.wp = le64_to_cpu(entry->z_wp);
665+ break;
666+ case VIRTIO_BLK_ZS_EOPEN:
667+ zone.cond = BLK_ZONE_COND_EXP_OPEN;
668+ break;
669+ case VIRTIO_BLK_ZS_IOPEN:
670+ zone.cond = BLK_ZONE_COND_IMP_OPEN;
671+ break;
672+ case VIRTIO_BLK_ZS_NOT_WP:
673+ zone.cond = BLK_ZONE_COND_NOT_WP;
674+ break;
675+ case VIRTIO_BLK_ZS_RDONLY:
676+ zone.cond = BLK_ZONE_COND_READONLY;
677+ zone.wp = ULONG_MAX;
678+ break;
679+ case VIRTIO_BLK_ZS_OFFLINE:
680+ zone.cond = BLK_ZONE_COND_OFFLINE;
681+ zone.wp = ULONG_MAX;
682+ break;
683+ default:
684+ dev_err(&vblk->vdev->dev, "zone %llu: invalid condition %#x\n",
685+ zone.start, entry->z_state);
686+ return -EIO;
687+ }
634688
689+ /*
690+ * The callback below checks the validity of the reported
691+ * entry data, no need to further validate it here.
692+ */
635693 return cb(&zone, idx, data);
636694 }
637695
@@ -641,39 +699,47 @@ static int virtblk_report_zones(struct gendisk *disk, sector_t sector, · 3 unmodified lines
641699 {
642700 struct virtio_blk *vblk = disk->private_data;
643701 struct virtio_blk_zone_report *report;
644− unsigned int zone_sectors = vblk->zone_sectors;
645− unsigned int nz, i;
646− int ret, zone_idx = 0;
702+ unsigned long long nz, i;
647703 size_t buflen;
704+ unsigned int zone_idx = 0;
705+ int ret;
648706
649707 if (WARN_ON_ONCE(!vblk->zone_sectors))
650708 return -EOPNOTSUPP;
651709
652− report = virtblk_alloc_report_buffer(vblk, nr_zones,
653− zone_sectors, &buflen);
710+ report = virtblk_alloc_report_buffer(vblk, nr_zones, &buflen);
654711 if (!report)
655712 return -ENOMEM;
656713
714+ mutex_lock(&vblk->vdev_mutex);
715+
716+ if (!vblk->vdev) {
717+ ret = -ENXIO;
718+ goto fail_report;
719+ }
720+
657721 while (zone_idx < nr_zones && sector < get_capacity(vblk->disk)) {
658722 memset(report, 0, buflen);
659723
660724 ret = virtblk_submit_zone_report(vblk, (char *)report,
661725 buflen, sector);
662− if (ret) {
663− if (ret > 0)
664− ret = -EIO;
665− goto out_free;
666− }
667− nz = min((unsigned int)le64_to_cpu(report->nr_zones), nr_zones);
726+ if (ret)
727+ goto fail_report;
728+
729+ nz = min_t(u64, virtio64_to_cpu(vblk->vdev, report->nr_zones),
730+ nr_zones);
668731 if (!nz)
669732 break;
670733
671734 for (i = 0; i < nz && zone_idx < nr_zones; i++) {
672735 ret = virtblk_parse_zone(vblk, &report->zones[i],
673− zone_idx, zone_sectors, cb, data);
736+ zone_idx, cb, data);
674737 if (ret)
675− goto out_free;
676− sector = le64_to_cpu(report->zones[i].z_start) + zone_sectors;
738+ goto fail_report;
739+
740+ sector = virtio64_to_cpu(vblk->vdev,
741+ report->zones[i].z_start) +
742+ vblk->zone_sectors;
677743 zone_idx++;
678744 }
679745 }
@@ -682,7 +748,8 @@ static int virtblk_report_zones(struct gendisk *disk, sector_t sector, · 2 unmodified lines
682748 ret = zone_idx;
683749 else
684750 ret = -EINVAL;
685−out_free:
751+fail_report:
752+ mutex_unlock(&vblk->vdev_mutex);
686753 kvfree(report);
687754 return ret;
688755 }
@@ -691,20 +758,28 @@ static void virtblk_revalidate_zones(struct virtio_blk *vblk) · 2 unmodified lines
691758 {
692759 u8 model;
693760
694− if (!vblk->zone_sectors)
695− return;
696−
697761 virtio_cread(vblk->vdev, struct virtio_blk_config,
698762 zoned.model, &model);
699− if (!blk_revalidate_disk_zones(vblk->disk, NULL))
700− set_capacity_and_notify(vblk->disk, 0);
763+ switch (model) {
764+ default:
765+ dev_err(&vblk->vdev->dev, "unknown zone model %d\n", model);
766+ fallthrough;
767+ case VIRTIO_BLK_Z_NONE:
768+ case VIRTIO_BLK_Z_HA:
769+ disk_set_zoned(vblk->disk, BLK_ZONED_NONE);
770+ return;
771+ case VIRTIO_BLK_Z_HM:
772+ WARN_ON_ONCE(!vblk->zone_sectors);
773+ if (!blk_revalidate_disk_zones(vblk->disk, NULL))
774+ set_capacity_and_notify(vblk->disk, 0);
775+ }
701776 }
702777
703778 static int virtblk_probe_zoned_device(struct virtio_device *vdev,
704779 struct virtio_blk *vblk,
705780 struct request_queue *q)
706781 {
707− u32 v;
782+ u32 v, wg;
708783 u8 model;
709784 int ret;
710785
@@ -713,16 +788,11 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev, · 2 unmodified lines
713788
714789 switch (model) {
715790 case VIRTIO_BLK_Z_NONE:
791+ case VIRTIO_BLK_Z_HA:
792+ /* Present the host-aware device as non-zoned */
716793 return 0;
717794 case VIRTIO_BLK_Z_HM:
718795 break;
719− case VIRTIO_BLK_Z_HA:
720− /*
721− * Present the host-aware device as a regular drive.
722− * TODO It is possible to add an option to make it appear
723− * in the system as a zoned drive.
724− */
725− return 0;
726796 default:
727797 dev_err(&vdev->dev, "unsupported zone model %d\n", model);
728798 return -EINVAL;
@@ -735,32 +805,31 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev, · 6 unmodified lines
735805
736806 virtio_cread(vdev, struct virtio_blk_config,
737807 zoned.max_open_zones, &v);
738− disk_set_max_open_zones(vblk->disk, le32_to_cpu(v));
739−
740− dev_dbg(&vdev->dev, "max open zones = %u\n", le32_to_cpu(v));
808+ disk_set_max_open_zones(vblk->disk, v);
809+ dev_dbg(&vdev->dev, "max open zones = %u\n", v);
741810
742811 virtio_cread(vdev, struct virtio_blk_config,
743812 zoned.max_active_zones, &v);
744− disk_set_max_active_zones(vblk->disk, le32_to_cpu(v));
745− dev_dbg(&vdev->dev, "max active zones = %u\n", le32_to_cpu(v));
813+ disk_set_max_active_zones(vblk->disk, v);
814+ dev_dbg(&vdev->dev, "max active zones = %u\n", v);
746815
747816 virtio_cread(vdev, struct virtio_blk_config,
748− zoned.write_granularity, &v);
749− if (!v) {
817+ zoned.write_granularity, &wg);
818+ if (!wg) {
750819 dev_warn(&vdev->dev, "zero write granularity reported\n");
751820 return -ENODEV;
752821 }
753− blk_queue_physical_block_size(q, le32_to_cpu(v));
754− blk_queue_io_min(q, le32_to_cpu(v));
822+ blk_queue_physical_block_size(q, wg);
823+ blk_queue_io_min(q, wg);
755824
756− dev_dbg(&vdev->dev, "write granularity = %u\n", le32_to_cpu(v));
825+ dev_dbg(&vdev->dev, "write granularity = %u\n", wg);
757826
758827 /*
759828 * virtio ZBD specification doesn't require zones to be a power of
760829 * two sectors in size, but the code in this driver expects that.
761830 */
762− virtio_cread(vdev, struct virtio_blk_config, zoned.zone_sectors, &v);
763− vblk->zone_sectors = le32_to_cpu(v);
831+ virtio_cread(vdev, struct virtio_blk_config, zoned.zone_sectors,
832+ &vblk->zone_sectors);
764833 if (vblk->zone_sectors == 0 || !is_power_of_2(vblk->zone_sectors)) {
765834 dev_err(&vdev->dev,
766835 "zoned device with non power of two zone size %u\n",
@@ -783,36 +852,46 @@ static int virtblk_probe_zoned_device(struct virtio_device *vdev, · 16 unmodified lines
783852 dev_warn(&vdev->dev, "zero max_append_sectors reported\n");
784853 return -ENODEV;
785854 }
786− blk_queue_max_zone_append_sectors(q, le32_to_cpu(v));
787− dev_dbg(&vdev->dev, "max append sectors = %u\n", le32_to_cpu(v));
855+ if ((v << SECTOR_SHIFT) < wg) {
856+ dev_err(&vdev->dev,
857+ "write granularity %u exceeds max_append_sectors %u limit\n",
858+ wg, v);
859+ return -ENODEV;
860+ }
861+
862+ blk_queue_max_zone_append_sectors(q, v);
863+ dev_dbg(&vdev->dev, "max append sectors = %u\n", v);
788864 }
789865
790866 return ret;
791867 }
792868
793−static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
794−{
795− return virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED);
796−}
797869 #else
798870
799871 /*
800872 * Zoned block device support is not configured in this kernel.
801− * We only need to define a few symbols to avoid compilation errors.
873+ * Host-managed zoned devices can't be supported, but others are
874+ * good to go as regular block devices.
802875 */
803876 #define virtblk_report_zones NULL
877+
804878 static inline void virtblk_revalidate_zones(struct virtio_blk *vblk)
805879 {
806880 }
881+
807882 static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
808883 struct virtio_blk *vblk, struct request_queue *q)
809884 {
810− return -EOPNOTSUPP;
811−}
885+ u8 model;
812886
813−static inline bool virtblk_has_zoned_feature(struct virtio_device *vdev)
814−{
815− return false;
887+ virtio_cread(vdev, struct virtio_blk_config, zoned.model, &model);
888+ if (model == VIRTIO_BLK_Z_HM) {
889+ dev_err(&vdev->dev,
890+ "virtio_blk: zoned devices are not supported");
891+ return -EOPNOTSUPP;
892+ }
893+
894+ return 0;
816895 }
817896 #endif /* CONFIG_BLK_DEV_ZONED */
818897
@@ -831,7 +910,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str) · 12 unmodified lines
831910 return PTR_ERR(req);
832911
833912 vbr = blk_mq_rq_to_pdu(req);
834− vbr->in_hdr_len = sizeof(vbr->status);
913+ vbr->in_hdr_len = sizeof(vbr->in_hdr.status);
835914 vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_GET_ID);
836915 vbr->out_hdr.sector = 0;
837916
@@ -840,7 +919,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str) · 2 unmodified lines
840919 goto out;
841920
842921 blk_execute_rq(req, false);
843− err = blk_status_to_errno(virtblk_result(vbr->status));
922+ err = blk_status_to_errno(virtblk_result(vbr->in_hdr.status));
844923 out:
845924 blk_mq_free_request(req);
846925 return err;
@@ -1498,15 +1577,16 @@ static int virtblk_probe(struct virtio_device *vdev) · 651 unmodified lines
14981577 virtblk_update_capacity(vblk, false);
14991578 virtio_device_ready(vdev);
15001579
1501− if (virtblk_has_zoned_feature(vdev)) {
1580+ /*
1581+ * All steps that follow use the VQs therefore they need to be
1582+ * placed after the virtio_device_ready() call above.
1583+ */
1584+ if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
15021585 err = virtblk_probe_zoned_device(vdev, vblk, q);
15031586 if (err)
15041587 goto out_cleanup_disk;
15051588 }
15061589
1507− dev_info(&vdev->dev, "blk config size: %zu\n",
1508− sizeof(struct virtio_blk_config));
1509−
15101590 err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);
15111591 if (err)
15121592 goto out_cleanup_disk;
@@ -1607,10 +1687,7 @@ static unsigned int features[] = { · 94 unmodified lines
16071687 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
16081688 VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE,
16091689 VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_WRITE_ZEROES,
1610− VIRTIO_BLK_F_SECURE_ERASE,
1611−#ifdef CONFIG_BLK_DEV_ZONED
1612− VIRTIO_BLK_F_ZONED,
1613−#endif /* CONFIG_BLK_DEV_ZONED */
1690+ VIRTIO_BLK_F_SECURE_ERASE, VIRTIO_BLK_F_ZONED,
16141691 };
16151692
16161693 static struct virtio_driver virtio_blk = {
drivers/vdpa/mlx5/net/mlx5_vnet.c+6−2
@@ -2467,10 +2467,11 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev) · 2466 unmodified lines
24672467 err = 0;
24682468 goto out;
24692469 }
2470+ mlx5_vdpa_add_debugfs(ndev);
24702471 err = setup_virtqueues(mvdev);
24712472 if (err) {
24722473 mlx5_vdpa_warn(mvdev, "setup_virtqueues\n");
2473− goto out;
2474+ goto err_setup;
24742475 }
24752476
24762477 err = create_rqt(ndev);
@@ -2500,6 +2501,8 @@ err_tir: · 23 unmodified lines
25002501 destroy_rqt(ndev);
25012502 err_rqt:
25022503 teardown_virtqueues(ndev);
2504+err_setup:
2505+ mlx5_vdpa_remove_debugfs(ndev->debugfs);
25032506 out:
25042507 return err;
25052508 }
@@ -2513,6 +2516,8 @@ static void teardown_driver(struct mlx5_vdpa_net *ndev) · 7 unmodified lines
25132516 if (!ndev->setup)
25142517 return;
25152518
2519+ mlx5_vdpa_remove_debugfs(ndev->debugfs);
2520+ ndev->debugfs = NULL;
25162521 teardown_steering(ndev);
25172522 destroy_tir(ndev);
25182523 destroy_rqt(ndev);
@@ -3261,7 +3266,6 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, · 742 unmodified lines
32613266 if (err)
32623267 goto err_reg;
32633268
3264− mlx5_vdpa_add_debugfs(ndev);
32653269 mgtdev->ndev = ndev;
32663270 return 0;
32673271
drivers/vdpa/vdpa_sim/vdpa_sim_net.c+9−4
@@ -466,16 +466,21 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, · 465 unmodified lines
466466
467467 vdpasim_net_setup_config(simdev, config);
468468
469− ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM);
470− if (ret)
471− goto reg_err;
472−
473469 net = sim_to_net(simdev);
474470
475471 u64_stats_init(&net->tx_stats.syncp);
476472 u64_stats_init(&net->rx_stats.syncp);
477473 u64_stats_init(&net->cq_stats.syncp);
478474
475+ /*
476+ * Initialization must be completed before this call, since it can
477+ * connect the device to the vDPA bus, so requests can arrive after
478+ * this call.
479+ */
480+ ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM);
481+ if (ret)
482+ goto reg_err;
483+
479484 return 0;
480485
481486 reg_err:
drivers/vhost/scsi.c+7−32
@@ -125,7 +125,6 @@ struct vhost_scsi_tpg { · 124 unmodified lines
125125 struct se_portal_group se_tpg;
126126 /* Pointer back to vhost_scsi, protected by tv_tpg_mutex */
127127 struct vhost_scsi *vhost_scsi;
128− struct list_head tmf_queue;
129128 };
130129
131130 struct vhost_scsi_tport {
@@ -206,10 +205,8 @@ struct vhost_scsi { · 74 unmodified lines
206205
207206 struct vhost_scsi_tmf {
208207 struct vhost_work vwork;
209− struct vhost_scsi_tpg *tpg;
210208 struct vhost_scsi *vhost;
211209 struct vhost_scsi_virtqueue *svq;
212− struct list_head queue_entry;
213210
214211 struct se_cmd se_cmd;
215212 u8 scsi_resp;
@@ -352,12 +349,9 @@ static void vhost_scsi_release_cmd_res(struct se_cmd *se_cmd) · 136 unmodified lines
352349
353350 static void vhost_scsi_release_tmf_res(struct vhost_scsi_tmf *tmf)
354351 {
355− struct vhost_scsi_tpg *tpg = tmf->tpg;
356352 struct vhost_scsi_inflight *inflight = tmf->inflight;
357353
358− mutex_lock(&tpg->tv_tpg_mutex);
359− list_add_tail(&tpg->tmf_queue, &tmf->queue_entry);
360− mutex_unlock(&tpg->tv_tpg_mutex);
354+ kfree(tmf);
361355 vhost_scsi_put_inflight(inflight);
362356 }
363357
@@ -1194,19 +1188,11 @@ vhost_scsi_handle_tmf(struct vhost_scsi *vs, struct vhost_scsi_tpg *tpg, · 830 unmodified lines
11941188 goto send_reject;
11951189 }
11961190
1197− mutex_lock(&tpg->tv_tpg_mutex);
1198− if (list_empty(&tpg->tmf_queue)) {
1199− pr_err("Missing reserve TMF. Could not handle LUN RESET.\n");
1200− mutex_unlock(&tpg->tv_tpg_mutex);
1191+ tmf = kzalloc(sizeof(*tmf), GFP_KERNEL);
1192+ if (!tmf)
12011193 goto send_reject;
1202− }
1203−
1204− tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf,
1205− queue_entry);
1206− list_del_init(&tmf->queue_entry);
1207− mutex_unlock(&tpg->tv_tpg_mutex);
12081194
1209− tmf->tpg = tpg;
1195+ vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work);
12101196 tmf->vhost = vs;
12111197 tmf->svq = svq;
12121198 tmf->resp_iov = vq->iov[vc->out];
@@ -1658,7 +1644,10 @@ undepend: · 445 unmodified lines
16581644 for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
16591645 tpg = vs_tpg[i];
16601646 if (tpg) {
1647+ mutex_lock(&tpg->tv_tpg_mutex);
1648+ tpg->vhost_scsi = NULL;
16611649 tpg->tv_tpg_vhost_count--;
1650+ mutex_unlock(&tpg->tv_tpg_mutex);
16621651 target_undepend_item(&tpg->se_tpg.tpg_group.cg_item);
16631652 }
16641653 }
@@ -2032,19 +2021,11 @@ static int vhost_scsi_port_link(struct se_portal_group *se_tpg, · 367 unmodified lines
20322021 {
20332022 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
20342023 struct vhost_scsi_tpg, se_tpg);
2035− struct vhost_scsi_tmf *tmf;
2036−
2037− tmf = kzalloc(sizeof(*tmf), GFP_KERNEL);
2038− if (!tmf)
2039− return -ENOMEM;
2040− INIT_LIST_HEAD(&tmf->queue_entry);
2041− vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work);
20422024
20432025 mutex_lock(&vhost_scsi_mutex);
20442026
20452027 mutex_lock(&tpg->tv_tpg_mutex);
20462028 tpg->tv_tpg_port_count++;
2047− list_add_tail(&tmf->queue_entry, &tpg->tmf_queue);
20482029 mutex_unlock(&tpg->tv_tpg_mutex);
20492030
20502031 vhost_scsi_hotplug(tpg, lun);
@@ -2059,16 +2040,11 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg, · 8 unmodified lines
20592040 {
20602041 struct vhost_scsi_tpg *tpg = container_of(se_tpg,
20612042 struct vhost_scsi_tpg, se_tpg);
2062− struct vhost_scsi_tmf *tmf;
20632043
20642044 mutex_lock(&vhost_scsi_mutex);
20652045
20662046 mutex_lock(&tpg->tv_tpg_mutex);
20672047 tpg->tv_tpg_port_count--;
2068− tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf,
2069− queue_entry);
2070− list_del(&tmf->queue_entry);
2071− kfree(tmf);
20722048 mutex_unlock(&tpg->tv_tpg_mutex);
20732049
20742050 vhost_scsi_hotunplug(tpg, lun);
@@ -2329,7 +2305,6 @@ vhost_scsi_make_tpg(struct se_wwn *wwn, const char *name) · 254 unmodified lines
23292305 }
23302306 mutex_init(&tpg->tv_tpg_mutex);
23312307 INIT_LIST_HEAD(&tpg->tv_tpg_list);
2332− INIT_LIST_HEAD(&tpg->tmf_queue);
23332308 tpg->tport = tport;
23342309 tpg->tport_tpgt = tpgt;
23352310
include/uapi/linux/virtio_blk.h+9−9
@@ -140,11 +140,11 @@ struct virtio_blk_config { · 139 unmodified lines
140140
141141 /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
142142 struct virtio_blk_zoned_characteristics {
143− __le32 zone_sectors;
144− __le32 max_open_zones;
145− __le32 max_active_zones;
146− __le32 max_append_sectors;
147− __le32 write_granularity;
143+ __virtio32 zone_sectors;
144+ __virtio32 max_open_zones;
145+ __virtio32 max_active_zones;
146+ __virtio32 max_append_sectors;
147+ __virtio32 write_granularity;
148148 __u8 model;
149149 __u8 unused2[3];
150150 } zoned;
@@ -241,11 +241,11 @@ struct virtio_blk_outhdr { · 90 unmodified lines
241241 */
242242 struct virtio_blk_zone_descriptor {
243243 /* Zone capacity */
244− __le64 z_cap;
244+ __virtio64 z_cap;
245245 /* The starting sector of the zone */
246− __le64 z_start;
246+ __virtio64 z_start;
247247 /* Zone write pointer position in sectors */
248− __le64 z_wp;
248+ __virtio64 z_wp;
249249 /* Zone type */
250250 __u8 z_type;
251251 /* Zone state */
@@ -254,7 +254,7 @@ struct virtio_blk_zone_descriptor { · 2 unmodified lines
254254 };
255255
256256 struct virtio_blk_zone_report {
257− __le64 nr_zones;
257+ __virtio64 nr_zones;
258258 __u8 reserved[56];
259259 struct virtio_blk_zone_descriptor zones[];
260260 };
tools/virtio/virtio-trace/README+1−1
@@ -61,7 +61,7 @@ and · 60 unmodified lines
6161 id=channel0,name=agent-ctl-path\
6262 ##data path##
6363 -chardev pipe,id=charchannel1,path=/tmp/virtio-trace/trace-path-cpu0\
64− -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel0,\
64+ -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
6565 id=channel1,name=trace-path-cpu0\
6666 ...
6767