Skip to content

Commit ed88863

Browse files
emuslnmstsirkin
authored andcommitted
pds_vdpa: clean and reset vqs entries
Make sure that we initialize the vqs[] entries the same way both for initial setup and after a vq reset. Fixes: 151cc83 ("pds_vdpa: add support for vdpa and vdpamgmt interfaces") Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Message-Id: <20230711042437.69381-4-shannon.nelson@amd.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
1 parent abdf31b commit ed88863

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/vdpa/pds/vdpa_dev.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,17 @@ static void pds_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)
428428
}
429429
}
430430

431+
static void pds_vdpa_init_vqs_entry(struct pds_vdpa_device *pdsv, int qid,
432+
void __iomem *notify)
433+
{
434+
memset(&pdsv->vqs[qid], 0, sizeof(pdsv->vqs[0]));
435+
pdsv->vqs[qid].qid = qid;
436+
pdsv->vqs[qid].pdsv = pdsv;
437+
pdsv->vqs[qid].ready = false;
438+
pdsv->vqs[qid].irq = VIRTIO_MSI_NO_VECTOR;
439+
pdsv->vqs[qid].notify = notify;
440+
}
441+
431442
static int pds_vdpa_reset(struct vdpa_device *vdpa_dev)
432443
{
433444
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
@@ -450,8 +461,7 @@ static int pds_vdpa_reset(struct vdpa_device *vdpa_dev)
450461
dev_err(dev, "%s: reset_vq failed qid %d: %pe\n",
451462
__func__, i, ERR_PTR(err));
452463
pds_vdpa_release_irq(pdsv, i);
453-
memset(&pdsv->vqs[i], 0, sizeof(pdsv->vqs[0]));
454-
pdsv->vqs[i].ready = false;
464+
pds_vdpa_init_vqs_entry(pdsv, i, pdsv->vqs[i].notify);
455465
}
456466
}
457467

@@ -640,11 +650,11 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
640650
pds_vdpa_cmd_set_mac(pdsv, pdsv->mac);
641651

642652
for (i = 0; i < pdsv->num_vqs; i++) {
643-
pdsv->vqs[i].qid = i;
644-
pdsv->vqs[i].pdsv = pdsv;
645-
pdsv->vqs[i].irq = VIRTIO_MSI_NO_VECTOR;
646-
pdsv->vqs[i].notify = vp_modern_map_vq_notify(&pdsv->vdpa_aux->vd_mdev,
647-
i, &pdsv->vqs[i].notify_pa);
653+
void __iomem *notify;
654+
655+
notify = vp_modern_map_vq_notify(&pdsv->vdpa_aux->vd_mdev,
656+
i, &pdsv->vqs[i].notify_pa);
657+
pds_vdpa_init_vqs_entry(pdsv, i, notify);
648658
}
649659

650660
pdsv->vdpa_dev.mdev = &vdpa_aux->vdpa_mdev;

0 commit comments

Comments
 (0)