Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp542418pxk; Wed, 23 Sep 2020 09:27:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKHgQ1G6FRuvsssPpAq/9xW5RmzyLd8bYJJu+UVErv3YokfhXr1Tt3InrIjGTvxbLUbLbN X-Received: by 2002:a50:d4d8:: with SMTP id e24mr120475edj.1.1600878465295; Wed, 23 Sep 2020 09:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600878465; cv=none; d=google.com; s=arc-20160816; b=yDlWUVL9JzJvwAJD4CE37DxGiCWIlHLe53vPij4HkRnvnnv1MRroCKELIqMc6cjrCq ZAuJLY1LV0/q5QqgHuWmybzHqn16WbNl0yLVoY05yV5WJ6YlpF6FP0lz6RTSruQB5ykJ 1QkaJuKZyLfa8mNnM2my11YbAnTvy30in7c1HnIcMACWQOeJD1kNZoQ60M4dXUukqPY2 SywG7UcShVgw+E+QlBCK/WtkMGnV5Vi7A5yYwol7uObo5lsdVROKDHxgMraL6dtxv8bw /UVnJfGq4kA77PHOkgu+uOuc3ShumiRP4/yKiQ0VcqKi+aiuY09FMVgWmy75W7U//biG th7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Y4Nf5PeD4MM9KehlnQAGI7EZfwLdiNo0JlU/qo45tgo=; b=dsKJqlU+Ke05AO4Iy4RcTXRu0ByJ83UE+ha2x92o/UEq6pUDa5/SupX7YePTusgjA7 h2ZxyexyOS22bLj5xcXqX4E4kI3CTkVjvtK8YhoKbcSCxVK3gFC3EVK7np508FXO0oHc soz8dXASR4v3lB3bZBwPTaG8gJit/olv5C7O9paz6xMFBO5QJ2ufYgF73rZvcdjZ/1tn /VLU9NyAL1vu0TjF8li/miTiwHgGvJ85D1CMVEi989ZmJQemMytbrFmvxSdO+ahv4+2x gMNZxtxoMjAmYWgu6uK928przT1BX95twi8KZPZ326EzHZMdeAAJ1JS+elD/NT68AjlG oGHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si251026edf.56.2020.09.23.09.27.22; Wed, 23 Sep 2020 09:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbgIWQYy (ORCPT + 99 others); Wed, 23 Sep 2020 12:24:54 -0400 Received: from foss.arm.com ([217.140.110.172]:50312 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbgIWQYy (ORCPT ); Wed, 23 Sep 2020 12:24:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 736E630E; Wed, 23 Sep 2020 09:24:53 -0700 (PDT) Received: from [10.57.48.76] (unknown [10.57.48.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2D263F718; Wed, 23 Sep 2020 09:24:52 -0700 (PDT) Subject: Re: [PATCH] iommu: of: skip iommu_device_list traversal in of_iommu_xlate() To: Charan Teja Reddy , joro@8bytes.org, iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org References: <1600872826-2254-1-git-send-email-charante@codeaurora.org> From: Robin Murphy Message-ID: <8722e4bc-efe0-27c4-2b7d-626188da5bfb@arm.com> Date: Wed, 23 Sep 2020 17:24:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <1600872826-2254-1-git-send-email-charante@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-09-23 15:53, Charan Teja Reddy wrote: > In of_iommu_xlate(), check if iommu device is enabled before traversing > the iommu_device_list through iommu_ops_from_fwnode(). It is of no use > in traversing the iommu_device_list only to return NO_IOMMU because of > iommu device node is disabled. Well, the "use" is that it keeps the code that much smaller and simpler to have a single path for returning this condition. This whole callstack isn't exactly a high-performance code path to begin with, and we've always assumed that IOMMUs present but disabled in DT would be a pretty rare exception. Do you have a system that challenges those assumptions and shows any benefit from this change? Robin. > Signed-off-by: Charan Teja Reddy > --- > drivers/iommu/of_iommu.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > index e505b91..225598c 100644 > --- a/drivers/iommu/of_iommu.c > +++ b/drivers/iommu/of_iommu.c > @@ -94,9 +94,10 @@ static int of_iommu_xlate(struct device *dev, > struct fwnode_handle *fwnode = &iommu_spec->np->fwnode; > int ret; > > + if (!of_device_is_available(iommu_spec->np)) > + return NO_IOMMU; > ops = iommu_ops_from_fwnode(fwnode); > - if ((ops && !ops->of_xlate) || > - !of_device_is_available(iommu_spec->np)) > + if (ops && !ops->of_xlate) > return NO_IOMMU; > > ret = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops); >