mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Mikko Perttunen <mperttunen@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>
Cc: Svyatoslav Ryhel <clamor95@gmail.com>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] memory: tegra: Deduplicate rate request management code
Date: Fri, 13 Feb 2026 11:24:47 +0100	[thread overview]
Message-ID: <2891e25d-33d0-42eb-8da0-b57d50651c2b@kernel.org> (raw)
In-Reply-To: <20260206-memory-refactor-v1-1-4385d439558a@nvidia.com>

On 06/02/2026 03:54, Mikko Perttunen wrote:
> As is, the EMC drivers for each 32-bit platform contain almost
> identical duplicated code for aggregating rate requests. Move this
> code out to a shared tegra-emc-common file to reduce duplication.
> 
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> This patch is on top of 'memory: tegra: Add Tegra114 EMC driver'

If that patch is not merged, then this should be reversed. First you
remove duplication then you add smaller new patch. Not vice versa, where
you add duplicated code just to remove it.

> ---
>  drivers/memory/tegra/Kconfig            |   7 ++
>  drivers/memory/tegra/Makefile           |   1 +
>  drivers/memory/tegra/tegra-emc-common.c |  96 ++++++++++++++++++++++++++++
>  drivers/memory/tegra/tegra-emc-common.h |  38 +++++++++++
>  drivers/memory/tegra/tegra114-emc.c     | 107 ++-----------------------------
>  drivers/memory/tegra/tegra124-emc.c     | 107 ++-----------------------------
>  drivers/memory/tegra/tegra20-emc.c      | 110 ++------------------------------
>  drivers/memory/tegra/tegra30-emc.c      | 107 ++-----------------------------
>  8 files changed, 167 insertions(+), 406 deletions(-)
> 
> diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig
> index 11e7cc357d39..aeda7f104d34 100644
> --- a/drivers/memory/tegra/Kconfig
> +++ b/drivers/memory/tegra/Kconfig
> @@ -17,6 +17,7 @@ config TEGRA20_EMC
>  	select DEVFREQ_GOV_SIMPLE_ONDEMAND
>  	select PM_DEVFREQ
>  	select DDR
> +	select TEGRA_EMC_COMMON
>  	help
>  	  This driver is for the External Memory Controller (EMC) found on
>  	  Tegra20 chips. The EMC controls the external DRAM on the board.
> @@ -29,6 +30,7 @@ config TEGRA30_EMC
>  	depends on ARCH_TEGRA_3x_SOC || COMPILE_TEST
>  	select PM_OPP
>  	select DDR
> +	select TEGRA_EMC_COMMON
>  	help
>  	  This driver is for the External Memory Controller (EMC) found on
>  	  Tegra30 chips. The EMC controls the external DRAM on the board.
> @@ -41,6 +43,7 @@ config TEGRA114_EMC
>  	depends on ARCH_TEGRA_114_SOC || COMPILE_TEST
>  	select TEGRA124_CLK_EMC if ARCH_TEGRA
>  	select PM_OPP
> +	select TEGRA_EMC_COMMON
>  	help
>  	  This driver is for the External Memory Controller (EMC) found on
>  	  Tegra114 chips. The EMC controls the external DRAM on the board.
> @@ -53,6 +56,7 @@ config TEGRA124_EMC
>  	depends on ARCH_TEGRA_124_SOC || COMPILE_TEST
>  	select TEGRA124_CLK_EMC if ARCH_TEGRA
>  	select PM_OPP
> +	select TEGRA_EMC_COMMON
>  	help
>  	  This driver is for the External Memory Controller (EMC) found on
>  	  Tegra124 chips. The EMC controls the external DRAM on the board.
> @@ -73,4 +77,7 @@ config TEGRA210_EMC
>  	  This driver is required to change memory timings / clock rate for
>  	  external memory.
>  
> +config TEGRA_EMC_COMMON
> +	tristate
> +
>  endif
> diff --git a/drivers/memory/tegra/Makefile b/drivers/memory/tegra/Makefile
> index 6b9156de4b66..28f22c957a34 100644
> --- a/drivers/memory/tegra/Makefile
> +++ b/drivers/memory/tegra/Makefile
> @@ -14,6 +14,7 @@ tegra-mc-$(CONFIG_ARCH_TEGRA_264_SOC) += tegra186.o tegra264.o
>  
>  obj-$(CONFIG_TEGRA_MC) += tegra-mc.o
>  
> +obj-$(CONFIG_TEGRA_EMC_COMMON) += tegra-emc-common.o
>  obj-$(CONFIG_TEGRA20_EMC)  += tegra20-emc.o
>  obj-$(CONFIG_TEGRA30_EMC)  += tegra30-emc.o
>  obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o
> diff --git a/drivers/memory/tegra/tegra-emc-common.c b/drivers/memory/tegra/tegra-emc-common.c
> new file mode 100644
> index 000000000000..9292472a5890
> --- /dev/null
> +++ b/drivers/memory/tegra/tegra-emc-common.c
> @@ -0,0 +1,96 @@
> +// SPDX-License-Identifier: GPL-2.0


... and that's why we ask for consistent license. Code in tegra30-emc
has difference license, so I assume here you copied the one matching
license above. Explain in the commit msg which code you copied or on
which existing code you based this.

> +
> +#include <linux/device.h>
> +#include <linux/mutex.h>
> +#include <linux/pm_opp.h>
> +
> +#include "tegra-emc-common.h"
> +

All exported functions need kerneldoc.

> +void tegra_emc_rate_requests_init(struct tegra_emc_rate_requests *reqs,
> +				  struct device *dev)
> +{
> +	unsigned int i;
> +
> +	mutex_init(&reqs->rate_lock);
> +	reqs->dev = dev;
> +
> +	for (i = 0; i < TEGRA_EMC_RATE_TYPE_MAX; i++) {
> +		reqs->requested_rate[i].min_rate = 0;
> +		reqs->requested_rate[i].max_rate = ULONG_MAX;
> +	}
> +}
> +EXPORT_SYMBOL_GPL(tegra_emc_rate_requests_init);
> +

Best regards,
Krzysztof

  reply	other threads:[~2026-02-13 10:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06  2:54 Mikko Perttunen
2026-02-13 10:24 ` Krzysztof Kozlowski [this message]
2026-02-17  4:22   ` Mikko Perttunen
2026-02-17  7:14     ` Krzysztof Kozlowski
2026-02-17 10:12       ` Mikko Perttunen

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=2891e25d-33d0-42eb-8da0-b57d50651c2b@kernel.org \
    --to=krzk@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --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

Powered by JetHome