]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arch: arm: mach-socfpga: Mailbox buffer and SDM doorbell improvement
authorAlif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>
Wed, 22 Jan 2025 02:21:02 +0000 (10:21 +0800)
committerTien Fong Chee <tien.fong.chee@intel.com>
Fri, 24 Jan 2025 01:55:42 +0000 (09:55 +0800)
The current write and notify SDM to read mechanism has a flaw where
SDM is not notified enough to be able to read all the data in the buffer.

This is caused by SDM doorbell will only be sent out once the command
buffer overflow check is satisfied. If the command buffer does not reach
overflow status, no SDM doorbell will be sent out, which may cause a
timeout as the mailbox driver will be waiting for the SDM to read the
buffer to empty even though SDM is not notified to do so.

The solution is to remove the command buffer overflow check
and set the SDM doorbell to always trigger at the end of the command
buffer.

This will ensure that the SDM is able to read all of the data.

Signed-off-by: Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>
arch/arm/mach-socfpga/mailbox_s10.c

index 2b4f26040febd42fb1bfc47477b8bb8e852fca4e..b69bd3e47ec26e7dcf11344689759705c8f58bf2 100644 (file)
@@ -88,6 +88,8 @@ static __always_inline int mbox_write_cmd_buffer(u32 *cin, u32 data,
                        MBOX_WRITE_CMD_BUF(data, (*cin)++);
                        *cin %= MBOX_CMD_BUFFER_SIZE;
                        MBOX_WRITEL(*cin, MBOX_CIN);
+                       if (is_cmdbuf_overflow)
+                               *is_cmdbuf_overflow = 0;
                        break;
                }
                timeout--;
@@ -96,10 +98,6 @@ static __always_inline int mbox_write_cmd_buffer(u32 *cin, u32 data,
        if (!timeout)
                return -ETIMEDOUT;
 
-       /* Wait for the SDM to drain the FIFO command buffer */
-       if (is_cmdbuf_overflow && *is_cmdbuf_overflow)
-               return mbox_wait_for_cmdbuf_empty(*cin);
-
        return 0;
 }
 
@@ -125,13 +123,11 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
                        return ret;
        }
 
-       /* If SDM doorbell is not triggered after the last data is
-        * written into mailbox FIFO command buffer, trigger the
-        * SDM doorbell again to ensure SDM able to read the remaining
-        * data.
+       /*
+        * Always trigger the SDM doorbell at the end to ensure SDM able to read
+        * the remaining data.
         */
-       if (!is_cmdbuf_overflow)
-               MBOX_WRITEL(1, MBOX_DOORBELL_TO_SDM);
+       MBOX_WRITEL(1, MBOX_DOORBELL_TO_SDM);
 
        return 0;
 }