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

Re: [XEN][RFC PATCH v4 09/16] xen/iommu: Introduce iommu_remove_dt_device()


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 23 Jan 2023 11:00:39 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=2zYprjtrKsdKBHl/ZKkPyjDmFujiX6ygwUsmkay0LJo=; b=DIBN5MG6VzJ5TkJz+eyFTPrnfGZdNf45Zqr7qAy1F7J1j3ZhDLPTeY6iLO4szS0LSk8209+Rvp+TL8i6r94AWwQ4IbHNVVt1DRf2gUTCk9NEzuDQ3c5e8Xo60iDF/MKvWTMsIU7FmiZHlanszgN9NhjQgXk/jXFXGwCQ+tJuztjvT+uVTDfiqErqh6ySXqeJS3ZVIndv5q+G47Ro6EJoQXV1dO80KCj3xZbo3JUXrrekNOw5qG6ujRaCLe+SiU/i1htLYEZdxGuIOw6E5pFHkaXAoAYJSY60wGizPXXRQjad7BqI/bTgrh6cOEk8neI2D/z/oSYkg02VFTfZOXRQkA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfbJW3y1trkUtR/0s7lwsITNZiW+yZRjc60sYCnSgQp0cDIAXXKKwdWWT6ad6kiTXkv2Dtyr9YhSOR49BJ5Sc7OY9w9DTbyDBWUt2S27oqKgUTFdMaky5RKZmXlsY1XboECu/+UFK2cNuoc7Tl5ktP7f94Yfxw7StZiAOsLBRT6FVYQyJd23BJ+l9iIzSJpUtynFvzGsl5h796qvHMpvBGlOoz25ulrYvoWy4PFMthlcxtxpImQ6G6Dv409PpPUsZXIEX27rNNtUHDmekxSRKin6gbmUKaxZ8c0vZcvDm8Vpq3XPtWbBgaQOy7TcC0zqYUencu0wJGz4ihkrnQyh/g==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <Luca.Fancellu@xxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 10:01:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Vikram,

On 07/12/2022 07:18, Vikram Garhwal wrote:
> 
> 
> Remove master device from the IOMMU.
Adding some description on the purpose would be beneficial.

> 
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
> ---
>  xen/drivers/passthrough/device_tree.c | 38 +++++++++++++++++++++++++++
>  xen/include/xen/iommu.h               |  2 ++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/xen/drivers/passthrough/device_tree.c 
> b/xen/drivers/passthrough/device_tree.c
> index 457df333a0..a8ba0b0d17 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -126,6 +126,44 @@ int iommu_release_dt_devices(struct domain *d)
>      return 0;
>  }
> 
> +int iommu_remove_dt_device(struct dt_device_node *np)
> +{
> +    const struct iommu_ops *ops = iommu_get_ops();
> +    struct device *dev = dt_to_dev(np);
> +    int rc;
> +
Aren't we missing a check if iommu is enabled?

> +    if ( !ops )
> +        return -EOPNOTSUPP;
-EINVAL to match the return values returned by other functions?

> +
> +    spin_lock(&dtdevs_lock);
> +
> +    if ( iommu_dt_device_is_assigned_locked(np) ) {
Incorrect coding style. The closing brace should be placed on the next line.

> +        rc = -EBUSY;
> +        goto fail;
> +    }
> +
> +    /*
> +     * The driver which supports generic IOMMU DT bindings must have
> +     * these callback implemented.
> +     */
> +    if ( !ops->remove_device ) {
Incorrect coding style. The closing brace should be placed on the next line.

> +        rc = -EOPNOTSUPP;
-EINVAL to match the return values returned by other functions?

> +        goto fail;
> +    }
> +
> +    /*
> +     * Remove master device from the IOMMU if latter is present and 
> available.
> +     */
No need for a multi-line comment style.

> +    rc = ops->remove_device(0, dev);
> +
> +    if ( rc == 0 )
!rc is preffered.

> +        iommu_fwspec_free(dev);
> +
> +fail:
> +    spin_unlock(&dtdevs_lock);
> +    return rc;
> +}
> +
>  int iommu_add_dt_device(struct dt_device_node *np)
>  {
>      const struct iommu_ops *ops = iommu_get_ops();
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index 4f22fc1bed..1b36c0419d 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -225,6 +225,8 @@ int iommu_release_dt_devices(struct domain *d);
>   */
>  int iommu_add_dt_device(struct dt_device_node *np);
> 
> +int iommu_remove_dt_device(struct dt_device_node *np);
These prototypes look to be placed in order. So your function should be
placed before add function.

> +
>  int iommu_do_dt_domctl(struct xen_domctl *, struct domain *,
>                         XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
> 
> --
> 2.17.1
> 
> 

~Michal



 


Rackspace

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