The branch stable/13 has been updated by khng:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6fd5a4a6f3ac3cb7bb3e6d55359a5ba087b76cd9

commit 6fd5a4a6f3ac3cb7bb3e6d55359a5ba087b76cd9
Author:     Ka Ho Ng <[email protected]>
AuthorDate: 2021-05-05 15:16:29 +0000
Commit:     Ka Ho Ng <[email protected]>
CommitDate: 2021-06-28 15:16:39 +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.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    grehan
    Approved by:    lwhsu (mentor)
    Differential Revision:  https://reviews.freebsd.org/D30049
    
    (cherry picked from commit 4e1e1d667fc84460c131dfe617b39072e87473ab)
---
 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)
 {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to