Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1684602 > unrolled thread

[PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

Started byPaul Kocialkowski <contact@paulk.fr>
First post2017-07-10 21:40 +0200
Last post2017-07-27 18:50 +0200
Articles 8 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach Paul Kocialkowski <contact@paulk.fr> - 2017-07-10 21:40 +0200
    Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Mikko Perttunen <cyndis@kapsi.fi> - 2017-07-11 08:50 +0200
      Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Jon Hunter <jonathanh@nvidia.com> - 2017-07-18 11:20 +0200
    Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Paul Kocialkowski <contact@paulk.fr> - 2017-07-11 11:00 +0200
      Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Marcel Ziswiler <marcel.ziswiler@toradex.com> - 2017-07-11 16:40 +0200
        Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Paul Kocialkowski <contact@paulk.fr> - 2017-07-11 16:50 +0200
          Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Mikko Perttunen <cyndis@kapsi.fi> - 2017-07-11 19:20 +0200
    Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no  device to attach Thierry Reding <thierry.reding@gmail.com> - 2017-07-27 18:50 +0200

#1684602 — [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromPaul Kocialkowski <contact@paulk.fr>
Date2017-07-10 21:40 +0200
Subject[PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u1MHf-HI-5@gated-at.bofh.it>
When there is no device to attach to the IOMMU domain, as may be the
case when the device-tree does not contain the proper iommu node, it is
best to keep going without IOMMU support rather than failing.
This allows the driver to probe and function instead of taking down
all of the tegra drm driver, leading to missing display support.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 drivers/gpu/host1x/dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index ac65f52850a6..f296738d0de8 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -186,8 +186,13 @@ static int host1x_probe(struct platform_device *pdev)
 			return -ENOMEM;
 
 		err = iommu_attach_device(host->domain, &pdev->dev);
-		if (err)
+		if (err == -ENODEV) {
+			iommu_domain_free(host->domain);
+			host->domain = NULL;
+			goto iommu_skip;
+		} else if (err) {
 			goto fail_free_domain;
+		}
 
 		geometry = &host->domain->geometry;
 
@@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device *pdev)
 		host->iova_end = geometry->aperture_end;
 	}
 
+iommu_skip:
 	err = host1x_channel_list_init(host);
 	if (err) {
 		dev_err(&pdev->dev, "failed to initialize channel list\n");
-- 
2.13.1

[toc] | [next] | [standalone]


#1684806 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromMikko Perttunen <cyndis@kapsi.fi>
Date2017-07-11 08:50 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u1X9D-7ho-15@gated-at.bofh.it>
In reply to#1684602
Thanks for the patch, didn't consider this case. I really need to get 
together some system to automatically test on multiple platforms.. :)

Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>

On 10.07.2017 22:33, Paul Kocialkowski wrote:
> When there is no device to attach to the IOMMU domain, as may be the
> case when the device-tree does not contain the proper iommu node, it is
> best to keep going without IOMMU support rather than failing.
> This allows the driver to probe and function instead of taking down
> all of the tegra drm driver, leading to missing display support.
>
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  drivers/gpu/host1x/dev.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
> index ac65f52850a6..f296738d0de8 100644
> --- a/drivers/gpu/host1x/dev.c
> +++ b/drivers/gpu/host1x/dev.c
> @@ -186,8 +186,13 @@ static int host1x_probe(struct platform_device *pdev)
>  			return -ENOMEM;
>
>  		err = iommu_attach_device(host->domain, &pdev->dev);
> -		if (err)
> +		if (err == -ENODEV) {
> +			iommu_domain_free(host->domain);
> +			host->domain = NULL;
> +			goto iommu_skip;
> +		} else if (err) {
>  			goto fail_free_domain;
> +		}
>
>  		geometry = &host->domain->geometry;
>
> @@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device *pdev)
>  		host->iova_end = geometry->aperture_end;
>  	}
>
> +iommu_skip:
>  	err = host1x_channel_list_init(host);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to initialize channel list\n");
>

[toc] | [prev] | [next] | [standalone]


