From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Roman Vivchar <rva333@protonmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Srinivas Kandagatla" <srini@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>, "Lee Jones" <lee@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org,
"Ben Grisdale" <bengris32@protonmail.ch>
Subject: Re: [PATCH 06/13] thermal: mediatek: add pmic thermal support
Date: Wed, 6 May 2026 16:26:16 +0300 [thread overview]
Message-ID: <aftBeFbVIap59FFS@ashevche-desk.local> (raw)
In-Reply-To: <cgsML96DsJh_Ow9XsSnyrZ3NhlCnNj1rKegzYNR3eQzkWoF5xQB5-aU6Zi7pKcT8GfUnO3B-D71je60APUtorB7p_A3GtUCp2oer3KYLn6k=@protonmail.com>
On Wed, May 06, 2026 at 11:22:15AM +0000, Roman Vivchar wrote:
> On Tuesday, May 5th, 2026 at 11:16 AM, Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > On Mon, May 04, 2026 at 09:24:58PM +0300, Roman Vivchar via B4 Relay wrote:
...
> > > +struct mtk_pmic_sensor {
> > > + struct mtk_pmic_thermal *mt;
> > > + int id;
> > > + struct iio_channel *adc_channel;
> > > + struct thermal_zone_device *tzdev;
> > > +};
> >
> > Can you confirm with `pahole` that this is the best layout (taking into account
> > the use in the below data structure)?
> >
> > > +struct mtk_pmic_thermal {
> > > + struct device *dev;
> > > + struct regmap *regmap;
> > > + struct mtk_pmic_sensor sensors[MAX_SENSORS];
> > > +
> > > + s32 t_slope1;
> > > + s32 t_slope2;
> > > + s32 t_intercept;
> > > +
> > > + const struct mtk_thermal_data *data;
> > > +};
>
> On the ARMv7 it shouldn't be an issue, because pointer size equals to
> the s32 or int. However, I've reordered the fields to group pointers
> and integers together.
>
> struct mtk_pmic_sensor {
> struct mtk_pmic_thermal * mt; /* 0 4 */
> struct iio_channel * adc_channel; /* 4 4 */
> struct thermal_zone_device * tzdev; /* 8 4 */
> int id; /* 12 4 */
>
> /* size: 16, cachelines: 1, members: 4 */
> /* last cacheline: 16 bytes */
> };
>
> struct mtk_pmic_thermal {
> struct device * dev; /* 0 4 */
> struct regmap * regmap; /* 4 4 */
> const struct mtk_thermal_data * data; /* 8 4 */
> s32 t_slope1; /* 12 4 */
> s32 t_slope2; /* 16 4 */
> s32 t_intercept; /* 20 4 */
> struct mtk_pmic_sensor sensors[1]; /* 24 16 */
>
> /* size: 40, cachelines: 1, members: 7 */
> /* last cacheline: 40 bytes */
> };
>
> The compiler will still add some padding on the AArch64 though.
>
> struct mtk_pmic_sensor {
> struct mtk_pmic_thermal * mt; /* 0 8 */
> struct iio_channel * adc_channel; /* 8 8 */
> struct thermal_zone_device * tzdev; /* 16 8 */
> int id; /* 24 4 */
>
> /* size: 32, cachelines: 1, members: 4 */
> /* padding: 4 */
> /* last cacheline: 32 bytes */
> };
>
> struct mtk_pmic_thermal {
> struct device * dev; /* 0 8 */
> struct regmap * regmap; /* 8 8 */
> const struct mtk_thermal_data * data; /* 16 8 */
> s32 t_slope1; /* 24 4 */
> s32 t_slope2; /* 28 4 */
> s32 t_intercept; /* 32 4 */
>
> /* XXX 4 bytes hole, try to pack */
^^^^
> struct mtk_pmic_sensor sensors[1]; /* 40 32 */
>
> /* size: 72, cachelines: 2, members: 7 */
> /* sum members: 68, holes: 1, sum holes: 4 */
> /* last cacheline: 8 bytes */
> };
>
> Is this good enough?
In the last it seems moving the s32 members to be the last will removes
the 4-byte hole.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-05-06 13:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 18:24 [PATCH 00/13] add AUXADC, EFUSE and thermal drivers for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay
2026-05-04 18:24 ` [PATCH 01/13] dt-bindings: iio: adc: add mt6323 PMIC AUXADC Roman Vivchar via B4 Relay
2026-05-06 7:56 ` Krzysztof Kozlowski
2026-05-06 10:59 ` Roman Vivchar
2026-05-06 13:08 ` Krzysztof Kozlowski
2026-05-04 18:24 ` [PATCH 02/13] dt-bindings: nvmem: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay
2026-05-06 7:57 ` Krzysztof Kozlowski
2026-05-04 18:24 ` [PATCH 03/13] dt-bindings: thermal: add mt6323 PMIC thermal Roman Vivchar via B4 Relay
2026-05-04 19:41 ` Rob Herring (Arm)
2026-05-05 14:05 ` Rob Herring
2026-05-04 18:24 ` [PATCH 04/13] iio: adc: mediatek: add mt6323 PMIC AUXADC driver Roman Vivchar via B4 Relay
2026-05-05 7:53 ` Andy Shevchenko
2026-05-06 15:46 ` Jonathan Cameron
2026-05-04 18:24 ` [PATCH 05/13] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay
2026-05-05 7:59 ` Andy Shevchenko
2026-05-05 16:24 ` Roman Vivchar
2026-05-06 7:30 ` Andy Shevchenko
2026-05-04 18:24 ` [PATCH 06/13] thermal: mediatek: add pmic thermal support Roman Vivchar via B4 Relay
2026-05-05 8:16 ` Andy Shevchenko
2026-05-06 11:22 ` Roman Vivchar
2026-05-06 13:26 ` Andy Shevchenko [this message]
2026-05-04 18:24 ` [PATCH 07/13] mfd: mt6397-core: add mt6323 AUXADC support Roman Vivchar via B4 Relay
2026-05-04 18:25 ` [PATCH 08/13] mfd: mt6397-core: add support for mt6323 efuse Roman Vivchar via B4 Relay
2026-05-04 18:25 ` [PATCH 09/13] mfd: mt6397-core: add support for mt6323 thermal Roman Vivchar via B4 Relay
2026-05-04 18:25 ` [PATCH 10/13] ARM: dts: mediatek: mt6323: add support for AUXADC Roman Vivchar via B4 Relay
2026-05-04 18:25 ` [PATCH 11/13] ARM: dts: mediatek: mt6323: add support for EFUSE Roman Vivchar via B4 Relay
2026-05-06 7:59 ` Krzysztof Kozlowski
2026-05-04 18:25 ` [PATCH 12/13] ARM: dts: mediatek: mt6323: add support for thermal Roman Vivchar via B4 Relay
2026-05-04 18:25 ` [PATCH 13/13] MAINTAINERS: add mt6323 drivers maintainer Roman Vivchar via B4 Relay
2026-05-06 8:26 ` Krzysztof Kozlowski
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=aftBeFbVIap59FFS@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bengris32@protonmail.ch \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=nuno.sa@analog.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=rva333@protonmail.com \
--cc=srini@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox