lkml.org 
[lkml]   [2022]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 14/32] iommu: introduce iommu_domain_alloc_type and the KVM type
    Date
    s390x will introduce an additional domain type that is used for
    managing IOMMU owned by KVM. Define the type here and add an
    interface for allocating a specified type vs the default type.

    Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
    ---
    drivers/iommu/iommu.c | 7 +++++++
    include/linux/iommu.h | 12 ++++++++++++
    2 files changed, 19 insertions(+)

    diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
    index f2c45b85b9fc..8bb57e0e3945 100644
    --- a/drivers/iommu/iommu.c
    +++ b/drivers/iommu/iommu.c
    @@ -1976,6 +1976,13 @@ void iommu_domain_free(struct iommu_domain *domain)
    }
    EXPORT_SYMBOL_GPL(iommu_domain_free);

    +struct iommu_domain *iommu_domain_alloc_type(struct bus_type *bus,
    + unsigned int t)
    +{
    + return __iommu_domain_alloc(bus, t);
    +}
    +EXPORT_SYMBOL_GPL(iommu_domain_alloc_type);
    +
    static int __iommu_attach_device(struct iommu_domain *domain,
    struct device *dev)
    {
    diff --git a/include/linux/iommu.h b/include/linux/iommu.h
    index 9208eca4b0d1..b427bbb9f387 100644
    --- a/include/linux/iommu.h
    +++ b/include/linux/iommu.h
    @@ -63,6 +63,7 @@ struct iommu_domain_geometry {
    implementation */
    #define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */
    #define __IOMMU_DOMAIN_DMA_FQ (1U << 3) /* DMA-API uses flush queue */
    +#define __IOMMU_DOMAIN_KVM (1U << 4) /* Domain is controlled by KVM */

    /*
    * This are the possible domain-types
    @@ -77,6 +78,7 @@ struct iommu_domain_geometry {
    * certain optimizations for these domains
    * IOMMU_DOMAIN_DMA_FQ - As above, but definitely using batched TLB
    * invalidation.
    + * IOMMU_DOMAIN_KVM - DMA mappings managed by KVM, used for VMs
    */
    #define IOMMU_DOMAIN_BLOCKED (0U)
    #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT)
    @@ -86,6 +88,8 @@ struct iommu_domain_geometry {
    #define IOMMU_DOMAIN_DMA_FQ (__IOMMU_DOMAIN_PAGING | \
    __IOMMU_DOMAIN_DMA_API | \
    __IOMMU_DOMAIN_DMA_FQ)
    +#define IOMMU_DOMAIN_KVM (__IOMMU_DOMAIN_PAGING | \
    + __IOMMU_DOMAIN_KVM)

    struct iommu_domain {
    unsigned type;
    @@ -421,6 +425,8 @@ extern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
    extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
    extern struct iommu_group *iommu_group_get_by_id(int id);
    extern void iommu_domain_free(struct iommu_domain *domain);
    +extern struct iommu_domain *iommu_domain_alloc_type(struct bus_type *bus,
    + unsigned int t);
    extern int iommu_attach_device(struct iommu_domain *domain,
    struct device *dev);
    extern void iommu_detach_device(struct iommu_domain *domain,
    @@ -708,6 +714,12 @@ static inline void iommu_domain_free(struct iommu_domain *domain)
    {
    }

    +static inline struct iommu_domain *iommu_domain_alloc_type(struct bus_type *bus,
    + unsigned int t)
    +{
    + return NULL;
    +}
    +
    static inline int iommu_attach_device(struct iommu_domain *domain,
    struct device *dev)
    {
    --
    2.27.0
    \
     
     \ /
      Last update: 2022-03-14 20:48    [W:4.108 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site