#1689911 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromJon Hunter <jonathanh@nvidia.com>
Date2017-07-18 11:20 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u4wPE-w0-25@gated-at.bofh.it>
In reply to#1684806
Hi Mikko,

On 11/07/17 07:43, Mikko Perttunen wrote:
> Thanks for the patch, didn't consider this case. I really need to get
> together some system to automatically test on multiple platforms.. :)
We already have the infrastructure in place to do this, however, at the
moment we are just making sure the platforms boot. Something like this
we should be able to catch, even if we don't explicitly test display/hdmi.

I was thinking that we could parse the /dev and /sys file-systems to
ensure that devices for a given platform are present after boot. I am
not sure if there is a good way to do this, but if you have any
thoughts, then I am willing to add more testing.

What is interesting about this case, was that there were no specific
error messages that indicated this had broken AFAICT.

Cheers
Jon

-- 
nvpublic

[toc] | [prev] | [next] | [standalone]


#1684888 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromPaul Kocialkowski <contact@paulk.fr>
Date2017-07-11 11:00 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u1Zbs-8vM-19@gated-at.bofh.it>
In reply to#1684602
On Mon, 2017-07-10 at 21:33 +0200, Paul Kocialkowski wrote:
> When there is no device to attach to the IOMMU domain, as may be the
> case when the device-tree does not contain the proper iommu node, it
> is
> best to keep going without IOMMU support rather than failing.
> This allows the driver to probe and function instead of taking down
> all of the tegra drm driver, leading to missing display support.

Fixes: 404bfb78daf3 ("gpu: host1x: Add IOMMU support")

> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  drivers/gpu/host1x/dev.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
> index ac65f52850a6..f296738d0de8 100644
> --- a/drivers/gpu/host1x/dev.c
> +++ b/drivers/gpu/host1x/dev.c
> @@ -186,8 +186,13 @@ static int host1x_probe(struct platform_device
> *pdev)
>  			return -ENOMEM;
>  
>  		err = iommu_attach_device(host->domain, &pdev->dev);
> -		if (err)
> +		if (err == -ENODEV) {
> +			iommu_domain_free(host->domain);
> +			host->domain = NULL;
> +			goto iommu_skip;
> +		} else if (err) {
>  			goto fail_free_domain;
> +		}
>  
>  		geometry = &host->domain->geometry;
>  
> @@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device
> *pdev)
>  		host->iova_end = geometry->aperture_end;
>  	}
>  
> +iommu_skip:
>  	err = host1x_channel_list_init(host);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to initialize channel
> list\n");
-- 
Paul Kocialkowski,

developer of free digital technology and hardware support

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/

[toc] | [prev] | [next] | [standalone]


