All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_ffa: Call ffa_rxtx_umap before calling ffa_rxtx_map
@ 2026-07-29 16:27 Nat Gurumoorthy
  2026-07-29 18:46 ` Sudeep Holla
  0 siblings, 1 reply; 2+ messages in thread
From: Nat Gurumoorthy @ 2026-07-29 16:27 UTC (permalink / raw)
  To: sudeep.holla; +Cc: linux-arm-kernel, Nat Gurumoorthy

In ffa_probe call ffa_rxtx_unmap before calling ffa_rxtx_map. It is
possible that crash or a kexec can leave crb_ffa with old mappings.
A call to ffa_rxtx_map will fail and leave crb_ffa interface unavalable.
The unmap makes crb_ffa forget old mappings and allows new mappings
to be set up. In kernels where arm_ffa is built in, module exit
routine ffa_exit will never get called during kexec operation. This
leaves behind stale mapping. New kernel's ffa_probe call to ffa_rxtx_map
will fail and crb_ffa driver will not be available.

Signed-off-by: Nat Gurumoorthy <natg@google.com>
---
 drivers/firmware/arm_ffa/driver.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 8654b3365c9b..44d095bc8569 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -2168,6 +2168,11 @@ static int ffa_probe(struct platform_device *pdev)
 		goto free_pages;
 	}
 
+	/*
+	 * Force unmap before mapping in case previous crash/kexec
+	 * has existing mapping.
+	 */
+	ffa_rxtx_unmap();
 	ret = ffa_rxtx_map(virt_to_phys(drv_info->tx_buffer),
 			   virt_to_phys(drv_info->rx_buffer),
 			   rxtx_bufsz / FFA_PAGE_SIZE);
-- 
2.55.0.487.gaf234c4eb3-goog



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] firmware: arm_ffa: Call ffa_rxtx_umap before calling ffa_rxtx_map
  2026-07-29 16:27 [PATCH] firmware: arm_ffa: Call ffa_rxtx_umap before calling ffa_rxtx_map Nat Gurumoorthy
@ 2026-07-29 18:46 ` Sudeep Holla
  0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2026-07-29 18:46 UTC (permalink / raw)
  To: Nat Gurumoorthy; +Cc: linux-arm-kernel, Sudeep Holla

On Wed, Jul 29, 2026 at 09:27:31AM -0700, Nat Gurumoorthy wrote:
> In ffa_probe call ffa_rxtx_unmap before calling ffa_rxtx_map. It is
> possible that crash or a kexec can leave crb_ffa with old mappings.
> A call to ffa_rxtx_map will fail and leave crb_ffa interface unavalable.
> The unmap makes crb_ffa forget old mappings and allows new mappings
> to be set up. In kernels where arm_ffa is built in, module exit
> routine ffa_exit will never get called during kexec operation. This
> leaves behind stale mapping. New kernel's ffa_probe call to ffa_rxtx_map
> will fail and crb_ffa driver will not be available.
> 

This is not a proper solution, what about the notifications and other
states.

Now that we have proper probe and remove, just assign or call remove
from shutdown callback which IIRC gets called in kexec. So something like
below is a proper fix IMO(not compiled or tested)

Regards,
Sudeep

-->8

firmware: arm_ffa: Tear down driver during shutdown

The platform core invokes a driver's shutdown callback, rather than its
remove callback, while preparing devices for a normal kexec. Without a
shutdown callback, the FF-A driver leaves notifications, partition devices,
and the RX/TX mapping active before the replacement kernel is booted.

Use ffa_remove() for shutdown so the existing cleanup runs before a normal
kexec and other orderly system shutdowns.

Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
 drivers/firmware/arm_ffa/driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 8654b3365c9b..28abc808fd32 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -2225,6 +2225,7 @@ static void ffa_remove(struct platform_device *pdev)
 static struct platform_driver ffa_driver = {
 	.probe = ffa_probe,
 	.remove = ffa_remove,
+	.shutdown = ffa_remove,
 	.driver = {
 		.name = FFA_PLATFORM_NAME,
 	},
--
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-29 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 16:27 [PATCH] firmware: arm_ffa: Call ffa_rxtx_umap before calling ffa_rxtx_map Nat Gurumoorthy
2026-07-29 18:46 ` Sudeep Holla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.