virtio: support VIRTIO_F_ORDER_PLATFORM
PATCH 1/1 virtio: support VIRTIO_F_ORDER_PLATFORM
This patch introduces the support for VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.
--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)
drivers/virtio/virtio_ring.c +8 -0
@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;
@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;
@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);
include/uapi/linux/virtio_config.h +6 -0
@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */
Signature · 6 lines
2.17.1 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 50 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +0
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34
include/uapi/linux/virtio_config.h line 89
Quoted 10 lines
include/uapi/linux/virtio_config.h +6
-0+/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */
I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
See ia64/include/asm/barrier.h:
* Note: "mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb() ia64_mf()
#define rmb() mb()
#define wmb() mb()
#define dma_rmb() mb()
=>efine dma_wmb() mb()
Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 50 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +0
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34
include/uapi/linux/virtio_config.h line 89
Quoted 10 lines
include/uapi/linux/virtio_config.h +6
-0+/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */
I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
See ia64/include/asm/barrier.h:
* Note: "mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb() ia64_mf()
#define rmb() mb()
#define wmb() mb()
#define dma_rmb() mb()
=>efine dma_wmb() mb()
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Michael S. Tsirkin
maintainerQuoted 54 lines · Jason Wang
Quoted 52 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +5
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36
Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 4 lines
include/uapi/linux/virtio_config.h +1
-0+/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
IIUC we don't need an mmio barrier because we are using a serializing API: Documentation/memory-barriers.txt says:
Note that, when using writel(), a prior
wmb() is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.
Quoted 12 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64. Sorry. Are any less esoteric platforms affected?
Signature · 5 lines
MST _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 54 lines · Jason Wang
Quoted 52 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +5
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36
Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 4 lines
include/uapi/linux/virtio_config.h +1
-0+/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
IIUC we don't need an mmio barrier because we are using a serializing API: Documentation/memory-barriers.txt says:
Note that, when using writel(), a prior
wmb() is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.
Quoted 12 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64. Sorry. Are any less esoteric platforms affected?
Signature · 5 lines
MST --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 61 lines · Michael S. Tsirkin
Quoted 52 lines · Jason Wang
Quoted 51 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +4
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 5 lines
include/uapi/linux/virtio_config.h +2
-0+#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
Quoted 6 lines
IIUC we don't need an mmio barrier because we are using a serializing API:
Documentation/memory-barriers.txtsays:Note that, when using
writel(), a prior
wmb()is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.
Ah, I get this.
Quoted 14 lines
Quoted 14 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()
Quoted 5 lines
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64.
Neither did me.
Quoted 3 lines
Sorry. Are any less esoteric platforms
affected?
E.g ppc64?
define dma_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memo\
ry")
/*
* Enforce synchronisation of stores vs. spin_unlock
* (this does it explicitly, though our implementation of spin_unlock
* does it implicitely too)
*/
static inline void mmiowb(void)
{
unsigned long tmp;
__asm__ __volatile__("sync; li %0,0; stb %0,%1(13)" : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync)) : "memory");
}
dma_wmb() is lwsync which is more lightweight than sync I guess?
Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 61 lines · Michael S. Tsirkin
Quoted 52 lines · Jason Wang
Quoted 51 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +4
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 5 lines
include/uapi/linux/virtio_config.h +2
-0+#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
Quoted 6 lines
IIUC we don't need an mmio barrier because we are using a serializing API:
Documentation/memory-barriers.txtsays:Note that, when using
writel(), a prior
wmb()is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.
Ah, I get this.
Quoted 14 lines
Quoted 14 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()
Quoted 5 lines
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64.
Neither did me.
Quoted 3 lines
Sorry. Are any less esoteric platforms
affected?
E.g ppc64?
define dma_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memo\
ry")
/*
* Enforce synchronisation of stores vs. spin_unlock
* (this does it explicitly, though our implementation of spin_unlock
* does it implicitely too)
*/
static inline void mmiowb(void)
{
unsigned long tmp;
__asm__ __volatile__("sync; li %0,0; stb %0,%1(13)" : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync)) : "memory");
}
dma_wmb() is lwsync which is more lightweight than sync I guess?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Michael S. Tsirkin
maintainerQuoted 95 lines · Jason Wang
Quoted 61 lines · Michael S. Tsirkin
Quoted 52 lines · Jason Wang
Quoted 51 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +4
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 5 lines
include/uapi/linux/virtio_config.h +2
-0+#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
Quoted 6 lines
IIUC we don't need an mmio barrier because we are using a serializing API:
Documentation/memory-barriers.txtsays:Note that, when using
writel(), a prior
wmb()is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.Ah, I get this.
Quoted 14 lines
Quoted 14 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()Quoted 5 lines
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64.
Quoted 8 lines
Neither did me.
Quoted 3 lines
Sorry. Are any less esoteric platforms
affected?E.g ppc64?
So
void iowrite32(u32 val, void __iomem *addr)
{
writel(val, addr);
}and that eventually gets to this one:
#define DEF_MMIO_OUT_D(name, size, insn) \
static inline void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
: "=m" (*addr) : "r" (val) : "memory"); \
IO_SET_SYNC_FLAG(); \}
and
#ifdef CONFIG_PPC64
#define IO_SET_SYNC_FLAG() do { local_paca->io_sync = 1; } while(0)
#else
#define IO_SET_SYNC_FLAG()
#endif
Quoted 7 lines
define dma_wmb()
__asm____volatile__(stringify_in_c(SMPWMB): :
:"memo\
ry")/*
* Enforce synchronisation of stores vs.spin_unlock
* (this does it explicitly, though our implementation ofspin_unlock
I don't know which spin_unlock does it refer to here.
Quoted 10 lines
* does it implicitely too)
*/
static inline void mmiowb(void)
{
unsigned long tmp;
__asm____volatile__("sync; li %0,0; stb %0,%1(13)" : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync)) : "memory");
}
So sync+set io_sync here and sync+io_sync above.
Quoted 4 lines
dma_wmb()is lwsync which is more lightweight than sync I guess?Thanks
Sounds about right.
Signature · 5 lines
MST _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 95 lines · Jason Wang
Quoted 61 lines · Michael S. Tsirkin
Quoted 52 lines · Jason Wang
Quoted 51 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +4
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ Quoted 8 lines
include/uapi/linux/virtio_config.h line 89
Quoted 5 lines
include/uapi/linux/virtio_config.h +2
-0+#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ I wonder whether or not this is sufficient. Is dma barrier implies a mmio barrier? Looks not.
Quoted 6 lines
IIUC we don't need an mmio barrier because we are using a serializing API:
Documentation/memory-barriers.txtsays:Note that, when using
writel(), a prior
wmb()is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region.Ah, I get this.
Quoted 14 lines
Quoted 14 lines
See
ia64/include/asm/barrier.h:* Note: "
mb()" and its variants cannot be used as a fence to order
* accesses to memory mapped I/O registers. For that, mf.a needs to
* be used. However, we don't want to always use mf.a because (a)
* it's (presumably) much slower than mf and (b) mf.a is supported for
* sequential memory pages only.
*/
#define mb()ia64_mf()
#define rmb()mb()
#define wmb()mb()Quoted 5 lines
Quoted 4 lines
#define dma_rmb()
mb()
=>efine dma_wmb()mb()Thanks
Frankly no idea about ia64.
Quoted 8 lines
Neither did me.
Quoted 3 lines
Sorry. Are any less esoteric platforms
affected?E.g ppc64?
So
void iowrite32(u32 val, void __iomem *addr)
{
writel(val, addr);
}and that eventually gets to this one:
#define DEF_MMIO_OUT_D(name, size, insn) \
static inline void name(volatile u##size __iomem *addr, u##size val) \
{ \
__asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
: "=m" (*addr) : "r" (val) : "memory"); \
IO_SET_SYNC_FLAG(); \}
and
#ifdef CONFIG_PPC64
#define IO_SET_SYNC_FLAG() do { local_paca->io_sync = 1; } while(0)
#else
#define IO_SET_SYNC_FLAG()
#endif
Quoted 7 lines
define dma_wmb()
__asm____volatile__(stringify_in_c(SMPWMB): :
:"memo\
ry")/*
* Enforce synchronisation of stores vs.spin_unlock
* (this does it explicitly, though our implementation ofspin_unlock
I don't know which spin_unlock does it refer to here.
Quoted 10 lines
* does it implicitely too)
*/
static inline void mmiowb(void)
{
unsigned long tmp;
__asm____volatile__("sync; li %0,0; stb %0,%1(13)" : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync)) : "memory");
}
So sync+set io_sync here and sync+io_sync above.
Quoted 4 lines
dma_wmb()is lwsync which is more lightweight than sync I guess?Thanks
Sounds about right.
Signature · 1 line
MST
Michael S. Tsirkin
maintainerQuoted 5 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>
Could you pls add a bit more explanation in the commit log? E.g. which configurations are broken without this patch? How severe is the problem?
I'm trying to decide whether this belongs in 5.0 or 5.1.
Quoted 57 lines
--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +6
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ Signature · 1 line
2.17.1
Michael S. Tsirkin
maintainerQuoted 5 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>
Could you pls add a bit more explanation in the commit log? E.g. which configurations are broken without this patch? How severe is the problem?
I'm trying to decide whether this belongs in 5.0 or 5.1.
Quoted 57 lines
--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +6
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ Signature · 1 line
2.17.1
Quoted 10 lines · Michael S. Tsirkin
Quoted 5 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>Could you pls add a bit more explanation in the commit log? E.g. which configurations are broken without this patch? How severe is the problem?
Sure. Will do that.
Thanks
Quoted 60 lines
I'm trying to decide whether this belongs in 5.0 or 5.1.
Quoted 57 lines
--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +6
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ Signature · 1 line
2.17.1
Quoted 10 lines · Michael S. Tsirkin
Quoted 5 lines · Tiwei Bie
This patch introduces the support for
VIRTIO_F_ORDER_PLATFORM. When this feature is negotiated, driver will use the barriers suitable for hardware devices.Signed-off-by Tiwei Bie <[email protected]>Could you pls add a bit more explanation in the commit log? E.g. which configurations are broken without this patch? How severe is the problem?
Sure. Will do that.
Thanks
Quoted 60 lines
I'm trying to decide whether this belongs in 5.0 or 5.1.
Quoted 57 lines
--- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_config.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/virtio/virtio_ring.c +8
-0@@ -1609,6 +1609,9 @@ static struct virtqueue *vring_create_virtqueue_packed( !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->packed.ring_dma_addr = ring_dma_addr; vq->packed.driver_event_dma_addr = driver_event_dma_addr; vq->packed.device_event_dma_addr = device_event_dma_addr;@@ -2079,6 +2082,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index, !context; vq->event =virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX ); +if (virtio_has_feature (vdev,VIRTIO_F_ORDER_PLATFORM )) + vq->weak_barriers = false; + vq->split.queue_dma_addr =0 ; vq->split.queue_size_in_bytes =0 ;@@ -2213,6 +2219,8 @@ void vring_transport_features(struct virtio_device *vdev)break ;case VIRTIO_F_RING_PACKED :break ; +case VIRTIO_F_ORDER_PLATFORM : +break ;default :/* We don't understand this bit. */ __virtio_clear_bit (vdev, i);include/uapi/linux/virtio_config.h +6
-0@@ -78,6 +78,12 @@/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34 +/* +* This feature indicates that memory accesses by the driver and the +* device are ordered in a way described by the platform. +*/ +#define VIRTIO_F_ORDER_PLATFORM 36 +/* * Does the device support Single Root I/O Virtualization? */ Signature · 1 line
2.17.1