[PATCH v3 2/2] firmware: zynqmp: Move config object permission check
Stefan Herbrechtsmeier
stefan.herbrechtsmeier-oss at weidmueller.com
Thu Apr 27 12:31:25 CEST 2023
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
Move the check of the permission to change a config object from
zynqmp_pmufw_node function to zynqmp_pmufw_load_config_object function
to simplify the code and check the permission only if required.
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
---
Changes in v3:
- Added
drivers/firmware/firmware-zynqmp.c | 32 +++++++++++++++---------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index 2b1ad5d2c3..d12159fa78 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -70,20 +70,11 @@ int zynqmp_pmufw_config_close(void)
int zynqmp_pmufw_node(u32 id)
{
- static bool skip_config;
- int ret;
-
- if (skip_config)
- return 0;
-
/* Record power domain id */
xpm_configobject[NODE_ID_LOCATION] = id;
- ret = zynqmp_pmufw_load_config_object(xpm_configobject,
- sizeof(xpm_configobject));
-
- if (ret == -EACCES && id == NODE_OCM_BANK_0)
- skip_config = true;
+ zynqmp_pmufw_load_config_object(xpm_configobject,
+ sizeof(xpm_configobject));
return 0;
}
@@ -239,9 +230,23 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
*/
int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
{
+ static bool checked;
+ static bool skip;
int err;
u32 ret_payload[PAYLOAD_ARG_CNT];
+ if (!checked) {
+ checked = true;
+
+ if (zynqmp_pmufw_node(NODE_OCM_BANK_0) == -EACCES) {
+ printf("PMUFW: No permission to change config object\n");
+ skip = true;
+ }
+ }
+
+ if (skip)
+ return -EACCES;
+
if (IS_ENABLED(CONFIG_SPL_BUILD))
printf("Loading new PMUFW cfg obj (%ld bytes)\n", size);
@@ -250,8 +255,6 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0,
0, ret_payload);
if (err == XST_PM_NO_ACCESS) {
- if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0)
- printf("PMUFW: No permission to change config object\n");
return -EACCES;
}
@@ -295,9 +298,6 @@ static int zynqmp_power_probe(struct udevice *dev)
ret >> ZYNQMP_PM_VERSION_MAJOR_SHIFT,
ret & ZYNQMP_PM_VERSION_MINOR_MASK);
- if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
- zynqmp_pmufw_node(NODE_OCM_BANK_0);
-
return 0;
};
--
2.30.2
More information about the U-Boot
mailing list