All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: jrossi@linux.ibm.com, qemu-devel@nongnu.org,
	qemu-s390x@nongnu.org, thuth@redhat.com, mst@redhat.com
Cc: jjherne@linux.ibm.com, alifm@linux.ibm.com,
	mjrosato@linux.ibm.com, zycai@linux.ibm.com
Subject: Re: [PATCH v4 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions
Date: Thu, 05 Mar 2026 13:37:31 -0500	[thread overview]
Message-ID: <27c3de8b032b057a7f07d3bab96421cd0dc7a41d.camel@linux.ibm.com> (raw)
In-Reply-To: <20260304025917.2157032-12-jrossi@linux.ibm.com>

On Tue, 2026-03-03 at 21:59 -0500, jrossi@linux.ibm.com wrote:
> From: Jared Rossi <jrossi@linux.ibm.com>
> 
> Define common functionality for interacting with virtio-pci devices.
> 
> Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
> ---
>  pc-bios/s390-ccw/Makefile     |   2 +-
>  pc-bios/s390-ccw/virtio-pci.c | 167 ++++++++++++++++++++++++++++++++++
>  pc-bios/s390-ccw/virtio-pci.h |  80 ++++++++++++++++
>  pc-bios/s390-ccw/virtio.h     |   5 +
>  4 files changed, 253 insertions(+), 1 deletion(-)
>  create mode 100644 pc-bios/s390-ccw/virtio-pci.c
>  create mode 100644 pc-bios/s390-ccw/virtio-pci.h
> 

...snip...
(Only comment I had in here was the s/0x1402/0x1042/ that Thomas pointed out.)


> diff --git a/pc-bios/s390-ccw/virtio-pci.h b/pc-bios/s390-ccw/virtio-pci.h
> new file mode 100644
> index 0000000000..54c524f698
> --- /dev/null
> +++ b/pc-bios/s390-ccw/virtio-pci.h
> @@ -0,0 +1,80 @@
> +/*
> + * Definitions for virtio-pci
> + *
> + * Copyright 2025 IBM Corp.
> + * Author(s): Jared Rossi <jrossi@linux.ibm.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef VIRTIO_PCI_H
> +#define VIRTIO_PCI_H
> +
> +/* Common configuration */
> +#define VPCI_CAP_COMMON_CFG          1
> +/* Notifications */
> +#define VPCI_CAP_NOTIFY_CFG          2
> +/* ISR access */
> +#define VPCI_CAP_ISR_CFG             3
> +/* Device specific configuration */
> +#define VPCI_CAP_DEVICE_CFG          4
> +/* PCI configuration access */
> +#define VPCI_CAP_PCI_CFG             5
> +/* Additional shared memory capability */
> +#define VPCI_CAP_SHARED_MEMORY_CFG   8
> +/* PCI vendor data configuration */
> +#define VPCI_CAP_VENDOR_CFG          9
> +
> +/* Offsets within capability header */
> +#define VPCI_CAP_VNDR        0
> +#define VPCI_CAP_NEXT        1
> +#define VPCI_CAP_LEN         2
> +#define VPCI_CAP_CFG_TYPE    3
> +#define VPCI_CAP_BAR         4
> +#define VPCI_CAP_OFFSET      8
> +#define VPCI_CAP_LENGTH      12
> +
> +#define VPCI_N_CAP_MULT 16 /* Notify multiplier, VPCI_CAP_NOTIFY_CFG only */
> +
> +/* Common Area Offsets for virtio-pci queue */
> +#define VPCI_C_OFFSET_DFSELECT      0
> +#define VPCI_C_OFFSET_DF            4
> +#define VPCI_C_OFFSET_GFSELECT      8
> +#define VPCI_C_OFFSET_GF            12
> +#define VPCI_C_COMMON_NUMQ          18
> +#define VPCI_C_OFFSET_STATUS        20
> +#define VPCI_C_OFFSET_Q_SELECT      22
> +#define VPCI_C_OFFSET_Q_SIZE        24
> +#define VPCI_C_OFFSET_Q_ENABLE      28
> +#define VPCI_C_OFFSET_Q_NOFF        30
> +#define VPCI_C_OFFSET_Q_DESCLO      32
> +#define VPCI_C_OFFSET_Q_DESCHI      36
> +#define VPCI_C_OFFSET_Q_AVAILLO     40
> +#define VPCI_C_OFFSET_Q_AVAILHI     44
> +#define VPCI_C_OFFSET_Q_USEDLO      48
> +#define VPCI_C_OFFSET_Q_USEDHI      52
> +
> +#define VIRTIO_F_VERSION_1          1   /* Feature bit 32 */
> +
> +struct VirtioPciCap {
> +    uint8_t bar;     /* Which PCIAS it's in */
> +    uint32_t off;    /* Offset within bar */
> +};
> +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);
> +
> +int vpci_read_flex(uint64_t offset, uint8_t pcias, void *buf, int len);
> +int vpci_read_bswap64(uint64_t offset, uint8_t pcias, uint64_t *buf);
> +int vpci_read_bswap32(uint64_t offset, uint8_t pcias, uint32_t *buf);
> +int vpci_read_bswap16(uint64_t offset, uint8_t pcias, uint16_t *buf);
> +int vpci_read_byte(uint64_t offset, uint8_t pcias, uint8_t *buf);
> +
> +int vpci_bswap64_write(uint64_t offset, uint8_t pcias, uint64_t data);
> +int vpci_bswap32_write(uint64_t offset, uint8_t pcias, uint32_t data);
> +int vpci_bswap16_write(uint64_t offset, uint8_t pcias, uint16_t data);
> +int vpci_write_byte(uint64_t offset, uint8_t pcias, uint8_t data);

I know it's pedantic, but since the reads are vpci_read_bXXXX while the writes are vcpi_bXXXX_write
(except the single byte case) could we make them consistent, please? (Soft preference for
vpci_read/write_bXXXX, but I don't much care.)

> +
> +#endif
> diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
> index c3cb5a6ee3..0e7dbdb64c 100644
> --- a/pc-bios/s390-ccw/virtio.h
> +++ b/pc-bios/s390-ccw/virtio.h
> @@ -18,6 +18,10 @@
>  #define VIRTIO_CONFIG_S_DRIVER          2
>  /* Driver has used its parts of the config, and is happy */
>  #define VIRTIO_CONFIG_S_DRIVER_OK       4
> +/* Feature negotiation complete */
> +#define VIRTIO_CONFIG_S_FEATURES_OK     8
> +/* Clear status byte */
> +#define VIRTIO_CONFIG_S_RESET           0x00

Heh, in v3 I wondered if you could add the new status bit(s) here. Buuuut... :)

Virtio section 2.1 defines "NEEDS_RESET" as 64 (0x40). Of course it says that the status field
starts as zero and is reinitialized to zero BY a reset, which is what you end up doing. Its
placement here between FEATURES_OK and FAILED with their spec-accurate definitions, but with a
different definition had me puzzled. Maybe move it to the top of this list, and rename it to
..._S_INIT or ..._S_ZERO or something? (Or don't define it and just set it to zero in the code.)

>  /* We've given up on this device. */
>  #define VIRTIO_CONFIG_S_FAILED          0x80
>  
> @@ -255,6 +259,7 @@ struct VDev {
>      uint8_t scsi_dev_heads;
>      bool scsi_device_selected;
>      ScsiDevice selected_scsi_device;
> +    uint32_t pci_fh;
>      uint32_t max_transfer;
>      uint32_t guest_features[2];
>  };


  parent reply	other threads:[~2026-03-05 18:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04  2:59 [PATCH v4 00/15] s390x: Add support for virtio-blk-pci IPL device jrossi
2026-03-04  2:59 ` [PATCH v4 01/15] pc-bios/s390-ccw: Fix misattributed function prototypes jrossi
2026-03-04  2:59 ` [PATCH v4 02/15] pc-bios/s390-ccw: Remove redundant vring schid attribute jrossi
2026-03-04  2:59 ` [PATCH v4 03/15] pc-bios/s390-ccw: Always reset virtio device on failed boot attempt jrossi
2026-03-04  8:23   ` Thomas Huth
2026-03-04 13:39   ` Eric Farman
2026-03-04  2:59 ` [PATCH v4 04/15] s390x: Remove duplicate definitions of IPL types jrossi
2026-03-04  8:34   ` Thomas Huth
2026-03-04  2:59 ` [PATCH v4 05/15] pc-bios/s390-ccw: Store device type independent of sense data jrossi
2026-03-04  2:59 ` [PATCH v4 06/15] pc-bios/s390-ccw: Split virtio-ccw and generic virtio jrossi
2026-03-04  8:42   ` Thomas Huth
2026-03-05 15:43   ` Eric Farman
2026-03-04  2:59 ` [PATCH v4 07/15] include/hw/s390x: Move CLP definitions for easier BIOS access jrossi
2026-03-04  2:59 ` [PATCH v4 08/15] pc-bios/s390-ccw: Introduce CLP Architecture jrossi
2026-03-04 14:05   ` Eric Farman
2026-03-04  2:59 ` [PATCH v4 09/15] s390x: Add definitions for PCI IPL type jrossi
2026-03-04  2:59 ` [PATCH v4 10/15] pc-bios/s390-ccw: Introduce PCI device jrossi
2026-03-04  9:10   ` Thomas Huth
2026-03-04 14:35     ` Jared Rossi
2026-03-04  2:59 ` [PATCH v4 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions jrossi
2026-03-04  9:18   ` Thomas Huth
2026-03-04 14:38     ` Jared Rossi
2026-03-05 18:37   ` Eric Farman [this message]
2026-03-04  2:59 ` [PATCH v4 12/15] pc-bios/s390-ccw: Add support for virtio-blk-pci IPL jrossi
2026-03-04  9:53   ` Thomas Huth
2026-03-04 14:29     ` Jared Rossi
2026-03-04 14:39       ` Thomas Huth
2026-03-04 20:17         ` Jared Rossi
2026-03-05  6:16           ` Thomas Huth
2026-03-05 22:25   ` Eric Farman
2026-03-04  2:59 ` [PATCH v4 13/15] s390x: Build IPLB for virtio-pci devices jrossi
2026-03-05 22:30   ` Eric Farman
2026-03-04  2:59 ` [PATCH v4 14/15] hw: Add "loadparm" property to virtio block PCI devices booting on s390x jrossi
2026-03-04  9:59   ` Thomas Huth
2026-03-04  2:59 ` [PATCH v4 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c jrossi

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=27c3de8b032b057a7f07d3bab96421cd0dc7a41d.camel@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=jjherne@linux.ibm.com \
    --cc=jrossi@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    --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.