From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Akihiko Odaki <akihiko.odaki@daynix.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: [PULL v3 83/85] pcie_sriov: Remove num_vfs from PCIESriovPF
Date: Wed, 3 Jul 2024 18:50:34 -0400 [thread overview]
Message-ID: <cbd9e5120bac3e292eee77b7a2e3692f235a1a26.1720046570.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1720046570.git.mst@redhat.com>
From: Akihiko Odaki <akihiko.odaki@daynix.com>
num_vfs is not migrated so use PCI_SRIOV_CTRL_VFE and PCI_SRIOV_NUM_VF
instead.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20240627-reuse-v10-8-7ca0b8ed3d9f@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci/pcie_sriov.h | 1 -
hw/pci/pcie_sriov.c | 28 ++++++++++++++++++++--------
hw/pci/trace-events | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h
index 70649236c1..5148c5b77d 100644
--- a/include/hw/pci/pcie_sriov.h
+++ b/include/hw/pci/pcie_sriov.h
@@ -16,7 +16,6 @@
#include "hw/pci/pci.h"
typedef struct PCIESriovPF {
- uint16_t num_vfs; /* Number of virtual functions created */
uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar */
PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */
} PCIESriovPF;
diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index 9bd7f8acc3..fae6acea4a 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -57,7 +57,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset,
pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1,
offset, PCI_EXT_CAP_SRIOV_SIZEOF);
dev->exp.sriov_cap = offset;
- dev->exp.sriov_pf.num_vfs = 0;
dev->exp.sriov_pf.vf = NULL;
pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset);
@@ -186,6 +185,12 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num,
}
}
+static void clear_ctrl_vfe(PCIDevice *dev)
+{
+ uint8_t *ctrl = dev->config + dev->exp.sriov_cap + PCI_SRIOV_CTRL;
+ pci_set_word(ctrl, pci_get_word(ctrl) & ~PCI_SRIOV_CTRL_VFE);
+}
+
static void register_vfs(PCIDevice *dev)
{
uint16_t num_vfs;
@@ -195,6 +200,7 @@ static void register_vfs(PCIDevice *dev)
assert(sriov_cap > 0);
num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_VF)) {
+ clear_ctrl_vfe(dev);
return;
}
@@ -203,20 +209,18 @@ static void register_vfs(PCIDevice *dev)
for (i = 0; i < num_vfs; i++) {
pci_set_enabled(dev->exp.sriov_pf.vf[i], true);
}
- dev->exp.sriov_pf.num_vfs = num_vfs;
}
static void unregister_vfs(PCIDevice *dev)
{
- uint16_t num_vfs = dev->exp.sriov_pf.num_vfs;
uint16_t i;
+ uint8_t *cfg = dev->config + dev->exp.sriov_cap;
trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn),
- PCI_FUNC(dev->devfn), num_vfs);
- for (i = 0; i < num_vfs; i++) {
+ PCI_FUNC(dev->devfn));
+ for (i = 0; i < pci_get_word(cfg + PCI_SRIOV_TOTAL_VF); i++) {
pci_set_enabled(dev->exp.sriov_pf.vf[i], false);
}
- dev->exp.sriov_pf.num_vfs = 0;
}
void pcie_sriov_config_write(PCIDevice *dev, uint32_t address,
@@ -242,6 +246,9 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t address,
} else {
unregister_vfs(dev);
}
+ } else if (range_covers_byte(off, len, PCI_SRIOV_NUM_VF)) {
+ clear_ctrl_vfe(dev);
+ unregister_vfs(dev);
}
}
@@ -304,7 +311,7 @@ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev)
PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n)
{
assert(!pci_is_vf(dev));
- if (n < dev->exp.sriov_pf.num_vfs) {
+ if (n < pcie_sriov_num_vfs(dev)) {
return dev->exp.sriov_pf.vf[n];
}
return NULL;
@@ -312,5 +319,10 @@ PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n)
uint16_t pcie_sriov_num_vfs(PCIDevice *dev)
{
- return dev->exp.sriov_pf.num_vfs;
+ uint16_t sriov_cap = dev->exp.sriov_cap;
+ uint8_t *cfg = dev->config + sriov_cap;
+
+ return sriov_cap &&
+ (pci_get_word(cfg + PCI_SRIOV_CTRL) & PCI_SRIOV_CTRL_VFE) ?
+ pci_get_word(cfg + PCI_SRIOV_NUM_VF) : 0;
}
diff --git a/hw/pci/trace-events b/hw/pci/trace-events
index 19643aa8c6..e98f575a9d 100644
--- a/hw/pci/trace-events
+++ b/hw/pci/trace-events
@@ -14,7 +14,7 @@ msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %d mask
# hw/pci/pcie_sriov.c
sriov_register_vfs(const char *name, int slot, int function, int num_vfs) "%s %02x:%x: creating %d vf devs"
-sriov_unregister_vfs(const char *name, int slot, int function, int num_vfs) "%s %02x:%x: Unregistering %d vf devs"
+sriov_unregister_vfs(const char *name, int slot, int function) "%s %02x:%x: Unregistering vf devs"
sriov_config_write(const char *name, int slot, int fun, uint32_t offset, uint32_t val, uint32_t len) "%s %02x:%x: sriov offset 0x%x val 0x%x len %d"
# pcie.c
--
MST
next prev parent reply other threads:[~2024-07-03 22:52 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 22:44 [PULL v3 00/85] virtio: features,fixes Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 01/85] vhost: dirty log should be per backend type Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 02/85] vhost: Perform memory section dirty scans once per iteration Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 03/85] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 04/85] virtio/virtio-pci: Handle extra notification data Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 05/85] virtio: Prevent creation of device using notification-data with ioeventfd Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 06/85] virtio-mmio: Handle extra notification data Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 07/85] virtio-ccw: " Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 08/85] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits Michael S. Tsirkin
2024-07-03 22:44 ` [PULL v3 09/85] Fix vhost user assertion when sending more than one fd Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 10/85] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 11/85] hw/virtio: Fix obtain the buffer id from the last descriptor Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 12/85] virtio-pci: only reset pm state during resetting Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 13/85] vhost-user-gpu: fix import of DMABUF Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 14/85] Revert "vhost-user: fix lost reconnect" Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 15/85] vhost-user: fix lost reconnect again Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 16/85] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 17/85] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 18/85] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 19/85] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 20/85] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 21/85] hw/mem/cxl_type3: Add support to create DC regions to " Michael S. Tsirkin
2024-07-03 22:45 ` [PULL v3 22/85] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 23/85] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 24/85] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 25/85] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 26/85] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 27/85] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 28/85] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 29/85] hw/mem/cxl_type3: Allow to release extent superset in QMP interface Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 30/85] linux-headers: update to 6.10-rc1 Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 31/85] hw/misc/pvpanic: centralize definition of supported events Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 32/85] tests/qtest/pvpanic: use centralized " Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 33/85] hw/misc/pvpanic: add support for normal shutdowns Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 34/85] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Michael S. Tsirkin
2024-07-03 22:46 ` [PULL v3 35/85] tests/qtest/pvpanic: add tests for pvshutdown event Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 36/85] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 37/85] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 38/85] hw/cxl: Fix read from bogus memory Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 39/85] virtio-pci: implement No_Soft_Reset bit Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 40/85] vhost-user-test: no set non-blocking for cal fd less than 0 Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 41/85] i386/apic: Add hint on boot failure because of disabling x2APIC Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 42/85] hw/virtio: Free vqs after vhost_dev_cleanup() Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 43/85] virtio-iommu: add error check before assert Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 44/85] vhost-user: Skip unnecessary duplicated VHOST_USER_SET_LOG_BASE requests Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 45/85] hw/net/virtio-net.c: fix crash in iov_copy() Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 46/85] qapi: clarify that the default is backend dependent Michael S. Tsirkin
2024-07-03 22:47 ` [PULL v3 47/85] libvhost-user: set msg.msg_control to NULL when it is empty Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 48/85] libvhost-user: fail vu_message_write() if sendmsg() is failing Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 49/85] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 50/85] vhost-user-server: do not set memory fd non-blocking Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 51/85] contrib/vhost-user-blk: fix bind() using the right size of the address Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 52/85] contrib/vhost-user-*: use QEMU bswap helper functions Michael S. Tsirkin
2024-07-12 14:24 ` Peter Maydell
2024-07-12 15:18 ` Stefano Garzarella
2024-07-12 15:23 ` Peter Maydell
2024-07-03 22:48 ` [PULL v3 53/85] hostmem: add a new memory backend based on POSIX shm_open() Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 54/85] tests/qtest/vhost-user-blk-test: use memory-backend-shm Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 55/85] tests/qtest/vhost-user-test: add a test case for memory-backend-shm Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 56/85] hw/virtio: Fix the de-initialization of vhost-user devices Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 57/85] hw/arm/virt-acpi-build: Drop local iort_node_offset Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 58/85] hw/i386/fw_cfg: Add etc/e820 to fw_cfg late Michael S. Tsirkin
2024-07-04 8:09 ` David Woodhouse
2024-07-04 9:54 ` Alex Bennée
2024-07-03 22:48 ` [PULL v3 59/85] hw/arm/virt-acpi-build: Fix id_count in build_iort_id_mapping Michael S. Tsirkin
2024-07-03 22:48 ` [PULL v3 60/85] uefi-test-tools/UefiTestToolsPkg: Add RISC-V support Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 61/85] uefi-test-tools: Add support for python based build script Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 62/85] tests/data/uefi-boot-images: Add RISC-V ISO image Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 63/85] qtest: bios-tables-test: Rename aarch64 tests with aarch64 in them Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 64/85] tests/qtest/bios-tables-test.c: Add support for arch in path Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 65/85] tests/qtest/bios-tables-test.c: Set "arch" for aarch64 tests Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 66/85] tests/qtest/bios-tables-test.c: Set "arch" for x86 tests Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 67/85] tests/data/acpi: Move x86 ACPI tables under x86/${machine} path Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 68/85] tests/data/acpi/virt: Move ARM64 ACPI tables under aarch64/${machine} path Michael S. Tsirkin
2024-07-03 22:56 ` Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 70/85] pc-bios/meson.build: Add support for RISC-V in unpack_edk2_blobs Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 71/85] tests/data/acpi/rebuild-expected-aml.sh: Add RISC-V Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 72/85] hw/cxl/events: Improve QMP interfaces and documentation for add/release dynamic capacity Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 73/85] hw/cxl/events: Mark cxl-add-dynamic-capacity and cxl-release-dynamic-capcity unstable Michael S. Tsirkin
2024-07-03 22:49 ` [PULL v3 74/85] virtio: remove virtio_tswap16s() call in vring_packed_event_read() Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 75/85] virtio-iommu: Clear IOMMUDevice when VFIO device is unplugged Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 76/85] hw/pci: Rename has_power to enabled Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 77/85] hw/ppc/spapr_pci: Do not create DT for disabled PCI device Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 78/85] hw/ppc/spapr_pci: Do not reject VFs created after a PF Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 79/85] pcie_sriov: Do not manually unrealize Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 80/85] pcie_sriov: Ensure VF function number does not overflow Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 81/85] pcie_sriov: Reuse SR-IOV VF device instances Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 82/85] pcie_sriov: Release VFs failed to realize Michael S. Tsirkin
2024-07-03 22:50 ` Michael S. Tsirkin [this message]
2024-07-03 22:50 ` [PULL v3 84/85] pcie_sriov: Register VFs after migration Michael S. Tsirkin
2024-07-03 22:50 ` [PULL v3 85/85] hw/pci: Replace -1 with UINT32_MAX for romsize Michael S. Tsirkin
2024-07-03 22:56 ` [PULL v3 69/85] meson.build: Add RISC-V to the edk2-target list Michael S. Tsirkin
2024-07-04 16:13 ` [PULL v3 00/85] virtio: features,fixes Richard Henderson
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=cbd9e5120bac3e292eee77b7a2e3692f235a1a26.1720046570.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).