Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4419666pxk; Wed, 30 Sep 2020 02:25:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVEQdEUp8yPSS08PlROqLo7YCavzkmnMNREAwxrANOOJIyVi+PJAYyz/l72SM0uOC2qEG7 X-Received: by 2002:a05:6402:1558:: with SMTP id p24mr1645292edx.194.1601457922177; Wed, 30 Sep 2020 02:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601457922; cv=none; d=google.com; s=arc-20160816; b=ne6PQ0MqNy7AObJ6eUUpWnc8j0XEalUHzMT+s/1Pu2vEFfoJyDg7kaSTmu/YFDqB78 NKWJ3UVCAkzCYCFhWlRytl0wQE3VU9Hjzqezh0Jq2uKX7iRw9/KFMqpLK3Nzhy/IQAKT pqb0rbdnlQyhZkbZoPr2Ff+XphZhdPy8EgvcOMzRBNif5DgN9eNjPtUoUib9SGXBkQtU L8mkxE1MTSs06K/z21ztgo0vbv0wb8qbTcCE3hyxg2cqi+MTr67zwq/QjsCGCW6MVtmD VBmT90ZOluAdRxswCt0tKuaEw6W01d0jwWhZwLFFTJNMrASP1QlpDs9uVo/jMdB1aal1 fIAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=glCXqZaTSgA5jHCE5eTmYkjxlsrQfpB58CBjpPM+p1c=; b=oi64vRWYGTX000y5iBqWqwQAytBAtHpnNPcxqUeDB2xC4mGMSyhMeixqaPwg56Ip4w 74HP5SXuHKh942OD8pUsw9fglsHWkLlCgBBizKn9aCkJns1MehGeLDvtQashfANf3293 4TtK5yskbsjRsWjdnI5hcnuVMXtNJOkNi4KFUKnx47Rl0QM4QN2TNOdErq+VxCjQjJ8i qrlcWzhhQl5nEZZChebmbZZEMsGDTNOkX2mleZD2QDRC42R8AK9+F9BmvIXg6EWFfZaZ NO5wKFMytkd9Ep9Kb7KVqfQDXMpYzyahICvODOZcWHML9XCmC4NU+86ufpTCt/CnZ4iG GWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D7bKfqTk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ha1si765988ejb.406.2020.09.30.02.24.58; Wed, 30 Sep 2020 02:25:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=D7bKfqTk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729127AbgI3JVb (ORCPT + 99 others); Wed, 30 Sep 2020 05:21:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:36206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727746AbgI3JV3 (ORCPT ); Wed, 30 Sep 2020 05:21:29 -0400 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 687812075F; Wed, 30 Sep 2020 09:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601457688; bh=WW8CAJWhJonVz80Z15S+f0UfVSWGlcSR9+MnjppwNVE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=D7bKfqTk7NZn7bGGx6g9rjABSHMAKQj8oaGfnwaAOaVdGURo/0X//nj2bfySKoahv kph+bbsNd6Ye+z9WtfBlwFUsWND1paKZ8FSYVDWv3xww1riXcp1E24Cqbn7nHQSkXL 1wKpyifb4znNf9O6wr+4d81oz24PuWbz//k+ptlQ= Received: by mail-ej1-f47.google.com with SMTP id u21so1777658eja.2; Wed, 30 Sep 2020 02:21:28 -0700 (PDT) X-Gm-Message-State: AOAM531VUCLa24aurGD0LoZCUeFk1Fw0qz9/DFNdAI93tdD8+VWpYyxn sbC5CbatMMrBwvBFr1uHTiw2c5XRTVugLovzDEc= X-Received: by 2002:a17:906:1984:: with SMTP id g4mr1789347ejd.119.1601457686869; Wed, 30 Sep 2020 02:21:26 -0700 (PDT) MIME-Version: 1.0 References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-3-nicoleotsuka@gmail.com> In-Reply-To: <20200930084258.25493-3-nicoleotsuka@gmail.com> From: Krzysztof Kozlowski Date: Wed, 30 Sep 2020 11:21:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev To: Nicolin Chen Cc: thierry.reding@gmail.com, joro@8bytes.org, digetx@gmail.com, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Sep 2020 at 10:48, Nicolin Chen wrote: > > Previously the driver relies on bus_set_iommu() in .probe() to call > in .probe_device() function so each client can poll iommus property > in DTB to configure fwspec via tegra_smmu_configure(). According to > the comments in .probe(), this is a bit of a hack. And this doesn't > work for a client that doesn't exist in DTB, PCI device for example. > > Actually when a device/client gets probed, the of_iommu_configure() > will call in .probe_device() function again, with a prepared fwspec > from of_iommu_configure() that reads the SWGROUP id in DTB as we do > in tegra-smmu driver. > > Additionally, as a new helper devm_tegra_get_memory_controller() is > introduced, there's no need to poll the iommus property in order to > get mc->smmu pointers or SWGROUP id. > > This patch reworks .probe_device() and .attach_dev() by doing: > 1) Using fwspec to get swgroup id in .attach_dev/.dettach_dev() > 2) Removing DT polling code, tegra_smmu_find/tegra_smmu_configure() > 3) Calling devm_tegra_get_memory_controller() in .probe_device() > 4) Also dropping the hack in .probe() that's no longer needed. > > Signed-off-by: Nicolin Chen > --- > > Changelog > v2->v3 > * Used devm_tegra_get_memory_controller() to get mc pointer > * Replaced IS_ERR_OR_NULL with IS_ERR in .probe_device() > v1->v2 > * Replaced in .probe_device() tegra_smmu_find/tegra_smmu_configure() > with tegra_get_memory_controller call. > * Dropped the hack in tegra_smmu_probe(). > > drivers/iommu/tegra-smmu.c | 144 ++++++++++--------------------------- > 1 file changed, 36 insertions(+), 108 deletions(-) > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c > index 6a3ecc334481..636dc3b89545 100644 > --- a/drivers/iommu/tegra-smmu.c > +++ b/drivers/iommu/tegra-smmu.c > @@ -61,6 +61,8 @@ struct tegra_smmu_as { > u32 attr; > }; > > +static const struct iommu_ops tegra_smmu_ops; I cannot find in this patch where this is assigned. Best regards, Krzysztof