Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4431089pxk; Wed, 30 Sep 2020 02:47:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMoKQJXIAA6DJY7zjgRoQNedrVipu/1SFKZCVfuErVTL1BADVacDYyg/zsHwgzbHb3ujOi X-Received: by 2002:a17:906:390d:: with SMTP id f13mr1904942eje.86.1601459249280; Wed, 30 Sep 2020 02:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601459249; cv=none; d=google.com; s=arc-20160816; b=zyNDOnq/HtNmTB3AiUAYMh6u3fnBlkpC1kn1r4L5FxLEaSer3YrqazgUthwqq4xa8h c3QhXe9d383UtxXyGAjh3uBxOl/0k04GD39QFy0lHmKfJFoJOqC3/N7xeOI4IC4Q0ZwY 1qaWdTS8TrgXf+k4LUy5mZHbLfC1h8U7DWBI/NiQ8AaR3KfKyFM/qnD8c2+auA+RzSQN J8BbJ+ap72WR1XHOUn//+R61rJXx186vT5INV+GQgq+4/zZQDBxxgcMuoMFDu94snqm+ xf/YMgN2mSvCF9/IHZz9HVS6AGbM01UN2PgE5XIZlYAw5Kg1VKF5ga6A7JzcVH7IvGLh eWSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=w6x76gtOHsFZbRIC64IzxvoZiSxuFZiWjvjCw4IeBQg=; b=yHEchQTeTopScxTale+xq3xyWaR/r82Qp0fSHz17NPtbDOZbGCCKb5BNNsSw4eBr02 wnGz35f991e1/1SXHHfkaSclWXglYIYNDF8xbEe0L7HiQAEcsUy/zhwGBjlBjprr3MEz 5y5+iUJ5oi2AQwfesjVqldQhrAIVdDfqenISWsdGfEGoAYVOKNn88Z62Zil3g80MgdoZ OEvLEstZVIkPiXod/3FU6ejag5yPDwJPqsYxCRYi0uBe7GId5xsS9QMgomcYUGe2aHTs YMMhky03UlgUvH2rJaH4bVIFQrYxTKWIBM5hJwVu9xJ2SbdmYTaFoQg2SiYUOHzWvGl5 Vfxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p2mQDBcC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m17si614828edj.540.2020.09.30.02.47.06; Wed, 30 Sep 2020 02:47:29 -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=@gmail.com header.s=20161025 header.b=p2mQDBcC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728399AbgI3JqI (ORCPT + 99 others); Wed, 30 Sep 2020 05:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbgI3JqI (ORCPT ); Wed, 30 Sep 2020 05:46:08 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF0F5C061755; Wed, 30 Sep 2020 02:46:07 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id y20so705605pll.12; Wed, 30 Sep 2020 02:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=w6x76gtOHsFZbRIC64IzxvoZiSxuFZiWjvjCw4IeBQg=; b=p2mQDBcCc34wHPCS1PNzUjlkF5oBkaoVSc4y0UTqBTEU0wukBKhr3l7IugLFhsWwPk sBCNpg2XDBk2OENMWkcxe87s5sTNnAguKCXJ6TDg0ls1rcGx0XE7jUu5FlJ7zDFPzzEX 2HzpcJjkCPTBS1Ppm4WKw0azG0UEKk1tjgWweFP0qty95Bj5RJ2laAt37HL+UhYr84ET 5e6ww1KK+tiIzJtD09T1/N6lgRK8YaMCWpGRjgcyGZ7ci/KArqSTfDL0wvfQ+6yfCzRr NpL977c4gkkhKnv3cQBQGpUIUkJiFUDixoD5gzENfM+OELC4byQ2AvKrHFt8FeG0C9OR xXtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=w6x76gtOHsFZbRIC64IzxvoZiSxuFZiWjvjCw4IeBQg=; b=kqDAtKc2rT7WbYp/Qk5DNLHOYS+UsMmhaUJMvW9W8rU8fmKMrQDPyCE/7pj03x4jmp 5xuB/5tTHvoqoqB1uzUmHsGg6j8U94PQHRfJ8PKZgqN2iijMNrIPt8n8aqgKkGE2hd1/ VJdPWzUD1p08szPVP5+lhWxR1x+i0LhLPuCwrc0V+JdCvDAYUh/x6lTeMyPM8Df97VXs 9h7k/xVyNQBIhSpfTqEF6LEq9njNGdbRlG6Yfk/K5FwAbYmqqz7w8GVOB8MtwgOQPq/6 oDd3QbRmgO7bXzT7FiQ3E+jxTBUVbsSN1MBi7/rf7iiRhudDifgiupwZ0Z+2WEAfgQum PdKA== X-Gm-Message-State: AOAM531ywgK9V7KDCkyZ4QNfsPfGYsfh+1pneo5E+7JG3QiJSsup2/75 BzD98TcFU+ioALPT7SEOuCk= X-Received: by 2002:a17:90b:33cb:: with SMTP id lk11mr1797687pjb.98.1601459167352; Wed, 30 Sep 2020 02:46:07 -0700 (PDT) Received: from Asurada-Nvidia (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id j26sm1890991pfa.160.2020.09.30.02.46.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Sep 2020 02:46:07 -0700 (PDT) Date: Wed, 30 Sep 2020 02:40:32 -0700 From: Nicolin Chen To: Krzysztof Kozlowski 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" Subject: Re: [PATCH v3 2/3] iommu/tegra-smmu: Rework .probe_device and .attach_dev Message-ID: <20200930094032.GA6686@Asurada-Nvidia> References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-3-nicoleotsuka@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 11:21:14AM +0200, Krzysztof Kozlowski wrote: > 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. Because it's already set in probe(): https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/iommu/tegra-smmu.c#n1162 And my PATCH-3 sets it for PCI bus also. Thanks