From: Eric Auger <eric.auger@redhat.com>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>, rafael@kernel.org
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
iommu@lists.linux.dev, linux-pci@vger.kernel.org,
helgaas@kernel.org
Subject: Re: [RESEND PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec
Date: Wed, 22 Mar 2023 11:04:48 +0100 [thread overview]
Message-ID: <1a227cc4-217b-01aa-ecee-9819160d9a44@redhat.com> (raw)
In-Reply-To: <20230320180528.281755-1-jean-philippe@linaro.org>
Hi Jean,
On 3/20/23 19:05, Jean-Philippe Brucker wrote:
> When setting up DMA for a PCI device, we need to initialize its
> iommu_fwspec with all possible alias RIDs (such as PCI bridges). To do
> this we use pci_for_each_dma_alias() which calls
> viot_pci_dev_iommu_init(). This function incorrectly initializes the
> fwspec of the bridge instead of the device being configured. Fix it by
> passing the original device as context to pci_for_each_dma_alias().
>
> Fixes: 3cf485540e7b ("ACPI: Add driver for the VIOT table")
> Reported-by: Eric Auger <eric.auger@redhat.com>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
With this patch the pcie-to-pci bridge is assigned an iommu group.
The iommu group topology is not yet correct (ie. end points downstream
to the pcie-to-pci bridge are put in a separate iommu group) however
this is not related to that patch and not supposed to be fixed here
(https://lore.kernel.org/all/4fead092-1058-198a-b430-3dee0fffcd51@arm.com/)
Thanks
Eric
> ---
> This fixes issue (1) reported here:
> https://lore.kernel.org/all/Y8qzOKm6kvhGWG1T@myrica/
>
> resend: Added linux-pci list
> ---
> drivers/acpi/viot.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
> index ed752cbbe636..c8025921c129 100644
> --- a/drivers/acpi/viot.c
> +++ b/drivers/acpi/viot.c
> @@ -328,6 +328,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
> {
> u32 epid;
> struct viot_endpoint *ep;
> + struct device *aliased_dev = data;
> u32 domain_nr = pci_domain_nr(pdev->bus);
>
> list_for_each_entry(ep, &viot_pci_ranges, list) {
> @@ -338,7 +339,7 @@ static int viot_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, void *data)
> epid = ((domain_nr - ep->segment_start) << 16) +
> dev_id - ep->bdf_start + ep->endpoint_id;
>
> - return viot_dev_iommu_init(&pdev->dev, ep->viommu,
> + return viot_dev_iommu_init(aliased_dev, ep->viommu,
> epid);
> }
> }
> @@ -372,7 +373,7 @@ int viot_iommu_configure(struct device *dev)
> {
> if (dev_is_pci(dev))
> return pci_for_each_dma_alias(to_pci_dev(dev),
> - viot_pci_dev_iommu_init, NULL);
> + viot_pci_dev_iommu_init, dev);
> else if (dev_is_platform(dev))
> return viot_mmio_dev_iommu_init(to_platform_device(dev));
> return -ENODEV;
next prev parent reply other threads:[~2023-03-22 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 18:05 [RESEND PATCH] ACPI: VIOT: Initialize the correct IOMMU fwspec Jean-Philippe Brucker
2023-03-22 10:04 ` Eric Auger [this message]
2023-03-30 17:22 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a227cc4-217b-01aa-ecee-9819160d9a44@redhat.com \
--to=eric.auger@redhat.com \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).