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

Re: [XEN][PATCH v5 07/17] xen/smmu: Add remove_device callback for smmu_iommu ops


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 17 Apr 2023 12:24:54 +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=yXXrP4sb1wUWjuiRCJUdQCZtqL4Tq1RBkstGbhiltNk=; b=YaMTFBQjwrGwg03P3x6Uj5gJjtGrbBeZ0GHRh1hwVIe818BASM4XstGcBC9qBSciwRUDY6PQFbRfgTumWmCYR4QU5fQ3TvZYCSsLXryoVkc4PfDv+YsMGd/Gl4zrnWNDJpx6a/ZX5bS2dNHWEGsoyStYtF5ngG7ZboGWcg9p019Nu+iJ0LpHAmdJ85Ijsp9Cfp09oe2tF5md59ZmCj2CA/vTaFwX913ffFy8p+t0N9m3SMqH8OVkF4aN0NDCrvQJxSDV3y/htMElDQyDBvadHDZMnGdHCgPK3wizRqeLJzluV153wsBnszKfEhO4y+z6M99/D4bIxNKMEn6UYuRX8g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gFY/t/I3XCuk11zRNnfx5nhvhs90dOH5ZdTA90ZMKnpyte8zz4NfNnzaWXNCK9auPtvyvG6yJMwOih1dIAWixwMMu4jTz0RWIPlCVCuKuHAfAH8oNj38DM0BcQlrL4U0P7NzIqlpcAEisH4AAi9Xcy0iHFar0aHHTMa5JzNGvQPt1xTiiE/rI5tKQ0J6gZneBLMxdV3cckE5+uMF5PiRNlG/kJhRrq7y2u3Wq02YBxiINgZ50KbtO0SMm3SXnBUJG5NNE6VV9nKWQrxJdXvrWBm3DgkVNCVXTEMSdoI2aehDPkE8C7sKvztIr0TLKx/WTK7y33HeBP3+yaUK/sWeUw==
  • Cc: <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 17 Apr 2023 10:25:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Vikram,

On 11/04/2023 21:16, Vikram Garhwal wrote:
> 
> 
> Add remove_device callback for removing the device entry from smmu-master 
> using
> following steps:
> 1. Find if SMMU master exists for the device node.
> 2. Remove the SMMU master
> 
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
> Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> ---
>  xen/drivers/passthrough/arm/smmu.c | 56 ++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/xen/drivers/passthrough/arm/smmu.c 
> b/xen/drivers/passthrough/arm/smmu.c
> index 0a514821b3..14e15f1bc6 100644
> --- a/xen/drivers/passthrough/arm/smmu.c
> +++ b/xen/drivers/passthrough/arm/smmu.c
> @@ -816,6 +816,19 @@ static int insert_smmu_master(struct arm_smmu_device 
> *smmu,
>         return 0;
>  }
> 
> +static int remove_smmu_master(struct arm_smmu_device *smmu,
> +                             struct arm_smmu_master *master)
> +{
> +       if (!smmu->masters.rb_node) {
> +               ASSERT_UNREACHABLE();
> +               return -ENOENT;
> +       }
> +
> +       rb_erase(&master->node, &smmu->masters);
> +
> +       return 0;
> +}
> +
>  static int arm_smmu_dt_add_device_legacy(struct arm_smmu_device *smmu,
>                                          struct device *dev,
>                                          struct iommu_fwspec *fwspec)
> @@ -853,6 +866,32 @@ static int arm_smmu_dt_add_device_legacy(struct 
> arm_smmu_device *smmu,
>         return insert_smmu_master(smmu, master);
>  }
> 
> +static int arm_smmu_dt_remove_device_legacy(struct arm_smmu_device *smmu,
> +                                        struct device *dev)
> +{
> +       struct arm_smmu_master *master;
> +       struct device_node *dev_node = dev_get_dev_node(dev);
> +       int ret;
> +
> +       master = find_smmu_master(smmu, dev_node);
> +       if (master == NULL) {
> +               dev_err(dev,
> +                       "No registrations found for master device %s\n",
> +                       dev_node->name);
> +               return -EINVAL;
> +       }
> +
> +       ret = remove_smmu_master(smmu, master);
This patch looks good although I remember seeing Julien advising you that it 
would be beneficial
for the SMMU driver itself to check if device is not currently used before you 
remove it (even though
you have this check in iommu_remove_dt_device(). I could not find your answer 
to this.

NIT: No need for a blank line here if the next instruction is checking the ret 
value.

With the above things clarified:
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®.