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

Re: [PATCH 09/10] iommu/ipmmu-vmsa: Use refcount for the micro-TLBs


  • To: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Wed, 15 Dec 2021 02:58:23 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sMCT9bfFXwIARly75ze9eByLQlmhSeE6onxcSwbJ6BI=; b=R5H68UQzownuZPQXfjvxiJPMFcP5nN3uyEue/cc/l9MKp6EIRilQkONW8yQnWJeX2376NVRYTvywcKo2/+Y7OFa3A/PjSJtSQSL2URVvLOmrgGYTliI4uW8aIwnQRZh87g3y2Ag7S/3+PlNkURe8ibIsUsYElitwT+8dzebBRqEOWoqS+qt8LAHJfQkX83LIjeGZ8+la4nH6lRgikVt3skOlK44Gj0GdeyhBwVwwR5f9/OwuHVsGVdEjDy7YFkb4OAxWetCwkqEAmu7XQK4GznagGvyG0cM3frckdK3WqOEZjYCvQnWPTgiyApY6iWzdiFHCqgZFBVPPFzT11DpK0A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dY0BA2R54nd1d5nhqfuZH8Ep/9C48paxKlLjsT9T/q8q1ShoioU7t9tI8HxzpvJTwmhO3J7rlJKPPOnlJgX6JRQJKKc3T97ssbJ4vlAX3uzjM/D4Z0DjGJKa4zS7NHXxfOjsr03+Tt5j4ps54kdHxQRB6bFXpjEJGxpfrsy2nbUgdz7Sobl7394pzZ8ZXiuw+C+84y1CM09gkaG5ep5LcBs1ywcQGCPei2pnwqSZ0IFa/iSzqJjvQuzydhnwXlvx8gKhOug6HHHK+RmN4JZ3NW4WxMhNYa1EPQ4OtM9YmsgQgedUavJVKsPr7YdTJNzT/4XbTgNJHORhzncPBi4LmQ==
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
  • Delivery-date: Wed, 15 Dec 2021 02:58:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX47d8XeRfYSQoykqwT5zn68xBhKwy9zgA
  • Thread-topic: [PATCH 09/10] iommu/ipmmu-vmsa: Use refcount for the micro-TLBs

Hi Oleksandr,


Oleksandr Tyshchenko <olekstysh@xxxxxxxxx> writes:

> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>
> Reference-count the micro-TLBs as several bus masters can be
> connected to the same micro-TLB (and drop TODO comment).
> This wasn't an issue so far, since the platform devices
> (this driver deals with) get assigned/deassigned together during
> domain creation/destruction. But, in order to support PCI devices
> (which are hot-pluggable) in the near future we will need to
> take care of.
>
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> ---
>  xen/drivers/passthrough/arm/ipmmu-vmsa.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c 
> b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> index 22dd84e..32609f8 100644
> --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
> @@ -134,6 +134,7 @@ struct ipmmu_vmsa_device {
>      spinlock_t lock;    /* Protects ctx and domains[] */
>      DECLARE_BITMAP(ctx, IPMMU_CTX_MAX);
>      struct ipmmu_vmsa_domain *domains[IPMMU_CTX_MAX];
> +    unsigned int utlb_refcount[IPMMU_UTLB_MAX];
>      const struct ipmmu_features *features;
>  };
>  
> @@ -477,13 +478,12 @@ static int ipmmu_utlb_enable(struct ipmmu_vmsa_domain 
> *domain,
>          }
>      }
>  
> -    /*
> -     * TODO: Reference-count the micro-TLB as several bus masters can be
> -     * connected to the same micro-TLB.
> -     */
> -    ipmmu_imuasid_write(mmu, utlb, 0);
> -    ipmmu_imuctr_write(mmu, utlb, imuctr |
> -                       IMUCTR_TTSEL_MMU(domain->context_id) | IMUCTR_MMUEN);
> +    if ( mmu->utlb_refcount[utlb]++ == 0 )
> +    {
> +        ipmmu_imuasid_write(mmu, utlb, 0);
> +        ipmmu_imuctr_write(mmu, utlb, imuctr |
> +                           IMUCTR_TTSEL_MMU(domain->context_id) | 
> IMUCTR_MMUEN);
> +    }
>  
>      return 0;
>  }
> @@ -494,7 +494,8 @@ static void ipmmu_utlb_disable(struct ipmmu_vmsa_domain 
> *domain,
>  {
>      struct ipmmu_vmsa_device *mmu = domain->mmu;
>  
> -    ipmmu_imuctr_write(mmu, utlb, 0);

It would be great to have

+      ASSERT(mmu->utlb_refcount[utlb] > 0);

there. Just in case.

> +    if ( --mmu->utlb_refcount[utlb] == 0 )
> +        ipmmu_imuctr_write(mmu, utlb, 0);
>  }
>  
>  /* Domain/Context Management */


-- 
Volodymyr Babchuk at EPAM


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.