From 5e4dbce2b710cbc3a91e810de1c0940d15a2e851 Mon Sep 17 00:00:00 2001 From: Sai Chaitanya Kaveti Date: Wed, 24 May 2023 18:00:01 +0530 Subject: [PATCH] msm: mhi_dev: Support async write in UCI for size greater than 8k In the current implementation of MHI UCI layer, write operation from device to host fails if the size requested by client is more than 8k. Removing this condition in this change as MHI supports buffer size of upto 64k in async path. Continuing to fail write in sync case, as MHI layer uses pre allocated buffers of size 8k. Also, added debug logs to check if buffer size of Diag is more than 16k. With this change async writes of size greater than 8k are supported in UCI layer. Change-Id: I084da6a49a00095e806872f591365eabb9edc1de Signed-off-by: Sai Chaitanya Kaveti --- drivers/platform/msm/mhi_dev/mhi.h | 1 + drivers/platform/msm/mhi_dev/mhi_uci.c | 33 +++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/platform/msm/mhi_dev/mhi.h b/drivers/platform/msm/mhi_dev/mhi.h index 253274b5d9e6..775c2690f2e0 100644 --- a/drivers/platform/msm/mhi_dev/mhi.h +++ b/drivers/platform/msm/mhi_dev/mhi.h @@ -267,6 +267,7 @@ struct mhi_config { #define MHI_ENV_VALUE 2 #define MHI_MASK_ROWS_CH_EV_DB 4 #define TRB_MAX_DATA_SIZE 8192 +#define TRB_MAX_DATA_SIZE_16K 16384 #define MHI_CTRL_STATE 100 /* maximum transfer completion events buffer */ diff --git a/drivers/platform/msm/mhi_dev/mhi_uci.c b/drivers/platform/msm/mhi_dev/mhi_uci.c index 222c71854d3b..8aca45f6957c 100644 --- a/drivers/platform/msm/mhi_dev/mhi_uci.c +++ b/drivers/platform/msm/mhi_dev/mhi_uci.c @@ -173,7 +173,7 @@ static const struct chan_attr mhi_chan_attr_table[] = { }, { MHI_CLIENT_DIAG_OUT, - TRB_MAX_DATA_SIZE, + TRB_MAX_DATA_SIZE_16K, MAX_NR_TRBS_PER_CHAN, MHI_DIR_OUT, NULL, @@ -184,7 +184,7 @@ static const struct chan_attr mhi_chan_attr_table[] = { }, { MHI_CLIENT_DIAG_IN, - TRB_MAX_DATA_SIZE, + TRB_MAX_DATA_SIZE_16K, MAX_NR_TRBS_PER_CHAN, MHI_DIR_IN, NULL, @@ -629,10 +629,17 @@ static int mhi_uci_send_sync(struct uci_client *uci_handle, struct mhi_req ureq; int ret_val; - uci_log(UCI_DBG_VERBOSE, + uci_log(UCI_DBG_DBG, "Sync write for ch_id:%d size %d\n", uci_handle->out_chan, size); + if (size > TRB_MAX_DATA_SIZE) { + uci_log(UCI_DBG_ERROR, + "Too big write size: %lu, max supported size is %d\n", + size, TRB_MAX_DATA_SIZE); + return -EFBIG; + } + ureq.client = uci_handle->out_handle; ureq.buf = data_loc; ureq.len = size; @@ -945,7 +952,7 @@ static int mhi_uci_read_sync(struct uci_client *uci_handle, int *bytes_avail) struct mhi_req ureq; struct mhi_dev_client *client_handle; - uci_log(UCI_DBG_INFO, + uci_log(UCI_DBG_DBG, "Sync read for ch_id:%d\n", uci_handle->in_chan); client_handle = uci_handle->in_handle; @@ -1484,11 +1491,10 @@ static ssize_t mhi_uci_client_write(struct file *file, return -ENODEV; } - if (count > TRB_MAX_DATA_SIZE) { - uci_log(UCI_DBG_ERROR, - "Too big write size: %lu, max supported size is %d\n", - count, TRB_MAX_DATA_SIZE); - return -EFBIG; + if (count > uci_handle->out_chan_attr->max_packet_size) { + uci_log(UCI_DBG_DBG, + "Warning: big write size: %lu, max supported size is %d\n", + count, uci_handle->out_chan_attr->max_packet_size); } data_loc = kmalloc(count, GFP_KERNEL); @@ -1543,11 +1549,10 @@ static ssize_t mhi_uci_client_write_iter(struct kiocb *iocb, return -ENODEV; } - if (count > TRB_MAX_DATA_SIZE) { - uci_log(UCI_DBG_ERROR, - "Too big write size: %lu, max supported size is %d\n", - count, TRB_MAX_DATA_SIZE); - return -EFBIG; + if (count > uci_handle->out_chan_attr->max_packet_size) { + uci_log(UCI_DBG_DBG, + "Warning: big write size: %lu, max supported size is %d\n", + count, uci_handle->out_chan_attr->max_packet_size); } data_loc = kmalloc(count, GFP_KERNEL);