Date: Wed, 5 May 2021 15:22:30 GMT From: Ka Ho Ng <khng@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 4e1e1d667fc8 - main - virtio_blk: Fix issuing T_GET_ID before DRIVER_OK status Message-ID: <202105051522.145FMUgw090700@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=4e1e1d667fc84460c131dfe617b39072e87473ab commit 4e1e1d667fc84460c131dfe617b39072e87473ab Author: Ka Ho Ng <khng@FreeBSD.org> AuthorDate: 2021-05-05 15:16:29 +0000 Commit: Ka Ho Ng <khng@FreeBSD.org> CommitDate: 2021-05-05 15:22:16 +0000 virtio_blk: Fix issuing T_GET_ID before DRIVER_OK status DRIVER_OK status is set after device_attach() succeeds. For now postpone disk_create to attach_completed() method. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Reviewed by: grehan Approved by: lwhsu (mentor) Differential Revision: https://reviews.freebsd.org/D30049 --- sys/dev/virtio/block/virtio_blk.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 50642fb0b009..8a5558f4571d 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -126,6 +126,7 @@ static int vtblk_detach(device_t); static int vtblk_suspend(device_t); static int vtblk_resume(device_t); static int vtblk_shutdown(device_t); +static int vtblk_attach_completed(device_t); static int vtblk_config_change(device_t); static int vtblk_open(struct disk *); @@ -255,6 +256,7 @@ static device_method_t vtblk_methods[] = { DEVMETHOD(device_shutdown, vtblk_shutdown), /* VirtIO methods. */ + DEVMETHOD(virtio_attach_completed, vtblk_attach_completed), DEVMETHOD(virtio_config_change, vtblk_config_change), DEVMETHOD_END @@ -378,8 +380,6 @@ vtblk_attach(device_t dev) goto fail; } - vtblk_create_disk(sc); - virtqueue_enable_intr(sc->vtblk_vq); fail: @@ -461,6 +461,22 @@ vtblk_shutdown(device_t dev) return (0); } +static int +vtblk_attach_completed(device_t dev) +{ + struct vtblk_softc *sc; + + sc = device_get_softc(dev); + + /* + * Create disk after attach as VIRTIO_BLK_T_GET_ID can only be + * processed after the device acknowledged + * VIRTIO_CONFIG_STATUS_DRIVER_OK. + */ + vtblk_create_disk(sc); + return (0); +} + static int vtblk_config_change(device_t dev) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105051522.145FMUgw090700>