From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756267AbeAHLpH (ORCPT + 1 other); Mon, 8 Jan 2018 06:45:07 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:37370 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756014AbeAHLpG (ORCPT ); Mon, 8 Jan 2018 06:45:06 -0500 Subject: Re: [PATCH] iommu/of: Only do IOMMU lookup for available ones To: Jeffy Chen , linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, iommu@lists.linux-foundation.org References: <20180103060920.23475-1-jeffy.chen@rock-chips.com> From: Robin Murphy Message-ID: <767a9f59-be14-2103-6675-a2028742e663@arm.com> Date: Mon, 8 Jan 2018 11:45:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180103060920.23475-1-jeffy.chen@rock-chips.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Jeffy, On 03/01/18 06:09, Jeffy Chen wrote: > The for_each_matching_node_and_match() would return every matching > nodes including unavailable ones. > > It's pointless to init unavailable IOMMUs, so add a sanity check to > avoid that. Even better would be to clean up the last remaining init_fn user and get rid of the whole business. With the probe-deferral mechanism, early initialisation hooks are no longer needed, and the IOMMU_OF_DECLARE section really only remains as a way of detecting builtin drivers long before their registration initcalls run. Robin. > Signed-off-by: Jeffy Chen > --- > > drivers/iommu/of_iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index 50947ebb6d17..6f7456caa30d 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -240,6 +240,9 @@ static int __init of_iommu_init(void) > for_each_matching_node_and_match(np, matches, &match) { > const of_iommu_init_fn init_fn = match->data; > > + if (!of_device_is_available(np)) > + continue; > + > if (init_fn && init_fn(np)) > pr_err("Failed to initialise IOMMU %pOF\n", np); > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Murphy Subject: Re: [PATCH] iommu/of: Only do IOMMU lookup for available ones Date: Mon, 8 Jan 2018 11:45:03 +0000 Message-ID: <767a9f59-be14-2103-6675-a2028742e663@arm.com> References: <20180103060920.23475-1-jeffy.chen@rock-chips.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180103060920.23475-1-jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org> Content-Language: en-GB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Jeffy Chen , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: jcliang-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: iommu@lists.linux-foundation.org Hi Jeffy, On 03/01/18 06:09, Jeffy Chen wrote: > The for_each_matching_node_and_match() would return every matching > nodes including unavailable ones. > > It's pointless to init unavailable IOMMUs, so add a sanity check to > avoid that. Even better would be to clean up the last remaining init_fn user and get rid of the whole business. With the probe-deferral mechanism, early initialisation hooks are no longer needed, and the IOMMU_OF_DECLARE section really only remains as a way of detecting builtin drivers long before their registration initcalls run. Robin. > Signed-off-by: Jeffy Chen > --- > > drivers/iommu/of_iommu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index 50947ebb6d17..6f7456caa30d 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -240,6 +240,9 @@ static int __init of_iommu_init(void) > for_each_matching_node_and_match(np, matches, &match) { > const of_iommu_init_fn init_fn = match->data; > > + if (!of_device_is_available(np)) > + continue; > + > if (init_fn && init_fn(np)) > pr_err("Failed to initialise IOMMU %pOF\n", np); > } >