All of lore.kernel.org
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
To: matthias.bgg@gmail.com
Cc: krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	robh+dt@kernel.org, angelogioacchino.delregno@collabora.com,
	p.zabel@pengutronix.de, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, kernel@collabora.com,
	wenst@chromium.org
Subject: [PATCH v1 05/20] soc: mediatek: mtk-svs: Reduce memory footprint of struct svs_bank
Date: Fri, 17 Nov 2023 10:42:13 +0100	[thread overview]
Message-ID: <20231117094228.40013-6-angelogioacchino.delregno@collabora.com> (raw)
In-Reply-To: <20231117094228.40013-1-angelogioacchino.delregno@collabora.com>

Many 32-bit members of this struct can be size reduced to either 16-bit
or even 8-bit, for a total saving of ~61 bytes per bank. Keeping in mind
that one SoC declares at least two banks, this brings a minimum of ~122
bytes saving (depending on compiler optimization).

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/soc/mediatek/mtk-svs.c | 51 +++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 1c7592fd6ae7..6c27fb523bfa 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -456,13 +456,13 @@ struct svs_bank {
 	char *buck_name;
 	char *tzone_name;
 	enum svsb_phase phase;
-	s32 volt_od;
+	short int volt_od;
 	u32 reg_data[SVSB_PHASE_MAX][SVS_REG_MAX];
 	u32 pm_runtime_enabled_count;
-	u32 mode_support;
+	u8 mode_support;
 	u32 freq_base;
 	u32 turn_freq_base;
-	u32 vboot;
+	u8 vboot;
 	u32 opp_dfreq[MAX_OPP_ENTRIES];
 	u32 opp_dvolt[MAX_OPP_ENTRIES];
 	u32 freq_pct[MAX_OPP_ENTRIES];
@@ -470,36 +470,36 @@ struct svs_bank {
 	u32 volt_step;
 	u32 volt_base;
 	u32 volt_flags;
-	u32 vmax;
-	u32 vmin;
+	u8 vmax;
+	u8 vmin;
 	u32 age_config;
-	u32 age_voffset_in;
+	u16 age_voffset_in;
 	u32 dc_config;
-	u32 dc_voffset_in;
-	u32 dvt_fixed;
-	u32 vco;
-	u32 chk_shift;
+	u16 dc_voffset_in;
+	u8 dvt_fixed;
+	u8 vco;
+	u8 chk_shift;
 	u32 core_sel;
-	u32 opp_count;
+	u8 opp_count;
 	u32 int_st;
-	u32 sw_id;
-	u32 cpu_id;
+	u8 sw_id;
+	u8 cpu_id;
 	u32 ctl0;
 	u32 temp;
 	u32 tzone_htemp;
-	u32 tzone_htemp_voffset;
+	u16 tzone_htemp_voffset;
 	u32 tzone_ltemp;
-	u32 tzone_ltemp_voffset;
-	u32 bts;
-	u32 mts;
-	u32 bdes;
-	u32 mdes;
-	u32 mtdes;
-	u32 dcbdet;
-	u32 dcmdet;
+	u16 tzone_ltemp_voffset;
+	u16 bts;
+	u16 mts;
+	u16 bdes;
+	u16 mdes;
+	u8 mtdes;
+	u8 dcbdet;
+	u8 dcmdet;
 	u32 turn_pt;
 	u32 vbin_turn_pt;
-	u32 type;
+	u8 type;
 };
 
 static u32 percent(u32 numerator, u32 denominator)
@@ -1267,6 +1267,7 @@ static inline void svs_error_isr_handler(struct svs_platform *svsp)
 static inline void svs_init01_isr_handler(struct svs_platform *svsp)
 {
 	struct svs_bank *svsb = svsp->pbank;
+	u32 val;
 
 	dev_info(svsb->dev, "%s: VDN74~30:0x%08x~0x%08x, DC:0x%08x\n",
 		 __func__, svs_readl_relaxed(svsp, VDESIGN74),
@@ -1276,8 +1277,8 @@ static inline void svs_init01_isr_handler(struct svs_platform *svsp)
 	svs_save_bank_register_data(svsp, SVSB_PHASE_INIT01);
 
 	svsb->phase = SVSB_PHASE_INIT01;
-	svsb->dc_voffset_in = ~(svs_readl_relaxed(svsp, DCVALUES) &
-				GENMASK(15, 0)) + 1;
+	val = ~(svs_readl_relaxed(svsp, DCVALUES) & GENMASK(15, 0)) + 1;
+	svsb->dc_voffset_in = val & GENMASK(15, 0);
 	if (svsb->volt_flags & SVSB_INIT01_VOLT_IGNORE ||
 	    (svsb->dc_voffset_in & SVSB_DC_SIGNED_BIT &&
 	     svsb->volt_flags & SVSB_INIT01_VOLT_INC_ONLY))
-- 
2.42.0


WARNING: multiple messages have this Message-ID (diff)
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: matthias.bgg@gmail.com
Cc: krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	robh+dt@kernel.org, angelogioacchino.delregno@collabora.com,
	p.zabel@pengutronix.de, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, kernel@collabora.com,
	wenst@chromium.org
Subject: [PATCH v1 05/20] soc: mediatek: mtk-svs: Reduce memory footprint of struct svs_bank
Date: Fri, 17 Nov 2023 10:42:13 +0100	[thread overview]
Message-ID: <20231117094228.40013-6-angelogioacchino.delregno@collabora.com> (raw)
In-Reply-To: <20231117094228.40013-1-angelogioacchino.delregno@collabora.com>

Many 32-bit members of this struct can be size reduced to either 16-bit
or even 8-bit, for a total saving of ~61 bytes per bank. Keeping in mind
that one SoC declares at least two banks, this brings a minimum of ~122
bytes saving (depending on compiler optimization).

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/soc/mediatek/mtk-svs.c | 51 +++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 1c7592fd6ae7..6c27fb523bfa 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -456,13 +456,13 @@ struct svs_bank {
 	char *buck_name;
 	char *tzone_name;
 	enum svsb_phase phase;
-	s32 volt_od;
+	short int volt_od;
 	u32 reg_data[SVSB_PHASE_MAX][SVS_REG_MAX];
 	u32 pm_runtime_enabled_count;
-	u32 mode_support;
+	u8 mode_support;
 	u32 freq_base;
 	u32 turn_freq_base;
-	u32 vboot;
+	u8 vboot;
 	u32 opp_dfreq[MAX_OPP_ENTRIES];
 	u32 opp_dvolt[MAX_OPP_ENTRIES];
 	u32 freq_pct[MAX_OPP_ENTRIES];
@@ -470,36 +470,36 @@ struct svs_bank {
 	u32 volt_step;
 	u32 volt_base;
 	u32 volt_flags;
-	u32 vmax;
-	u32 vmin;
+	u8 vmax;
+	u8 vmin;
 	u32 age_config;
-	u32 age_voffset_in;
+	u16 age_voffset_in;
 	u32 dc_config;
-	u32 dc_voffset_in;
-	u32 dvt_fixed;
-	u32 vco;
-	u32 chk_shift;
+	u16 dc_voffset_in;
+	u8 dvt_fixed;
+	u8 vco;
+	u8 chk_shift;
 	u32 core_sel;
-	u32 opp_count;
+	u8 opp_count;
 	u32 int_st;
-	u32 sw_id;
-	u32 cpu_id;
+	u8 sw_id;
+	u8 cpu_id;
 	u32 ctl0;
 	u32 temp;
 	u32 tzone_htemp;
-	u32 tzone_htemp_voffset;
+	u16 tzone_htemp_voffset;
 	u32 tzone_ltemp;
-	u32 tzone_ltemp_voffset;
-	u32 bts;
-	u32 mts;
-	u32 bdes;
-	u32 mdes;
-	u32 mtdes;
-	u32 dcbdet;
-	u32 dcmdet;
+	u16 tzone_ltemp_voffset;
+	u16 bts;
+	u16 mts;
+	u16 bdes;
+	u16 mdes;
+	u8 mtdes;
+	u8 dcbdet;
+	u8 dcmdet;
 	u32 turn_pt;
 	u32 vbin_turn_pt;
-	u32 type;
+	u8 type;
 };
 
 static u32 percent(u32 numerator, u32 denominator)
@@ -1267,6 +1267,7 @@ static inline void svs_error_isr_handler(struct svs_platform *svsp)
 static inline void svs_init01_isr_handler(struct svs_platform *svsp)
 {
 	struct svs_bank *svsb = svsp->pbank;
+	u32 val;
 
 	dev_info(svsb->dev, "%s: VDN74~30:0x%08x~0x%08x, DC:0x%08x\n",
 		 __func__, svs_readl_relaxed(svsp, VDESIGN74),
@@ -1276,8 +1277,8 @@ static inline void svs_init01_isr_handler(struct svs_platform *svsp)
 	svs_save_bank_register_data(svsp, SVSB_PHASE_INIT01);
 
 	svsb->phase = SVSB_PHASE_INIT01;
-	svsb->dc_voffset_in = ~(svs_readl_relaxed(svsp, DCVALUES) &
-				GENMASK(15, 0)) + 1;
+	val = ~(svs_readl_relaxed(svsp, DCVALUES) & GENMASK(15, 0)) + 1;
+	svsb->dc_voffset_in = val & GENMASK(15, 0);
 	if (svsb->volt_flags & SVSB_INIT01_VOLT_IGNORE ||
 	    (svsb->dc_voffset_in & SVSB_DC_SIGNED_BIT &&
 	     svsb->volt_flags & SVSB_INIT01_VOLT_INC_ONLY))
-- 
2.42.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-11-17  9:42 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17  9:42 [PATCH v1 00/20] MediaTek SVS driver partial refactoring AngeloGioacchino Del Regno
2023-11-17  9:42 ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 01/20] arm64: dts: mediatek: mt8183: Change iospaces for thermal and svs AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 02/20] soc: mediatek: mtk-svs: Subtract offset from regs_v2 to avoid conflict AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 03/20] soc: mediatek: mtk-svs: Convert sw_id and type to enumerations AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 04/20] soc: mediatek: mtk-svs: Build bank name string dynamically AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` AngeloGioacchino Del Regno [this message]
2023-11-17  9:42   ` [PATCH v1 05/20] soc: mediatek: mtk-svs: Reduce memory footprint of struct svs_bank AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 06/20] soc: mediatek: mtk-svs: Change the thermal sensor device name AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 07/20] soc: mediatek: mtk-svs: Add a map to retrieve fused values AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 08/20] soc: mediatek: mtk-svs: Add SVS-Thermal coefficient to SoC platform data AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 09/20] soc: mediatek: mtk-svs: Move t-calibration-data retrieval to svs_probe() AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 10/20] soc: mediatek: mtk-svs: Commonize efuse parse function for most SoCs AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 11/20] soc: mediatek: mtk-svs: Drop supplementary svs per-bank pointer AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 12/20] soc: mediatek: mtk-svs: Commonize MT8192 probe function for MT8186 AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 13/20] soc: mediatek: mtk-svs: Remove redundant print in svs_get_efuse_data AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 14/20] soc: mediatek: mtk-svs: Compress of_device_id entries AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 15/20] soc: mediatek: mtk-svs: Cleanup of svs_probe() function AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 16/20] soc: mediatek: mtk-svs: Check if SVS mode is available in the beginning AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 17/20] soc: mediatek: mtk-svs: Use ULONG_MAX to compare floor frequency AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 18/20] soc: mediatek: mtk-svs: Constify runtime-immutable members of svs_bank AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17 14:32   ` Eugen Hristev
2023-11-17 14:32     ` Eugen Hristev
2023-11-21 11:53     ` AngeloGioacchino Del Regno
2023-11-21 11:53       ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 19/20] arm64: dts: mediatek: mt8192: Add Smart Voltage Scaling node AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno
2023-11-17  9:42 ` [PATCH v1 20/20] arm64: dts: mediatek: mt8195: Add SVS node and reduce LVTS_AP iospace AngeloGioacchino Del Regno
2023-11-17  9:42   ` AngeloGioacchino Del Regno

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=20231117094228.40013-6-angelogioacchino.delregno@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@collabora.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=wenst@chromium.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.