From 84a1d6986ad606035b06b05489172513b61a476f Mon Sep 17 00:00:00 2001 From: Jiyoung Jeong Date: Wed, 24 Oct 2018 17:08:26 +0900 Subject: [PATCH] [9610] drivers: modem_if: change recv buffer property to Cacheable Change-Id: I96a305749625f029e816fd8f0e06490498cbaf75 Signed-off-by: Jiyoung Jeong --- drivers/misc/modem_if/Kconfig | 5 ++ drivers/misc/modem_if/modem_dump.c | 43 +++++++++++--- .../misc/modem_if/modem_link_device_shmem.c | 56 ++++++++++++++++++- .../misc/modem_if/modem_link_device_shmem.h | 4 ++ 4 files changed, 100 insertions(+), 8 deletions(-) diff --git a/drivers/misc/modem_if/Kconfig b/drivers/misc/modem_if/Kconfig index 6a5672b85713..73e946bf7b30 100644 --- a/drivers/misc/modem_if/Kconfig +++ b/drivers/misc/modem_if/Kconfig @@ -16,6 +16,7 @@ config MODEM_CHIP_MODAP_S3XXAP select CP_SECURE_BOOT select LINK_DEVICE_NAPI select MODEM_IF_NET_GRO + select CACHED_RAW_RX_BUFFER default n menu "Configurations" @@ -58,6 +59,10 @@ config MODEM_IF_NET_GRO ---help--- This enables GRO(Generic Receive Offload) feature +config CACHED_RAW_RX_BUFFER + bool "Set cached RX RAW BUFFER for high data performance" + default n + config UART_SWITCH bool "UART SWITCH Support" default n diff --git a/drivers/misc/modem_if/modem_dump.c b/drivers/misc/modem_if/modem_dump.c index f3a2041b44cd..b73e8ffbecf3 100644 --- a/drivers/misc/modem_if/modem_dump.c +++ b/drivers/misc/modem_if/modem_dump.c @@ -30,12 +30,6 @@ static int save_dump_file(struct link_device *ld, struct io_device *iod, return -EFAULT; } - ret = copy_to_user((void __user *)arg, &dump_size, sizeof(dump_size)); - if (ret) { - mif_err("ERR! copy_from_user fail!\n"); - return -EFAULT; - } - while (copied < dump_size) { if (dump_size - copied < alloc_size) alloc_size = dump_size - copied; @@ -79,12 +73,19 @@ int save_vss_dump(struct link_device *ld, struct io_device *iod, { struct shmem_link_device *shmd = to_shmem_link_device(ld); size_t vss_size = shm_get_vss_size(); + int ret = 0; if (vss_size == 0 || shmd->vss_base == NULL) { mif_err("ERR! save_vss_dump fail!\n"); return -EFAULT; } + ret = copy_to_user((void __user *)arg, &vss_size, sizeof(vss_size)); + if (ret) { + mif_err("ERR! copy_from_user fail!\n"); + return -EFAULT; + } + return save_dump_file(ld, iod, arg, shmd->vss_base, vss_size); } @@ -93,12 +94,19 @@ int save_acpm_dump(struct link_device *ld, struct io_device *iod, { struct shmem_link_device *shmd = to_shmem_link_device(ld); size_t acpm_size = shm_get_acpm_size(); + int ret = 0; if (acpm_size == 0 || shmd->acpm_base == NULL) { mif_err("ERR! save_acpm_dump fail!\n"); return -EFAULT; } + ret = copy_to_user((void __user *)arg, &acpm_size, sizeof(acpm_size)); + if (ret) { + mif_err("ERR! copy_from_user fail!\n"); + return -EFAULT; + } + return save_dump_file(ld, iod, arg, shmd->acpm_base, acpm_size); } @@ -107,11 +115,32 @@ int save_shmem_dump(struct link_device *ld, struct io_device *iod, { struct shmem_link_device *shmd = to_shmem_link_device(ld); size_t shmem_size = shmd->size; + int ret = 0; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + u8 *rxq_buff; + int rxq_buff_size; + + rxq_buff = get_rxq_buff(shmd, IPC_RAW); + rxq_buff_size = get_rxq_buff_size(shmd, IPC_RAW); +#endif if (shmem_size == 0 || shmd->base == NULL) { mif_err("ERR! save_shmem_dump fail!\n"); return -EFAULT; } - return save_dump_file(ld, iod, arg, (u8 __iomem *)shmd->base, shmem_size); + ret = copy_to_user((void __user *)arg, &shmem_size, sizeof(shmem_size)); + if (ret) { + mif_err("ERR! copy_from_user fail!\n"); + return -EFAULT; + } + +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + ret = save_dump_file(ld, iod, arg, (u8 __iomem *)shmd->base, shmem_size - rxq_buff_size); + __inval_dcache_area((void *)rxq_buff, rxq_buff_size); + ret = save_dump_file(ld, iod, arg, (u8 __iomem *)rxq_buff, rxq_buff_size); +#else + ret = save_dump_file(ld, iod, arg, (u8 __iomem *)shmd->base, shmem_size); +#endif + return ret; } diff --git a/drivers/misc/modem_if/modem_link_device_shmem.c b/drivers/misc/modem_if/modem_link_device_shmem.c index 3c4ed5fed949..b0ac06613c19 100644 --- a/drivers/misc/modem_if/modem_link_device_shmem.c +++ b/drivers/misc/modem_if/modem_link_device_shmem.c @@ -668,6 +668,9 @@ static int rx_ipc_frames(struct shmem_link_device *shmd, int dev, int out; /* index to the start of current frame */ int tot; /* total length including padding data */ int rcvd_pkt; /* number of received packets */ +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + int len; +#endif src = circ->buff; qsize = circ->qsize; @@ -678,6 +681,17 @@ static int rx_ipc_frames(struct shmem_link_device *shmd, int dev, tot = 0; rcvd_pkt = 0; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + if ((out + rcvd) <= qsize) { + __inval_dcache_area((void *)(src + out), rcvd); + } else { + len = qsize - out; + + __inval_dcache_area((void *)(src + out), len); + __inval_dcache_area((void *)src, rcvd - len); + } +#endif + while (rest > 0) { u8 ch; @@ -779,6 +793,9 @@ static int rx_ipc_frames(struct shmem_link_device *shmd, int dev, int rest; /* size of the rest data */ int out; /* index to the start of current frame */ int tot; /* total length including padding data */ +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + int len; +#endif src = circ->buff; qsize = circ->qsize; @@ -788,6 +805,17 @@ static int rx_ipc_frames(struct shmem_link_device *shmd, int dev, rest = circ->size; tot = 0; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + if ((out + rcvd) <= qsize) { + __inval_dcache_area((void *)(src + out), rcvd); + } else { + len = qsize - out; + + __inval_dcache_area((void *)(src + out), len); + __inval_dcache_area((void *)src, rcvd - len); + } +#endif + while (rest > 0) { u8 ch; @@ -1188,6 +1216,9 @@ static int rx_udl_frames(struct shmem_link_device *shmd, int dev, u32 rest; /* size of the rest data */ u32 out; /* index to the start of current frame */ unsigned int tot; /* total length including padding data */ +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + int len; +#endif src = circ->buff; qsize = circ->qsize; @@ -1195,6 +1226,18 @@ static int rx_udl_frames(struct shmem_link_device *shmd, int dev, rcvd = circ->size; rest = circ->size; tot = 0; + +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + if ((out + rcvd) <= qsize) { + __inval_dcache_area((void *)(src + out), rcvd); + } else { + len = qsize - out; + + __inval_dcache_area((void *)(src + out), len); + __inval_dcache_area((void *)src, rcvd - len); + } +#endif + while (rest > 0) { u8 ch; @@ -2254,7 +2297,11 @@ static void shmem_remap_4mb_ipc_region(struct shmem_link_device *shmd) dev->rxq.head = (u32 __iomem *)&map->raw_rx_head; dev->rxq.tail = (u32 __iomem *)&map->raw_rx_tail; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + dev->rxq.buff = (u8 __iomem *)phys_to_virt(shmd->start + SZ_2M); +#else dev->rxq.buff = (u8 __iomem *)&map->raw_rx_buff[0]; +#endif dev->rxq.size = SHM_4M_RAW_RX_BUFF_SZ; dev->mask_req_ack = INT_MASK_REQ_ACK_R; @@ -2273,8 +2320,11 @@ static int shmem_init_ipc_map(struct shmem_link_device *shmd) else return -EINVAL; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + memset(shmd->base, 0, shmd->size - SHM_4M_RAW_RX_BUFF_SZ); +#else memset(shmd->base, 0, shmd->size); - +#endif shmd->magic = shmd->ipc_map.magic; shmd->access = shmd->ipc_map.access; @@ -2879,7 +2929,11 @@ struct link_device *shmem_create_link_device(struct platform_device *pdev) shmd->start = modem->shmem_base + modem->ipcmem_offset; shmd->size = modem->ipc_size; +#ifdef CONFIG_CACHED_RAW_RX_BUFFER + shmd->base = shm_request_region(shmd->start, shmd->size - SHM_4M_RAW_RX_BUFF_SZ); +#else shmd->base = shm_request_region(shmd->start, shmd->size); +#endif if (!shmd->base) { mif_err("%s: ERR! shm_request_region fail\n", ld->name); goto error; diff --git a/drivers/misc/modem_if/modem_link_device_shmem.h b/drivers/misc/modem_if/modem_link_device_shmem.h index 2a3e3ac0c6f1..e11c2c6edae1 100644 --- a/drivers/misc/modem_if/modem_link_device_shmem.h +++ b/drivers/misc/modem_if/modem_link_device_shmem.h @@ -15,6 +15,10 @@ #ifndef __MODEM_LINK_DEVICE_SHMEM_H__ #define __MODEM_LINK_DEVICE_SHMEM_H__ +#ifdef CONFIG_CACHED_RAW_RX_BUFFER +#include +#endif + #include "modem_utils.h" #include "modem_link_device_memory.h" -- 2.20.1