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

Re: [PATCH v3 2/6] iommu/arm: Add iommu_dt_xlate()


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 22 May 2023 16:48:15 +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=bu8tc6QUaD2f1Bg+pJtdesvDnIdQHpfh5WkPGu9o9vI=; b=A5Hfsge6A+oMgi1YfWN5VJy+BPp3d9OHwem8fQP0xw6oHwtwvK9PKH8MMPoWoZZjXdLogOfvmWH6ynSUhKhD5BtWiuVjNZLHZ+Jrn6WUEXKcpBwMZ/xTSjCC5Bs5ZfYA1M/qJCfuFPJfuX9uvSUhg/mJC/x9W8UAyG8gPSoN3+LTmTAl+an3JW3dp7C38JUPYJJz46le3kRSk0hyhXJZf87R09lpf7gFXsMYaeB9O/UkzPXzK6L1+EKaFCJoZrP4gC8qNMQmkfPUCMi7CHOQAlSHiqAd6lhFFrvX6QZ0vsd1POOSJq5DSOGWFnEuQiBGQhyxGFVLGAtgIq3J+LAfNQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Obt0/fydd3hKwj9etMrkyV6F48TcgzFv86SkRL7pCjrJrG/lrHHS1Fd91jnPBWPTR31bZ5eXPSFAuA0q+r9FgB8veeKYjdp3tY3wTio6PdjcIzs8jWSlOVuU4KKckGCOdIj2zEh+66ZtvbqRL0LcG8HnDXtii6gw6xJgVW7+4Hj7KLIqS2xKSdFDnexub33cALOpS/51+IkuiINpb7mTL2DdfxLclYlYlmojsbkXEUzJXzYxQquSF2PlIXsHYcKPWPKZCQgm5S2vvIMj2/ntsrkijtD2aT/05UbvcJYB6tpGPFi2NHVx417p/PHkePFU8xjV5miAxQWhqu4HhQs8Jw==
  • Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 22 May 2023 14:48:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Stewart,

On 18/05/2023 23:06, Stewart Hildebrand wrote:
> 
> 
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> 
> Move code for processing DT IOMMU specifier to a separate helper.
> This helper will be re-used for adding PCI devices by the subsequent
> patches as we will need exact the same actions for processing
> DT PCI-IOMMU specifier.
> 
> While at it introduce NO_IOMMU to avoid magic "1".
> 
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx> # rename
> ---
> v2->v3:
> * no change
> 
> v1->v2:
> * no change
> 
> downstream->v1:
> * trivial rebase
> * s/dt_iommu_xlate/iommu_dt_xlate/
> 
> (cherry picked from commit c26bab0415ca303df86aba1d06ef8edc713734d3 from
>  the downstream branch poc/pci-passthrough from
>  https://gitlab.com/xen-project/people/bmarquis/xen-arm-poc.git)
> ---
>  xen/drivers/passthrough/device_tree.c | 42 +++++++++++++++++----------
>  1 file changed, 27 insertions(+), 15 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/device_tree.c 
> b/xen/drivers/passthrough/device_tree.c
> index b5bd13393b56..1b50f4670944 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -127,15 +127,39 @@ int iommu_release_dt_devices(struct domain *d)
>      return 0;
>  }
> 
> +/* This correlation must not be altered */
> +#define NO_IOMMU    1
> +
> +static int iommu_dt_xlate(struct device *dev,
> +                          struct dt_phandle_args *iommu_spec)
I think iommu_spec can be const.

> +{
> +    const struct iommu_ops *ops = iommu_get_ops();
> +    int rc;
> +
> +    if ( !dt_device_is_available(iommu_spec->np) )
> +        return NO_IOMMU;
> +
> +    rc = iommu_fwspec_init(dev, &iommu_spec->np->dev);
> +    if ( rc )
> +        return rc;
> +
> +    /*
> +     * Provide DT IOMMU specifier which describes the IOMMU master
> +     * interfaces of that device (device IDs, etc) to the driver.
> +     * The driver is responsible to decide how to interpret them.
> +     */
> +    return ops->dt_xlate(dev, iommu_spec);
Wouldn't it be better to move the check (!ops->dt_xlate) from 
iommu_add_dt_device to this helper?
After all it is the only function that calls dt_xlate so for me it would be a 
natural placement.
Looking at the next patch it will also reduce the similar check in 
iommu_add_dt_pci_sideband_ids.

~Michal



 


Rackspace

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