[PATCH] soc: mediatek: mtk-socinfo: Restructure SoC attribute information
Fei Shao
fshao at chromium.org
Mon Feb 17 22:19:22 PST 2025
On Thu, Dec 19, 2024 at 7:34 PM Fei Shao <fshao at chromium.org> wrote:
>
> So far, the MediaTek socinfo driver populates the SoC information as
> follows:
> - family: "MediaTek"
> - machine: "<marketing_name> (<soc_name>)"
> e.g., "Kompanio 1380 (MT8195)"
> - soc_id: <null>
>
> This approach has some drawbacks:
> 1. "soc_id" can be used for showing the SoC name (e.g. "MT8195"), while
> it's currently unused.
> 2. The newer socinfo API automatically populates the "machine"
> attribute with the model name from board DTS if unspecified, which
> we may want to preserve if possible.
> 3. "machine" combines the marketing name and SoC name, making it
> trickier to parse. Ideally, the marketing name and SoC name should
> be in separate attributes so userspace to utilize them as needed.
> 4. There's no guarantee that the marketing name will be announced along
> with the SoC name. If either is undetermined, the current design
> will result in a malformed "machine" output. This is observed on
> some newer MediaTek platforms, where the marketing name is still
> undetermined but the SoC information needs to be settled for device
> registration and validation before launch.
>
> To address these points, this commit proposes a new theme to display the
> SoC information:
> - family: "MediaTek <marketing_name>"
> e.g., "MediaTek Kompanio 1380"
> - machine: "<dt_model_name>" (auto-populated)
> e.g., "Acer Tomato (rev1) board"
> - soc_id: "<soc_name>"
> e.g., "MT8195"
>
> Moreover, if the marketing name is not provided, the driver displays
> "MediaTek" in the "family" attribute instead, consistent with the
> previous behavior.
>
> Restructure the way driver populates the SoC information as described
> above.
>
> Note that Mediatek-based Chromebooks are the primary consumers of this
> socinfo driver, and Google has prepared corresponding userspace changes
> to comply with this update, so the impact to userspace is controlled.
>
> Signed-off-by: Fei Shao <fshao at chromium.org>
Just want to resurface this patch. Should I resend?
Regards,
Fei
> ---
>
> drivers/soc/mediatek/mtk-socinfo.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-socinfo.c b/drivers/soc/mediatek/mtk-socinfo.c
> index 123b12cd2543..b9dbc90d7814 100644
> --- a/drivers/soc/mediatek/mtk-socinfo.c
> +++ b/drivers/soc/mediatek/mtk-socinfo.c
> @@ -62,17 +62,24 @@ static struct socinfo_data socinfo_data_table[] = {
> static int mtk_socinfo_create_socinfo_node(struct mtk_socinfo *mtk_socinfop)
> {
> struct soc_device_attribute *attrs;
> - static char machine[30] = {0};
> + struct socinfo_data *data = mtk_socinfop->socinfo_data;
> static const char *soc_manufacturer = "MediaTek";
>
> attrs = devm_kzalloc(mtk_socinfop->dev, sizeof(*attrs), GFP_KERNEL);
> if (!attrs)
> return -ENOMEM;
>
> - snprintf(machine, sizeof(machine), "%s (%s)", mtk_socinfop->socinfo_data->marketing_name,
> - mtk_socinfop->socinfo_data->soc_name);
> - attrs->family = soc_manufacturer;
> - attrs->machine = machine;
> + if (data->marketing_name != NULL && data->marketing_name[0] != '\0')
> + attrs->family = devm_kasprintf(mtk_socinfop->dev, GFP_KERNEL, "MediaTek %s",
> + data->marketing_name);
> + else
> + attrs->family = soc_manufacturer;
> +
> + attrs->soc_id = data->soc_name;
> + /*
> + * The "machine" field will be populated automatically with the model
> + * name from board DTS (if available).
> + **/
>
> mtk_socinfop->soc_dev = soc_device_register(attrs);
> if (IS_ERR(mtk_socinfop->soc_dev))
> --
> 2.47.1.613.gc27f4b7a9f-goog
>
More information about the linux-arm-kernel
mailing list