Re: [PATCH 4/5] iommu/tegra-smmu: Add PCI support

From: Nicolin Chen
Date: Mon Sep 28 2020 - 19:15:00 EST


On Mon, Sep 28, 2020 at 09:55:45AM +0200, Thierry Reding wrote:
> On Sat, Sep 26, 2020 at 01:07:18AM -0700, Nicolin Chen wrote:
> > +#ifdef CONFIG_PCI
> > + if (!iommu_present(&pci_bus_type)) {
> > + pci_request_acs();
> > + err = bus_set_iommu(&pci_bus_type, &tegra_smmu_ops);
> > + if (err < 0) {
> > + bus_set_iommu(&platform_bus_type, NULL);
> > + iommu_device_unregister(&smmu->iommu);
> > + iommu_device_sysfs_remove(&smmu->iommu);
> > + return ERR_PTR(err);
>
> It might be worth factoring out the cleanup code now that there are
> multiple failures from which we may need to clean up.

Will do.

> Also, it'd be great if somehow we could do this without the #ifdef,
> but I guess since we're using the pci_bus_type global variable directly,
> there isn't much we can do here?

Probably no -- both pci_bus_type and pci_request_acs seem to depend
on it.