Author: bryanv
Date: Mon Feb 19 19:28:24 2018
New Revision: 329601
URL: https://svnweb.freebsd.org/changeset/base/329601

Log:
  Add VirtIO bus config_generation method
  
  VirtIO buses (PCI, MMIO) can provide a generation field so a driver
  can ensure either a 64-bit or array read was stable.
  
  MFC after:    2 weeks

Modified:
  head/sys/dev/virtio/virtio.c
  head/sys/dev/virtio/virtio.h
  head/sys/dev/virtio/virtio_bus_if.m

Modified: head/sys/dev/virtio/virtio.c
==============================================================================
--- head/sys/dev/virtio/virtio.c        Mon Feb 19 19:08:25 2018        
(r329600)
+++ head/sys/dev/virtio/virtio.c        Mon Feb 19 19:28:24 2018        
(r329601)
@@ -240,6 +240,13 @@ virtio_reinit_complete(device_t dev)
        VIRTIO_BUS_REINIT_COMPLETE(device_get_parent(dev));
 }
 
+int
+virtio_config_generation(device_t dev)
+{
+
+       return (VIRTIO_BUS_CONFIG_GENERATION(device_get_parent(dev)));
+}
+
 void
 virtio_read_device_config(device_t dev, bus_size_t offset, void *dst, int len)
 {

Modified: head/sys/dev/virtio/virtio.h
==============================================================================
--- head/sys/dev/virtio/virtio.h        Mon Feb 19 19:08:25 2018        
(r329600)
+++ head/sys/dev/virtio/virtio.h        Mon Feb 19 19:28:24 2018        
(r329601)
@@ -78,6 +78,7 @@ int    virtio_alloc_virtqueues(device_t dev, int flags, 
 int     virtio_setup_intr(device_t dev, enum intr_type type);
 int     virtio_with_feature(device_t dev, uint64_t feature);
 void    virtio_stop(device_t dev);
+int     virtio_config_generation(device_t dev);
 int     virtio_reinit(device_t dev, uint64_t features);
 void    virtio_reinit_complete(device_t dev);
 

Modified: head/sys/dev/virtio/virtio_bus_if.m
==============================================================================
--- head/sys/dev/virtio/virtio_bus_if.m Mon Feb 19 19:08:25 2018        
(r329600)
+++ head/sys/dev/virtio/virtio_bus_if.m Mon Feb 19 19:28:24 2018        
(r329601)
@@ -34,6 +34,14 @@ HEADER {
 struct vq_alloc_info;
 };
 
+CODE {
+       static int
+       virtio_bus_default_config_generation(device_t dev)
+       {
+               return (0);
+       }
+};
+
 METHOD uint64_t negotiate_features {
        device_t        dev;
        uint64_t        child_features;
@@ -73,6 +81,10 @@ METHOD void notify_vq {
        device_t        dev;
        uint16_t        queue;
 };
+
+METHOD int config_generation {
+       device_t        dev;
+} DEFAULT virtio_bus_default_config_generation;
 
 METHOD void read_device_config {
        device_t        dev;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to