[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid
From: |
Liu Yi L |
Subject: |
[Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid |
Date: |
Fri, 5 Jul 2019 19:01:40 +0800 |
This patch adds two callbacks pci_device_bind/unbind_gpasid() to
PCIPASIDOps. These two callbacks are used to propagate guest pasid
bind/unbind to host. The implementations of the callbacks would be
device passthru modules like vfio.
Cc: Kevin Tian <address@hidden>
Cc: Jacob Pan <address@hidden>
Cc: Peter Xu <address@hidden>
Cc: Eric Auger <address@hidden>
Cc: Yi Sun <address@hidden>
Cc: David Gibson <address@hidden>
Signed-off-by: Liu Yi L <address@hidden>
---
hw/pci/pci.c | 30 ++++++++++++++++++++++++++++++
include/hw/pci/pci.h | 9 +++++++++
2 files changed, 39 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 710f9e9..2229229 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2676,6 +2676,36 @@ int pci_device_request_pasid_free(PCIBus *bus, int32_t
devfn,
return -1;
}
+void pci_device_bind_gpasid(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data)
+{
+ PCIDevice *dev;
+
+ if (!bus) {
+ return;
+ }
+
+ dev = bus->devices[devfn];
+ if (dev && dev->pasid_ops) {
+ dev->pasid_ops->bind_gpasid(bus, devfn, g_bind_data);
+ }
+}
+
+void pci_device_unbind_gpasid(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data)
+{
+ PCIDevice *dev;
+
+ if (!bus) {
+ return;
+ }
+
+ dev = bus->devices[devfn];
+ if (dev && dev->pasid_ops) {
+ dev->pasid_ops->unbind_gpasid(bus, devfn, g_bind_data);
+ }
+}
+
static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
{
Range *range = opaque;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 16e5b8e..8d849e6 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -9,6 +9,7 @@
#include "hw/isa/isa.h"
#include "hw/pci/pcie.h"
+#include <linux/iommu.h>
extern bool pci_available;
@@ -267,6 +268,10 @@ struct PCIPASIDOps {
int (*alloc_pasid)(PCIBus *bus, int32_t devfn,
uint32_t min_pasid, uint32_t max_pasid);
int (*free_pasid)(PCIBus *bus, int32_t devfn, uint32_t pasid);
+ void (*bind_gpasid)(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data);
+ void (*unbind_gpasid)(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data);
};
struct PCIDevice {
@@ -497,6 +502,10 @@ bool pci_device_is_ops_set(PCIBus *bus, int32_t devfn);
int pci_device_request_pasid_alloc(PCIBus *bus, int32_t devfn,
uint32_t min_pasid, uint32_t max_pasid);
int pci_device_request_pasid_free(PCIBus *bus, int32_t devfn, uint32_t pasid);
+void pci_device_bind_gpasid(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data);
+void pci_device_unbind_gpasid(PCIBus *bus, int32_t devfn,
+ struct gpasid_bind_data *g_bind_data);
static inline void
pci_set_byte(uint8_t *config, uint8_t val)
--
2.7.4
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, (continued)
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, David Gibson, 2019/07/23
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, Liu, Yi L, 2019/07/24
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, Auger Eric, 2019/07/24
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, Liu, Yi L, 2019/07/26
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, David Gibson, 2019/07/26
[Qemu-devel] [RFC v1 06/18] intel_iommu: support virtual command emulation and pasid request, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid,
Liu Yi L <=
[Qemu-devel] [RFC v1 08/18] vfio/pci: add vfio bind/unbind_gpasid implementation, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 09/18] intel_iommu: process pasid cache invalidation, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 11/18] intel_iommu: create VTDAddressSpace per BDF+PASID, Liu Yi L, 2019/07/06