Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1009088pxf; Thu, 1 Apr 2021 21:22:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsVH/1X0Pt+jheQqZcplteFVb06sO6/7z0O0ePihNUu5stKO4XXS2GMq14IogNQMkkRywD X-Received: by 2002:a05:6638:dc3:: with SMTP id m3mr11193552jaj.130.1617337357504; Thu, 01 Apr 2021 21:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617337357; cv=none; d=google.com; s=arc-20160816; b=MOkvxkQ0lVBg/9lqaDBpiTvWgtoZ7QBbc6r7G4i7oGJ+Q46CqhfDqK1vPHH6TOWVOz Cwj6QkZAqcym/b6BTwacbKYkmZp6qXvqkgHc37rmB4pUtqP5ArZ9xn7Owf2hhl+oaZ2b tRlPiV462e4CrewKyv1oMlDS69FqGGSVrDUT71qzD/VdF3bkoz0o1bAJKajzgwoVjBUy j0C5sWFEd0tvFuZJKQVHduiV0l7MRTHYDysWS1nRjBZXRqIM2GYrsDMgQVDd8o3Yxpa6 jAeDp1oFMZL3gf38BC3MIz91iatT8EnKM16/1nh9bLgXLMabjNLq8+C4zcH4Tt6lewJb MCVQ== 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=WpaaAD4PmenHHvOL/jyRNYMJvLhUShrEir1c7Nvth/w=; b=faag8wiOxDW+e+KOvT/Y0aF5GyJ2VgUHOUMigfRRebq3FsIkNFZeoi9umUniBGBVVr XioIlUYRGhUtRT1EHXyfuvFhWv3b3rqMrFukbYZ8P2YIEJA0ajn28sNk4MnNDjoGZgep 4kSKbz0PAS66JXh5YCopC2tPt57aJa5KjPhMVnT/Jyo+EmRC0pNU4PadWjt71daZrKAs a4hLNizdvj4EfJWLgmBkAlYVcsnfMh2QD+VojGFvNwATeOdX6c7HnwgUi5g43dbChv5z hJq+L5jyLSoU6kk7X/eotmssQluUOnMCTN7GUOxSoi339ehG/y0DudBYLWkC3R32K/bI QH4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TiJLbOXP; 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 s17si6786726jat.66.2021.04.01.21.22.23; Thu, 01 Apr 2021 21:22:37 -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=TiJLbOXP; 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 S229594AbhDBEV6 (ORCPT + 99 others); Fri, 2 Apr 2021 00:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbhDBEV5 (ORCPT ); Fri, 2 Apr 2021 00:21:57 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E77C0613E6; Thu, 1 Apr 2021 21:21:55 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id x126so2848598pfc.13; Thu, 01 Apr 2021 21:21:55 -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=WpaaAD4PmenHHvOL/jyRNYMJvLhUShrEir1c7Nvth/w=; b=TiJLbOXPDzTlqOKy5t1e7/FJ7kHujYcoRlmf0TDUDrdD+jIAB9lqtjO4UDN/+Xl9nY 7d/nJ1e1UlB3HmHXr1mZ0lLpdl3ZjZRHTEr1SoofgI7XmUtSGRI6NJKNfn9tVIFF+u4A T5p2fCub/HvLz3VC7QesCriApf1lEOQ/uHcSjaqHFgsTtqD3xUnPvtFQylPiLUspBj/0 u7hi9LIVl28SO/7ChuAPzlofRIEP99j833FvcqOfI0Vkj1PrEwFxDhReBA0LWRArtSEs Xwnk6Qx2nLc35xpHoDJv4xlCXISvv2KmZyvv8PEzF4UT3ZN2ykvHT6RmqJe+TezFcu+2 9bbQ== 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=WpaaAD4PmenHHvOL/jyRNYMJvLhUShrEir1c7Nvth/w=; b=gj/+Xm2zVycBK9aa2GPckSKE0XOd08/EAaUxTraGTieC/iYk74By4okqxszXJMbzcR 8DsNYC+Z3jrGU6SE2x42GXQoq39s8EiYual9AWJHEQfQRR0I7SISWwCFJZ2xER+SsAtk SLDF4OfGlo0v9sTXj0Imeq9Y/Z53/fe4fqeaEqVYFBcCrgWvXLS7AsMNH6xrC89bUnT7 cC9/bP/YRAKpnmHjS5up7MiCaifY7bWkEwo3IXHaTDXPxhwKqxyMhFfUw1H6643A9wFf OEoE9S3BPpY/fUO9/9oLi/hIJDEmr/f2uN92oYDnHgRHvhdjd6C60rYEue9Psf+ahGys FyYg== X-Gm-Message-State: AOAM530xA0WOTGXci14CezqnLI9Iw3eZVxsxaJlOZiri5n9cVU8z630S 1RN6ij1hlhkqIy2qEWl7iJ0= X-Received: by 2002:a62:1ad5:0:b029:1fa:c667:2776 with SMTP id a204-20020a621ad50000b02901fac6672776mr10524988pfa.6.1617337314902; Thu, 01 Apr 2021 21:21:54 -0700 (PDT) Received: from Asurada-Nvidia (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id v13sm6423592pfu.54.2021.04.01.21.21.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Apr 2021 21:21:54 -0700 (PDT) Date: Thu, 1 Apr 2021 21:19:56 -0700 From: Nicolin Chen To: Thierry Reding Cc: joro@8bytes.org, will@kernel.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 v5] iommu/tegra-smmu: Add pagetable mappings to debugfs Message-ID: <20210402041954.GB31146@Asurada-Nvidia> References: <20210315203631.24990-1-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 Tue, Mar 16, 2021 at 12:16:43PM +0100, Thierry Reding wrote: > > +struct tegra_smmu_group_debug { > > + const struct tegra_smmu_swgroup *group; > > + void *priv; > > This always stores the address space, so why not make this: > > struct tegra_smmu_as *as; > > ? While at it, perhaps throw in a const to make sure we don't modify > this structure in the debugfs code. OK. I will try to change that. > > @@ -334,7 +350,7 @@ static void tegra_smmu_domain_free(struct iommu_domain *domain) > > } > > > > static const struct tegra_smmu_swgroup * > > -tegra_smmu_find_swgroup(struct tegra_smmu *smmu, unsigned int swgroup) > > +tegra_smmu_find_swgroup(struct tegra_smmu *smmu, unsigned int swgroup, int *index) > > { > > const struct tegra_smmu_swgroup *group = NULL; > > unsigned int i; > > @@ -342,6 +358,8 @@ tegra_smmu_find_swgroup(struct tegra_smmu *smmu, unsigned int swgroup) > > for (i = 0; i < smmu->soc->num_swgroups; i++) { > > if (smmu->soc->swgroups[i].swgroup == swgroup) { > > group = &smmu->soc->swgroups[i]; > > + if (index) > > + *index = i; > > This doesn't look like the right place for this. And this also makes > things hard to follow because it passes out-of-band data in the index > parameter. > > I'm thinking that this could benefit from a bit of refactoring where > we could for example embed struct tegra_smmu_group_debug into struct > tegra_smmu_group and then reference that when necessary instead of > carrying all that data in an orthogonal array. That should also make > it easier to track this. > > Come to think of it, everything that's currently in your new struct > tegra_smmu_group_debug would be useful in struct tegra_smmu_group, > irrespective of debugfs support. Will try to embed it or see what I can do following the suggestion. > > +static int tegra_smmu_mappings_show(struct seq_file *s, void *data) > > +{ > > + seq_printf(s, "\nSWGROUP: %s\nASID: %d\nreg: 0x%x\n", > > + group->name, as->id, group->reg); > > Is group->reg really that useful here? Can drop it. > > + > > + smmu_writel(smmu, as->id & 0x7f, SMMU_PTB_ASID); > > + ptb_reg = smmu_readl(smmu, SMMU_PTB_DATA); > > + > > + seq_printf(s, "PTB_ASID: 0x%x\nas->pd_dma: %pad\n", > > + ptb_reg, &as->pd_dma); > > This looks somewhat redundant because as->pd_dma is already part of the > PTB_ASID register value. Instead, perhaps decode the upper bits of that > register and simply output as->pdma so that we don't duplicate the base > address of the page table? That's a good idea. Will change that too.