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

Re: [PATCH v1 4/6] pci/arm: Use iommu_add_dt_pci_device() instead of arch hook


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 2 May 2023 09:50:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=slYW9KRkZUY7iZeaVQfzOkx3O2g9GRcyd0agbY3CAwQ=; b=dry7INdnYsNVFGnMPxY12sJLAHSTp++OBkX3gBIgfRaCBlpt3x7oIseGbTx525u2SZuLkmFSq5mv8M0LZsP7lGIT7pleNBld5auNM1To6ewqx0zg1Cg4Dwlpd0YDiShq6x4Lkd9FzX/xP6ua/nXcdp26HOfb0H6AgHO+FCElmDLMSd0Ac7gVtKFx1g7OobifQEeC/2xSyp4V1kMOUfehm+wihdV3EndPxmBsZi1EVF0CrUHW6WrpJRCOOTf2YPaYelaO4mLoBWkIIZMhC9W4GAhpfw3uQ/oHNISESgESTlgmD3HfV9OynqP6KBXpLIrZfVSgzhl3pI4VQBW7uGJy2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxgGpEdCxhX8SEPQ22d/9zZfV8TsALWT/TM8iN0kTAkzpMBiS9BcL7exV3exbiYVH1d+4U0U1rn68sIxOxtHGY97K5LxhFeDJ2FVvhgZM/yYGscsFKImsllbqw86gInNBdQW11QNQ6ZGwN6U20GsZ20QAgTa7GVPivYLQHKNqwc99arKuVy+ICSS7fgKBV64yIfpmzHmwiSJ/2xAghhrj7rNeQpMJLWW1qjPN/Zli4tfRhCUfghIMPwafLYOuN6YyEH+XFmi2WIZQGXqazPKsAHYJqr+/nD/1MVUVGnYozRbdAu6mOqWQts0uYfZkUoYe/VF1i48m5ZM++Fvc5ocgA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 02 May 2023 07:50:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.05.2023 22:03, Stewart Hildebrand wrote:
> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -1305,7 +1305,7 @@ __initcall(setup_dump_pcidevs);
>  
>  static int iommu_add_device(struct pci_dev *pdev)
>  {
> -    const struct domain_iommu *hd;
> +    const struct domain_iommu *hd __maybe_unused;
>      int rc;
>      unsigned int devfn = pdev->devfn;
>  
> @@ -1318,17 +1318,30 @@ static int iommu_add_device(struct pci_dev *pdev)
>      if ( !is_iommu_enabled(pdev->domain) )
>          return 0;
>  
> +#ifdef CONFIG_HAS_DEVICE_TREE
> +    rc = iommu_add_dt_pci_device(devfn, pdev);
> +#else
>      rc = iommu_call(hd->platform_ops, add_device, devfn, pci_to_dev(pdev));
> -    if ( rc || !pdev->phantom_stride )
> +#endif
> +    if ( rc < 0 || !pdev->phantom_stride )
> +    {
> +        if ( rc < 0 )
> +            printk(XENLOG_WARNING "IOMMU: add %pp failed (%d)\n",
> +                   &pdev->sbdf, rc);
>          return rc;
> +    }
>  
>      for ( ; ; )
>      {
>          devfn += pdev->phantom_stride;
>          if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) )
>              return 0;
> +#ifdef CONFIG_HAS_DEVICE_TREE
> +        rc = iommu_add_dt_pci_device(devfn, pdev);
> +#else
>          rc = iommu_call(hd->platform_ops, add_device, devfn, 
> pci_to_dev(pdev));
> -        if ( rc )
> +#endif
> +        if ( rc < 0 )
>              printk(XENLOG_WARNING "IOMMU: add %pp failed (%d)\n",
>                     &PCI_SBDF(pdev->seg, pdev->bus, devfn), rc);
>      }

Such #ifdef-ary may be okay at the call site(s), but replacing a per-
IOMMU hook with a system-wide DT function here looks wrong to me. The
!= 0 => < 0 changes also would want, after respective auditing,
clarifying that they're indeed no functional change to existing code.

Jan



 


Rackspace

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