[v1] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have IPMMU-VMSA
diff mbox series

Message ID 20180726211916.10264-1-digetx@gmail.com
State New
Headers show
Series
  • [v1] iommu/ipmmu-vmsa: Don't register as BUS IOMMU if machine doesn't have IPMMU-VMSA
Related show

Commit Message

Dmitry Osipenko July 26, 2018, 9:19 p.m. UTC
This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
a multiplatform configuration and IPMMU-VMSA driver is enabled.

Cc: <stable@vger.kernel.org> # v3.20+
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/iommu/ipmmu-vmsa.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Joerg Roedel July 27, 2018, 7:51 a.m. UTC | #1
On Fri, Jul 27, 2018 at 12:19:16AM +0300, Dmitry Osipenko wrote:
> This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
> a multiplatform configuration and IPMMU-VMSA driver is enabled.
> 
> Cc: <stable@vger.kernel.org> # v3.20+
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Laurent Pinchart July 27, 2018, 9:10 a.m. UTC | #2
Hi Dmitry,

(CC'ing Geert and Magnus)

Thank you for the patch.

On Friday, 27 July 2018 00:19:16 EEST Dmitry Osipenko wrote:
> This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
> a multiplatform configuration and IPMMU-VMSA driver is enabled.
> 
> Cc: <stable@vger.kernel.org> # v3.20+
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 9e8495762bc8..78c50db9cd71 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1109,12 +1109,19 @@ static struct platform_driver ipmmu_driver = {
> 
>  static int __init ipmmu_init(void)
>  {
> +	struct device_node *np;
>  	static bool setup_done;
>  	int ret;
> 
>  	if (setup_done)
>  		return 0;
> 
> +	np = of_find_matching_node(NULL, ipmmu_of_ids);
> +	if (!np)
> +		return 0;
> +
> +	of_node_put(np);
> +

While functionally correct, this will add some unnecessary overhead when 
iommu_init() is called from IOMMU_OF_DECLARE(). I'm OK with this fix as a 
temporary measure to solve your problem, but we need to address the underlying 
issue properly.

Geert, Magnus, the ipmmu-vmsa driver is a bit of a mess. We should brush it up 
and start using IOMMU_OF_DECLARE() on all platforms (and eventually get rid of 
bus_set_iommu() completely...). Do you have plans to address this ? If not, 
could you please add it to your to-do list ?

>  	ret = platform_driver_register(&ipmmu_driver);
>  	if (ret < 0)
>  		return ret;
Geert Uytterhoeven Aug. 27, 2018, 2:20 p.m. UTC | #3
Hi Laurent,

On Fri, Jul 27, 2018 at 11:09 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> (CC'ing Geert and Magnus)
>
> Thank you for the patch.
>
> On Friday, 27 July 2018 00:19:16 EEST Dmitry Osipenko wrote:
> > This fixes kernel crashing on NVIDIA Tegra if kernel is compiled in
> > a multiplatform configuration and IPMMU-VMSA driver is enabled.
> >
> > Cc: <stable@vger.kernel.org> # v3.20+
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > ---
> >  drivers/iommu/ipmmu-vmsa.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> > index 9e8495762bc8..78c50db9cd71 100644
> > --- a/drivers/iommu/ipmmu-vmsa.c
> > +++ b/drivers/iommu/ipmmu-vmsa.c
> > @@ -1109,12 +1109,19 @@ static struct platform_driver ipmmu_driver = {
> >
> >  static int __init ipmmu_init(void)
> >  {
> > +     struct device_node *np;
> >       static bool setup_done;
> >       int ret;
> >
> >       if (setup_done)
> >               return 0;
> >
> > +     np = of_find_matching_node(NULL, ipmmu_of_ids);
> > +     if (!np)
> > +             return 0;
> > +
> > +     of_node_put(np);
> > +
>
> While functionally correct, this will add some unnecessary overhead when
> iommu_init() is called from IOMMU_OF_DECLARE(). I'm OK with this fix as a
> temporary measure to solve your problem, but we need to address the underlying
> issue properly.
>
> Geert, Magnus, the ipmmu-vmsa driver is a bit of a mess. We should brush it up
> and start using IOMMU_OF_DECLARE() on all platforms (and eventually get rid of
> bus_set_iommu() completely...). Do you have plans to address this ? If not,
> could you please add it to your to-do list ?

On the contrary: IOMMU_OF_DECLARE() has been removed.

>
> >       ret = platform_driver_register(&ipmmu_driver);
> >       if (ret < 0)
> >               return ret;

Gr{oetje,eeting}s,

                        Geert

Patch
diff mbox series

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 9e8495762bc8..78c50db9cd71 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1109,12 +1109,19 @@  static struct platform_driver ipmmu_driver = {
 
 static int __init ipmmu_init(void)
 {
+	struct device_node *np;
 	static bool setup_done;
 	int ret;
 
 	if (setup_done)
 		return 0;
 
+	np = of_find_matching_node(NULL, ipmmu_of_ids);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+
 	ret = platform_driver_register(&ipmmu_driver);
 	if (ret < 0)
 		return ret;