remoteproc: xlnx: enhancements and new features
cover remoteproc: xlnx: enhancements and new features
Introduce new enhancements in the remoteproc xlnx driver. Handle mailbox optional properties gracefully. Handle buffer-less IPI without crash i.e. no message is expected from the mailbox callback. Also gracefully free mailbox channels during shutdown callback.
These small enhancements make driver more robust.
Ben Levinsky (1):
remoteproc: xlnx: Only access buffer information if IPI is buffered
Tanmay Shah (2):
remoteproc: xlnx: avoid mailbox setup
remoteproc: zynqmp: release mailbox channels on shutdown
drivers/remoteproc/xlnx_r5_remoteproc.c | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
base-commit: 098493c6dced7b02545e8bd0053ef4099a2b769e
Signature · 1 line
2.34.1
PATCH 1/3 remoteproc: xlnx: avoid mailbox setup
Mailbox properties are optional in the remoteproc xlnx bindings. If mailbox properties are not found in device-tree it's not fatal error in the driver. Driver will print warning messages and continue with normal operation. However, these warning messages can be interpreted as error. Check "mboxes" and "mbox-names" properties in the driver and setup mailbox only if they are available in the device-tree.
This will avoid any unwanted warning/error messages.
--- drivers/remoteproc/xlnx_r5_remoteproc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/remoteproc/xlnx_r5_remoteproc.c +4 -0
@@ -265,6 +265,10 @@ static struct mbox_info *zynqmp_r5_setup_mbox(struct device *cdev)struct mbox_client *mbox_cl;struct mbox_info *ipi; +if (!of_property_present (dev_of_node (cdev),"mboxes" ) || + !of_property_present (dev_of_node (cdev),"mbox-names" )) +return NULL ; + ipi =kzalloc_obj (*ipi);if (!ipi)return NULL ;
Signature · 1 line
2.34.1
PATCH 2/3 remoteproc: xlnx: Only access buffer information if IPI is buffered
In reply to Tanmay ShahFrom: Ben Levinsky <[email protected]>
In the receive callback check if message is NULL to prevent possibility of crash by NULL pointer dereferencing.
--- drivers/remoteproc/xlnx_r5_remoteproc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/remoteproc/xlnx_r5_remoteproc.c +11 -9
@@ -232,17 +232,19 @@ static void zynqmp_r5_mb_rx_cb(struct mbox_client *cl, void *msg) ipi = container_of(cl, struct mbox_info, mbox_cl); -/* copy data from ipi buffer to r5_core */ +/* copy data from ipi buffer to r5_core if IPI is buffered. */ ipi_msg = (struct zynqmp_ipi_message *)msg; - buf_msg = (struct zynqmp_ipi_message *)ipi->rx_mc_buf; - len = ipi_msg->len; -if (len >IPI_BUF_LEN_MAX ) { -dev_warn (cl->dev,"msg size exceeded than %d\n" , -IPI_BUF_LEN_MAX ); - len =IPI_BUF_LEN_MAX ; +if (ipi_msg) { + buf_msg = (struct zynqmp_ipi_message *)ipi->rx_mc_buf; + len = ipi_msg->len; +if (len >IPI_BUF_LEN_MAX ) { +dev_warn (cl->dev,"msg size exceeded than %d\n" , +IPI_BUF_LEN_MAX ); + len =IPI_BUF_LEN_MAX ; + } + buf_msg->len = len; +memcpy (buf_msg->data, ipi_msg->data, len); } - buf_msg->len = len; -memcpy (buf_msg->data, ipi_msg->data, len);/* received and processed interrupt ack */ if (mbox_send_message (ipi->rx_chan,NULL ) <0 )
Signature · 1 line
2.34.1
PATCH 3/3 remoteproc: zynqmp: release mailbox channels on shutdown
In reply to Tanmay Shahmailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/xlnx_r5_remoteproc.c +2 -0
@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi); } }
Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 15 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 5 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);
This is already called in zynqmp_r5_cluster_exit(), why doing it here again?
I have applied the other two patches in this series.
Thanks,
Mathieu
Quoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Re: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?
Hi,
Thanks for reviews.
I think cluster_exit() call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.
That is why I am calling it separately during shutdown() callback.
Thanks,
Tanmay
Quoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 28 lines · Tanmay
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?
Quoted 8 lines
Hi,
Thanks for reviews.
I thinkcluster_exit()call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.That is why I am calling it separately during
shutdown()callback.
The problem here is that zynqmp_r5_free_mbox() is called twice. At shutdown time all drivers go throuth the normal driver shutdown process where platform_driver.shutdown() is called and subsequently device management callbacks such as zynqmp_r5_cluster_exit(). The same applies to loading and unloading of drivers. Unless there is a corner case I can't see, calling zynqmp_r5_free_mbox() twice is not needed.
Quoted 16 lines
Thanks,
TanmayQuoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Re: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 36 lines · Mathieu Poirier
Quoted 35 lines · Tanmay
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?Hi,
Thanks for reviews.
I thinkcluster_exit()call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.
Quoted 9 lines
Quoted 1 line
That is why I am calling it separately during
shutdown()callback.The problem here is that
zynqmp_r5_free_mbox()is called twice. At shutdown time all drivers go throuth the normal driver shutdown process whereplatform_driver.shutdown()is called and subsequently device management callbacks such aszynqmp_r5_cluster_exit(). The same applies to loading and unloading of drivers. Unless there is a corner case I can't see, callingzynqmp_r5_free_mbox()twice is not needed.
Hi Mathieu,
I tested this patch again. On my platform I don't see zynqmp_r5_cluster_exit() being called when issuing reboot command.
It only calls platform_driver.shutdown() callback.
I think device management APIs are called only during driver remove callback, and not shutdown sequence.
Thanks,
Tanmay
Quoted 16 lines
Quoted 16 lines
Thanks,
TanmayQuoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
In reply to Shah, TanmayQuoted 28 lines · Tanmay
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?
Quoted 8 lines
Hi,
Thanks for reviews.
I thinkcluster_exit()call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.That is why I am calling it separately during
shutdown()callback.
Then call zynqmp_r5_free_mbox() from zynqmp_r5_remoteproc_shutdown() rather than zynqmp_r5_cluster_exit().
Quoted 16 lines
Thanks,
TanmayQuoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Re: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 36 lines · Mathieu Poirier
Quoted 35 lines · Tanmay
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?Hi,
Thanks for reviews.
I thinkcluster_exit()call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.
Quoted 5 lines
Quoted 1 line
That is why I am calling it separately during
shutdown()callback.Then call
zynqmp_r5_free_mbox()fromzynqmp_r5_remoteproc_shutdown()rather thanzynqmp_r5_cluster_exit().
I have to call zynqmp_r5_free_mbox() from both handlers i.e. platform_driver.remove() and platform_driver.shutdown(). I can't skip either of them.
Because during driver unload (rmmod), shutdown() handler won't be called. And during power-off commands (reboot, shutdown) remove() handler won't be called.
Let me know if I am still missing something.
Thanks,
Tanmay
Quoted 16 lines
Quoted 16 lines
Thanks,
TanmayQuoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1
Mathieu Poirier
maintainerRe: [PATCH 3/3] remoteproc: zynqmp: release mailbox channels on shutdown
Quoted 45 lines · Tanmay
Quoted 36 lines · Mathieu Poirier
Quoted 35 lines · Tanmay
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Tanmay Shah
mailbox driver can't introduce shutdown callback, as it might endup closing mbox channels prematurely. By allowing the client driver to manage the shutdown process, it's ensured that mailbox channels are closed only when they are no longer needed.
Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/xlnx_r5_remoteproc.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
drivers/remoteproc/xlnx_r5_remoteproc.c static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev) · line 1494
Quoted 10 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +2
-0@@ -1490,6 +1490,8 @@ static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)dev_err (cluster->dev,"failed to %s rproc %d\n" , rproc_state_str, rproc->index); } + +zynqmp_r5_free_mbox (r5_core->ipi);This is already called in
zynqmp_r5_cluster_exit(), why doing it here again?Hi,
Thanks for reviews.
I thinkcluster_exit()call is called only during driver unload. Where as shutdown callback is called during power-off commands of linux like reboot or shutdown.Quoted 5 lines
Quoted 1 line
That is why I am calling it separately during
shutdown()callback.Then call
zynqmp_r5_free_mbox()fromzynqmp_r5_remoteproc_shutdown()rather thanzynqmp_r5_cluster_exit().
Quoted 7 lines
I have to call
zynqmp_r5_free_mbox()from both handlers i.e.platform_driver.remove()andplatform_driver.shutdown(). I can't skip either of them.Because during driver unload (rmmod),
shutdown()handler won't be called. And during power-off commands (reboot, shutdown)remove()handler won't be called.
I was under the impression that during system shutdown, ->remove() and ->shutdown() were called sequentially. I looked into the platform_driver structure documentation and nothing of that nature is described, leading me to beleive your assessment is correct.
I'll apply your patch.
Quoted 23 lines
Let me know if I am still missing something.
Thanks,
TanmayQuoted 16 lines
Quoted 16 lines
Thanks,
TanmayQuoted 11 lines
I have applied the other two patches in this series.
Thanks,
MathieuQuoted 6 lines
drivers/remoteproc/xlnx_r5_remoteproc.c +0
-0} }Signature · 1 line
2.34.1