From 58114830df4bc6e930af7907fe12572dcb28ebda Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Fri, 7 Jul 2023 15:38:32 -0700 Subject: [PATCH] virt: haven: Correct max_buf_size for a connection Continuation messages can carry a maximum payload of HH_RM_MAX_MSG_SIZE_BYTES. When initializing a connection buffer for reply sequences, the hdr_size is 4 bytes larger than the HH_RM_MAX_MSG_SIZE_BYTES: see the difference between struct hh_rm_rpc_hdr and struct hh_rm_rpc_reply_hdr. Fix the calculation. Change-Id: If7a1124f581c9d1da8f7749d0296e064e6499cdf [eberman: Make change in hh_rm_core.c] Signed-off-by: Elliot Berman --- drivers/virt/haven/hh_rm_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/virt/haven/hh_rm_core.c b/drivers/virt/haven/hh_rm_core.c index cb45cd65aad4a..a473513ae6785 100644 --- a/drivers/virt/haven/hh_rm_core.c +++ b/drivers/virt/haven/hh_rm_core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. * */ @@ -114,8 +115,8 @@ hh_rm_init_connection_buff(struct hh_rm_connection *connection, if (!payload_size) return 0; - max_buf_size = (HH_MSGQ_MAX_MSG_SIZE_BYTES - hdr_size) * - (hdr->fragments + 1); + max_buf_size = payload_size + + (hdr->fragments * HH_RM_MAX_MSG_SIZE_BYTES); if (payload_size > max_buf_size) { pr_err("%s: Payload size exceeds max buff size\n", __func__);