From: Cornelia Huck <cohuck@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Zhuoying Cai <zycai@linux.ibm.com>,
Jared Rossi <jrossi@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [PULL 03/15] pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations
Date: Tue, 7 Jul 2026 14:58:35 +0200 [thread overview]
Message-ID: <20260707125847.1785168-4-cohuck@redhat.com> (raw)
In-Reply-To: <20260707125847.1785168-1-cohuck@redhat.com>
From: Zhuoying Cai <zycai@linux.ibm.com>
The initial support for virtio-blk-pci IPL devices used a single virt-queue, but
other device types require multiple queues, and for PCI device types this also
requires a per-queue notification offset.
Add a PCI notify field to the VRing struct so that each queue has a unique
notify offset as defined in the virtio spec.
Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
Message-ID: <20260630141917.673995-4-jrossi@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
pc-bios/s390-ccw/virtio-pci.c | 38 +++++++++++++++++++++--------------
pc-bios/s390-ccw/virtio-pci.h | 2 +-
pc-bios/s390-ccw/virtio.c | 2 +-
pc-bios/s390-ccw/virtio.h | 1 +
4 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/pc-bios/s390-ccw/virtio-pci.c b/pc-bios/s390-ccw/virtio-pci.c
index 53bdb52e76ab..2c83ec4f1316 100644
--- a/pc-bios/s390-ccw/virtio-pci.c
+++ b/pc-bios/s390-ccw/virtio-pci.c
@@ -21,7 +21,6 @@ VirtioPciCap c_cap; /* Common capabilities */
VirtioPciCap d_cap; /* Device capabilities */
VirtioPciCap n_cap; /* Notify capabilities */
uint32_t notify_mult;
-uint16_t q_notify_offset;
static int virtio_pci_set_status(uint8_t status)
{
@@ -74,10 +73,10 @@ int virtio_pci_reset(VDev *vdev)
return 0;
}
-long virtio_pci_notify(int vq_id)
+long virtio_pci_notify(VRing *vr)
{
- uint32_t offset = n_cap.off + notify_mult * q_notify_offset;
- return vpci_bswap16_write(offset, n_cap.bar, (uint16_t) vq_id);
+ uint32_t offset = n_cap.off + notify_mult * vr->pci_notify;
+ return vpci_bswap16_write(offset, n_cap.bar, (uint16_t) vr->id);
}
/*
@@ -301,8 +300,7 @@ static int virtio_pci_read_pci_cap_config(void)
}
rc = vpci_read_bswap32(pos + VPCI_N_CAP_MULT, PCI_CFGBAR, ¬ify_mult);
- if (rc || vpci_read_bswap16(c_cap.off + VPCI_C_OFFSET_Q_NOFF, c_cap.bar,
- &q_notify_offset)) {
+ if (rc) {
puts("Failed to read notification queue configuration");
return -EIO;
}
@@ -332,7 +330,6 @@ int virtio_pci_setup(VDev *vdev)
VRing *vr;
int rc;
uint8_t status;
- uint16_t vq_size;
int i = 0;
vdev->guessed_disk_nature = VIRTIO_GDN_NONE;
@@ -380,28 +377,39 @@ int virtio_pci_setup(VDev *vdev)
return -EIO;
}
- if (vpci_read_bswap16(VPCI_C_OFFSET_Q_SIZE, c_cap.bar, &vq_size)) {
- puts("Failed to read virt-queue configuration");
- return -EIO;
- }
-
/* Configure virt-queues for pci */
for (i = 0; i < vdev->nr_vqs; i++) {
+ uint16_t vq_size;
+ uint16_t vq_notify;
VqInfo info = {
.queue = (unsigned long long) virtio_get_ring_area(i),
.align = KVM_S390_VIRTIO_RING_ALIGN,
.index = i,
- .num = vq_size,
+ .num = 0,
};
vr = &vdev->vrings[i];
- vring_init(vr, &info);
- if (vpci_set_selected_vq(vr->id)) {
+ if (vpci_set_selected_vq(i)) {
puts("Failed to set selected virt-queue");
return -EIO;
}
+ if (vpci_read_bswap16(c_cap.off + VPCI_C_OFFSET_Q_SIZE, c_cap.bar, &vq_size)) {
+ printf("Failed to read virt-queue %d size\n", i);
+ return -EIO;
+ }
+
+ info.num = vq_size;
+
+ if (vpci_read_bswap16(c_cap.off + VPCI_C_OFFSET_Q_NOFF, c_cap.bar, &vq_notify)) {
+ printf("Failed to read virt-queue %d notify offset\n", i);
+ return -EIO;
+ }
+
+ vr->pci_notify = vq_notify;
+ vring_init(vr, &info);
+
rc = set_pci_vq_addr(VPCI_C_OFFSET_Q_DESCLO, vr->desc);
rc |= set_pci_vq_addr(VPCI_C_OFFSET_Q_AVAILLO, vr->avail);
rc |= set_pci_vq_addr(VPCI_C_OFFSET_Q_USEDLO, vr->used);
diff --git a/pc-bios/s390-ccw/virtio-pci.h b/pc-bios/s390-ccw/virtio-pci.h
index 90d07cb9a76a..2494df161988 100644
--- a/pc-bios/s390-ccw/virtio-pci.h
+++ b/pc-bios/s390-ccw/virtio-pci.h
@@ -64,7 +64,7 @@ typedef struct VirtioPciCap VirtioPciCap;
void virtio_pci_id2type(VDev *vdev, uint16_t device_id);
int virtio_pci_reset(VDev *vdev);
-long virtio_pci_notify(int vq_id);
+long virtio_pci_notify(VRing *vr);
int virtio_pci_setup(VDev *vdev);
int virtio_pci_setup_device(void);
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 7883871033c4..df04479aa69c 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -114,7 +114,7 @@ bool vring_notify(VRing *vr)
vr->cookie = virtio_ccw_notify(vdev.schid, vr->id, vr->cookie);
break;
case S390_IPL_TYPE_PCI:
- vr->cookie = virtio_pci_notify(vr->id);
+ vr->cookie = virtio_pci_notify(vr);
break;
default:
return 1;
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index d32a4830cad1..75ae5bdbc229 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -107,6 +107,7 @@ struct VRing {
VRingUsed *used;
long cookie;
int id;
+ uint16_t pci_notify;
};
typedef struct VRing VRing;
--
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 ` [PULL 01/15] pc-bios/s390-ccw: Refactor byte swapping Cornelia Huck
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 ` Cornelia Huck [this message]
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-4-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.