[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <01728f61-df0c-291d-5589-4468be25f00c@gmail.com>
Date: Wed, 30 Sep 2020 17:41:42 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Nicolin Chen <nicoleotsuka@...il.com>, thierry.reding@...il.com,
joro@...tes.org, krzk@...nel.org
Cc: vdumpa@...dia.com, jonathanh@...dia.com,
linux-tegra@...r.kernel.org, iommu@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and
.attach_dev
...
> + struct tegra_mc *mc = devm_tegra_get_memory_controller(dev);
> + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
>
> - of_node_put(args.np);
> - index++;
> - }
> + /* An invalid mc pointer means mc and smmu drivers are not ready */
> + if (IS_ERR(mc))
> + return ERR_PTR(-EPROBE_DEFER);
>
> - if (!smmu)
> + /*
> + * IOMMU core allows -ENODEV return to carry on. So bypass any call
> + * from bus_set_iommu() during tegra_smmu_probe(), as a device will
> + * call in again via of_iommu_configure when fwspec is prepared.
> + */
> + if (!mc->smmu || !fwspec || fwspec->ops != &tegra_smmu_ops)
> return ERR_PTR(-ENODEV);
>
> - return &smmu->iommu;
> + dev_iommu_priv_set(dev, mc->smmu);
> +
> + return &mc->smmu->iommu;
> }
Is it really okay to use devm_tegra_get_memory_controller() here?
I assume it should be more preferred to do it only for devices that have
fwspec->ops == &tegra_smmu_ops.
Secondly, it also looks to me that a non-devm variant should be more
appropriate here because tegra_smmu_probe_device() isn't invoked by the
devices themselves.
Powered by blists - more mailing lists