From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: [PULL 10/31] pci: Add an API to get IOMMU's min page size and virtual address width
Date: Sun, 1 Jun 2025 11:25:09 -0400 [thread overview]
Message-ID: <042cbc9aec7caca639dcb1a8a996406a7c572706.1748791463.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1748791463.git.mst@redhat.com>
From: CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com>
This kind of information is needed by devices implementing ATS in order
to initialize their translation cache.
Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com>
Message-Id: <20250520071823.764266-8-clement.mathieu--drif@eviden.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci/pci.h | 26 ++++++++++++++++++++++++++
hw/pci/pci.c | 17 +++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index c2fe6caa2c..d67ffe12db 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -429,6 +429,19 @@ typedef struct PCIIOMMUOps {
* @devfn: device and function number of the PCI device.
*/
void (*unset_iommu_device)(PCIBus *bus, void *opaque, int devfn);
+ /**
+ * @get_iotlb_info: get properties required to initialize a device IOTLB.
+ *
+ * Callback required if devices are allowed to cache translations.
+ *
+ * @opaque: the data passed to pci_setup_iommu().
+ *
+ * @addr_width: the address width of the IOMMU (output parameter).
+ *
+ * @min_page_size: the page size of the IOMMU (output parameter).
+ */
+ void (*get_iotlb_info)(void *opaque, uint8_t *addr_width,
+ uint32_t *min_page_size);
} PCIIOMMUOps;
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
@@ -436,6 +449,19 @@ bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
Error **errp);
void pci_device_unset_iommu_device(PCIDevice *dev);
+/**
+ * pci_iommu_get_iotlb_info: get properties required to initialize a
+ * device IOTLB.
+ *
+ * Returns 0 on success, or a negative errno otherwise.
+ *
+ * @dev: the device that wants to get the information.
+ * @addr_width: the address width of the IOMMU (output parameter).
+ * @min_page_size: the page size of the IOMMU (output parameter).
+ */
+int pci_iommu_get_iotlb_info(PCIDevice *dev, uint8_t *addr_width,
+ uint32_t *min_page_size);
+
/**
* pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus
*
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 1114ba8529..fc4954ac81 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2970,6 +2970,23 @@ void pci_device_unset_iommu_device(PCIDevice *dev)
}
}
+int pci_iommu_get_iotlb_info(PCIDevice *dev, uint8_t *addr_width,
+ uint32_t *min_page_size)
+{
+ PCIBus *bus;
+ PCIBus *iommu_bus;
+ int devfn;
+
+ pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn);
+ if (iommu_bus && iommu_bus->iommu_ops->get_iotlb_info) {
+ iommu_bus->iommu_ops->get_iotlb_info(iommu_bus->iommu_opaque,
+ addr_width, min_page_size);
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque)
{
/*
--
MST
next prev parent reply other threads:[~2025-06-01 15:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-01 15:24 [PULL 00/31] virtio,pci,pc: features, fixes, tests Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 01/31] virtio: check for validity of indirect descriptors Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 02/31] hw/i386/amd_iommu: Fix device setup failure when PT is on Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 03/31] hw/i386/amd_iommu: Fix xtsup when vcpus < 255 Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 04/31] pcie: Add helper to declare PASID capability for a pcie device Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 05/31] pcie: Helper functions to check if PASID is enabled Michael S. Tsirkin
2025-06-01 15:24 ` [PULL 06/31] pcie: Helper function to check if ATS " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 07/31] pcie: Add a helper to declare the PRI capability for a pcie device Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 08/31] pcie: Helper functions to check to check if PRI is enabled Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 09/31] pci: Cache the bus mastering status in the device Michael S. Tsirkin
2025-06-01 15:25 ` Michael S. Tsirkin [this message]
2025-06-01 15:25 ` [PULL 11/31] memory: Store user data pointer in the IOMMU notifiers Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 12/31] pci: Add a pci-level initialization function for " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 13/31] pci: Add a pci-level API for ATS Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 14/31] pci: Add a PCI-level API for PRI Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 15/31] uefi-test-tools:: Add LoongArch64 support Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 16/31] tests/data/uefi-boot-images: Add ISO image for LoongArch system Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 17/31] tests/qtest/bios-tables-test: Use MiB macro rather hardcode value Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 18/31] tests/acpi: Add empty ACPI data files for LoongArch Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 19/31] tests/qtest/bios-tables-test: Add basic testing " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 20/31] rebuild-expected-aml.sh: Add support " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 21/31] tests/acpi: Fill acpi table data " Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 22/31] tests/acpi: Remove stale allowed tables Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 23/31] vhost: Don't set vring call if guest notifier is unused Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 24/31] vdpa: check for iova tree initialized at net_client_start Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 25/31] vdpa: reorder vhost_vdpa_set_backend_cap Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 26/31] vdpa: set backend capabilities at vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 27/31] vdpa: add listener_registered Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 28/31] vdpa: reorder listener assignment Michael S. Tsirkin
2025-06-01 15:25 ` [PULL 29/31] vdpa: move iova_tree allocation to net_vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:26 ` [PULL 30/31] vdpa: move memory listener register to vhost_vdpa_init Michael S. Tsirkin
2025-06-01 15:26 ` [PULL 31/31] hw/i386/pc_piix: Fix RTC ISA IRQ wiring of isapc machine Michael S. Tsirkin
2025-06-02 8:39 ` [PULL 00/31] virtio,pci,pc: features, fixes, tests Michael S. Tsirkin
2025-06-02 16:39 ` Stefan Hajnoczi
2025-06-02 17:54 ` Michael S. Tsirkin
2025-06-02 18:25 ` Stefan Hajnoczi
2025-06-02 18:31 ` Michael S. Tsirkin
2025-06-02 21:58 ` Michael S. Tsirkin
2025-06-02 22:27 ` Stefan Hajnoczi
2025-06-03 1:09 ` Bibo Mao
2025-06-02 20:43 ` 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=042cbc9aec7caca639dcb1a8a996406a7c572706.1748791463.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=clement.mathieu--drif@eviden.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).