From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>,
joro@8bytes.org, krzk@kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
jonathanh@nvidia.com
Subject: Re: [PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device()
Date: Mon, 28 Sep 2020 09:29:55 +0200 [thread overview]
Message-ID: <20200928072955.GE2837573@ulmo> (raw)
In-Reply-To: <ccb95c4e-64ba-bab9-1f75-0c6d287540b0@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2427 bytes --]
On Sat, Sep 26, 2020 at 05:48:17PM +0300, Dmitry Osipenko wrote:
> 26.09.2020 11:07, Nicolin Chen пишет:
> ...
> > + /* NULL smmu pointer means that SMMU driver is not probed yet */
> > + if (unlikely(!smmu))
> > + return ERR_PTR(-EPROBE_DEFER);
>
> Hello, Nicolin!
>
> Please don't pollute code with likely/unlikely. This is not a
> performance-critical code.
>
> ...
> > -static struct platform_driver tegra_mc_driver = {
> > +struct platform_driver tegra_mc_driver = {
> > .driver = {
> > .name = "tegra-mc",
> > .of_match_table = tegra_mc_of_match,
> > diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
> > index 1238e35653d1..49a4cf64c4b9 100644
> > --- a/include/soc/tegra/mc.h
> > +++ b/include/soc/tegra/mc.h
> > @@ -184,4 +184,6 @@ struct tegra_mc {
> > int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
> > unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc);
> >
> > +extern struct platform_driver tegra_mc_driver;
>
> No global variables, please. See for the example:
>
> https://elixir.bootlin.com/linux/v5.9-rc6/source/drivers/devfreq/tegra20-devfreq.c#L100
>
> The tegra_get_memory_controller() is now needed by multiple Tegra
> drivers, I think it should be good to have it added into the MC driver
> and then make it globally available for all drivers by making use of
> of_find_matching_node_and_match().
>
> diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
> index e1db209fd2ea..ed1bd6d00aaf 100644
> --- a/drivers/memory/tegra/mc.c
> +++ b/drivers/memory/tegra/mc.c
> @@ -43,6 +43,29 @@ static const struct of_device_id tegra_mc_of_match[] = {
> };
> MODULE_DEVICE_TABLE(of, tegra_mc_of_match);
>
> +struct tegra_mc *tegra_get_memory_controller(void)
> +{
> + struct platform_device *pdev;
> + struct device_node *np;
> + struct tegra_mc *mc;
> +
> + np = of_find_matching_node_and_match(NULL, tegra_mc_of_match, NULL);
> + if (!np)
> + return ERR_PTR(-ENOENT);
> +
> + pdev = of_find_device_by_node(np);
> + of_node_put(np);
> + if (!pdev)
> + return ERR_PTR(-ENODEV);
> +
> + mc = platform_get_drvdata(pdev);
> + if (!mc)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + return mc;
> +}
> +EXPORT_SYMBOL_GPL(tegra_get_memory_controller);
We already have tegra_smmu_find(), which should be enough for this
particular use-case.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-09-28 7:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-26 8:07 [PATCH 0/5] iommu/tegra-smmu: Adding PCI support and mappings debugfs node Nicolin Chen
2020-09-26 8:07 ` [PATCH 1/5] iommu/tegra-smmu: Unwrap tegra_smmu_group_get Nicolin Chen
2020-09-28 7:13 ` Thierry Reding
2020-09-28 19:33 ` Nicolin Chen
2020-09-26 8:07 ` [PATCH 2/5] iommu/tegra-smmu: Expend mutex protection range Nicolin Chen
2020-09-26 8:07 ` [PATCH 3/5] iommu/tegra-smmu: Use iommu_fwspec in .probe_/.attach_device() Nicolin Chen
2020-09-26 14:48 ` Dmitry Osipenko
2020-09-26 20:42 ` Nicolin Chen
2020-09-28 7:29 ` Thierry Reding [this message]
2020-09-28 7:52 ` Thierry Reding
2020-09-28 22:18 ` Nicolin Chen
2020-09-29 4:06 ` Dmitry Osipenko
2020-09-29 5:36 ` Nicolin Chen
2020-09-26 8:07 ` [PATCH 4/5] iommu/tegra-smmu: Add PCI support Nicolin Chen
2020-09-26 22:18 ` Dmitry Osipenko
2020-09-28 22:31 ` Nicolin Chen
2020-09-28 7:55 ` Thierry Reding
2020-09-28 22:33 ` Nicolin Chen
2020-09-26 8:07 ` [PATCH 5/5] iommu/tegra-smmu: Add pagetable mappings to debugfs Nicolin Chen
2020-09-26 14:48 ` Dmitry Osipenko
2020-09-26 20:47 ` Nicolin Chen
2020-09-26 21:41 ` Dmitry Osipenko
2020-09-26 21:24 ` Dmitry Osipenko
2020-09-26 21:37 ` Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200928072955.GE2837573@ulmo \
--to=thierry.reding@gmail.com \
--cc=digetx@gmail.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=nicoleotsuka@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).