Commit dfc19154 authored by Linus Torvalds's avatar Linus Torvalds

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
parents c118b59e 9da667e5
This diff is collapsed.
...@@ -2467,10 +2467,11 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev) ...@@ -2467,10 +2467,11 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev)
err = 0; err = 0;
goto out; goto out;
} }
mlx5_vdpa_add_debugfs(ndev);
err = setup_virtqueues(mvdev); err = setup_virtqueues(mvdev);
if (err) { if (err) {
mlx5_vdpa_warn(mvdev, "setup_virtqueues\n"); mlx5_vdpa_warn(mvdev, "setup_virtqueues\n");
goto out; goto err_setup;
} }
err = create_rqt(ndev); err = create_rqt(ndev);
...@@ -2500,6 +2501,8 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev) ...@@ -2500,6 +2501,8 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev)
destroy_rqt(ndev); destroy_rqt(ndev);
err_rqt: err_rqt:
teardown_virtqueues(ndev); teardown_virtqueues(ndev);
err_setup:
mlx5_vdpa_remove_debugfs(ndev->debugfs);
out: out:
return err; return err;
} }
...@@ -2513,6 +2516,8 @@ static void teardown_driver(struct mlx5_vdpa_net *ndev) ...@@ -2513,6 +2516,8 @@ static void teardown_driver(struct mlx5_vdpa_net *ndev)
if (!ndev->setup) if (!ndev->setup)
return; return;
mlx5_vdpa_remove_debugfs(ndev->debugfs);
ndev->debugfs = NULL;
teardown_steering(ndev); teardown_steering(ndev);
destroy_tir(ndev); destroy_tir(ndev);
destroy_rqt(ndev); destroy_rqt(ndev);
...@@ -3261,7 +3266,6 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, ...@@ -3261,7 +3266,6 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
if (err) if (err)
goto err_reg; goto err_reg;
mlx5_vdpa_add_debugfs(ndev);
mgtdev->ndev = ndev; mgtdev->ndev = ndev;
return 0; return 0;
......
...@@ -466,16 +466,21 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, ...@@ -466,16 +466,21 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
vdpasim_net_setup_config(simdev, config); vdpasim_net_setup_config(simdev, config);
ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM);
if (ret)
goto reg_err;
net = sim_to_net(simdev); net = sim_to_net(simdev);
u64_stats_init(&net->tx_stats.syncp); u64_stats_init(&net->tx_stats.syncp);
u64_stats_init(&net->rx_stats.syncp); u64_stats_init(&net->rx_stats.syncp);
u64_stats_init(&net->cq_stats.syncp); u64_stats_init(&net->cq_stats.syncp);
/*
* Initialization must be completed before this call, since it can
* connect the device to the vDPA bus, so requests can arrive after
* this call.
*/
ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM);
if (ret)
goto reg_err;
return 0; return 0;
reg_err: reg_err:
......
...@@ -125,7 +125,6 @@ struct vhost_scsi_tpg { ...@@ -125,7 +125,6 @@ struct vhost_scsi_tpg {
struct se_portal_group se_tpg; struct se_portal_group se_tpg;
/* Pointer back to vhost_scsi, protected by tv_tpg_mutex */ /* Pointer back to vhost_scsi, protected by tv_tpg_mutex */
struct vhost_scsi *vhost_scsi; struct vhost_scsi *vhost_scsi;
struct list_head tmf_queue;
}; };
struct vhost_scsi_tport { struct vhost_scsi_tport {
...@@ -206,10 +205,8 @@ struct vhost_scsi { ...@@ -206,10 +205,8 @@ struct vhost_scsi {
struct vhost_scsi_tmf { struct vhost_scsi_tmf {
struct vhost_work vwork; struct vhost_work vwork;
struct vhost_scsi_tpg *tpg;
struct vhost_scsi *vhost; struct vhost_scsi *vhost;
struct vhost_scsi_virtqueue *svq; struct vhost_scsi_virtqueue *svq;
struct list_head queue_entry;
struct se_cmd se_cmd; struct se_cmd se_cmd;
u8 scsi_resp; u8 scsi_resp;
...@@ -352,12 +349,9 @@ static void vhost_scsi_release_cmd_res(struct se_cmd *se_cmd) ...@@ -352,12 +349,9 @@ static void vhost_scsi_release_cmd_res(struct se_cmd *se_cmd)
static void vhost_scsi_release_tmf_res(struct vhost_scsi_tmf *tmf) static void vhost_scsi_release_tmf_res(struct vhost_scsi_tmf *tmf)
{ {
struct vhost_scsi_tpg *tpg = tmf->tpg;
struct vhost_scsi_inflight *inflight = tmf->inflight; struct vhost_scsi_inflight *inflight = tmf->inflight;
mutex_lock(&tpg->tv_tpg_mutex); kfree(tmf);
list_add_tail(&tpg->tmf_queue, &tmf->queue_entry);
mutex_unlock(&tpg->tv_tpg_mutex);
vhost_scsi_put_inflight(inflight); vhost_scsi_put_inflight(inflight);
} }
...@@ -1194,19 +1188,11 @@ vhost_scsi_handle_tmf(struct vhost_scsi *vs, struct vhost_scsi_tpg *tpg, ...@@ -1194,19 +1188,11 @@ vhost_scsi_handle_tmf(struct vhost_scsi *vs, struct vhost_scsi_tpg *tpg,
goto send_reject; goto send_reject;
} }
mutex_lock(&tpg->tv_tpg_mutex); tmf = kzalloc(sizeof(*tmf), GFP_KERNEL);
if (list_empty(&tpg->tmf_queue)) { if (!tmf)
pr_err("Missing reserve TMF. Could not handle LUN RESET.\n");
mutex_unlock(&tpg->tv_tpg_mutex);
goto send_reject; goto send_reject;
}
tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf,
queue_entry);
list_del_init(&tmf->queue_entry);
mutex_unlock(&tpg->tv_tpg_mutex);
tmf->tpg = tpg; vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work);
tmf->vhost = vs; tmf->vhost = vs;
tmf->svq = svq; tmf->svq = svq;
tmf->resp_iov = vq->iov[vc->out]; tmf->resp_iov = vq->iov[vc->out];
...@@ -1658,7 +1644,10 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, ...@@ -1658,7 +1644,10 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
tpg = vs_tpg[i]; tpg = vs_tpg[i];
if (tpg) { if (tpg) {
mutex_lock(&tpg->tv_tpg_mutex);
tpg->vhost_scsi = NULL;
tpg->tv_tpg_vhost_count--; tpg->tv_tpg_vhost_count--;
mutex_unlock(&tpg->tv_tpg_mutex);
target_undepend_item(&tpg->se_tpg.tpg_group.cg_item); target_undepend_item(&tpg->se_tpg.tpg_group.cg_item);
} }
} }
...@@ -2032,19 +2021,11 @@ static int vhost_scsi_port_link(struct se_portal_group *se_tpg, ...@@ -2032,19 +2021,11 @@ static int vhost_scsi_port_link(struct se_portal_group *se_tpg,
{ {
struct vhost_scsi_tpg *tpg = container_of(se_tpg, struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg); struct vhost_scsi_tpg, se_tpg);
struct vhost_scsi_tmf *tmf;
tmf = kzalloc(sizeof(*tmf), GFP_KERNEL);
if (!tmf)
return -ENOMEM;
INIT_LIST_HEAD(&tmf->queue_entry);
vhost_work_init(&tmf->vwork, vhost_scsi_tmf_resp_work);
mutex_lock(&vhost_scsi_mutex); mutex_lock(&vhost_scsi_mutex);
mutex_lock(&tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tpg->tv_tpg_port_count++; tpg->tv_tpg_port_count++;
list_add_tail(&tmf->queue_entry, &tpg->tmf_queue);
mutex_unlock(&tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
vhost_scsi_hotplug(tpg, lun); vhost_scsi_hotplug(tpg, lun);
...@@ -2059,16 +2040,11 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg, ...@@ -2059,16 +2040,11 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg,
{ {
struct vhost_scsi_tpg *tpg = container_of(se_tpg, struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg); struct vhost_scsi_tpg, se_tpg);
struct vhost_scsi_tmf *tmf;
mutex_lock(&vhost_scsi_mutex); mutex_lock(&vhost_scsi_mutex);
mutex_lock(&tpg->tv_tpg_mutex); mutex_lock(&tpg->tv_tpg_mutex);
tpg->tv_tpg_port_count--; tpg->tv_tpg_port_count--;
tmf = list_first_entry(&tpg->tmf_queue, struct vhost_scsi_tmf,
queue_entry);
list_del(&tmf->queue_entry);
kfree(tmf);
mutex_unlock(&tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
vhost_scsi_hotunplug(tpg, lun); vhost_scsi_hotunplug(tpg, lun);
...@@ -2329,7 +2305,6 @@ vhost_scsi_make_tpg(struct se_wwn *wwn, const char *name) ...@@ -2329,7 +2305,6 @@ vhost_scsi_make_tpg(struct se_wwn *wwn, const char *name)
} }
mutex_init(&tpg->tv_tpg_mutex); mutex_init(&tpg->tv_tpg_mutex);
INIT_LIST_HEAD(&tpg->tv_tpg_list); INIT_LIST_HEAD(&tpg->tv_tpg_list);
INIT_LIST_HEAD(&tpg->tmf_queue);
tpg->tport = tport; tpg->tport = tport;
tpg->tport_tpgt = tpgt; tpg->tport_tpgt = tpgt;
......
...@@ -140,11 +140,11 @@ struct virtio_blk_config { ...@@ -140,11 +140,11 @@ struct virtio_blk_config {
/* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */ /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
struct virtio_blk_zoned_characteristics { struct virtio_blk_zoned_characteristics {
__le32 zone_sectors; __virtio32 zone_sectors;
__le32 max_open_zones; __virtio32 max_open_zones;
__le32 max_active_zones; __virtio32 max_active_zones;
__le32 max_append_sectors; __virtio32 max_append_sectors;
__le32 write_granularity; __virtio32 write_granularity;
__u8 model; __u8 model;
__u8 unused2[3]; __u8 unused2[3];
} zoned; } zoned;
...@@ -241,11 +241,11 @@ struct virtio_blk_outhdr { ...@@ -241,11 +241,11 @@ struct virtio_blk_outhdr {
*/ */
struct virtio_blk_zone_descriptor { struct virtio_blk_zone_descriptor {
/* Zone capacity */ /* Zone capacity */
__le64 z_cap; __virtio64 z_cap;
/* The starting sector of the zone */ /* The starting sector of the zone */
__le64 z_start; __virtio64 z_start;
/* Zone write pointer position in sectors */ /* Zone write pointer position in sectors */
__le64 z_wp; __virtio64 z_wp;
/* Zone type */ /* Zone type */
__u8 z_type; __u8 z_type;
/* Zone state */ /* Zone state */
...@@ -254,7 +254,7 @@ struct virtio_blk_zone_descriptor { ...@@ -254,7 +254,7 @@ struct virtio_blk_zone_descriptor {
}; };
struct virtio_blk_zone_report { struct virtio_blk_zone_report {
__le64 nr_zones; __virtio64 nr_zones;
__u8 reserved[56]; __u8 reserved[56];
struct virtio_blk_zone_descriptor zones[]; struct virtio_blk_zone_descriptor zones[];
}; };
......
...@@ -61,7 +61,7 @@ and ...@@ -61,7 +61,7 @@ and
id=channel0,name=agent-ctl-path\ id=channel0,name=agent-ctl-path\
##data path## ##data path##
-chardev pipe,id=charchannel1,path=/tmp/virtio-trace/trace-path-cpu0\ -chardev pipe,id=charchannel1,path=/tmp/virtio-trace/trace-path-cpu0\
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel0,\ -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
id=channel1,name=trace-path-cpu0\ id=channel1,name=trace-path-cpu0\
... ...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment