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

Re: [PATCH v3 2/3] arm,smmu: restructure code in preparation to new bindings support


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Tue, 2 Feb 2021 16:09:14 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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-SenderADCheck; bh=chfXEkVNIDp0GgWIUFBj6dfTAutsmq0UA7H8E2F9h+c=; b=UXYUfLUh/cm8asgpk2yP/OorSyXYD7fTQHAeWEVId4WjRcHK7hBsTxLpa4s9DlJ+rOBOBb9OS/YhmQWXRqdqYwnyztQoiTY6q8OH/GzYQ4O9kbA9Ym2u2fy9YN1Q6cwWBnl41d6srcs6jjHFxjPW7+LVnErWqOi4RtbIUsNyeeNfDtBxDhw9fog4/IhZHFvLSx84QqebNoIkdNO1eWSb2QIugKGpB5UT6BIz77atKAgE8Stbi8sPklyfcGjgYydwIApTPNg6Y0IrpqXob6wdFiepwSCs9OPrb1JgE7UA1YD1Rtl5wcDuxTQinOxZ3hjikWCKg4TiS0qU+8ocVfh2Gg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gol0c7zjWQ+Cqp6b9zpMlaW4IxvUWyjR4AADNNMMYZfo9IsCJl+PIdZUF37P2nTeCxv3m0CYEXnOGQwXijxkO+jWR+f7OOpGQKAEBcOQTGcGFU7ErV4wvAQxLXRhYuW9MN7oQF+7735nTuB1v16TV0Odn8a6LeKP1Ya4j6tEe6MhQKyJFH4lfq9uuRxrO8cTOFzqGUsOspiONH0vYl6jlnT5bkTc6mxP4NCtpTMjZ+sjVQUZuwcKO32QW0ABfimPYlkKnOJfi/Gp6RsBw3giCP86aDnOP2bcA9dGaEGbvS4NLLWpy2Ef/wKvxRLPHYWNHgYf7EBW3hj/kaknkwu3lA==
  • Authentication-results-original: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "Volodymyr_Babchuk@xxxxxxxx" <Volodymyr_Babchuk@xxxxxxxx>, "brian.woods@xxxxxxxxxx" <brian.woods@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
  • Delivery-date: Tue, 02 Feb 2021 16:10:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHW9DbzkpN/GsglfUeaXlWwDlkioapFExCA
  • Thread-topic: [PATCH v3 2/3] arm,smmu: restructure code in preparation to new bindings support

Hello Stefano,

> On 26 Jan 2021, at 10:58 pm, Stefano Stabellini <sstabellini@xxxxxxxxxx> 
> wrote:
> 
> From: Brian Woods <brian.woods@xxxxxxxxxx>
> 
> Restructure some of the code and add supporting functions for adding
> generic device tree (DT) binding support.  This will allow for using
> current Linux device trees with just modifying the chosen field to
> enable Xen.
> 
> Signed-off-by: Brian Woods <brian.woods@xxxxxxxxxx>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>

Reviewed-by: Rahul Singh <rahul.singh@xxxxxxx>
Tested-by: Rahul Singh <rahul.singh@xxxxxxx>

Regards,
Rahul
> ---
> Changes in v3:
> - split patch
> ---
> xen/drivers/passthrough/arm/smmu.c | 60 +++++++++++++++++-------------
> 1 file changed, 35 insertions(+), 25 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/arm/smmu.c 
> b/xen/drivers/passthrough/arm/smmu.c
> index 3898d1d737..9687762283 100644
> --- a/xen/drivers/passthrough/arm/smmu.c
> +++ b/xen/drivers/passthrough/arm/smmu.c
> @@ -782,50 +782,36 @@ static int insert_smmu_master(struct arm_smmu_device 
> *smmu,
>       return 0;
> }
> 
> -static int register_smmu_master(struct arm_smmu_device *smmu,
> -                             struct device *dev,
> -                             struct of_phandle_args *masterspec)
> +static int arm_smmu_dt_add_device_legacy(struct arm_smmu_device *smmu,
> +                                      struct device *dev,
> +                                      struct iommu_fwspec *fwspec)
> {
> -     int i, ret = 0;
> +     int i;
>       struct arm_smmu_master *master;
> -     struct iommu_fwspec *fwspec;
> +     struct device_node *dev_node = dev_get_dev_node(dev);
> 
> -     master = find_smmu_master(smmu, masterspec->np);
> +     master = find_smmu_master(smmu, dev_node);
>       if (master) {
>               dev_err(dev,
>                       "rejecting multiple registrations for master device 
> %s\n",
> -                     masterspec->np->name);
> +                     dev_node->name);
>               return -EBUSY;
>       }
> 
>       master = devm_kzalloc(dev, sizeof(*master), GFP_KERNEL);
>       if (!master)
>               return -ENOMEM;
> -     master->of_node = masterspec->np;
> -
> -     ret = iommu_fwspec_init(&master->of_node->dev, smmu->dev);
> -     if (ret) {
> -             kfree(master);
> -             return ret;
> -     }
> -     fwspec = dev_iommu_fwspec_get(dev);
> -
> -     /* adding the ids here */
> -     ret = iommu_fwspec_add_ids(&masterspec->np->dev,
> -                                masterspec->args,
> -                                masterspec->args_count);
> -     if (ret)
> -             return ret;
> +     master->of_node = dev_node;
> 
>       /* Xen: Let Xen know that the device is protected by an SMMU */
> -     dt_device_set_protected(masterspec->np);
> +     dt_device_set_protected(dev_node);
> 
>       if (!(smmu->features & ARM_SMMU_FEAT_STREAM_MATCH)) {
>               for (i = 0; i < fwspec->num_ids; ++i) {
> -                     if (masterspec->args[i] >= smmu->num_mapping_groups) {
> +                     if (fwspec->ids[i] >= smmu->num_mapping_groups) {
>                               dev_err(dev,
>                                       "stream ID for master device %s greater 
> than maximum allowed (%d)\n",
> -                                     masterspec->np->name, 
> smmu->num_mapping_groups);
> +                                     dev_node->name, 
> smmu->num_mapping_groups);
>                               return -ERANGE;
>                       }
>               }
> @@ -833,6 +819,30 @@ static int register_smmu_master(struct arm_smmu_device 
> *smmu,
>       return insert_smmu_master(smmu, master);
> }
> 
> +static int register_smmu_master(struct arm_smmu_device *smmu,
> +                             struct device *dev,
> +                             struct of_phandle_args *masterspec)
> +{
> +     int ret = 0;
> +     struct iommu_fwspec *fwspec;
> +
> +     ret = iommu_fwspec_init(&masterspec->np->dev, smmu->dev);
> +     if (ret)
> +             return ret;
> +
> +     fwspec = dev_iommu_fwspec_get(&masterspec->np->dev);
> +
> +     ret = iommu_fwspec_add_ids(&masterspec->np->dev,
> +                                masterspec->args,
> +                                masterspec->args_count);
> +     if (ret)
> +             return ret;
> +
> +     return arm_smmu_dt_add_device_legacy(smmu,
> +                                          &masterspec->np->dev,
> +                                          fwspec);
> +}
> +
> static struct arm_smmu_device *find_smmu_for_device(struct device *dev)
> {
>       struct arm_smmu_device *smmu;
> -- 
> 2.17.1
> 
> 




 


Rackspace

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