From: Cornelia Huck <cohuck@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Zhuoying Cai <zycai@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Jared Rossi <jrossi@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [PULL 01/15] pc-bios/s390-ccw: Refactor byte swapping
Date: Tue, 7 Jul 2026 14:58:33 +0200 [thread overview]
Message-ID: <20260707125847.1785168-2-cohuck@redhat.com> (raw)
In-Reply-To: <20260707125847.1785168-1-cohuck@redhat.com>
From: Zhuoying Cai <zycai@linux.ibm.com>
Introduce local variables to cache the byte-swapped values eliminating
some redundant byte swap operations. Additionally, do byte swap when
polling to avoid a special case where endianness is preserved.
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
Message-ID: <20260630141917.673995-2-jrossi@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
pc-bios/s390-ccw/virtio.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 390b55c7b924..a448dc96e269 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -153,14 +153,14 @@ static void vr_bswap_descriptor(VRingDesc *desc)
void vring_send_buf(VRing *vr, void *p, int len, int flags)
{
- if (!be_ipl()) {
- vr->avail->idx = bswap16(vr->avail->idx);
- }
+ uint16_t avail_idx;
+
+ avail_idx = be_ipl() ? vr->avail->idx : bswap16(vr->avail->idx);
/* For follow-up chains we need to keep the first entry point */
if (!(flags & VRING_HIDDEN_IS_CHAIN)) {
- vr->avail->ring[vr->avail->idx % vr->num] = be_ipl() ? vr->next_idx :
- bswap16(vr->next_idx);
+ vr->avail->ring[avail_idx % vr->num] = be_ipl() ? vr->next_idx :
+ bswap16(vr->next_idx);
}
vr->desc[vr->next_idx].addr = (unsigned long)p;
@@ -177,23 +177,23 @@ void vring_send_buf(VRing *vr, void *p, int len, int flags)
/* Chains only have a single ID */
if (!(flags & VRING_DESC_F_NEXT)) {
- vr->avail->idx++;
- }
-
- if (!be_ipl()) {
- vr->avail->idx = bswap16(vr->avail->idx);
+ avail_idx++;
+ vr->avail->idx = be_ipl() ? avail_idx : bswap16(avail_idx);
}
}
int vr_poll(VRing *vr)
{
- if (vr->used->idx == vr->used_idx) {
+ uint16_t used_idx;
+
+ used_idx = be_ipl() ? vr->used->idx : bswap16(vr->used->idx);
+ if (used_idx == vr->used_idx) {
vring_notify(vr);
yield();
return 0;
}
- vr->used_idx = vr->used->idx; /* Endianness is preserved */
+ vr->used_idx = used_idx;
vr->next_idx = 0;
vr->desc[0].len = 0;
vr->desc[0].flags = 0;
--
2.54.0
next prev parent reply other threads:[~2026-07-07 13:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 12:58 [PULL 00/15] s390x updates (contains Linux headers update) Cornelia Huck
2026-07-07 12:58 ` Cornelia Huck [this message]
2026-07-07 12:58 ` [PULL 02/15] pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications Cornelia Huck
2026-07-07 12:58 ` [PULL 03/15] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations Cornelia Huck
2026-07-07 12:58 ` [PULL 04/15] pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x Cornelia Huck
2026-07-07 12:58 ` [PULL 05/15] pc-bios/s390-ccw: write IPLB location for non-net virtio devices Cornelia Huck
2026-07-07 12:58 ` [PULL 06/15] s390x: Enable boot menu for virtio pci device Cornelia Huck
2026-07-07 12:58 ` [PULL 07/15] linux-headers: Update to Linux v7.2-rc1 with KVM_S390_VM_CPU_FEAT_ASTFLEIE2 Cornelia Huck
2026-07-07 12:58 ` [PULL 08/15] s390x/kvm: Add ASTFLE facility 2 for nested virtualization Cornelia Huck
2026-07-07 12:58 ` [PULL 09/15] target/s390x: Fix wrong address handling in address loops Cornelia Huck
2026-07-07 12:58 ` [PULL 10/15] s390x/sclp: reject invalid write event data headers Cornelia Huck
2026-07-07 12:58 ` [PULL 11/15] s390x/pci: Tighten region detection for BAR read/write Cornelia Huck
2026-07-07 12:58 ` [PULL 12/15] s390x/pci: Shrink RPCIT ranges to registered window Cornelia Huck
2026-07-07 12:58 ` [PULL 13/15] s390x/ioinst: Require strict length and format for SEI CHSC handler Cornelia Huck
2026-07-07 12:58 ` [PULL 14/15] s390x/css: limit number of CHPIDs in description Cornelia Huck
2026-07-07 12:58 ` [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios Cornelia Huck
2026-07-08 5:54 ` [PULL 00/15] s390x updates (contains Linux headers update) Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707125847.1785168-2-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=zycai@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.