From patchwork Fri May 5 13:23:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9713545 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E65E860362 for ; Fri, 5 May 2017 13:23:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D31DA28678 for ; Fri, 5 May 2017 13:23:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6624286BB; Fri, 5 May 2017 13:23:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50CE828678 for ; Fri, 5 May 2017 13:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbdEENXo (ORCPT ); Fri, 5 May 2017 09:23:44 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:34136 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbdEENXm (ORCPT ); Fri, 5 May 2017 09:23:42 -0400 Received: by mail-io0-f195.google.com with SMTP id 12so1383295iol.1; Fri, 05 May 2017 06:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5bp7leui+Wpg9dcnuHlFbT5sXSopR29DKHpibHCifl8=; b=WO8s61leLnEdm2EsyVrJWOxPMdDI+WQ72E4PtRaiOaqaUN4POtKqznA8KhoAwpFlMh MSCEwYNLkzgf/UkEJLWqzUXWSg2xOjtjhOBqVPi7h24A9CsOVmHLsYfV/fgX7ygaDqM/ HGljwX2bdB937RgAF1GbTw4/sVRJXarEqtH1TEa3QnNt++fWMnIpBzITQm+FYEY6uySq vkqvbXwy/7bxN0vANiO18CDwiRfPMXSZ+nh/RGTxm709BY1RAA99NiAlC2JIFBfbeQFF xgzlR8/X2s3He3OfuQ7CRQoSWgsl9Lk/61AxHRWzeDuu3pYsApKHnG4Q8t6P/NMd2S45 mbwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=5bp7leui+Wpg9dcnuHlFbT5sXSopR29DKHpibHCifl8=; b=U1sClZkUz7BpncN0lsUCrDu+q0oIhGq6SFyh9VYKDpmQfREx2t3359kgAeE0ZXev20 KSCDSbIsb1br3Aq/iB+/5CNOTN90aa0WmegD0ieOQevGMX2zNUgrJQAOPASkfaxIU7lE FxoOwLuHf8pOTcBDON6FRnHhKpT/I7+f2f8HpzteKKq6E+eBaYqNyVle5w2kCQvASPRC +/GzaLD2te9qy+09U6fOz747+1Yqke1WsG0Mq01A/iLTlnv5CJZNuHZWajSNrieDtEZy YtiPfLh9/+m4vpWi33qpjnTNIPVJvvpl+GjwbLfXn9dx/qvXF57zGGko7SM6BbKuaXrH douQ== X-Gm-Message-State: AN3rC/4aYEA/qPyjAQjWsIjYKM0kPzNuTXprOuih4ZegA/tczLqg7AlM 2Vv9TFRFS+C/SJYyz098QBIVIKdQyQ== X-Received: by 10.107.35.6 with SMTP id j6mr46683939ioj.77.1493990621336; Fri, 05 May 2017 06:23:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.39.212 with HTTP; Fri, 5 May 2017 06:23:40 -0700 (PDT) In-Reply-To: <26defadf-6380-4af4-6323-b51198376bc1@codeaurora.org> References: <1486136933-20328-1-git-send-email-sricharan@codeaurora.org> <1486136933-20328-8-git-send-email-sricharan@codeaurora.org> <2bfd11dc-9f94-2b69-7b03-c640e53155e1@arm.com> <26defadf-6380-4af4-6323-b51198376bc1@codeaurora.org> From: Geert Uytterhoeven Date: Fri, 5 May 2017 15:23:40 +0200 X-Google-Sender-Auth: z_6aXdOseH-Zh7Nr53ZkGW83Mok Message-ID: Subject: Re: [PATCH V8 07/11] iommu: of: Handle IOMMU lookup failure with deferred probing or error To: Sricharan R , Robin Murphy Cc: Will Deacon , Joerg Roedel , Lorenzo Pieralisi , iommu@lists.linux-foundation.org, "linux-arm-kernel@lists.infradead.org" , "linux-arm-msm@vger.kernel.org" , Marek Szyprowski , Bjorn Helgaas , linux-pci , ACPI Devel Maling List , tn@semihalf.com, Hanjun Guo , okaya@codeaurora.org, Magnus Damm , Linux-Renesas Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Sricharan, Robin, On Wed, May 3, 2017 at 12:24 PM, Sricharan R wrote: > On 5/3/2017 3:24 PM, Robin Murphy wrote: >> On 02/05/17 19:35, Geert Uytterhoeven wrote: >>> On Fri, Feb 3, 2017 at 4:48 PM, Sricharan R wrote: >>>> From: Laurent Pinchart >>>> >>>> Failures to look up an IOMMU when parsing the DT iommus property need to >>>> be handled separately from the .of_xlate() failures to support deferred >>>> probing. >>>> >>>> The lack of a registered IOMMU can be caused by the lack of a driver for >>>> the IOMMU, the IOMMU device probe not having been performed yet, having >>>> been deferred, or having failed. >>>> >>>> The first case occurs when the device tree describes the bus master and >>>> IOMMU topology correctly but no device driver exists for the IOMMU yet >>>> or the device driver has not been compiled in. Return NULL, the caller >>>> will configure the device without an IOMMU. >>>> >>>> The second and third cases are handled by deferring the probe of the bus >>>> master device which will eventually get reprobed after the IOMMU. >>>> >>>> The last case is currently handled by deferring the probe of the bus >>>> master device as well. A mechanism to either configure the bus master >>>> device without an IOMMU or to fail the bus master device probe depending >>>> on whether the IOMMU is optional or mandatory would be a good >>>> enhancement. >>>> >>>> Tested-by: Marek Szyprowski >>>> Signed-off-by: Laurent Pichart >>>> Signed-off-by: Sricharan R >>> >>> This patch broke Renesas R-Car Gen3 platforms in renesas-drivers. >>> As the IOMMU nodes in DT are not yet enabled, all devices having iommus >>> properties in DT now fail to probe. >> >> How exactly do they fail to probe? Per d7b0558230e4, if there are no ops >> registered then they should merely defer until we reach the point of >> giving up and ignoring the IOMMU. Is it just that you have no other >> late-probing drivers or post-init module loads to kick the deferred >> queue after that point? I did try to find a way to explicitly kick it >> from a suitably late initcall, but there didn't seem to be any obvious >> public interface - anyone have any suggestions? >> >> I think that's more of a general problem with the probe deferral >> mechanism itself (I've seen the same thing happen with some of the >> CoreSight stuff on Juno due to the number of inter-component >> dependencies) rather than any specific fault of this series. I had a deeper look into the issue. What changed, is that of_dma_configure() now returns an error code, and dma_configure() looks at it. Actually there are two failure modes: 1. Devices with an iommus property pointing to a disabled IOMMU node. These return -EPROBE_DEFER, and are now retried forever. 2. Devices that are blacklisted in the IPMMU driver, as we don't want to use them with an IOMMU yet. These return -ENODEV, due to ipmmu_of_xlate_dma(). > I was thinking of an additional check like below to avoid the > situation ? > > From 499b6e662f60f23740b8880882b0a16f16434501 Mon Sep 17 00:00:00 2001 > From: Sricharan R > Date: Wed, 3 May 2017 13:16:59 +0530 > Subject: [PATCH] iommu: of: Fix check for returning EPROBE_DEFER > > While returning EPROBE_DEFER for iommu masters > take in to account of iommu nodes that could be > marked in DT as 'status=disabled', in which case > simply return NULL and let the master's probe > continue rather than deferring. > > Signed-off-by: Sricharan R > --- > drivers/iommu/of_iommu.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index 9f44ee8..e6e9bec 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -118,6 +118,7 @@ static bool of_iommu_driver_present(struct device_node *np) > > ops = iommu_ops_from_fwnode(fwnode); > if ((ops && !ops->of_xlate) || > + !of_device_is_available(iommu_spec->np) || > (!ops && !of_iommu_driver_present(iommu_spec->np))) > return NULL; Thanks, this fixes the first class of failures. The second class can be worked around using: but obviously that's too hackish to apply... Magnus, do you have a suggestion? Thanks! Gr{oetje,eeting}s, Geert --- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -196,6 +196,11 @@ static const struct iommu_ops ops = of_iommu_xlate(dev, &iommu_spec); of_node_put(iommu_spec.np); idx++; + if (PTR_ERR(ops) == -ENODEV) { + dev_info(dev, "%s: Ignoring -ENODEV => NULL\n", + __func__); + return NULL; + } if (IS_ERR_OR_NULL(ops)) break; }