#1685079 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromMarcel Ziswiler <marcel.ziswiler@toradex.com>
Date2017-07-11 16:40 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u24uu-3uu-15@gated-at.bofh.it>
In reply to#1684888
On Tue, 2017-07-11 at 11:49 +0300, Paul Kocialkowski wrote:
> On Mon, 2017-07-10 at 21:33 +0200, Paul Kocialkowski wrote:
> > When there is no device to attach to the IOMMU domain, as may be
> > the
> > case when the device-tree does not contain the proper iommu node,
> > it
> > is
> > best to keep going without IOMMU support rather than failing.
> > This allows the driver to probe and function instead of taking down
> > all of the tegra drm driver, leading to missing display support.
> 
> Fixes: 404bfb78daf3 ("gpu: host1x: Add IOMMU support")
> 
> > Signed-off-by: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.
> > org>
> > ---
> >  drivers/gpu/host1x/dev.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
> > index ac65f52850a6..f296738d0de8 100644
> > --- a/drivers/gpu/host1x/dev.c
> > +++ b/drivers/gpu/host1x/dev.c
> > @@ -186,8 +186,13 @@ static int host1x_probe(struct platform_device
> > *pdev)
> >  			return -ENOMEM;
> >  
> >  		err = iommu_attach_device(host->domain, &pdev-
> > >dev);
> > -		if (err)
> > +		if (err == -ENODEV) {
> > +			iommu_domain_free(host->domain);
> > +			host->domain = NULL;
> > +			goto iommu_skip;
> > +		} else if (err) {
> >  			goto fail_free_domain;
> > +		}
> >  
> >  		geometry = &host->domain->geometry;
> >  
> > @@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device
> > *pdev)
> >  		host->iova_end = geometry->aperture_end;
> >  	}
> >  
> > +iommu_skip:
> >  	err = host1x_channel_list_init(host);
> >  	if (err) {
> >  		dev_err(&pdev->dev, "failed to initialize channel
> > list\n");

Please note that this does no longer cleanly apply after Mikko's 'gpu:
host1x: Refactor channel allocation code' commit from June 15 already
applied to current -next. Other than that

Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Apalis TK1, Apalis T30, Beaver, Colibri T30, Jetson-TK1

Finally graphics working again, thanks guys!

[toc] | [prev] | [next] | [standalone]


#1685087 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromPaul Kocialkowski <contact@paulk.fr>
Date2017-07-11 16:50 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u24E9-3xP-5@gated-at.bofh.it>
In reply to#1685079
On Tue, 2017-07-11 at 14:37 +0000, Marcel Ziswiler wrote:
> On Tue, 2017-07-11 at 11:49 +0300, Paul Kocialkowski wrote:
> > On Mon, 2017-07-10 at 21:33 +0200, Paul Kocialkowski wrote:
> > > When there is no device to attach to the IOMMU domain, as may be
> > > the
> > > case when the device-tree does not contain the proper iommu node,
> > > it
> > > is
> > > best to keep going without IOMMU support rather than failing.
> > > This allows the driver to probe and function instead of taking
> > > down
> > > all of the tegra drm driver, leading to missing display support.
> > 
> > Fixes: 404bfb78daf3 ("gpu: host1x: Add IOMMU support")
> > 
> > > Signed-off-by: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane
> > > .
> > > org>
> > > ---
> > >  drivers/gpu/host1x/dev.c | 8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
> > > index ac65f52850a6..f296738d0de8 100644
> > > --- a/drivers/gpu/host1x/dev.c
> > > +++ b/drivers/gpu/host1x/dev.c
> > > @@ -186,8 +186,13 @@ static int host1x_probe(struct
> > > platform_device
> > > *pdev)
> > >  			return -ENOMEM;
> > >  
> > >  		err = iommu_attach_device(host->domain, &pdev-
> > > > dev);
> > > 
> > > -		if (err)
> > > +		if (err == -ENODEV) {
> > > +			iommu_domain_free(host->domain);
> > > +			host->domain = NULL;
> > > +			goto iommu_skip;
> > > +		} else if (err) {
> > >  			goto fail_free_domain;
> > > +		}
> > >  
> > >  		geometry = &host->domain->geometry;
> > >  
> > > @@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device
> > > *pdev)
> > >  		host->iova_end = geometry->aperture_end;
> > >  	}
> > >  
> > > +iommu_skip:
> > >  	err = host1x_channel_list_init(host);
> > >  	if (err) {
> > >  		dev_err(&pdev->dev, "failed to initialize channel
> > > list\n");
> 
> Please note that this does no longer cleanly apply after Mikko's 'gpu:
> host1x: Refactor channel allocation code' commit from June 15 already
> applied to current -next. Other than that

Good to know! I intended this patch for fixing 4.12 stable, so I'm not
even entirely sure it should land in next. The patch that fixes the
device-tree to actually enable the iommu should be merged in priority.

If that is the case and anyone wants this patch rebased to next, feel
free to let me know and I'll send a rebased version.

> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-on: Apalis TK1, Apalis T30, Beaver, Colibri T30, Jetson-TK1
> 
> Finally graphics working again, thanks guys!

Yay! :)

-- 
Paul Kocialkowski,

developer of free digital technology and hardware support

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/

[toc] | [prev] | [next] | [standalone]


#1685223 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromMikko Perttunen <cyndis@kapsi.fi>
Date2017-07-11 19:20 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u26Zk-59q-5@gated-at.bofh.it>
In reply to#1685087
On 07/11/2017 05:44 PM, Paul Kocialkowski wrote:
> On Tue, 2017-07-11 at 14:37 +0000, Marcel Ziswiler wrote:
>> On Tue, 2017-07-11 at 11:49 +0300, Paul Kocialkowski wrote:
>>> On Mon, 2017-07-10 at 21:33 +0200, Paul Kocialkowski wrote:
>>>> When there is no device to attach to the IOMMU domain, as may be
>>>> the
>>>> case when the device-tree does not contain the proper iommu node,
>>>> it
>>>> is
>>>> best to keep going without IOMMU support rather than failing.
>>>> This allows the driver to probe and function instead of taking
>>>> down
>>>> all of the tegra drm driver, leading to missing display support.
>>>
>>> Fixes: 404bfb78daf3 ("gpu: host1x: Add IOMMU support")
>>>
>>>> Signed-off-by: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane
>>>> .
>>>> org>
>>>> ---
>>>>   drivers/gpu/host1x/dev.c | 8 +++++++-
>>>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
>>>> index ac65f52850a6..f296738d0de8 100644
>>>> --- a/drivers/gpu/host1x/dev.c
>>>> +++ b/drivers/gpu/host1x/dev.c
>>>> @@ -186,8 +186,13 @@ static int host1x_probe(struct
>>>> platform_device
>>>> *pdev)
>>>>   			return -ENOMEM;
>>>>   
>>>>   		err = iommu_attach_device(host->domain, &pdev-
>>>>> dev);
>>>>
>>>> -		if (err)
>>>> +		if (err == -ENODEV) {
>>>> +			iommu_domain_free(host->domain);
>>>> +			host->domain = NULL;
>>>> +			goto iommu_skip;
>>>> +		} else if (err) {
>>>>   			goto fail_free_domain;
>>>> +		}
>>>>   
>>>>   		geometry = &host->domain->geometry;
>>>>   
>>>> @@ -198,6 +203,7 @@ static int host1x_probe(struct platform_device
>>>> *pdev)
>>>>   		host->iova_end = geometry->aperture_end;
>>>>   	}
>>>>   
>>>> +iommu_skip:
>>>>   	err = host1x_channel_list_init(host);
>>>>   	if (err) {
>>>>   		dev_err(&pdev->dev, "failed to initialize channel
>>>> list\n");
>>
>> Please note that this does no longer cleanly apply after Mikko's 'gpu:
>> host1x: Refactor channel allocation code' commit from June 15 already
>> applied to current -next. Other than that
> 
> Good to know! I intended this patch for fixing 4.12 stable, so I'm not
> even entirely sure it should land in next. The patch that fixes the
> device-tree to actually enable the iommu should be merged in priority.
> 
> If that is the case and anyone wants this patch rebased to next, feel
> free to let me know and I'll send a rebased version.

We should definitely have this for non-stable kernels too - it would be 
a bit strange if the driver worked if IOMMU support wasn't built into 
the kernel but failed if it was :) It can also be helpful for debugging 
to be able to disable IOMMU just for host1x.

> 
>> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>> Tested-on: Apalis TK1, Apalis T30, Beaver, Colibri T30, Jetson-TK1
>>
>> Finally graphics working again, thanks guys!
> 
> Yay! :)
> 

[toc] | [prev] | [next] | [standalone]


#1698186 — Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach

FromThierry Reding <thierry.reding@gmail.com>
Date2017-07-27 18:50 +0200
SubjectRe: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach
Message-ID<u7U95-8vc-27@gated-at.bofh.it>
In reply to#1684602

[Multipart message — attachments visible in raw view] — view raw

On Mon, Jul 10, 2017 at 09:33:05PM +0200, Paul Kocialkowski wrote:
> When there is no device to attach to the IOMMU domain, as may be the
> case when the device-tree does not contain the proper iommu node, it is
> best to keep going without IOMMU support rather than failing.
> This allows the driver to probe and function instead of taking down
> all of the tegra drm driver, leading to missing display support.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  drivers/gpu/host1x/dev.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Applied to drm-misc-fixes, thanks.

Oh, just noticed now that this didn't actually go to the DRM mailing
list (dri-devel@lists.freedesktop.org). Might be a good idea to do that
next time to get more visibility.

Thierry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web