From: Jay Buddhabhatti <jbuddhab@amd.com>
To: Sudeep Holla <sudeep.holla@kernel.org>,
Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Cc: michal.simek@amd.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, ptsm@linux.microsoft.com,
radhey.shyam.pandey@amd.com
Subject: Re: [PATCH v3 1/3] firmware: xilinx: Add support to clear TF-A PM state
Date: Wed, 29 Jul 2026 12:35:17 +0530 [thread overview]
Message-ID: <9c6b14ca-a9e3-45ae-961e-46c20b0eb446@amd.com> (raw)
In-Reply-To: <20260724-stirring-bloodhound-of-sufficiency-5bedff@sudeepholla>
Hi Sudeep,
Thanks for the review. Replies inline.
On 7/24/2026 4:43 PM, Sudeep Holla wrote:
> On Fri, Jul 24, 2026 at 03:19:46AM -0700, Jay Buddhabhatti wrote:
>> Currently, during a kexec restart, only the kernel is reloaded, while the
>> TF-A specific data remain unchanged. This leads to a mismatch between the
>> kernel state and the TF-A firmware state like SGI number and shutdown
>> scope variable.
>>
>
> Avoid using TF-A in general as it can be any other firmware as well.
> You can always generalise as PSCI or EL3 firmware.
Agreed. Updated the commit message and in-patch comments to refer to
"EL3 firmware" / "secure firmware" rather than TF-A.
>
>> For example, the kernel registers an SGI number with TF-A so that TF-A can
>> notify the kernel of events via that SGI. TF-A stores this SGI number in
>> its internal state. After a kexec, the newly loaded kernel re-registers
>> and may request a different SGI number, but the stale value programmed in
>> TF-A remains, so event notifications are delivered on the old SGI and are
>> missed by the new kernel. The shutdown scope variable has a similar stale
>> state problem.
>>
>
> Doesn't it reset it every time CPU_OFF or CPU_ON is called ?
No. The SGI registration is done once via zynqmp_pm_register_sgi() when
the event manager driver probes; it programs the SGI number into EL3 PM
state. On CPU hotplug, the kernel only enables/disables the per-CPU IRQ
(enable_percpu_irq() / disable_percpu_irq() in xlnx_event_manager.c);
it does not re-register the SGI with EL3 on CPU_ON or clear that
registration on CPU_OFF.
So while SGI delivery is per-CPU from the GIC side, the SGI number EL3
uses to raise the interrupt is subsystem-global state held in EL3, not
per-CPU state that is reset by CPU hotplug.
>
>> To resolve this, the TF_A_CLEAR_PM_STATE PM API is introduced to clear
>> TF-A-specific state during kexec. On a graceful reboot, this API is
>> triggered by zynqmp_firmware_shutdown(), while in a crash kernel scenario,
>> it is invoked by zynqmp_firmware_probe() in the reloaded kernel.
>>
>
> I don't see the need for such an API just for kexec needs. You must deal
> with it as part of CPU_ON as it should start with clean slate as SGIs are
> per CPU, no ?
Handling this purely in the CPU_ON path would require either EL3 to
clear/re-init this PM state on every CPU bring-up, or the kernel to
re-register the SGI on every CPU_ON. Neither happens today. CPU_ON is
not the point at which this state is established or torn down; driver
probe/shutdown is. That is why the platform firmware exposes
TF_A_CLEAR_PM_STATE - to reset EL3 PM subsystem state when the OS is
replaced without a full firmware reload.
The kexec cleanup is therefore a targeted reset at the OS transition
boundary (zynqmp_firmware_shutdown() on graceful kexec,
zynqmp_firmware_probe() on kdump), not a general CPU hotplug hook.
Given the above, I believe adding a dedicated API and invoking it at the
kexec boundary is the correct approach.
Thanks,
Jay
>
next prev parent reply other threads:[~2026-07-29 7:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 12:48 [PATCH 0/4] firmware: xilinx: Clean up firmware and TF-A state on kexec Jay Buddhabhatti
2026-07-23 12:48 ` [PATCH 1/4] firmware: xilinx: Add support to clear TF-A PM state Jay Buddhabhatti
2026-07-23 16:25 ` Pandey, Radhey Shyam
2026-07-24 6:17 ` Prasanna Kumar T S M
2026-07-23 12:48 ` [PATCH 2/4] firmware: xilinx: Release all peripheral devices from firmware Jay Buddhabhatti
2026-07-23 16:25 ` Pandey, Radhey Shyam
2026-07-24 6:17 ` Prasanna Kumar T S M
2026-07-23 12:48 ` [PATCH 3/4] firmware: xilinx: Clear firmware notifiers across kexec transitions Jay Buddhabhatti
2026-07-23 16:27 ` Pandey, Radhey Shyam
2026-07-24 6:18 ` Prasanna Kumar T S M
2026-07-23 12:48 ` [PATCH 4/4] firmware: xilinx: Use TF-A feature check for TF-A specific APIs Jay Buddhabhatti
2026-07-23 16:28 ` Pandey, Radhey Shyam
2026-07-24 6:31 ` Prasanna Kumar T S M
2026-07-24 7:37 ` Buddhabhatti, Jay
2026-07-24 9:52 ` [PATCH v2 0/3] firmware: xilinx: Clean up firmware and TF-A state on kexec Jay Buddhabhatti
2026-07-24 9:52 ` [PATCH v2 1/4] firmware: xilinx: Add support to clear TF-A PM state Jay Buddhabhatti
2026-07-24 9:53 ` [PATCH v2 2/4] firmware: xilinx: Release all peripheral devices from firmware Jay Buddhabhatti
2026-07-24 9:53 ` [PATCH v2 3/4] firmware: xilinx: Clear firmware notifiers across kexec transitions Jay Buddhabhatti
2026-07-24 10:19 ` [PATCH v3 0/3] firmware: xilinx: Clean up firmware and TF-A state on kexec Jay Buddhabhatti
2026-07-24 10:19 ` [PATCH v3 1/3] firmware: xilinx: Add support to clear TF-A PM state Jay Buddhabhatti
2026-07-24 11:13 ` Sudeep Holla
2026-07-29 7:05 ` Jay Buddhabhatti [this message]
2026-07-24 10:19 ` [PATCH v3 2/3] firmware: xilinx: Release all peripheral devices from firmware Jay Buddhabhatti
2026-07-24 10:19 ` [PATCH v3 3/3] firmware: xilinx: Clear firmware notifiers across kexec transitions Jay Buddhabhatti
2026-07-29 12:25 ` [PATCH v4 0/3] firmware: xilinx: Clean up firmware and EL3 state on kexec Jay Buddhabhatti
2026-07-29 12:25 ` [PATCH v4 1/3] firmware: xilinx: Add support to clear EL3 PM state Jay Buddhabhatti
2026-07-29 12:25 ` [PATCH v4 2/3] firmware: xilinx: Release all peripheral devices from firmware Jay Buddhabhatti
2026-07-29 12:25 ` [PATCH v4 3/3] firmware: xilinx: Clear firmware notifiers across kexec transitions Jay Buddhabhatti
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=9c6b14ca-a9e3-45ae-961e-46c20b0eb446@amd.com \
--to=jbuddhab@amd.com \
--cc=jay.buddhabhatti@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=ptsm@linux.microsoft.com \
--cc=radhey.shyam.pandey@amd.com \
--cc=sudeep.holla@kernel.org \
/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