Skip to contentSkip to conversation

memory: tegra: Deduplicate rate request management code

PATCH Applied Mikko Perttunen 2 participants 2 messages May 1 – May 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 memory: tegra: Deduplicate rate request management code

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, and add kerneldoc comments.

Based on code from the tegra20-emc driver.

---
Changes in v3:
- Added comments and lockdep assertion on the rate_lock mutex,
addressing checkpatch 'CHECK'.
- Added module.h include.
- Link to v2: https://patch.msgid.link/[email protected]

---
 drivers/memory/tegra/Kconfig            |   6 ++
 drivers/memory/tegra/Makefile           |   1 +
 drivers/memory/tegra/tegra-emc-common.c | 143 ++++++++++++++++++++++++++++++++
 drivers/memory/tegra/tegra-emc-common.h |  46 ++++++++++
 drivers/memory/tegra/tegra124-emc.c     | 107 ++----------------------
 drivers/memory/tegra/tegra20-emc.c      | 110 ++----------------------
 drivers/memory/tegra/tegra30-emc.c      | 107 ++----------------------
 7 files changed, 215 insertions(+), 305 deletions(-)
drivers/memory/tegra/Kconfig +6 -0
index fc5a27791826..92671f9df672 100644
@@ -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 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.
@@ -61,4 +64,7 @@ config TEGRA210_EMC
 	  This driver is required to change memory timings / clock rate for
 	  external memory.
 
+config TEGRA_EMC_COMMON
+	tristate
+
 endif
drivers/memory/tegra/Makefile +1 -0
index 6334601e6120..75ebb4cb4f29 100644
@@ -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_TEGRA124_EMC) += tegra124-emc.o
drivers/memory/tegra/tegra-emc-common.c new file +143 -0

143 lines not on this page · raw message

drivers/memory/tegra/tegra-emc-common.h new file +46 -0

46 lines not on this page · raw message

drivers/memory/tegra/tegra124-emc.c +6 -101

161 lines not on this page · raw message

drivers/memory/tegra/tegra20-emc.c +7 -103

170 lines not on this page · raw message

drivers/memory/tegra/tegra30-emc.c +6 -101

161 lines not on this page · raw message

---
base-commit: 028ef9c96e96197026887c0f092424679298aae8
change-id: 20260203-memory-refactor-54a6089a8dcf

maintainer Applied
#1 lore raw
Quoted 8 lines · Mikko Perttunen

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, and add kerneldoc comments.

Based on code from the tegra20-emc driver.

[...]

Applied, thanks!

[1/1] memory: tegra: Deduplicate rate request management code

      https://git.kernel.org/krzk/linux-mem-ctrl/c/8879cff7f86f82e8922208668fb0f7227e4836db

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>