Re: [PATCH v2 3/4] ACPI: scan: Add support for LoongArch in acpi_iommu_configure_id()
"Rafael J. Wysocki (Intel)" <[email protected]> Tue, 21 Jul 2026 21:07:35 +0200
| Newsgroups | dev.linux.lists.acpica-devel,dev.linux.lists.loongarch,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAJZ5v0gupBWfJu-Mh73N8AjgBBHXBirhzKE9Byc=Cp+ULZNVkA@mail.gmail.com> |
On Fri, Jul 17, 2026 at 8:44=E2=80=AFAM Bibo Mao <[email protected]> wrot= e: > > acpi_iommu_configure_id() currently supports only IORT and VIOT. Add > support for IOVT as well. > > Signed-off-by: Bibo Mao <[email protected]> The one-liner in scan.c is fine with me, so Acked-by: Rafael J. Wysocki (Intel) <[email protected]> # ACPI core for this one, but conditional on the acceptance of the Loongarch-specific p= arts. Thanks! > --- > drivers/acpi/loongarch/iovt.c | 61 +++++++++++++++++++++++++++++++++++ > drivers/acpi/scan.c | 3 ++ > include/linux/acpi_iovt.h | 13 ++++++++ > 3 files changed, 77 insertions(+) > create mode 100644 include/linux/acpi_iovt.h > > diff --git a/drivers/acpi/loongarch/iovt.c b/drivers/acpi/loongarch/iovt.= c > index fb384664ba78..09fcf09e0f85 100644 > --- a/drivers/acpi/loongarch/iovt.c > +++ b/drivers/acpi/loongarch/iovt.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0-only > > #include <linux/acpi.h> > +#include <linux/acpi_iovt.h> > #include <linux/pci.h> > #include "init.h" > > @@ -217,3 +218,63 @@ void __init acpi_iovt_late_init(void) > iovt_init_devices(hdr); > acpi_put_table(hdr); > } > + > +static int iovt_pci_dev_iommu_init(struct pci_dev *pdev, u16 dev_id, voi= d *data) > +{ > + u32 sbdf; > + struct iovt_fwnode *np; > + struct device *aliased_dev =3D data; > + u32 domain =3D pci_domain_nr(pdev->bus); > + struct iovt_device_entry *entry; > + bool found =3D false; > + > + list_for_each_entry(np, &iovt_fwnode_list, list) { > + if (domain !=3D np->segment) > + continue; > + > + /* We're not translating ourself */ > + if (dev_id =3D=3D np->devid) > + return -EINVAL; > + > + if (np->flag & ACPI_IOVT_MAGAGE_BY_SEGMENT) { > + found =3D true; > + break; > + } > + > + list_for_each_entry(entry, &np->ep_list, list) { > + if (dev_id < entry->start_devid) > + continue; > + > + if (dev_id > entry->end_devid) > + continue; > + > + found =3D true; > + break; > + } > + > + if (found) > + break; > + } > + > + if (!found) > + return -ENODEV; > + > + sbdf =3D (domain << 16) + dev_id; > + return acpi_iommu_fwspec_init(aliased_dev, sbdf, np->fwnode); > +} > + > +/* > + * iovt_iommu_configure_id - Set-up IOMMU configuration for a device. > + * > + * @dev: device to configure > + * @id_in: optional input id const value pointer > + * > + * Returns: 0 on success, <0 on failure > + */ > +int iovt_iommu_configure_id(struct device *dev, const u32 *id_in) > +{ > + if (!dev_is_pci(dev)) > + return -ENODEV; > + > + return pci_for_each_dma_alias(to_pci_dev(dev), iovt_pci_dev_iommu= _init, dev); > +} > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 9a7ac2eb9ce0..508575f25e10 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -13,6 +13,7 @@ > #include <linux/kernel.h> > #include <linux/acpi.h> > #include <linux/acpi_iort.h> > +#include <linux/acpi_iovt.h> > #include <linux/acpi_rimt.h> > #include <linux/acpi_viot.h> > #include <linux/iommu.h> > @@ -1629,6 +1630,8 @@ static int acpi_iommu_configure_id(struct device *d= ev, const u32 *id_in) > err =3D rimt_iommu_configure_id(dev, id_in); > if (err && err !=3D -EPROBE_DEFER) > err =3D viot_iommu_configure(dev); > + if (err && err !=3D -EPROBE_DEFER) > + err =3D iovt_iommu_configure_id(dev, id_in); > > mutex_unlock(&iommu_probe_device_lock); > > diff --git a/include/linux/acpi_iovt.h b/include/linux/acpi_iovt.h > new file mode 100644 > index 000000000000..25a846b96260 > --- /dev/null > +++ b/include/linux/acpi_iovt.h > @@ -0,0 +1,13 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#ifndef __ACPI_IOVT_H__ > +#define __ACPI_IOVT_H__ > + > +#if defined(CONFIG_IOMMU_API) && defined(CONFIG_ACPI_IOVT) > +int iovt_iommu_configure_id(struct device *dev, const u32 *id_in); > +#else > +static inline int iovt_iommu_configure_id(struct device *dev, const u32 = *id_in) > +{ return -ENODEV; } > +#endif > + > +#endif > -- > 2.39.3 >