public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v1] memory: tegra30-emc: Print additional memory info
Date: Tue, 21 Dec 2021 18:34:41 +0300	[thread overview]
Message-ID: <f775891b-12c4-ae6c-364c-abaa7ea3f249@gmail.com> (raw)
In-Reply-To: <84487ed8-2f9d-c178-012b-8407e5083b87@canonical.com>

21.12.2021 11:14, Krzysztof Kozlowski пишет:
>>>> +static void emc_read_lpddr_sdram_info(struct tegra_emc *emc,
>>>> +				      unsigned int emem_dev)
>>>> +{
>>>> +	union lpddr2_basic_config4 basic_conf4;
>>>> +	unsigned int manufacturer_id;
>>>> +	unsigned int revision_id1;
>>>> +	unsigned int revision_id2;
>>>> +
>>>> +	/* these registers are standard for all LPDDR JEDEC memory chips */
>>>> +	emc_read_lpddr_mode_register(emc, emem_dev, 5, &manufacturer_id);
>>>> +	emc_read_lpddr_mode_register(emc, emem_dev, 6, &revision_id1);
>>>> +	emc_read_lpddr_mode_register(emc, emem_dev, 7, &revision_id2);
>>>> +	emc_read_lpddr_mode_register(emc, emem_dev, 8, &basic_conf4.value);
>>>> +
>>>> +	dev_info(emc->dev, "SDRAM[dev%u]: manufacturer: 0x%x (%s) rev1: 0x%x rev2: 0x%x prefetch: S%u density: %uMbit iowidth: %ubit\n",
>>>> +		 emem_dev, manufacturer_id,
>>>> +		 lpddr2_jedec_manufacturer(manufacturer_id),
>>>> +		 revision_id1, revision_id2,
>>>> +		 4 >> basic_conf4.arch_type,
>>>> +		 64 << basic_conf4.density,
>>>> +		 32 >> basic_conf4.io_width);
>>>> +}
>>>> +
>>> Quickly looking, these two functions are exactly the same as ones in
>>> tegra20-emc.c
>>> . Later you might come up with another set for other SoCs, so it looks
>>> it is worth to share these.
>> Should be too much trouble for not much gain, IMO. How many bytes will
>> be shared in the end? There is no much code here, we may lose more than
>> win. All these Tegra EMC drivers can be compiled as a loadable modules,
>> that's what distro kernels usually do. There are no plans for other SoCs
>> for today.
> It's not about the bytes but source code lines to maintain and fix (if
> there is something to fix). But if you don't plan to make a third copy
> of it, it is okay.

Only Tegra114 SoC potentially supports LPDDR2, later SoCs dropped LPDDR2
support. We don't even have memory driver for T114 at all in the today's
mainline. I also doubt that there were any consumer T114 devices sold
with LPDDR2. Hence we shouldn't have a need for the third copy anytime
soon, likely ever.

>> I don't see how that sharing could be done easily and nicely. Please
>> tell if you see.
> Since it is not about duplicated object code, but code for review, it is
> pretty straightforward:
> 
> 1. Create tegra-emc-common.[ch]
> 2. In Makefile:
> 
> +tegra20_emc-y += tegra20-emc.o tegra-emc-common.o
> 
> +obj-$(CONFIG_TEGRA20_EMC)  += tegra20_emc.o
> 
> +
> 
> +tegra30_emc-y += tegra30-emc.o tegra-emc-common.o
> 
> +obj-$(CONFIG_TEGRA30_EMC)  += tegra30_emc.o
> 

The problem that struct tegra_emc isn't shareable and this common code
should introduce messiness to the Tegra EMC drivers. I'd prefer not to
share anything for now and get back to this option with sharing later
on, if will be another good reason.

  reply	other threads:[~2021-12-21 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 23:47 [PATCH v1] memory: tegra30-emc: Print additional memory info Dmitry Osipenko
2021-12-20 11:03 ` Krzysztof Kozlowski
2021-12-20 13:44   ` Dmitry Osipenko
2021-12-21  8:14     ` Krzysztof Kozlowski
2021-12-21 15:34       ` Dmitry Osipenko [this message]
2021-12-20 15:27 ` 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=f775891b-12c4-ae6c-364c-abaa7ea3f249@gmail.com \
    --to=digetx@gmail.com \
    --cc=clamor95@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@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