[PATCH 8/9] hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope

Philippe Mathieu-Daudé posted 9 patches 1 month, 2 weeks ago
Maintainers: "Philippe Mathieu-Daudé" <philmd@linaro.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@kernel.org>, Zhao Liu <zhao1.liu@intel.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH 8/9] hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
virtio_lduw_phys_cached() and virtio_stw_phys_cached() are
only used within hw/virtio/virtio.c: reduce their scope by
moving their definitions there.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/virtio/virtio-access.h | 21 ---------------------
 hw/virtio/virtio.c                | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index c866769cad8..5b5fff5295e 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -102,27 +102,6 @@ static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s)
 #endif
 }
 
-static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
-                                               MemoryRegionCache *cache,
-                                               hwaddr pa)
-{
-    if (virtio_access_is_big_endian(vdev)) {
-        return lduw_be_phys_cached(cache, pa);
-    }
-    return lduw_le_phys_cached(cache, pa);
-}
-
-static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
-                                          MemoryRegionCache *cache,
-                                          hwaddr pa, uint16_t value)
-{
-    if (virtio_access_is_big_endian(vdev)) {
-        stw_be_phys_cached(cache, pa, value);
-    } else {
-        stw_le_phys_cached(cache, pa, value);
-    }
-}
-
 static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s)
 {
     *s = virtio_tswap16(vdev, *s);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 257cda506a4..fba9d347d17 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -216,6 +216,27 @@ static void virtio_check_indirect_feature(VirtIODevice *vdev)
     }
 }
 
+static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
+                                               MemoryRegionCache *cache,
+                                               hwaddr pa)
+{
+    if (virtio_access_is_big_endian(vdev)) {
+        return lduw_be_phys_cached(cache, pa);
+    }
+    return lduw_le_phys_cached(cache, pa);
+}
+
+static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
+                                          MemoryRegionCache *cache,
+                                          hwaddr pa, uint16_t value)
+{
+    if (virtio_access_is_big_endian(vdev)) {
+        stw_be_phys_cached(cache, pa, value);
+    } else {
+        stw_le_phys_cached(cache, pa, value);
+    }
+}
+
 /* Called within call_rcu().  */
 static void virtio_free_region_cache(VRingMemoryRegionCaches *caches)
 {
-- 
2.52.0


Re: [PATCH 8/9] hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope
Posted by Richard Henderson 1 month, 1 week ago
On 12/25/25 02:13, Philippe Mathieu-Daudé wrote:
> virtio_lduw_phys_cached() and virtio_stw_phys_cached() are
> only used within hw/virtio/virtio.c: reduce their scope by
> moving their definitions there.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   include/hw/virtio/virtio-access.h | 21 ---------------------
>   hw/virtio/virtio.c                | 21 +++++++++++++++++++++
>   2 files changed, 21 insertions(+), 21 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

Re: [PATCH 8/9] hw/virtio: Reduce virtio_lduw/stw_phys_cached() scope
Posted by Manos Pitsidianakis 1 month, 2 weeks ago
On Wed, Dec 24, 2025 at 5:15 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> virtio_lduw_phys_cached() and virtio_stw_phys_cached() are
> only used within hw/virtio/virtio.c: reduce their scope by
> moving their definitions there.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>


>  include/hw/virtio/virtio-access.h | 21 ---------------------
>  hw/virtio/virtio.c                | 21 +++++++++++++++++++++
>  2 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
> index c866769cad8..5b5fff5295e 100644
> --- a/include/hw/virtio/virtio-access.h
> +++ b/include/hw/virtio/virtio-access.h
> @@ -102,27 +102,6 @@ static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s)
>  #endif
>  }
>
> -static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
> -                                               MemoryRegionCache *cache,
> -                                               hwaddr pa)
> -{
> -    if (virtio_access_is_big_endian(vdev)) {
> -        return lduw_be_phys_cached(cache, pa);
> -    }
> -    return lduw_le_phys_cached(cache, pa);
> -}
> -
> -static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
> -                                          MemoryRegionCache *cache,
> -                                          hwaddr pa, uint16_t value)
> -{
> -    if (virtio_access_is_big_endian(vdev)) {
> -        stw_be_phys_cached(cache, pa, value);
> -    } else {
> -        stw_le_phys_cached(cache, pa, value);
> -    }
> -}
> -
>  static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s)
>  {
>      *s = virtio_tswap16(vdev, *s);
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 257cda506a4..fba9d347d17 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -216,6 +216,27 @@ static void virtio_check_indirect_feature(VirtIODevice *vdev)
>      }
>  }
>
> +static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
> +                                               MemoryRegionCache *cache,
> +                                               hwaddr pa)
> +{
> +    if (virtio_access_is_big_endian(vdev)) {
> +        return lduw_be_phys_cached(cache, pa);
> +    }
> +    return lduw_le_phys_cached(cache, pa);
> +}
> +
> +static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
> +                                          MemoryRegionCache *cache,
> +                                          hwaddr pa, uint16_t value)
> +{
> +    if (virtio_access_is_big_endian(vdev)) {
> +        stw_be_phys_cached(cache, pa, value);
> +    } else {
> +        stw_le_phys_cached(cache, pa, value);
> +    }
> +}
> +
>  /* Called within call_rcu().  */
>  static void virtio_free_region_cache(VRingMemoryRegionCaches *caches)
>  {
> --
> 2.52.0
>