From af066316427244120dd805d9264d62196c5711c8 Mon Sep 17 00:00:00 2001 From: Piyush Dhyani Date: Tue, 3 Nov 2020 19:46:21 +0530 Subject: [PATCH 1/6] msm: ipa3: Add debug logs to check unregister netdev completion time Add debug logs to check how long unregister netdev completion taking time. Change-Id: I0cd7ec2655d32cfdf9b758f6147628c7fa33f568 Signed-off-by: Piyush Dhyani --- drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c | 2 ++ drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c | 3 ++- drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c b/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c index 0c319f951e5a..691e0c22ea85 100644 --- a/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c +++ b/drivers/platform/msm/ipa/ipa_clients/ecm_ipa.c @@ -830,7 +830,9 @@ void ecm_ipa_cleanup(void *priv) ecm_ipa_rules_destroy(ecm_ipa_ctx); ecm_ipa_debugfs_destroy(ecm_ipa_ctx); + ECM_IPA_DEBUG("ECM_IPA unregister_netdev started\n"); unregister_netdev(ecm_ipa_ctx->net); + ECM_IPA_DEBUG("ECM_IPA unregister_netdev completed\n"); free_netdev(ecm_ipa_ctx->net); ECM_IPA_INFO("ECM_IPA was destroyed successfully\n"); diff --git a/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c b/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c index 8b93ee9b0e35..06fa55126b8c 100644 --- a/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c +++ b/drivers/platform/msm/ipa/ipa_clients/rndis_ipa.c @@ -1401,8 +1401,9 @@ void rndis_ipa_cleanup(void *private) rndis_ipa_debugfs_destroy(rndis_ipa_ctx); RNDIS_IPA_DEBUG("debugfs remove was done\n"); + RNDIS_IPA_DEBUG("RNDIS_IPA netdev unregister started\n"); unregister_netdev(rndis_ipa_ctx->net); - RNDIS_IPA_DEBUG("netdev unregistered\n"); + RNDIS_IPA_DEBUG("RNDIS_IPA netdev unregister completed\n"); spin_lock_irqsave(&rndis_ipa_ctx->state_lock, flags); next_state = rndis_ipa_next_state(rndis_ipa_ctx->state, diff --git a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c index 69d9656eb3a5..d31f3b5ba50a 100644 --- a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c @@ -2668,8 +2668,9 @@ static int ipa3_wwan_remove(struct platform_device *pdev) else rmnet_ipa3_ctx->apps_to_ipa3_hdl = -1; mutex_unlock(&rmnet_ipa3_ctx->pipe_handle_guard); - IPAWANINFO("rmnet_ipa unregister_netdev\n"); + IPAWANDBG("rmnet_ipa unregister_netdev started\n"); unregister_netdev(IPA_NETDEV()); + IPAWANDBG("rmnet_ipa unregister_netdev completed\n"); ipa3_wwan_deregister_netdev_pm_client(); cancel_work_sync(&ipa3_tx_wakequeue_work); cancel_delayed_work(&ipa_tether_stats_poll_wakequeue_work); From 18daf0b0d45e40f98489c5e6e06665fb66942737 Mon Sep 17 00:00:00 2001 From: Chaitanya Pratapa Date: Sun, 22 Mar 2020 23:56:47 -0700 Subject: [PATCH 2/6] msm: ipa: Fix considering prefetch buf size when mapping IPA HW tries to prefetch 128 Bytes of additional memory when dealing with filter/routing tables. This can result in overflowing of memory if we map only the required size. Make changes to consider prefetch memory when allocating routing/filter tables. Change-Id: Id72e4df285a4683dddebb18d98bb9c4dd9667eeb Signed-off-by: Chaitanya Pratapa --- drivers/platform/msm/ipa/ipa_v3/ipa_flt.c | 3 +++ drivers/platform/msm/ipa/ipa_v3/ipa_rt.c | 3 +++ .../platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c | 12 ++++++++++++ .../platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.h | 3 +++ .../platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt_i.h | 1 + 5 files changed, 22 insertions(+) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c index 7931a8e491a0..d294bac51a79 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c @@ -227,6 +227,9 @@ static int ipa_translate_flt_tbl_to_hw_fmt(enum ipa_ip_type ip, /* only body (no header) */ tbl_mem.size = tbl->sz[rlt] - ipahal_get_hw_tbl_hdr_width(); + /* Add prefetech buf size. */ + tbl_mem.size += + ipahal_get_hw_prefetch_buf_size(); if (ipahal_fltrt_allocate_hw_sys_tbl(&tbl_mem)) { IPAERR("fail to alloc sys tbl of size %d\n", tbl_mem.size); diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c index 213184590249..c39678af1af2 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c @@ -169,6 +169,9 @@ static int ipa_translate_rt_tbl_to_hw_fmt(enum ipa_ip_type ip, /* only body (no header) */ tbl_mem.size = tbl->sz[rlt] - ipahal_get_hw_tbl_hdr_width(); + /* Add prefetech buf size. */ + tbl_mem.size += + ipahal_get_hw_prefetch_buf_size(); if (ipahal_fltrt_allocate_hw_sys_tbl(&tbl_mem)) { IPAERR_RL("fail to alloc sys tbl of size %d\n", tbl_mem.size); diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c index 5a2fc92985e6..d62f191f66d8 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c @@ -44,6 +44,7 @@ * @flt_parse_hw_rule: Parse flt rule read from H/W * @eq_bitfield: Array of the bit fields of the support equations. * 0xFF means the equation is not supported + * @prefetech_buf_size: Prefetch buf size; */ struct ipahal_fltrt_obj { bool support_hash; @@ -73,6 +74,7 @@ struct ipahal_fltrt_obj { int (*rt_parse_hw_rule)(u8 *addr, struct ipahal_rt_rule_entry *rule); int (*flt_parse_hw_rule)(u8 *addr, struct ipahal_flt_rule_entry *rule); u8 eq_bitfield[IPA_EQ_MAX]; + u32 prefetech_buf_size; }; @@ -654,6 +656,7 @@ static struct ipahal_fltrt_obj ipahal_fltrt_objs[IPA_HW_MAX] = { [IPA_IS_FRAG] = 15, [IPA_IS_PURE_ACK] = 0xFF, }, + IPA3_0_HW_RULE_PREFETCH_BUF_SIZE, }, /* IPAv4 */ @@ -699,6 +702,7 @@ static struct ipahal_fltrt_obj ipahal_fltrt_objs[IPA_HW_MAX] = { [IPA_IS_FRAG] = 15, [IPA_IS_PURE_ACK] = 0xFF, }, + IPA3_0_HW_RULE_PREFETCH_BUF_SIZE, }, /* IPAv4.2 */ @@ -744,6 +748,7 @@ static struct ipahal_fltrt_obj ipahal_fltrt_objs[IPA_HW_MAX] = { [IPA_IS_FRAG] = 15, [IPA_IS_PURE_ACK] = 0xFF, }, + IPA3_0_HW_RULE_PREFETCH_BUF_SIZE, }, /* IPAv4.5 */ @@ -789,6 +794,7 @@ static struct ipahal_fltrt_obj ipahal_fltrt_objs[IPA_HW_MAX] = { [IPA_IS_FRAG] = 15, [IPA_IS_PURE_ACK] = 0, }, + IPA3_0_HW_RULE_PREFETCH_BUF_SIZE, }, }; @@ -3593,6 +3599,12 @@ u32 ipahal_get_lcl_tbl_addr_alignment(void) return ipahal_fltrt_objs[ipahal_ctx->hw_type].lcladdr_alignment; } +/* Get the H/W (flt/rt) prefetch buf size */ +u32 ipahal_get_hw_prefetch_buf_size(void) +{ + return ipahal_fltrt_objs[ipahal_ctx->hw_type].prefetech_buf_size; +} + /* * Rule priority is used to distinguish rules order * at the integrated table consisting from hashable and diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.h b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.h index 6328f64f154e..e3799b7d84e1 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.h +++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.h @@ -140,6 +140,9 @@ u32 ipahal_get_hw_tbl_hdr_width(void); */ u32 ipahal_get_lcl_tbl_addr_alignment(void); +/* Get the H/W (flt/rt) prefetch buf size */ +u32 ipahal_get_hw_prefetch_buf_size(void); + /* * Rule priority is used to distinguish rules order * at the integrated table consisting from hashable and diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt_i.h b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt_i.h index a36ede1a2924..5626d78255ef 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt_i.h +++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt_i.h @@ -44,6 +44,7 @@ enum ipa_fltrt_equations { #define IPA3_0_HW_TBL_ADDR_MASK (127) #define IPA3_0_HW_RULE_BUF_SIZE (256) #define IPA3_0_HW_RULE_START_ALIGNMENT (7) +#define IPA3_0_HW_RULE_PREFETCH_BUF_SIZE (128) /* From 56618828056ecd279af7fdd47f32760cf8367334 Mon Sep 17 00:00:00 2001 From: Ashok Vuyyuru Date: Wed, 11 Nov 2020 03:10:23 -0800 Subject: [PATCH 3/6] Revert "msm: ipa3: Assert the device when IPA FW not loaded" This reverts commit c3b184eac49daa49302a5f234b0834ff46ebbc83. Change-Id: I0ddaca27bb7c6073026b6c408402903e8141f705 --- drivers/platform/msm/ipa/ipa_v3/ipa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c index 15b06c6c6af2..5a1419a72918 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c @@ -6593,7 +6593,6 @@ static void ipa3_load_ipa_fw(struct work_struct *work) if (result) { IPAERR("IPA FW loading process has failed result=%d\n", result); - ipa_assert(); return; } mutex_lock(&ipa3_ctx->fw_load_data.lock); From 3b10b9d33b13094342c4084357c5f144691abf30 Mon Sep 17 00:00:00 2001 From: Ashok Vuyyuru Date: Fri, 20 Nov 2020 00:36:22 +0530 Subject: [PATCH 4/6] msm: ipa3: Fix to unmap LOW LAT consumer pipe buffers Currently LOW LAT consumer pipe replnish skb not unmapped properly. Due to this running into out of memory issue. Adding changes to unmap LOW LAT consumer replnish buffers using correct method. Change-Id: I253519f7c2f5eba11d32074c7b1879feed1f413c Signed-off-by: Ashok Vuyyuru --- drivers/platform/msm/ipa/ipa_v3/ipa_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c index 6e1addd91aa4..4f8c4521222a 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c @@ -2784,7 +2784,7 @@ static void ipa3_cleanup_rx(struct ipa3_sys_context *sys) tail = atomic_read(&sys->repl->tail_idx); while (head != tail) { rx_pkt = sys->repl->cache[head]; - if (!ipa3_ctx->ipa_wan_skb_page) { + if (sys->repl_hdlr != ipa3_replenish_rx_page_recycle) { dma_unmap_single(ipa3_ctx->pdev, rx_pkt->data.dma_addr, sys->rx_buff_sz, From 0d291ba2354718ba727bd4e9c96ff50d3871eadc Mon Sep 17 00:00:00 2001 From: Ashok Vuyyuru Date: Tue, 17 Nov 2020 00:43:34 +0530 Subject: [PATCH 5/6] msm: ipa3: Changes to control the IPA BW vote using debugfs Changes to control the IPA BW vote persistent using debugfs. Change-Id: Ie1edf294558a61af065f3fddec410808dc1abdd5 Signed-off-by: Ashok Vuyyuru --- drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c index 4cae77a34cb5..6d6f24036568 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c @@ -430,6 +430,49 @@ static ssize_t ipa3_read_ep_reg(struct file *file, char __user *ubuf, return size; } +static ssize_t ipa3_set_clk_index(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + s8 option = 0; + int ret; + uint32_t bw_idx = 0; + + ret = kstrtos8_from_user(buf, count, 0, &option); + if (ret) + return ret; + + switch (option) { + case 0: + bw_idx = 0; + break; + case 1: + bw_idx = 1; + break; + case 2: + bw_idx = 2; + break; + case 3: + bw_idx = 3; + break; + case 4: + bw_idx = 4; + break; + default: + pr_err("Not support this vote (%d)\n", option); + return -EFAULT; + } + pr_info("Make sure some client connected before scaling the BW\n"); + ipa3_ctx->enable_clock_scaling = 1; + if (ipa3_set_clock_plan_from_pm(bw_idx)) { + IPAERR("Failed to vote for bus BW (%u)\n", bw_idx); + return -EFAULT; + } + ipa3_ctx->enable_clock_scaling = 0; + IPAERR("Clock scaling is done sucessful\n"); + + return count; +} + static ssize_t ipa3_write_keep_awake(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { @@ -2770,6 +2813,10 @@ static const struct ipa3_debugfs_file debugfs_files[] = { .read = ipa3_read_keep_awake, .write = ipa3_write_keep_awake, } + }, { + "set_clk_idx", IPA_READ_WRITE_MODE, NULL, { + .write = ipa3_set_clk_index, + } }, { "holb", IPA_WRITE_ONLY_MODE, NULL, { .write = ipa3_write_ep_holb, From d71a7a3641dda7c2012e7972c0e450b1abcd6a2f Mon Sep 17 00:00:00 2001 From: Akshay Pandit Date: Tue, 3 Nov 2020 19:35:52 +0530 Subject: [PATCH 6/6] msm: gsi: Define scratch reg for gsi v1 header Define scratch register 6 & 7 for gsi v1 targets to avoid compilation failure. Derive the hw_type index after platform type and auto/mhi configs are already stored in ipa3_ctx. Signed-off-by: Akshay Pandit --- drivers/platform/msm/gsi/gsi_reg_v1.h | 10 ++++++++++ drivers/platform/msm/ipa/ipa_v3/ipa.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/platform/msm/gsi/gsi_reg_v1.h b/drivers/platform/msm/gsi/gsi_reg_v1.h index af3bc598ad7d..e28c8cdbe834 100644 --- a/drivers/platform/msm/gsi/gsi_reg_v1.h +++ b/drivers/platform/msm/gsi/gsi_reg_v1.h @@ -591,6 +591,16 @@ #define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_BMSK 0xffffffff #define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_SHFT 0x0 +#define GSI_EE_n_GSI_CH_k_SCRATCH_6_OFFS(k, n) \ + (GSI_GSI_REG_BASE_OFFS + 0x0000f048 + 0x4000 * (n) + 0x80 * (k)) +#define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_BMSK 0xffffffff +#define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_SHFT 0x0 + +#define GSI_EE_n_GSI_CH_k_SCRATCH_7_OFFS(k, n) \ + (GSI_GSI_REG_BASE_OFFS + 0x0000f04c + 0x4000 * (n) + 0x80 * (k)) +#define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_BMSK 0xffffffff +#define GSI_EE_n_GSI_CH_k_SCRATCH_3_SCRATCH_SHFT 0x0 + #define GSI_EE_n_EV_CH_k_CNTXT_0_OFFS(k, n) \ (GSI_GSI_REG_BASE_OFFS + 0x0001d000 + 0x4000 * (n) + 0x80 * (k)) #define GSI_EE_n_EV_CH_k_CNTXT_0_ELEMENT_SIZE_BMSK 0xff000000 diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c index 5a1419a72918..a7e63baea081 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c @@ -6995,7 +6995,6 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p, ipa3_ctx->ipa_wrapper_size = resource_p->ipa_mem_size; ipa3_ctx->ipa_hw_type = resource_p->ipa_hw_type; ipa3_ctx->ipa_config_is_mhi = resource_p->ipa_mhi_dynamic_config; - ipa3_ctx->hw_type_index = ipa3_get_hw_type_index(); ipa3_ctx->ipa3_hw_mode = resource_p->ipa3_hw_mode; ipa3_ctx->platform_type = resource_p->platform_type; ipa3_ctx->use_ipa_teth_bridge = resource_p->use_ipa_teth_bridge; @@ -7052,6 +7051,7 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p, ipa3_ctx->ipa_config_is_auto = resource_p->ipa_config_is_auto; ipa3_ctx->manual_fw_load = resource_p->manual_fw_load; ipa3_ctx->max_num_smmu_cb = resource_p->max_num_smmu_cb; + ipa3_ctx->hw_type_index = ipa3_get_hw_type_index(); if (resource_p->gsi_fw_file_name) { ipa3_ctx->gsi_fw_file_name =