Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933448AbdGKOok (ORCPT ); Tue, 11 Jul 2017 10:44:40 -0400 Received: from gagarine.paulk.fr ([109.190.93.129]:49822 "EHLO gagarine.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933184AbdGKOoh (ORCPT ); Tue, 11 Jul 2017 10:44:37 -0400 Message-ID: <1499784254.1340.13.camel@paulk.fr> Subject: Re: [PATCH] gpu: host1x: Free the IOMMU domain when there is no device to attach From: Paul Kocialkowski To: Marcel Ziswiler , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" Cc: "jonathanh@nvidia.com" , "mperttunen@nvidia.com" , "treding@nvidia.com" , "swarren@nvidia.com" Date: Tue, 11 Jul 2017 17:44:14 +0300 In-Reply-To: <1499783851.1520.16.camel@toradex.com> References: <20170710193305.5987-1-contact@paulk.fr> <1499762987.1340.10.camel@paulk.fr> <1499783851.1520.16.camel@toradex.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2774 Lines: 82 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 > > . > > > 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 > 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/