Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:20:50AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:10, Dmitry Osipenko пишет: > > 30.09.2020 03:30, Nicolin Chen пишет: > >> static void tegra_smmu_release_device(struct device *dev) > > > > The tegra_get_memory_controller() uses of_find_device_by_node(), hence > > t

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 09:13, Nicolin Chen пишет: > On Wed, Sep 30, 2020 at 09:10:38AM +0300, Dmitry Osipenko wrote: >> 30.09.2020 08:49, Nicolin Chen пишет: >>> On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: 30.09.2020 03:30, Nicolin Chen пишет: > + /* An invalid mc pointer means mc

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:59:45AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:41, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:39:54AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> static int tegra_smmu_attach_dev(struct iommu_domain *domain, > >>>

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 09:10:38AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:49, Nicolin Chen пишет: > > On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: > >> 30.09.2020 03:30, Nicolin Chen пишет: > >>> + /* An invalid mc pointer means mc and smmu drivers are not ready */ > >>>

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 08:49, Nicolin Chen пишет: > On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: >> 30.09.2020 03:30, Nicolin Chen пишет: >>> + /* An invalid mc pointer means mc and smmu drivers are not ready */ >>> + if (IS_ERR_OR_NULL(mc)) >> >> tegra_get_memory_controller() doesn't r

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 08:41, Nicolin Chen пишет: > On Wed, Sep 30, 2020 at 08:39:54AM +0300, Dmitry Osipenko wrote: >> 30.09.2020 03:30, Nicolin Chen пишет: >>> static int tegra_smmu_attach_dev(struct iommu_domain *domain, >>> struct device *dev) >>> { >>> + struct iommu_fwspe

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:20:50AM +0300, Dmitry Osipenko wrote: > 30.09.2020 08:10, Dmitry Osipenko пишет: > > 30.09.2020 03:30, Nicolin Chen пишет: > >> static void tegra_smmu_release_device(struct device *dev) > > > > The tegra_get_memory_controller() uses of_find_device_by_node(), hence > > t

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:11:52AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > + /* An invalid mc pointer means mc and smmu drivers are not ready */ > > + if (IS_ERR_OR_NULL(mc)) > > tegra_get_memory_controller() doesn't return NULL. Well, I don't want to assume

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 08:39, Nicolin Chen пишет: > On Wed, Sep 30, 2020 at 08:24:02AM +0300, Dmitry Osipenko wrote: >> 30.09.2020 03:30, Nicolin Chen пишет: >>> + /* >>> +* IOMMU core allows -ENODEV return to carry on. So bypass any call >>> +* from bus_set_iommu() during tegra_smmu_probe(), as a de

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:39:54AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > static int tegra_smmu_attach_dev(struct iommu_domain *domain, > > struct device *dev) > > { > > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); >

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
On Wed, Sep 30, 2020 at 08:24:02AM +0300, Dmitry Osipenko wrote: > 30.09.2020 03:30, Nicolin Chen пишет: > > + /* > > +* 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

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 03:30, Nicolin Chen пишет: > static int tegra_smmu_attach_dev(struct iommu_domain *domain, >struct device *dev) > { > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > struct tegra_smmu *smmu = dev_iommu_priv_get(dev); > struct

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 03:30, Nicolin Chen пишет: > + /* > + * 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 (!

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 08:10, Dmitry Osipenko пишет: > 30.09.2020 03:30, Nicolin Chen пишет: >> static void tegra_smmu_release_device(struct device *dev) > > The tegra_get_memory_controller() uses of_find_device_by_node(), hence > tegra_smmu_release_device() should put_device(mc) in order to balance > back t

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 03:30, Nicolin Chen пишет: > + /* An invalid mc pointer means mc and smmu drivers are not ready */ > + if (IS_ERR_OR_NULL(mc)) tegra_get_memory_controller() doesn't return NULL. > + return ERR_PTR(-EPROBE_DEFER); ___ iomm

Re: [PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Dmitry Osipenko
30.09.2020 03:30, Nicolin Chen пишет: > static void tegra_smmu_release_device(struct device *dev) The tegra_get_memory_controller() uses of_find_device_by_node(), hence tegra_smmu_release_device() should put_device(mc) in order to balance back the refcounting.

[PATCH v2 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev

2020-09-29 Thread Nicolin Chen
Previously the driver relies on bus_set_iommu() in .probe() to call in .probe_device() function so each client can poll iommus property in DTB to configure fwspec via tegra_smmu_configure(). According to the comments in .probe(), this is a bit of a hack. And this doesn't work for a client that does