[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241219113411.3999355-1-fshao@chromium.org>
Date: Thu, 19 Dec 2024 19:33:50 +0800
From: Fei Shao <fshao@...omium.org>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Matthias Brugger <matthias.bgg@...il.com>
Cc: Fei Shao <fshao@...omium.org>,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org
Subject: [PATCH] soc: mediatek: mtk-socinfo: Restructure SoC attribute information
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@...omium.org>
---
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
Powered by blists - more mailing lists