From 2de7dfb6813facba8e376897290bedb18ef38401 Mon Sep 17 00:00:00 2001 From: Shibo Zhu <3499129952@qq.com> Date: Mon, 17 Aug 2026 23:55:37 +0800 Subject: [PATCH] lib: sbi_mpxy: Fix shared memory size rounding The sbi_mpxy_register_channel() currently performs ceiling division by PAGE_SIZE but stores the resulting page count in mpxy_shmem_size. All consumers interpret mpxy_shmem_size as a byte count, so channels requiring more than one page get an undersized shared memory value. Address the above issue by using ROUNDUP() to keep the rounded value in bytes. Fixes: ec09918426a5 ("lib: sbi: Update MPXY framework and SBI extension as per latest spec") Signed-off-by: Shibo Zhu <3499129952@qq.com> Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/tencent_14AA3BA0083001905C262A5CD64E442FC205@qq.com Signed-off-by: Anup Patel --- lib/sbi/sbi_mpxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sbi/sbi_mpxy.c b/lib/sbi/sbi_mpxy.c index 2b9ad351..9f0ca031 100644 --- a/lib/sbi/sbi_mpxy.c +++ b/lib/sbi/sbi_mpxy.c @@ -257,8 +257,8 @@ int sbi_mpxy_register_channel(struct sbi_mpxy_channel *channel) /* Update shared memory size if required */ if (mpxy_shmem_size < channel->attrs.msg_data_maxlen) { - mpxy_shmem_size = channel->attrs.msg_data_maxlen; - mpxy_shmem_size = (mpxy_shmem_size + (PAGE_SIZE - 1)) / PAGE_SIZE; + mpxy_shmem_size = ROUNDUP(channel->attrs.msg_data_maxlen, + PAGE_SIZE); } sbi_list_add_tail(&channel->head, &mpxy_channel_list);