mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Chuan Liu <chuan.liu@amlogic.com>
To: Cristian Marussi <cristian.marussi@arm.com>,
	Lucas Tanure <tanure@linux.com>
Cc: Jian Hu <jian.hu@amlogic.com>,
	Xianwei Zhao <xianwei.zhao@amlogic.com>,
	Nick Xie <nick@khadas.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	arm-scmi@vger.kernel.org,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	linux-amlogic@lists.infradead.org, kelvin.zhang@amlogic.com
Subject: Re: [BUG] T7 SCMI firmware: CLOCK_ATTRIBUTES reply is too short for the clock protocol version it reports
Date: Wed, 2 Dec 2026 20:29:14 +0800	[thread overview]
Message-ID: <8dd30f81-2b94-4fff-8c75-b7c7a62cc3cc@amlogic.com> (raw)
In-Reply-To: <awxy0ewB8jpyEOhn@pluto>

Hi Cristian, Lucas,

On 11/30/2026 2:45 AM, Cristian Marussi wrote:
> [Some people who received this message don't often get email from cristian.marussi@arm.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> [ EXTERNAL EMAIL ]
> 
> On Sun, Nov 29, 2026 at 09:19:03AM +0000, Lucas Tanure wrote:
>> Hello,
> 
> Hi Lucas,
> 
>>
>> I am working on mainline Linux support for the Amlogic T7 (A311D2) on
>> the Khadas VIM4. The SCMI server in the T7 firmware sends a reply that
>> does not match the SCMI specification. Because of it, linux-next no
>> longer boots on these boards, and mainline will not either once that
>> change is merged.
>>
>> The problem
>> -----------
>> The firmware reports SCMI clock protocol version 2.0 or later. From
>> that version (SCMI v3.1) the CLOCK_ATTRIBUTES reply has a
>> clock_enable_latency field at the end, so the payload is 24 bytes:
>> attributes (4), name (16), clock_enable_latency (4). The T7 firmware
>> sends only 20 bytes, without clock_enable_latency.
> 
> this is the typical case in which after tightening the kernel checks we
> broke some out-of-spec platform running in the wild.
> 
> While we'd like to have the FW fixed (as per your ask) we try NOT to
> break existent deployment by using quirks when needed.
> 
> I'll post a possible trivial quirk for you to try about this AMLOGiC
> issue.

Our SCMI server in BL31 is based on the upstream Trusted Firmware-A
"scmi-msg" driver (drivers/scmi-msg/), v2.7 baseline [1].

In TF-A v2.7, the clock protocol reports SCMI_PROTOCOL_VERSION_CLOCK
0x20000 (protocol v2.0) [2], and the CLOCK_ATTRIBUTES reply is built
from:

   struct scmi_clock_attributes_p2a {
         int32_t status;
         uint32_t attributes;
         char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
   };

i.e. a 20-byte payload with no clock_enable_latency field. So what
Lucas observed on the T7 (37 clocks, HDR 0x14/0x03, expected 24 /
received 20) is not a modification specific to Amlogic.

Later Kamlesh added clock_enable_delay when he submitted a patch 
introducing SCMI clock protocol version 3.0 [3], So before this upstream 
TF-A adaptation SCMI clock vendors may encounter similar issues.

> 
>>
>> Linux log, one line per clock (37 clocks), with a debug change that
>> only warns:
>>
>>    arm-scmi arm-scmi.0.auto: SCMI Protocol v2.0 'AMLOGIC:' Firmware version 0x0
> 
> While at it, it would be good if the FW guys could fix also the reported
> FW version which is now 0x0 BUT it should identify somehow the installed
> FW binary blob...given that all of the SCMI quirk framework is based on
> this.

Regarding the firmware version, we did not change but keep the default 
version number of TF-A [4]. If this is necessary, we will deliberately 
improve and manage this version number later.

> 
>>    arm-scmi arm-scmi.0.auto: Truncated reply - HDR:002C5003
>> expected:24  received:20
>>    ...
>>    arm-scmi arm-scmi.0.auto: Truncated reply - HDR:014C5003
>> expected:24  received:20
>>
>> (protocol 0x14 = clock, message 0x03 = CLOCK_ATTRIBUTES)
>>
>> Effect on Linux
>> ---------------
>> linux-next now checks the size of every SCMI reply ("firmware: arm_scmi:
>> Add centralized detection of truncated replies"). With the T7 firmware
>> every SCMI clock fails, so devices that use them do not probe. On the
>> VIM4 the SD card and eMMC hosts fail, and the board cannot mount its
>> root filesystem. Older kernels accepted the short reply, but they read
>> clock_enable_latency from past the end of it, so the value was wrong
>> there too.
>>
>> Two other replies from the same firmware are also out of spec:
>>   - CLOCK_DESCRIBE_RATES: Linux needs a quirk for it
>>     (quirk_clock_rates_triplet_out_of_spec).
>>   - During SCMI initialisation Linux logs "Malformed reply -
>>     real_sz:8 calc_sz:4 (loop_num_ret:1)". I have not checked which
>>     command this is.
> 
> This is an historical quirk that is enabled on any FW, because was
> historically present on most of original FW reference from which many
> vendor FW were forked....nothing really to do here...the quirk is active
> and working...
> 
>>
>> Firmware on my board
>> --------------------
>>    BL2   : Built 11:37:41, Apr 12 2024, t7 projects/t7 g6adeddf
>>    BL2E  : Built 11:23:05, Apr 17 2024, t7 projects/amlogic-dev g31eecf9
>>    BL2X  : Built 11:37:21, Apr 25 2024, t7 projects/amlogic-dev g767c913
>>    BL31  : v1.3.2(release):2dd964006, Built 16:38:51, Feb 1 2026,
>>            t7 amlogic-dev-1.3 g2dd964006
>>    BL32  : ATOS-V3.8.0-ec8c40b03, 11 May 2024
>>    U-Boot: 2019.01 (Aug 02 2026), Khadas VIMs mainline build
>>    SCMI transport: SMC
>>
>> This BL31 is the newest one Khadas has published: khadas/u-boot branch
>> khadas-vims-v2019.01-mainline, commit a7b06ca0498f ("bl31: bl31_1.3:
>> bin: update to version 3539ff675", 6 Mar 2026), which contains Amlogic
>> BL31 commit 2dd964006 (16 Jan 2026).
>>
>> Questions
>> ---------
>> 1. Can the SCMI server send the full 24-byte CLOCK_ATTRIBUTES reply
>>     (clock_enable_latency may be 0), or report clock protocol version
>>     1.0 if version 2.0 is not fully supported?
>> 2. Which other SoCs use the same SCMI server code (S4, A4, others)? They
>>     may have the same problem.

Yes, Currently all our SoCs supporting SCMI server are based on the 
native TF-A v2.7.

>> 3. Khadas: if Amlogic fixes this, can you release an updated firmware
>>     (bootloader) for the VIM4?

Yes, If this is necessary later we can provide SCMI clock protocol 
version support up to 3.0 firmware.

>>
>> Boards that keep the current firmware will probably still need a
>> workaround in Linux, so a firmware fix alone does not solve this. But a
>> fixed firmware would help everyone who uses mainline on these boards.
>> I have copied Cristian Marussi, who works on the Linux SCMI code and
>> wrote the new size check, so that the firmware side and the Linux side
>> can be agreed together.
> 
> 
> I'll post a possoble quirk for you to test...it will be matching against
> 
>          Vendor:AMLOGIC SubVendor:<NULL> FirmVersion:0x0
> 
> Feel free to adapt to your needs.
> 
> Thanks,
> Cristian

[1] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
[2] 
https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/c9e8300012113df5d279dbef5435c77f6b6dea67
[3] 
https://github.com/TrustedFirmware-A/trusted-firmware-a/commit/684952d17275d49ddb0fcb1e3d5df020fb5eae0f
[4] 
https://github.com/TrustedFirmware-A/trusted-firmware-a/blob/main/drivers/scmi-msg/common.h#L21

-- 
Best regards,
Chuan


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2026-12-02 12:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:19 Lucas Tanure
2026-11-29 18:45 ` Cristian Marussi
2026-12-02 12:29   ` Chuan Liu [this message]

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=8dd30f81-2b94-4fff-8c75-b7c7a62cc3cc@amlogic.com \
    --to=chuan.liu@amlogic.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=jian.hu@amlogic.com \
    --cc=kelvin.zhang@amlogic.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=nick@khadas.com \
    --cc=tanure@linux.com \
    --cc=xianwei.zhao@amlogic.com \
    /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

all inboxes | Powered by JetHome®