Re: [PATCH v4 2/3] iommu/tegra-smmu: Rework tegra_smmu_probe_device()
From: Nicolin Chen
Date: Fri Oct 02 2020 - 14:07:39 EST
On Fri, Oct 02, 2020 at 05:23:14PM +0300, Dmitry Osipenko wrote:
> 02.10.2020 09:08, Nicolin Chen пишет:
> > static struct iommu_device *tegra_smmu_probe_device(struct device *dev)
> > {
> > - struct device_node *np = dev->of_node;
> > - struct tegra_smmu *smmu = NULL;
> > - struct of_phandle_args args;
> > - unsigned int index = 0;
> > - int err;
> > -
> > - while (of_parse_phandle_with_args(np, "iommus", "#iommu-cells", index,
> > - &args) == 0) {
> > - smmu = tegra_smmu_find(args.np);
> > - if (smmu) {
> > - err = tegra_smmu_configure(smmu, dev, &args);
> > - of_node_put(args.np);
> > -
> > - if (err < 0)
> > - return ERR_PTR(err);
> > -
> > - /*
> > - * Only a single IOMMU master interface is currently
> > - * supported by the Linux kernel, so abort after the
> > - * first match.
> > - */
> > - dev_iommu_priv_set(dev, smmu);
> > -
> > - break;
> > - }
> > -
> > - of_node_put(args.np);
> > - index++;
> > - }
> > + struct tegra_smmu *smmu = dev_iommu_priv_get(dev);
> >
> > if (!smmu)
> > return ERR_PTR(-ENODEV);
>
> The !smmu can't ever be true now, isn't it? Then please remove it.
How can you be so sure? Have you read my commit message? The whole
point of removing the hack in tegra_smmu_probe() is to return the
ERR_PTR(-ENODEV) here. The bus_set_iommu() will call this function
when mc->smmu is not assigned it, as it's assigned after we return
tegra_smmu_probe() while bus_set_iommu() is still in the middle of
the tegra_smmu_probe().