[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2dd6857c-5895-4a53-8ccf-7407e454fd1d@collabora.com>
Date: Mon, 17 Nov 2025 13:39:08 +0100
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: Nicolas Frattaroli <nicolas.frattaroli@...labora.com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Matthias Brugger
<matthias.bgg@...il.com>, Henry Chen <henryc.chen@...iatek.com>,
Georgi Djakov <djakov@...nel.org>
Cc: kernel@...labora.com, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH 10/13] soc: mediatek: mtk-dvfsrc: Rework bandwidth
calculations
Il 14/11/25 17:54, Nicolas Frattaroli ha scritto:
> The code, as it is, plays fast and loose with bandwidth units. It also
> doesn't specify its constraints in the actual maximum hardware value,
> but as some roundabout thing that then ends up multiplied into the
> actual hardware value constraint after some indirections. In part, this
> is due to the use of individual members for storing each limit, instead
> of making it possible to index them by type.
>
> Rework all of this by adding const array members indexed by the
> bandwidth type enum to the soc_data struct. This array expresses the
> actual hardware value limitations, not a factor thereof.
>
> Use the clamp function macro to clamp the values between the minimum and
> maximum constraints after all the calculations, which also means the
> code doesn't write nonsense to a hardware register when the math is
> wrong, as it'll constrain after all the calculations.
>
> Pass the type as the actual enum type as well, and not as an int. If
> there's some type checking that can be extracted from the function
> signature, then we may as well use it.
>
> Don't needlessly explicitly cast return values to the return type
> either; this is both unnecessary and makes it harder to spot type safety
> issues.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@...labora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Powered by blists - more mailing lists