From: jrossi@linux.ibm.com
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com,
mjrosato@linux.ibm.com
Cc: jrossi@linux.ibm.com, zycai@linux.ibm.com, jdaley@linux.ibm.com,
jjherne@linux.ibm.com, farman@linux.ibm.com, nrb@linux.ibm.com
Subject: [PATCH v2 1/6] pc-bios/s390-ccw: Refactor byte swapping
Date: Tue, 30 Jun 2026 10:19:12 -0400 [thread overview]
Message-ID: <20260630141917.673995-2-jrossi@linux.ibm.com> (raw)
In-Reply-To: <20260630141917.673995-1-jrossi@linux.ibm.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>
---
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 390b55c7b9..a448dc96e2 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-06-30 14:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 14:19 [PATCH v2 0/6] s390x: Fix intermittent errors with IPL from PCI devices on s390x jrossi
2026-06-30 14:19 ` jrossi [this message]
2026-06-30 14:19 ` [PATCH v2 2/6] pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications jrossi
2026-07-02 1:44 ` Eric Farman
2026-07-02 2:12 ` Matthew Rosato
2026-06-30 14:19 ` [PATCH v2 3/6] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations jrossi
2026-07-02 1:49 ` Eric Farman
2026-06-30 14:19 ` [PATCH v2 4/6] pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x jrossi
2026-07-02 2:03 ` Eric Farman
2026-06-30 14:19 ` [PATCH v2 5/6] pc-bios/s390-ccw: write IPLB location for non-net virtio devices jrossi
2026-07-02 2:04 ` Eric Farman
2026-06-30 14:19 ` [PATCH v2 6/6] s390x: Enable boot menu for virtio pci device jrossi
2026-07-02 2:08 ` Matthew Rosato
2026-07-02 2:12 ` [PATCH v2 0/6] s390x: Fix intermittent errors with IPL from PCI devices on s390x Matthew Rosato
2026-07-07 11:59 ` Cornelia Huck
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=20260630141917.673995-2-jrossi@linux.ibm.com \
--to=jrossi@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=jdaley@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=nrb@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.