public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mailbox: k3-sec-proxy: Fill non-message tx data fields with 0x0
@ 2023-06-20 18:17 Nishanth Menon
  2023-07-25 21:12 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Nishanth Menon @ 2023-06-20 18:17 UTC (permalink / raw)
  To: Tom Rini, Vignesh Raghavendra, praneeth; +Cc: d-gole, u-boot, Nishanth Menon

Sec proxy data buffer is 60 bytes with the last of the registers
indicating transmission completion. This however poses a bit of a
challenge.

The backing memory for sec_proxy is regular memory, and all sec proxy
does is to trigger a burst of all 60 bytes of data over to the target
thread backing ring accelerator. It doesn't do a memory scrub when
it moves data out in the burst. When we transmit multiple messages,
remnants of previous message is also transmitted which results in
some random data being set in TISCI fields of messages that have been
expanded forward.

The entire concept of backward compatibility hinges on the fact that
the unused message fields remain 0x0 allowing for 0x0 value to be
specially considered when backward compatibility of message extension
is done.

So, instead of just writing the completion register, we continue
to fill the message buffer up with 0x0 (note: for partial message
involving completion, we already do this).

This allows us to scale and introduce ABI changes back also work with
other boot stages that may have left data in the internal memory.

While at this, drop the unused accessor function.

Fixes: f9aa41023bd9 ("mailbox: Introduce K3 Secure Proxy Driver")
Signed-off-by: Nishanth Menon <nm@ti.com>
---
 drivers/mailbox/k3-sec-proxy.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c
index a862e55bc391..815808498f2e 100644
--- a/drivers/mailbox/k3-sec-proxy.c
+++ b/drivers/mailbox/k3-sec-proxy.c
@@ -94,11 +94,6 @@ static inline u32 sp_readl(void __iomem *addr, unsigned int offset)
 	return readl(addr + offset);
 }
 
-static inline void sp_writel(void __iomem *addr, unsigned int offset, u32 data)
-{
-	writel(data, addr + offset);
-}
-
 /**
  * k3_sec_proxy_of_xlate() - Translation of phandle to channel
  * @chan:	Mailbox channel
@@ -241,15 +236,20 @@ static int k3_sec_proxy_send(struct mbox_chan *chan, const void *data)
 		/* Ensure all unused data is 0 */
 		data_trail &= 0xFFFFFFFF >> (8 * (sizeof(u32) - trail_bytes));
 		writel(data_trail, data_reg);
-		data_reg++;
+		data_reg += sizeof(u32);
 	}
 
 	/*
 	 * 'data_reg' indicates next register to write. If we did not already
 	 * write on tx complete reg(last reg), we must do so for transmit
+	 * In addition, we also need to make sure all intermediate data
+	 * registers(if any required), are reset to 0 for TISCI backward
+	 * compatibility to be maintained.
 	 */
-	if (data_reg <= (spt->data + spm->desc->data_end_offset))
-		sp_writel(spt->data, spm->desc->data_end_offset, 0);
+	while (data_reg <= (spt->data + spm->desc->data_end_offset)) {
+		writel(0x0, data_reg);
+		data_reg += sizeof(u32);
+	}
 
 	debug("%s: Message successfully sent on thread %ld\n",
 	      __func__, chan->id);
-- 
2.40.0


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

* Re: [PATCH] mailbox: k3-sec-proxy: Fill non-message tx data fields with 0x0
  2023-06-20 18:17 [PATCH] mailbox: k3-sec-proxy: Fill non-message tx data fields with 0x0 Nishanth Menon
@ 2023-07-25 21:12 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2023-07-25 21:12 UTC (permalink / raw)
  To: Nishanth Menon; +Cc: Vignesh Raghavendra, praneeth, d-gole, u-boot

[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]

On Tue, Jun 20, 2023 at 01:17:09PM -0500, Nishanth Menon wrote:

> Sec proxy data buffer is 60 bytes with the last of the registers
> indicating transmission completion. This however poses a bit of a
> challenge.
> 
> The backing memory for sec_proxy is regular memory, and all sec proxy
> does is to trigger a burst of all 60 bytes of data over to the target
> thread backing ring accelerator. It doesn't do a memory scrub when
> it moves data out in the burst. When we transmit multiple messages,
> remnants of previous message is also transmitted which results in
> some random data being set in TISCI fields of messages that have been
> expanded forward.
> 
> The entire concept of backward compatibility hinges on the fact that
> the unused message fields remain 0x0 allowing for 0x0 value to be
> specially considered when backward compatibility of message extension
> is done.
> 
> So, instead of just writing the completion register, we continue
> to fill the message buffer up with 0x0 (note: for partial message
> involving completion, we already do this).
> 
> This allows us to scale and introduce ABI changes back also work with
> other boot stages that may have left data in the internal memory.
> 
> While at this, drop the unused accessor function.
> 
> Fixes: f9aa41023bd9 ("mailbox: Introduce K3 Secure Proxy Driver")
> Signed-off-by: Nishanth Menon <nm@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-07-25 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 18:17 [PATCH] mailbox: k3-sec-proxy: Fill non-message tx data fields with 0x0 Nishanth Menon
2023-07-25 21:12 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox