Hi,
On Fri, Jan 21, 2022 at 07:54:20PM -0800, Florian Fainelli wrote:
Add support for the Broadcom STB system suspend operations which
leverage the standard PSCI functions and uses the
psci_cpu_suspend_enter() operation to power off the system with or
without retention ("echo standby > /sys/power/state").
What exactly does this enable that can't be achieved with the existing PSCI
driver as-is?
When you say "retention", what specifically do you mean? Retention of CPU
state? DRAM contents?
We already have SYSTEM_SUSPEND for states where DRAM content is retained but
CPU (and some system state) is lost, and IIUC we can do suspend-to-idle with
CPU_SUSPEND states.
interface necessary?
The system reset path also supports a special "powercycle" mode which
signals to the ARM Trusted Firmware that an external PMIC chip must
force the SoC into a power cycle.
How does that compare to the regular SYSTEM_RESET call?
The PSCI spec says of SYSTEM_RESET:
| This function provides a method for performing a system cold reset. To the
| caller, the behavior is equivalent to a hardware power-cycle sequence.
... so I don't follow how this is different, unless this platform's
SYSTEM_RESET implementation is *not* actually performing a system cold reset?
If that *doesn't* perform a cold rest, it seems like a bug?
As much as possible extensions were built using the SIP namespace rather
than the standard PSCI namespace, however compatibility with the
standard PSCI implementation is retained when CONFIG_BRCMSTB_PM is not
selected.
I really don't like this, because it seems to be creating a parallel
infrastructure for doing things that can *already* be done with standard PSCI
driver. The actual PSCI bits just seem to be playing about with the power_state
value, which we should be able to do in the regular PSCI driver, and the
SIP-specific functions seem to have nothing to do with PSCI.
At the least there needs to be a much better explanation of why this is
necessary, but overall I'd very much like to have *any* vendor specific code
for suspend states, and if there are limitations in the standard PSCI driver we
go and address those. Otherwise we're going to gain a plethora of
vendor-specific suspend implementations, which is exactly what PSCI was
intended to avoid in the first place.
I have some specific comments below, but even with those addressed, I don't
think this is the right approach, and as things stand, NAK to this.
+static int brcmstb_psci_integ_region_reset_all(void)
+{
+ return invoke_psci_fn(SIP_FUNC_INTEG_REGION_RESET_ALL, 0, 0, 0);
+}
What's all this? Below I see the phrase "integrity checking regions", but only
the brcmstb_psci_integ_region_reset_all() function is used, and it's not clear
what this is supposed to be for.
+static int brcmstb_psci_sys_reset(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ const char *cmd = data;
+ /*
+ * reset_type[31] = 0 (architectural)
+ * reset_type[30:0] = 0 (SYSTEM_WARM_RESET)
+ * cookie = 0 (ignored by the implementation)
+ */
+ uint32_t reboot_type = 0;
+
+ if ((action == REBOOT_COLD || action == REBOOT_WARM ||
+ action == REBOOT_SOFT) &&
+ brcmstb_psci_system_reset2_supported) {
+ if (cmd && !strcmp(cmd, "powercycle"))
+ reboot_type = BIT(31) | 1;
+ invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), reboot_type, 0, 0);
+ } else {
+ invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+ }
+
+ return NOTIFY_DONE;
+}
If there are a bunch of specific SYSTEM_RESET2 values we want to expose, I'd
rather we described those generically in the DT, and somehow handle that in the
generic driver.
+
+static struct notifier_block brcmstb_psci_nb = {
+ .notifier_call = brcmstb_psci_panic_notify,
+};
This appears to have nothing to do with idle/suspend states (and so might be OK
on its own if you need it, but it should be in a separate patch with some
justification).
Immediately after this switch, we know we there is *a* SMCCCv1.1+
implementation, but we have no idea *which* implementation that is. It could be
Broadcom's brcmstb implementation, it could be KVM's implementation, or anyone
else's...
+
+ /* Check the revision of monitor */
+ if (invoke_psci_fn == __invoke_psci_fn_hvc)
+ arm_smccc_hvc(SIP_SVC_REVISION,
+ 0, 0, 0, 0, 0, 0, 0, &res);
+ else
+ arm_smccc_smc(SIP_SVC_REVISION,
+ 0, 0, 0, 0, 0, 0, 0, &res);
This tells us the SIP interface's revision (if implemented), but not that the
SIP is Broadcom, and we still don't know that this is the brcmstb
implementation specifically.
+ pr_info("Using PSCI based system PM (full featured)\n");
This should be explicit with something like "Overriding stnadard PSCI
functionaliy with brcmstb-specific code".
As it stands this is at best meaningless, and at worst misleading and
disparaging of standard PSCI.
+#define SIP_SVC_REVISION \
+ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
+ IS_ENABLED(CONFIG_64BIT), \
+ ARM_SMCCC_OWNER_SIP, \
+ 0xFF02)
Looking at the SMCCC spec, isn't the "general service query" REVISION call
0xFF03? 0xFF02 is reserved.
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature