firmware: xilinx: Request pre-allocated peripheral nodes after bulk release
PATCH 1/1 firmware: xilinx: Request pre-allocated peripheral nodes after bulk release
During a kexec restart, zynqmp_clear_pm_state() releases all peripheral devices via PM_DEV_ALL_PERIPH. Pre-allocated nodes are then left released, so Linux no longer owns them and later peripheral access can fail.
Immediately re-request those nodes with zynqmp_pm_request_node( PM_DEV_ALL_PERIPH, ...) so Linux retains ownership. On a graceful kexec this runs from zynqmp_firmware_shutdown(). On a crash kernel restart it runs from zynqmp_firmware_probe() in the reloaded kernel.
The bulk request depends on firmware support for PM_DEV_ALL_PERIPH (PM_REQUEST_NODE feature check version >= PM_API_VERSION_3). On firmware that does not implement it, the request is skipped and a warning is logged. Errors are already logged inside zynqmp_clear_pm_state() and zynqmp_firmware_probe() does not abort if the request fails.
Also, drop the redundant ret = 0 assignments whose value is overwritten by the next do_feature_check_call()
--- drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/firmware/xilinx/zynqmp.c +13 -2
@@ -2193,7 +2193,6 @@ static int zynqmp_clear_pm_state(struct device *dev) "Failed to clear EL3 PM subsystem state: %d\n", ret); }else {dev_warn (dev,"TF_A_CLEAR_PM_STATE is not supported by EL3 firmware: %d\n" , ret); - ret =0 ; }/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */
@@ -2206,7 +2205,19 @@ static int zynqmp_clear_pm_state(struct device *dev) }else {dev_warn (dev,"Bulk device release is not supported by firmware: %d\n" , ret); - ret =0 ; + } + +/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */ + ret =do_feature_check_call (PM_REQUEST_NODE ); +if (ret >=0 && ((ret &FIRMWARE_VERSION_MASK ) >=PM_API_VERSION_3 )) { +/* Attempt to request all nodes via firmware */ + ret =zynqmp_pm_request_node (PM_DEV_ALL_PERIPH ,0 ,0 ,0 ); +if (ret) +dev_err (dev,"Failed to request all peripheral devices: %d\n" , ret); + }else { +dev_warn (dev, +"Firmware doesn't support request all peripheral devices at once: %d\n" , + ret); }/* Check if the firmware supports the PM_ALL_NOTIFIERS node ID */
Signature · 1 line
2.54.0
Quoted 15 lines · Jay Buddhabhatti
During a kexec restart,
zynqmp_clear_pm_state()releases all peripheral devices viaPM_DEV_ALL_PERIPH. Pre-allocated nodes are then left released, so Linux no longer owns them and later peripheral access can fail.Immediately re-request those nodes with
zynqmp_pm_request_node( PM_DEV_ALL_PERIPH, ...)so Linux retains ownership. On a graceful kexec this runs fromzynqmp_firmware_shutdown(). On a crash kernel restart it runs fromzynqmp_firmware_probe()in the reloaded kernel.The bulk request depends on firmware support for
PM_DEV_ALL_PERIPH(PM_REQUEST_NODEfeature check version >=PM_API_VERSION_3). On firmware that does not implement it, the request is skipped and a warning is logged. Errors are already logged insidezynqmp_clear_pm_state()andzynqmp_firmware_probe()does not abort if the request fails.
Quoted 4 lines
Also, drop the redundant ret = 0 assignments whose value is overwritten by the next
do_feature_check_call()Signed-off-by Jay Buddhabhatti <[email protected]>
Thanks!
Quoted 37 lines
--- drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/firmware/xilinx/zynqmp.c +13
-2@@ -2193,7 +2193,6 @@ static int zynqmp_clear_pm_state(struct device *dev) "Failed to clear EL3 PM subsystem state: %d\n", ret); }else {dev_warn (dev,"TF_A_CLEAR_PM_STATE is not supported by EL3 firmware: %d\n" , ret); - ret =0 ; }/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */ @@ -2206,7 +2205,19 @@ static int zynqmp_clear_pm_state(struct device *dev) }else {dev_warn (dev,"Bulk device release is not supported by firmware: %d\n" , ret); - ret =0 ; + } + +/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */ + ret =do_feature_check_call (PM_REQUEST_NODE ); +if (ret >=0 && ((ret &FIRMWARE_VERSION_MASK ) >=PM_API_VERSION_3 )) { +/* Attempt to request all nodes via firmware */ + ret =zynqmp_pm_request_node (PM_DEV_ALL_PERIPH ,0 ,0 ,0 ); +if (ret) +dev_err (dev,"Failed to request all peripheral devices: %d\n" , ret); + }else { +dev_warn (dev, +"Firmware doesn't support request all peripheral devices at once: %d\n" , + ret); }/* Check if the firmware supports the PM_ALL_NOTIFIERS node ID */
PATCH v2 1/1 firmware: xilinx: Request pre-allocated peripheral nodes after bulk release
In reply to Jay BuddhabhattiDuring a kexec restart, zynqmp_clear_pm_state() releases all peripheral devices via PM_DEV_ALL_PERIPH. Pre-allocated nodes are then left released, so Linux no longer owns them and later peripheral access can fail.
Immediately re-request those nodes with zynqmp_pm_request_node( PM_DEV_ALL_PERIPH, ...) so Linux retains ownership. On a graceful kexec this runs from zynqmp_firmware_shutdown(). On a crash kernel restart it runs from zynqmp_firmware_probe() in the reloaded kernel.
The bulk request depends on firmware support for PM_DEV_ALL_PERIPH (PM_REQUEST_NODE feature check version >= PM_API_VERSION_3). On firmware that does not implement it, the request is skipped and a warning is logged. Errors are already logged inside zynqmp_clear_pm_state() and zynqmp_firmware_probe() does not abort if the request fails.
Also, drop the redundant ret = 0 assignments whose value is overwritten by the next do_feature_check_call()
---
Changes in v2:
- Add Fixes tag for the bulk peripheral release commit.
- Add Reviewed-by from Radhey Shyam Pandey (v1 review).
--- drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/firmware/xilinx/zynqmp.c +13 -2
@@ -2193,7 +2193,6 @@ static int zynqmp_clear_pm_state(struct device *dev) "Failed to clear EL3 PM subsystem state: %d\n", ret); }else {dev_warn (dev,"TF_A_CLEAR_PM_STATE is not supported by EL3 firmware: %d\n" , ret); - ret =0 ; }/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */
@@ -2206,7 +2205,19 @@ static int zynqmp_clear_pm_state(struct device *dev) }else {dev_warn (dev,"Bulk device release is not supported by firmware: %d\n" , ret); - ret =0 ; + } + +/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */ + ret =do_feature_check_call (PM_REQUEST_NODE ); +if (ret >=0 && ((ret &FIRMWARE_VERSION_MASK ) >=PM_API_VERSION_3 )) { +/* Attempt to request all nodes via firmware */ + ret =zynqmp_pm_request_node (PM_DEV_ALL_PERIPH ,0 ,0 ,0 ); +if (ret) +dev_err (dev,"Failed to request all peripheral devices: %d\n" , ret); + }else { +dev_warn (dev, +"Firmware doesn't support request all peripheral devices at once: %d\n" , + ret); }/* Check if the firmware supports the PM_ALL_NOTIFIERS node ID */
Signature · 1 line
2.54.0
Quoted 51 lines · Jay Buddhabhatti
During a kexec restart,
zynqmp_clear_pm_state()releases all peripheral devices viaPM_DEV_ALL_PERIPH. Pre-allocated nodes are then left released, so Linux no longer owns them and later peripheral access can fail.Immediately re-request those nodes with
zynqmp_pm_request_node( PM_DEV_ALL_PERIPH, ...)so Linux retains ownership. On a graceful kexec this runs fromzynqmp_firmware_shutdown(). On a crash kernel restart it runs fromzynqmp_firmware_probe()in the reloaded kernel.The bulk request depends on firmware support for
PM_DEV_ALL_PERIPH(PM_REQUEST_NODEfeature check version >=PM_API_VERSION_3). On firmware that does not implement it, the request is skipped and a warning is logged. Errors are already logged insidezynqmp_clear_pm_state()andzynqmp_firmware_probe()does not abort if the request fails.Also, drop the redundant ret = 0 assignments whose value is overwritten by the next
do_feature_check_call()Fixes 84dbfa5519cf ("firmware: xilinx: Release all peripheral devices from firmware")Signed-off-by Jay Buddhabhatti <[email protected]>Reviewed-by Radhey Shyam Pandey <[email protected]>---
Changes in v2:
- Add Fixes tag for the bulk peripheral release commit.
- Add Reviewed-by from Radhey Shyam Pandey (v1 review).--- drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/firmware/xilinx/zynqmp.c +3
-2@@ -2193,7 +2193,6 @@ static int zynqmp_clear_pm_state(struct device *dev) "Failed to clear EL3 PM subsystem state: %d\n", ret); }else {dev_warn (dev,"TF_A_CLEAR_PM_STATE is not supported by EL3 firmware: %d\n" , ret); - ret =0 ; }/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */ @@ -2206,7 +2205,19 @@ static int zynqmp_clear_pm_state(struct device *dev) }else {dev_warn (dev,"Bulk device release is not supported by firmware: %d\n" , ret); - ret =0 ; + } + +/* Check if the firmware supports the PM_DEV_ALL_PERIPH node ID */
drivers/firmware/xilinx/zynqmp.c static int zynqmp_clear_pm_state(struct device *dev) · line 2220
Quoted 10 lines
drivers/firmware/xilinx/zynqmp.c +10
-0+ ret =do_feature_check_call (PM_REQUEST_NODE ); +if (ret >=0 && ((ret &FIRMWARE_VERSION_MASK ) >=PM_API_VERSION_3 )) { +/* Attempt to request all nodes via firmware */ + ret =zynqmp_pm_request_node (PM_DEV_ALL_PERIPH ,0 ,0 ,0 ); +if (ret) +dev_err (dev,"Failed to request all peripheral devices: %d\n" , ret); + }else { +dev_warn (dev, +"Firmware doesn't support request all peripheral devices at once: %d\n" , + ret);
Tested this change, works fine. And the code looks good to me.
Quoted 3 lines
drivers/firmware/xilinx/zynqmp.c +0
-0}/* Check if the firmware supports the PM_ALL_NOTIFIERS node ID */
Quoted 26 lines · Jay Buddhabhatti
During a kexec restart,
zynqmp_clear_pm_state()releases all peripheral devices viaPM_DEV_ALL_PERIPH. Pre-allocated nodes are then left released, so Linux no longer owns them and later peripheral access can fail.Immediately re-request those nodes with
zynqmp_pm_request_node( PM_DEV_ALL_PERIPH, ...)so Linux retains ownership. On a graceful kexec this runs fromzynqmp_firmware_shutdown(). On a crash kernel restart it runs fromzynqmp_firmware_probe()in the reloaded kernel.The bulk request depends on firmware support for
PM_DEV_ALL_PERIPH(PM_REQUEST_NODEfeature check version >=PM_API_VERSION_3). On firmware that does not implement it, the request is skipped and a warning is logged. Errors are already logged insidezynqmp_clear_pm_state()andzynqmp_firmware_probe()does not abort if the request fails.Also, drop the redundant ret = 0 assignments whose value is overwritten by the next
do_feature_check_call()Fixes 84dbfa5519cf ("firmware: xilinx: Release all peripheral devices from firmware")Signed-off-by Jay Buddhabhatti <[email protected]>Reviewed-by Radhey Shyam Pandey <[email protected]>---
Changes in v2:
- Add Fixes tag for the bulk peripheral release commit.
- Add Reviewed-by from Radhey Shyam Pandey (v1 review).
Quoted 4 lines
--- drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Applied.
M