Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH RFC 14/13] gpio: virtio: fix DMA alignment
       [not found] <cover.1767089672.git.mst@redhat.com>
@ 2025-12-30 16:40 ` Michael S. Tsirkin
  2026-01-02 12:46   ` Bartosz Golaszewski
  2026-01-05  4:56   ` Viresh Kumar
  2025-12-30 16:40 ` [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding Michael S. Tsirkin
  1 sibling, 2 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-12-30 16:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Cong Wang, Jonathan Corbet, Olivia Mackall, Herbert Xu,
	Jason Wang, Paolo Bonzini, Stefan Hajnoczi, Eugenio Pérez,
	James E.J. Bottomley, Martin K. Petersen, Gerd Hoffmann,
	Xuan Zhuo, Marek Szyprowski, Robin Murphy, Stefano Garzarella,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Petr Tesarik, Leon Romanovsky, Jason Gunthorpe,
	linux-doc, linux-crypto, virtualization, linux-scsi, iommu, kvm,
	netdev, Enrico Weigelt, metux IT consult, Viresh Kumar,
	Linus Walleij, Bartosz Golaszewski, linux-gpio

The res and ires buffers in struct virtio_gpio_line and struct
vgpio_irq_line respectively are used for DMA_FROM_DEVICE via virtqueue_add_sgs().
However, within these structs, even though these elements are tagged
as ____cacheline_aligned, adjacent struct elements
can share DMA cachelines on platforms where ARCH_DMA_MINALIGN >
L1_CACHE_BYTES (e.g., arm64 with 128-byte DMA alignment but 64-byte
cache lines).

The existing ____cacheline_aligned annotation aligns to L1_CACHE_BYTES
which is now always sufficient for DMA alignment. For example,
with L1_CACHE_BYTES = 32 and ARCH_DMA_MINALIGN = 128
  - irq_lines[0].ires at offset 128
  - irq_lines[1].type at offset 192
both in same 128-byte DMA cacheline [128-256)

When the device writes to irq_lines[0].ires and the CPU concurrently
modifies one of irq_lines[1].type/disabled/masked/queued flags,
corruption can occur on non-cache-coherent platform.

Fix by using __dma_from_device_aligned_begin/end annotations on the
DMA buffers. Drop ____cacheline_aligned - it's not required to isolate
request and response, and keeping them would increase the memory cost.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/gpio/gpio-virtio.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index 17e040991e46..32b578b46df8 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/completion.h>
+#include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/gpio/driver.h>
 #include <linux/io.h>
@@ -24,8 +25,12 @@
 struct virtio_gpio_line {
 	struct mutex lock; /* Protects line operation */
 	struct completion completion;
-	struct virtio_gpio_request req ____cacheline_aligned;
-	struct virtio_gpio_response res ____cacheline_aligned;
+
+	__dma_from_device_aligned_begin
+	struct virtio_gpio_request req;
+	struct virtio_gpio_response res;
+
+	__dma_from_device_aligned_end
 	unsigned int rxlen;
 };
 
@@ -37,8 +42,9 @@ struct vgpio_irq_line {
 	bool update_pending;
 	bool queue_pending;
 
-	struct virtio_gpio_irq_request ireq ____cacheline_aligned;
-	struct virtio_gpio_irq_response ires ____cacheline_aligned;
+	__dma_from_device_aligned_begin
+	struct virtio_gpio_irq_request ireq;
+	struct virtio_gpio_irq_response ires;
 };
 
 struct virtio_gpio {
-- 
MST


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding
       [not found] <cover.1767089672.git.mst@redhat.com>
  2025-12-30 16:40 ` [PATCH RFC 14/13] gpio: virtio: fix DMA alignment Michael S. Tsirkin
@ 2025-12-30 16:40 ` Michael S. Tsirkin
  2026-01-02 12:47   ` Bartosz Golaszewski
  2026-01-05  4:57   ` Viresh Kumar
  1 sibling, 2 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2025-12-30 16:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: Cong Wang, Jonathan Corbet, Olivia Mackall, Herbert Xu,
	Jason Wang, Paolo Bonzini, Stefan Hajnoczi, Eugenio Pérez,
	James E.J. Bottomley, Martin K. Petersen, Gerd Hoffmann,
	Xuan Zhuo, Marek Szyprowski, Robin Murphy, Stefano Garzarella,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Petr Tesarik, Leon Romanovsky, Jason Gunthorpe,
	linux-doc, linux-crypto, virtualization, linux-scsi, iommu, kvm,
	netdev, Enrico Weigelt, metux IT consult, Viresh Kumar,
	Linus Walleij, Bartosz Golaszewski, linux-gpio

Reorder struct virtio_gpio_line fields to place the DMA buffers (req/res)
last. This eliminates the need for __dma_from_device_aligned_end padding
after the DMA buffer, since struct tail padding naturally protects it,
making the struct a bit smaller.

Size reduction estimation when ARCH_DMA_MINALIGN=128:
- request is 8 bytes
- response is 2 bytes
- removing _end saves up to 128-6=122 bytes padding to align rxlen field

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/gpio/gpio-virtio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index 32b578b46df8..8b30a94e4625 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -26,12 +26,11 @@ struct virtio_gpio_line {
 	struct mutex lock; /* Protects line operation */
 	struct completion completion;
 
+	unsigned int rxlen;
+
 	__dma_from_device_aligned_begin
 	struct virtio_gpio_request req;
 	struct virtio_gpio_response res;
-
-	__dma_from_device_aligned_end
-	unsigned int rxlen;
 };
 
 struct vgpio_irq_line {
-- 
MST


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 14/13] gpio: virtio: fix DMA alignment
  2025-12-30 16:40 ` [PATCH RFC 14/13] gpio: virtio: fix DMA alignment Michael S. Tsirkin
@ 2026-01-02 12:46   ` Bartosz Golaszewski
  2026-01-05  4:56   ` Viresh Kumar
  1 sibling, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-01-02 12:46 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Cong Wang, Jonathan Corbet, Olivia Mackall, Herbert Xu,
	Jason Wang, Paolo Bonzini, Stefan Hajnoczi, Eugenio Pérez,
	James E.J. Bottomley, Martin K. Petersen, Gerd Hoffmann,
	Xuan Zhuo, Marek Szyprowski, Robin Murphy, Stefano Garzarella,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Petr Tesarik, Leon Romanovsky, Jason Gunthorpe,
	linux-doc, linux-crypto, virtualization, linux-scsi, iommu, kvm,
	netdev, Enrico Weigelt, metux IT consult, Viresh Kumar,
	Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

On Tue, 30 Dec 2025 17:40:28 +0100, "Michael S. Tsirkin" <mst@redhat.com> said:
> The res and ires buffers in struct virtio_gpio_line and struct
> vgpio_irq_line respectively are used for DMA_FROM_DEVICE via virtqueue_add_sgs().
> However, within these structs, even though these elements are tagged
> as ____cacheline_aligned, adjacent struct elements
> can share DMA cachelines on platforms where ARCH_DMA_MINALIGN >
> L1_CACHE_BYTES (e.g., arm64 with 128-byte DMA alignment but 64-byte
> cache lines).
>
> The existing ____cacheline_aligned annotation aligns to L1_CACHE_BYTES
> which is now always sufficient for DMA alignment. For example,
> with L1_CACHE_BYTES = 32 and ARCH_DMA_MINALIGN = 128
>   - irq_lines[0].ires at offset 128
>   - irq_lines[1].type at offset 192
> both in same 128-byte DMA cacheline [128-256)
>
> When the device writes to irq_lines[0].ires and the CPU concurrently
> modifies one of irq_lines[1].type/disabled/masked/queued flags,
> corruption can occur on non-cache-coherent platform.
>
> Fix by using __dma_from_device_aligned_begin/end annotations on the
> DMA buffers. Drop ____cacheline_aligned - it's not required to isolate
> request and response, and keeping them would increase the memory cost.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---

Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding
  2025-12-30 16:40 ` [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding Michael S. Tsirkin
@ 2026-01-02 12:47   ` Bartosz Golaszewski
  2026-01-02 13:02     ` Michael S. Tsirkin
  2026-01-05  4:57   ` Viresh Kumar
  1 sibling, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-01-02 12:47 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Cong Wang, Jonathan Corbet, Olivia Mackall,
	Herbert Xu, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
	Gerd Hoffmann, Xuan Zhuo, Marek Szyprowski, Robin Murphy,
	Stefano Garzarella, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Petr Tesarik, Leon Romanovsky,
	Jason Gunthorpe, linux-doc, linux-crypto, virtualization,
	linux-scsi, iommu, kvm, netdev, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, Bartosz Golaszewski, linux-gpio

On Tue, 30 Dec 2025 17:40:33 +0100, "Michael S. Tsirkin" <mst@redhat.com> said:
> Reorder struct virtio_gpio_line fields to place the DMA buffers (req/res)
> last. This eliminates the need for __dma_from_device_aligned_end padding
> after the DMA buffer, since struct tail padding naturally protects it,
> making the struct a bit smaller.
>
> Size reduction estimation when ARCH_DMA_MINALIGN=128:
> - request is 8 bytes
> - response is 2 bytes
> - removing _end saves up to 128-6=122 bytes padding to align rxlen field
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/gpio/gpio-virtio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 32b578b46df8..8b30a94e4625 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -26,12 +26,11 @@ struct virtio_gpio_line {
>  	struct mutex lock; /* Protects line operation */
>  	struct completion completion;
>
> +	unsigned int rxlen;
> +
>  	__dma_from_device_aligned_begin
>  	struct virtio_gpio_request req;
>  	struct virtio_gpio_response res;
> -
> -	__dma_from_device_aligned_end
> -	unsigned int rxlen;
>  };
>
>  struct vgpio_irq_line {
> --
> MST
>
>

Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding
  2026-01-02 12:47   ` Bartosz Golaszewski
@ 2026-01-02 13:02     ` Michael S. Tsirkin
  2026-01-02 13:27       ` Bartosz Golaszewski
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-01-02 13:02 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: linux-kernel, Cong Wang, Jonathan Corbet, Olivia Mackall,
	Herbert Xu, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
	Gerd Hoffmann, Xuan Zhuo, Marek Szyprowski, Robin Murphy,
	Stefano Garzarella, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Petr Tesarik, Leon Romanovsky,
	Jason Gunthorpe, linux-doc, linux-crypto, virtualization,
	linux-scsi, iommu, kvm, netdev, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, linux-gpio

On Fri, Jan 02, 2026 at 12:47:04PM +0000, Bartosz Golaszewski wrote:
> On Tue, 30 Dec 2025 17:40:33 +0100, "Michael S. Tsirkin" <mst@redhat.com> said:
> > Reorder struct virtio_gpio_line fields to place the DMA buffers (req/res)
> > last. This eliminates the need for __dma_from_device_aligned_end padding
> > after the DMA buffer, since struct tail padding naturally protects it,
> > making the struct a bit smaller.
> >
> > Size reduction estimation when ARCH_DMA_MINALIGN=128:
> > - request is 8 bytes
> > - response is 2 bytes
> > - removing _end saves up to 128-6=122 bytes padding to align rxlen field
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  drivers/gpio/gpio-virtio.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> > index 32b578b46df8..8b30a94e4625 100644
> > --- a/drivers/gpio/gpio-virtio.c
> > +++ b/drivers/gpio/gpio-virtio.c
> > @@ -26,12 +26,11 @@ struct virtio_gpio_line {
> >  	struct mutex lock; /* Protects line operation */
> >  	struct completion completion;
> >
> > +	unsigned int rxlen;
> > +
> >  	__dma_from_device_aligned_begin
> >  	struct virtio_gpio_request req;
> >  	struct virtio_gpio_response res;
> > -
> > -	__dma_from_device_aligned_end
> > -	unsigned int rxlen;
> >  };
> >
> >  struct vgpio_irq_line {
> > --
> > MST
> >
> >
> 
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Thanks! There's a new API as suggested by Petr so these patches got changed,
but the same idea. Do you want me to carry your ack or you prefer to
re-review?

-- 
MST


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding
  2026-01-02 13:02     ` Michael S. Tsirkin
@ 2026-01-02 13:27       ` Bartosz Golaszewski
  0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-01-02 13:27 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Cong Wang, Jonathan Corbet, Olivia Mackall,
	Herbert Xu, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
	Gerd Hoffmann, Xuan Zhuo, Marek Szyprowski, Robin Murphy,
	Stefano Garzarella, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Petr Tesarik, Leon Romanovsky,
	Jason Gunthorpe, linux-doc, linux-crypto, virtualization,
	linux-scsi, iommu, kvm, netdev, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, linux-gpio

On Fri, Jan 2, 2026 at 2:02 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Fri, Jan 02, 2026 at 12:47:04PM +0000, Bartosz Golaszewski wrote:
> > On Tue, 30 Dec 2025 17:40:33 +0100, "Michael S. Tsirkin" <mst@redhat.com> said:
> > > Reorder struct virtio_gpio_line fields to place the DMA buffers (req/res)
> > > last. This eliminates the need for __dma_from_device_aligned_end padding
> > > after the DMA buffer, since struct tail padding naturally protects it,
> > > making the struct a bit smaller.
> > >
> > > Size reduction estimation when ARCH_DMA_MINALIGN=128:
> > > - request is 8 bytes
> > > - response is 2 bytes
> > > - removing _end saves up to 128-6=122 bytes padding to align rxlen field
> > >
> > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > ---
> > >  drivers/gpio/gpio-virtio.c | 5 ++---
> > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> > > index 32b578b46df8..8b30a94e4625 100644
> > > --- a/drivers/gpio/gpio-virtio.c
> > > +++ b/drivers/gpio/gpio-virtio.c
> > > @@ -26,12 +26,11 @@ struct virtio_gpio_line {
> > >     struct mutex lock; /* Protects line operation */
> > >     struct completion completion;
> > >
> > > +   unsigned int rxlen;
> > > +
> > >     __dma_from_device_aligned_begin
> > >     struct virtio_gpio_request req;
> > >     struct virtio_gpio_response res;
> > > -
> > > -   __dma_from_device_aligned_end
> > > -   unsigned int rxlen;
> > >  };
> > >
> > >  struct vgpio_irq_line {
> > > --
> > > MST
> > >
> > >
> >
> > Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
>
> Thanks! There's a new API as suggested by Petr so these patches got changed,
> but the same idea. Do you want me to carry your ack or you prefer to
> re-review?
>
> --
> MST
>

I'll take a second look. Can you Cc me on all the key patches - like
the ones introducing new APIs? I needed to grab it from lore this
time.

Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 14/13] gpio: virtio: fix DMA alignment
  2025-12-30 16:40 ` [PATCH RFC 14/13] gpio: virtio: fix DMA alignment Michael S. Tsirkin
  2026-01-02 12:46   ` Bartosz Golaszewski
@ 2026-01-05  4:56   ` Viresh Kumar
  1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2026-01-05  4:56 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Cong Wang, Jonathan Corbet, Olivia Mackall,
	Herbert Xu, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
	Gerd Hoffmann, Xuan Zhuo, Marek Szyprowski, Robin Murphy,
	Stefano Garzarella, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Petr Tesarik, Leon Romanovsky,
	Jason Gunthorpe, linux-doc, linux-crypto, virtualization,
	linux-scsi, iommu, kvm, netdev, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, Bartosz Golaszewski, linux-gpio

On 30-12-25, 11:40, Michael S. Tsirkin wrote:
> The res and ires buffers in struct virtio_gpio_line and struct
> vgpio_irq_line respectively are used for DMA_FROM_DEVICE via virtqueue_add_sgs().
> However, within these structs, even though these elements are tagged
> as ____cacheline_aligned, adjacent struct elements
> can share DMA cachelines on platforms where ARCH_DMA_MINALIGN >
> L1_CACHE_BYTES (e.g., arm64 with 128-byte DMA alignment but 64-byte
> cache lines).
> 
> The existing ____cacheline_aligned annotation aligns to L1_CACHE_BYTES
> which is now always sufficient for DMA alignment. For example,
> with L1_CACHE_BYTES = 32 and ARCH_DMA_MINALIGN = 128
>   - irq_lines[0].ires at offset 128
>   - irq_lines[1].type at offset 192
> both in same 128-byte DMA cacheline [128-256)
> 
> When the device writes to irq_lines[0].ires and the CPU concurrently
> modifies one of irq_lines[1].type/disabled/masked/queued flags,
> corruption can occur on non-cache-coherent platform.
> 
> Fix by using __dma_from_device_aligned_begin/end annotations on the
> DMA buffers. Drop ____cacheline_aligned - it's not required to isolate
> request and response, and keeping them would increase the memory cost.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/gpio/gpio-virtio.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding
  2025-12-30 16:40 ` [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding Michael S. Tsirkin
  2026-01-02 12:47   ` Bartosz Golaszewski
@ 2026-01-05  4:57   ` Viresh Kumar
  1 sibling, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2026-01-05  4:57 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Cong Wang, Jonathan Corbet, Olivia Mackall,
	Herbert Xu, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
	Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
	Gerd Hoffmann, Xuan Zhuo, Marek Szyprowski, Robin Murphy,
	Stefano Garzarella, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Petr Tesarik, Leon Romanovsky,
	Jason Gunthorpe, linux-doc, linux-crypto, virtualization,
	linux-scsi, iommu, kvm, netdev, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, Bartosz Golaszewski, linux-gpio

On 30-12-25, 11:40, Michael S. Tsirkin wrote:
> Reorder struct virtio_gpio_line fields to place the DMA buffers (req/res)
> last. This eliminates the need for __dma_from_device_aligned_end padding
> after the DMA buffer, since struct tail padding naturally protects it,
> making the struct a bit smaller.
> 
> Size reduction estimation when ARCH_DMA_MINALIGN=128:
> - request is 8 bytes
> - response is 2 bytes
> - removing _end saves up to 128-6=122 bytes padding to align rxlen field
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/gpio/gpio-virtio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-05  4:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1767089672.git.mst@redhat.com>
2025-12-30 16:40 ` [PATCH RFC 14/13] gpio: virtio: fix DMA alignment Michael S. Tsirkin
2026-01-02 12:46   ` Bartosz Golaszewski
2026-01-05  4:56   ` Viresh Kumar
2025-12-30 16:40 ` [PATCH RFC 15/13] gpio: virtio: reorder fields to reduce struct padding Michael S. Tsirkin
2026-01-02 12:47   ` Bartosz Golaszewski
2026-01-02 13:02     ` Michael S. Tsirkin
2026-01-02 13:27       ` Bartosz Golaszewski
2026-01-05  4:57   ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox