The attribute came from the FreeBSD structure this was copied from,
which ends in a flexible array member for the ring data and is
asserted to be page sized. DPDK computes the data offset from the
page size instead and never declared that member, so nothing is
left that packing affects: all remaining members are naturally
aligned and the layout is identical without it.

Byte alignment does prevent atomic access to the ring indexes,
which clang rejects with -Watomic-alignment. The write index store
in vmbus_txbr_write() no longer needs a cast through uintptr_t to
launder the alignment, so drop it and the comment explaining it.

This is not a fix on its own, so it carries no Fixes: tag, but the
two ordering fixes that follow do not build with clang without it.

Cc: [email protected]

Signed-off-by: Stephen Hemminger <[email protected]>
Reviewed-by: Wei Hu <[email protected]>
---
 drivers/bus/vmbus/rte_vmbus_reg.h | 4 ++--
 drivers/bus/vmbus/vmbus_bufring.c | 7 ++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/vmbus/rte_vmbus_reg.h 
b/drivers/bus/vmbus/rte_vmbus_reg.h
index 6370a07f95..210328c877 100644
--- a/drivers/bus/vmbus/rte_vmbus_reg.h
+++ b/drivers/bus/vmbus/rte_vmbus_reg.h
@@ -69,7 +69,7 @@ struct __rte_packed_begin vmbus_mon_page {
  * Buffer ring
  */
 
-struct __rte_packed_begin vmbus_bufring {
+struct vmbus_bufring {
        volatile uint32_t windex;
        volatile uint32_t rindex;
 
@@ -111,7 +111,7 @@ struct __rte_packed_begin vmbus_bufring {
         * page aligned and starts at rte_mem_page_size() from the beginning
         * of this structure
         */
-} __rte_packed_end;
+};
 
 /*
  * Channel packets
diff --git a/drivers/bus/vmbus/vmbus_bufring.c 
b/drivers/bus/vmbus/vmbus_bufring.c
index dcd66390a3..b49725da3e 100644
--- a/drivers/bus/vmbus/vmbus_bufring.c
+++ b/drivers/bus/vmbus/vmbus_bufring.c
@@ -160,11 +160,8 @@ vmbus_txbr_write(struct vmbus_br *tbr, const struct iovec 
iov[], int iovlen,
        /* Wait for previous producer to publish their windex update */
        rte_wait_until_equal_32(&vbr->windex, old_windex, 
rte_memory_order_acquire);
 
-       /* Publish our windex update; prior data writes ordered via release.
-        * windex is 4-byte aligned in practice (struct is page-aligned, windex
-        * at offset 0); cast launders the packed-struct alignment-1 attribute.
-        */
-       rte_atomic_store_explicit((volatile __rte_atomic uint32_t 
*)(uintptr_t)&vbr->windex,
+       /* Publish our windex update; prior data writes ordered via release. */
+       rte_atomic_store_explicit((volatile uint32_t __rte_atomic 
*)&vbr->windex,
                                  next_windex, rte_memory_order_release);
 
        /* If host had read all data before this, then need to signal */
-- 
2.53.0

Reply via email to