Message ID | 20231122125643.1717160-1-adeep@lexina.in |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1301379vqb; Wed, 22 Nov 2023 05:00:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5DX50orXO2K85ODiQMlSS1swo9dk5L7ChmObgQGmYVkh/20vTbmIosjSoPGkbmWwLaA85 X-Received: by 2002:a17:902:650a:b0:1cf:7439:690c with SMTP id b10-20020a170902650a00b001cf7439690cmr4349867plk.11.1700658021473; Wed, 22 Nov 2023 05:00:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700658021; cv=none; d=google.com; s=arc-20160816; b=IW4VJYroxiDQLKS/fB/00b0d4iEofPlrhPGRIZEUYIHk4BKVDXlEDjh8/ve+DmaR3G UsEFi8vZVGqp1BXcteDeqERtDJQEO9fUXznuWlqbGOjfDaeVZ1mxGJSDtvPooDDTjODH 2nj+0711zGBD8D1efB7tsT6rEtfgZ/zyHAkYlUi9dXtMJlcOzZSj7PKfXs1T25vMFJ+N tRpZuBX6cUVxpLv2p1sDkYK/DXhOYv9PGp0x/fn0NFYhdQmzZv5j724YdoKvJO0rw5UL ZzBMysFEZjygrhSOBVEZ2rJbKar8Cm2O7wcefR04efex34bnBqhPjC7Dp+i6Nv4Lz6iW vKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=NJqnHAtPlKbGsmXwWt6Mzhb01vRIrHrGSJJ9KKN9CCc=; fh=Bllhknq5mciwRt9/KlTV9ZyEB86DXiZLRo/zORr6zwc=; b=bp2I4mP2P3lebpPKkoEQ5qKFp3kb4HvFYnqE+/737v6nL9gUuGkKFyteZtIwlyfjqC ogHyvvThyO5GxGIiKWaJvqIogL/5VWFLGQHPkp9iMJqgxHYqXwF5Xv6EZ508alJdUZgy 2olLrjdoJiOdduXjbbEoTDx1qAbZTiVpWtCKN6LjDX1yRolW2GxOt32w+DAYkxQVZmCy hA7DRgK9dajXBGj2AHONy94KJUA76y3rjBoUcAnLiD321ZV7CvSLh9Vkpr8xHzvseMeV +c34i5hJxZpoweTTitbm65kuVQX8vmdpOlpw8AvumWT2G91z7MNuRn8exqpnmZH1izIz 8Bog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=fetTjSdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t14-20020a170902e84e00b001cc4107a515si13158214plg.48.2023.11.22.05.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 05:00:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@lexina.in header.s=dkim header.b=fetTjSdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=lexina.in Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A1FEE80A7E75; Wed, 22 Nov 2023 04:57:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344258AbjKVM5O (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Wed, 22 Nov 2023 07:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344242AbjKVM5H (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Nov 2023 07:57:07 -0500 Received: from mx.msync.work (mx.msync.work [62.182.159.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36DFAD4F; Wed, 22 Nov 2023 04:56:56 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 99D4153ED3; Wed, 22 Nov 2023 12:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexina.in; s=dkim; t=1700657813; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding; bh=NJqnHAtPlKbGsmXwWt6Mzhb01vRIrHrGSJJ9KKN9CCc=; b=fetTjSddAWPcFfjStVgAKIIqceJ4c6B6mXFlCugrJlyGmrjsGOelHSc2y2oEnfWrgWJKz3 NLFhStEMpLN0We0NMEWCrw2XkTJuyLOrmS8/0tUUCuFcqrKBwcWwKv9POQb+TmpuVCWymO SWf4kPm41WaAKEoDHAdZk1ZV4xhIfhrSCru/2U0sUM7ya8y7GaGelOt6CeaM41USx/TqMa jv6fXyLf+ndyTD24zb6E1F84eJshhYiX1TdTE2ujLP+2ONiFTrsLx4gkzqF9SlO66JPc9D 8PuRzxhSfBE2p/T+7++iiRHrV6u2FnK7wTJbhD6/y6F0BMn87uy0Ze5DmqQDDA== From: Viacheslav Bocharov <adeep@lexina.in> To: Neil Armstrong <neil.armstrong@linaro.org>, Jerome Brunet <jbrunet@baylibre.com>, Kevin Hilman <khilman@baylibre.com>, Martin Blumenstingl <martin.blumenstingl@googlemail.com>, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 0/5] soc: amlogic: add new meson-gx-socinfo-sm driver Date: Wed, 22 Nov 2023 15:56:38 +0300 Message-Id: <20231122125643.1717160-1-adeep@lexina.in> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1267; h=from:subject; bh=DcgIzLHIf256LOHM599wpJilJoTBV1o/3eeRP7SNgIc=; b=owGbwMvMwCHmnhFhrJcZuJTxtFoSQ2rstyOOs3z8P159rJUk2rqkoqfX9FXs5NANbz6c3bD/8vfk R2/fdZSyMIhxMMiKKbKEdQRN3eex+uLEBUYHYOawMoEMYeDiFICJPM1n+KfjHLLE+OoKdqc4v9s8T4 zMIlxC8/07525l3F9pqiR4/CnD/zAjyWnzdLtDZbPTbiWKOO3Y1bQsvmmpcnZK0TN7uTnr2AE= X-Developer-Key: i=adeep@lexina.in; a=openpgp; fpr=E2FA1A767ACB0716E02E3E7AEE36B110025A8DFA Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:57:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783269185865643801 X-GMAIL-MSGID: 1783269185865643801 |
Series |
soc: amlogic: add new meson-gx-socinfo-sm driver
|
|
Message
Viacheslav
Nov. 22, 2023, 12:56 p.m. UTC
The Amlogic Meson SoC Secure Monitor implements a call to retrieve an unique SoC ID starting from the GX Family and all new families. But GX-family chips (e.g. GXB, GXL and newer) supports also 128-bit chip ID. 128-bit chip ID consists 32-bit SoC version and 96-bit OTP data. This is the second attempt to publish data from the Amlogic secure monitor chipid call. After discussions with Neil Armstrong, it was decided to publish the chipid call results through the soc driver. Since soc_device_match cannot wait for the soc driver to load, and the secure monitor calls in turn depend on the sm driver, it was necessary to create a new driver rather than expand an existing one. In the patches, in addition to writing the driver: - convert commonly used structures and functions of the meson-gx-socinfo driver to a header file. - transfer the chipid sm call constants to a header file (perhaps they need renaming?). - add secure-monitor references for amlogic,meson-gx-ao-secure sections in dts files of the a1, axg, g12, gx families. Viacheslav Bocharov (5): soc: amlogic: meson-gx-socinfo: move common code to header file soc: amlogic: meson-gx-socinfo: move common code to exported function firmware: meson_sm: move common definitions to header file soc: amlogic: Add Amlogic secure-monitor SoC Information driver arm64: dts: meson: add dts links to secure-monitor for soc driver in a1, axg, gx, g12 arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + .../boot/dts/amlogic/meson-g12-common.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + drivers/firmware/meson/meson_sm.c | 4 - drivers/soc/amlogic/Kconfig | 10 + drivers/soc/amlogic/Makefile | 1 + .../soc/amlogic/meson-gx-socinfo-internal.h | 102 ++++++++++ drivers/soc/amlogic/meson-gx-socinfo-sm.c | 178 ++++++++++++++++++ drivers/soc/amlogic/meson-gx-socinfo.c | 106 ++--------- include/linux/firmware/meson/meson_sm.h | 4 + 11 files changed, 317 insertions(+), 92 deletions(-) create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-internal.h create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-sm.c
Comments
Hello Neil, May I put in my two cents on this patch series? There appears to be a misunderstanding regarding the terminology used. Allow me to clarify my perspective. The original Amlogic chipid has the following format: 4 bytes 12 bytes +-------+-------------------+ | | | | CPUID | SOC SERIAL NUMBER | | | | +-------+-------------------+ 0 15 In the current uboot [1] and kernel [2] upstream, only the SOC SERIAL NUMBER bytes are read from efuse OTP storage (and it isn't swapped, as Amlogic reference code does [3]). We refer to these bytes as "serial". The original chipid value is utilized in several algorithms (for example, in the Amlogic boot protocols), making it crucial to have the ability to read the original chipid value as intended by the vendor. In my opinion, we should align our naming terminology as follows: - "chipid" - Represents the complete Amlogic SoC ID, includes "cpuid" and "serial" - "serial" - 12 byte unique SoC number, identifying particular die We strongly believe that this patch series is essential and are highly interested in seeing it applied to the upstream linux-amlogic, for the following reasons: - We use chipid for device identification in our boards - The Amlogic boot protocols utilize the full version of chipid (ADNL, Optimus). As I mentioned in the IRC, we are preparing a patch series for uboot incorporating them. - in OPTEE: for generation of SSK (Secure Storage Key) [4] - RPMB: for generation of RPMB key, further provisioned into RPMB controller (thus particular SoC is bound to particular eMMC Therefore, I propose that we rename "soc_id" in the Viacheslav patch series to "chipid" and subsequently port this patch series to uboot. What are your thoughts on this matter? Links: [1] - https://elixir.bootlin.com/u-boot/v2024.01/source/arch/arm/mach-meson/sm.c#L84 [2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/firmware/meson/meson_sm.c#L268 [3] - https://github.com/CoreELEC/u-boot/blob/3efc85a8370796bcec3bcadcdecec9aed973f4a9/arch/arm/mach-meson/g12a/bl31_apis.c#L398-L417 [4] - https://github.com/OP-TEE/optee_os/blob/5df2a985b2ffd0b6f1107f12ca2a88203bf31328/core/tee/tee_fs_key_manager.c#L152 On Wed, Nov 22, 2023 at 03:56:38PM +0300, Viacheslav Bocharov wrote: > The Amlogic Meson SoC Secure Monitor implements a call to retrieve an > unique SoC ID starting from the GX Family and all new families. > But GX-family chips (e.g. GXB, GXL and newer) supports also 128-bit > chip ID. 128-bit chip ID consists 32-bit SoC version and 96-bit OTP data. > > This is the second attempt to publish data from the Amlogic secure monitor > chipid call. After discussions with Neil Armstrong, it was decided to > publish the chipid call results through the soc driver. Since > soc_device_match cannot wait for the soc driver to load, and the secure > monitor calls in turn depend on the sm driver, it was necessary to create > a new driver rather than expand an existing one. > > In the patches, in addition to writing the driver: > - convert commonly used structures and functions of the meson-gx-socinfo > driver to a header file. > - transfer the chipid sm call constants to a header file (perhaps they > need renaming?). > - add secure-monitor references for amlogic,meson-gx-ao-secure sections > in dts files of the a1, axg, g12, gx families. > > Viacheslav Bocharov (5): > soc: amlogic: meson-gx-socinfo: move common code to header file > soc: amlogic: meson-gx-socinfo: move common code to exported function > firmware: meson_sm: move common definitions to header file > soc: amlogic: Add Amlogic secure-monitor SoC Information driver > arm64: dts: meson: add dts links to secure-monitor for soc driver in > a1, axg, gx, g12 > > arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 1 + > arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + > .../boot/dts/amlogic/meson-g12-common.dtsi | 1 + > arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + > drivers/firmware/meson/meson_sm.c | 4 - > drivers/soc/amlogic/Kconfig | 10 + > drivers/soc/amlogic/Makefile | 1 + > .../soc/amlogic/meson-gx-socinfo-internal.h | 102 ++++++++++ > drivers/soc/amlogic/meson-gx-socinfo-sm.c | 178 ++++++++++++++++++ > drivers/soc/amlogic/meson-gx-socinfo.c | 106 ++--------- > include/linux/firmware/meson/meson_sm.h | 4 + > 11 files changed, 317 insertions(+), 92 deletions(-) > create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-internal.h > create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-sm.c > > -- > 2.34.1 > > > _______________________________________________ > linux-amlogic mailing list > linux-amlogic@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-amlogic
On 16/02/2024 08:47, Dmitry Rokosov wrote: > Hello Neil, > > May I put in my two cents on this patch series? > > There appears to be a misunderstanding regarding the terminology used. > Allow me to clarify my perspective. > > The original Amlogic chipid has the following format: > > 4 bytes 12 bytes > +-------+-------------------+ > | | | > | CPUID | SOC SERIAL NUMBER | > | | | > +-------+-------------------+ > 0 15 > > > In the current uboot [1] and kernel [2] upstream, only the SOC SERIAL > NUMBER bytes are read from efuse OTP storage (and it isn't swapped, as > Amlogic reference code does [3]). We refer to these bytes as "serial". > > The original chipid value is utilized in several algorithms (for > example, in the Amlogic boot protocols), making it crucial to have the > ability to read the original chipid value as intended by the vendor. > > In my opinion, we should align our naming terminology as follows: > - "chipid" - Represents the complete Amlogic SoC ID, includes > "cpuid" and "serial" > - "serial" - 12 byte unique SoC number, identifying particular die > > We strongly believe that this patch series is essential and are highly interested in seeing it applied to the upstream linux-amlogic, for the following reasons: > - We use chipid for device identification in our boards > - The Amlogic boot protocols utilize the full version of chipid > (ADNL, Optimus). As I mentioned in the IRC, we are preparing a > patch series for uboot incorporating them. > - in OPTEE: for generation of SSK (Secure Storage Key) [4] > - RPMB: for generation of RPMB key, further provisioned into RPMB > controller (thus particular SoC is bound to particular eMMC > > Therefore, I propose that we rename "soc_id" in the Viacheslav patch > series to "chipid" and subsequently port this patch series to uboot. > > What are your thoughts on this matter? I'm perfectly fine with that, but I don't like the shared functions, the only shared stuff are the soc id tables, the shared functions is not important enough to be shared. Neil > > Links: > [1] - https://elixir.bootlin.com/u-boot/v2024.01/source/arch/arm/mach-meson/sm.c#L84 > [2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/firmware/meson/meson_sm.c#L268 > [3] - https://github.com/CoreELEC/u-boot/blob/3efc85a8370796bcec3bcadcdecec9aed973f4a9/arch/arm/mach-meson/g12a/bl31_apis.c#L398-L417 > [4] - https://github.com/OP-TEE/optee_os/blob/5df2a985b2ffd0b6f1107f12ca2a88203bf31328/core/tee/tee_fs_key_manager.c#L152 > > On Wed, Nov 22, 2023 at 03:56:38PM +0300, Viacheslav Bocharov wrote: >> The Amlogic Meson SoC Secure Monitor implements a call to retrieve an >> unique SoC ID starting from the GX Family and all new families. >> But GX-family chips (e.g. GXB, GXL and newer) supports also 128-bit >> chip ID. 128-bit chip ID consists 32-bit SoC version and 96-bit OTP data. >> >> This is the second attempt to publish data from the Amlogic secure monitor >> chipid call. After discussions with Neil Armstrong, it was decided to >> publish the chipid call results through the soc driver. Since >> soc_device_match cannot wait for the soc driver to load, and the secure >> monitor calls in turn depend on the sm driver, it was necessary to create >> a new driver rather than expand an existing one. >> >> In the patches, in addition to writing the driver: >> - convert commonly used structures and functions of the meson-gx-socinfo >> driver to a header file. >> - transfer the chipid sm call constants to a header file (perhaps they >> need renaming?). >> - add secure-monitor references for amlogic,meson-gx-ao-secure sections >> in dts files of the a1, axg, g12, gx families. >> >> Viacheslav Bocharov (5): >> soc: amlogic: meson-gx-socinfo: move common code to header file >> soc: amlogic: meson-gx-socinfo: move common code to exported function >> firmware: meson_sm: move common definitions to header file >> soc: amlogic: Add Amlogic secure-monitor SoC Information driver >> arm64: dts: meson: add dts links to secure-monitor for soc driver in >> a1, axg, gx, g12 >> >> arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 1 + >> arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + >> .../boot/dts/amlogic/meson-g12-common.dtsi | 1 + >> arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + >> drivers/firmware/meson/meson_sm.c | 4 - >> drivers/soc/amlogic/Kconfig | 10 + >> drivers/soc/amlogic/Makefile | 1 + >> .../soc/amlogic/meson-gx-socinfo-internal.h | 102 ++++++++++ >> drivers/soc/amlogic/meson-gx-socinfo-sm.c | 178 ++++++++++++++++++ >> drivers/soc/amlogic/meson-gx-socinfo.c | 106 ++--------- >> include/linux/firmware/meson/meson_sm.h | 4 + >> 11 files changed, 317 insertions(+), 92 deletions(-) >> create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-internal.h >> create mode 100644 drivers/soc/amlogic/meson-gx-socinfo-sm.c >> >> -- >> 2.34.1 >> >> >> _______________________________________________ >> linux-amlogic mailing list >> linux-amlogic@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-amlogic >