qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasi


From: Auger Eric
Subject: Re: [Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid
Date: Tue, 9 Jul 2019 10:37:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hi Liu,

On 7/5/19 1:01 PM, Liu Yi L wrote:
> 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)
struct gpasid_bind_data is defined in linux headers so I think you would
need: #ifdef __linux__
> +{
> +    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)
> 
Thanks

Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]