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

Re: [XEN][PATCH v5 10/17] xen/iommu: Introduce iommu_remove_dt_device()


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 17 Apr 2023 12:49:40 +0200
  • 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=0h/tw2Xxd4md3b/WR2PSFmwygza9eelOtUn0TBTW5o4=; b=BD7SsnnCRiZ+ZQL7c4wk2N7RW+GOoZninqtt4pcIQ7dP3L9fLKdZzD48XbIRn5j1DiG9jEL6KpT3hdJHx4YxYmVx5z+MphH1RpzYkjY51WH8jpxPxdYux4G8juRnlBHZfpq3YzRcFXpDKAp2lq/y9kgPAQeGNhHEoKBAaUEur3wvTW4DGq1q+W8kvQa83w63XpaqD37r54lnWzes7FnTxPN8tJHPgdlRDGjmZSCmup4U13HrcSkS+f5KdapdK3R5nXKn3vJ+rlZL0Z0XgKXwqwkArlrX6yrV73HtuT4JMyyO9fwjkFfmzT0WGaswSzKsvMsBwvSMWjc0pu5q1A+HRQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+op2pTk/8syq7/tZu+ELKYFFGWJQRq2IeC1NIFtRycExFYABc0vuxTHJYIjG9DUk+JofV82p4MxDBKzfPI8N5MkjlzHxCNl+yInpuK+hjX6n/5dnMxobKT7SoVVR95R8hUYh2XiJvp9FkCjGAkAafRYJIay8I5LBTajVjmCk1FYCjQfv6SQ1507ogMhC1Du1giBZFpfUXSfY+9uW9i4HgjwENTi59QoZIV+dTGlaFtOtz2ZX4TclH1I9n1ubzePk3xIUm06T57lDdRgo1BZpQd97UFtQD1BxONCLIx/h5nMBBASfWqa3AzsxzYYMW34CBqOCKtLveCuR5VByABEyw==
  • Cc: <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 17 Apr 2023 10:49:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Vikram,

On 11/04/2023 21:16, Vikram Garhwal wrote:
> 
> 
> Remove master device from the IOMMU. This will be helpful when removing the
> overlay nodes using dynamic programming during run time.
> 
> 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..a77a217f3d 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;
> +
> +    if ( !ops )
> +        return -EOPNOTSUPP;
> +
> +    spin_lock(&dtdevs_lock);
> +
> +    if ( iommu_dt_device_is_assigned_locked(np) )
> +    {
> +        rc = -EBUSY;
> +        goto fail;
> +    }
> +
> +    /*
> +     * The driver which supports generic IOMMU DT bindings must have
> +     * these callback implemented.
s/these/this since you are checking for a single callback.

> +     */
> +    if ( !ops->remove_device )
> +    {
> +        rc = -EOPNOTSUPP;
> +        goto fail;
> +    }
> +
> +    /* Remove master device from the IOMMU if latter is present and 
> available. */
80 chars length exceeded -> please fix.
Apart from that, similarly to comment inside iommu_add_dt_device(), I would 
also write
something that the driver is responsible for unsetting is_protected flag.

Apart from that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal



 


Rackspace

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