From c099b88b491c182daf29d8a3be7391bc9697f99c Mon Sep 17 00:00:00 2001 From: Jagadeesh Ponduru Date: Fri, 18 Feb 2022 20:32:23 +0530 Subject: [PATCH 1/2] msm: ipa3: creating new ipc log file for IPA Clocks Created new ipc ipa_clk log for adding more debug prints for IPA Clocks in which provides the explicit time taken by IPA ICC Voting for BW Paths and IPA Enable/Disable Clocks. Change-Id: I53b7b5baba0ff72df286c86a4b45b0f860014474 Signed-off-by: Jagadeesh Ponduru (cherry picked from commit 331da84e7fa7b3e3c833a38a7e828d72894ed297) --- drivers/platform/msm/ipa/ipa_v3/ipa.c | 15 +++++++++++++++ drivers/platform/msm/ipa/ipa_v3/ipa_i.h | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c index 2fe49feaa860..aa2cc02cb268 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c @@ -5384,6 +5384,7 @@ void ipa3_enable_clks(void) idx = ipa3_get_bus_vote(); + IPADBG_CLK("IPA ICC Voting for BW Started\n"); for (i = 0; i < ipa3_ctx->icc_num_paths; i++) { if (ipa3_ctx->ctrl->icc_path[i] && icc_set_bw( @@ -5391,8 +5392,13 @@ void ipa3_enable_clks(void) ipa3_ctx->icc_clk[idx][i][IPA_ICC_AB], ipa3_ctx->icc_clk[idx][i][IPA_ICC_IB])) WARN(1, "path %d bus scaling failed", i); + IPADBG_CLK("IPA ICC Voting for BW %d Path Completed\n", i); } + IPADBG_CLK("IPA ICC Voting for BW Finished\n"); + + IPADBG_CLK("Enabling IPA Clocks Started\n"); ipa3_ctx->ctrl->ipa3_enable_clks(); + IPADBG_CLK("Enabling IPA Clocks Finished\n"); atomic_set(&ipa3_ctx->ipa_clk_vote, 1); } @@ -5444,10 +5450,13 @@ void ipa3_disable_clks(void) ipa_assert(); } + IPADBG_CLK("Disabling IPA Clocks Started\n"); ipa3_ctx->ctrl->ipa3_disable_clks(); + IPADBG_CLK("Disabling IPA Clocks Finished\n"); ipa_pm_set_clock_index(0); + IPADBG_CLK("IPA ICC Voting for BW Started\n"); for (i = 0; i < ipa3_ctx->icc_num_paths; i++) { if (ipa3_ctx->ctrl->icc_path[i] && icc_set_bw( @@ -5455,7 +5464,9 @@ void ipa3_disable_clks(void) ipa3_ctx->icc_clk[IPA_ICC_NONE][i][IPA_ICC_AB], ipa3_ctx->icc_clk[IPA_ICC_NONE][i][IPA_ICC_IB])) WARN(1, "path %d bus off failed", i); + IPADBG_CLK("IPA ICC Voting for BW %d Path Completed\n", i); } + IPADBG_CLK("IPA ICC Voting for BW Finished\n"); atomic_set(&ipa3_ctx->ipa_clk_vote, 0); } @@ -7299,6 +7310,10 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p, if (ipa3_ctx->logbuf == NULL) IPADBG("failed to create IPC log, continue...\n"); + ipa3_ctx->logbuf_clk = ipc_log_context_create(IPA_IPC_LOG_PAGES, "ipa_clk", 0); + if (ipa3_ctx->logbuf_clk == NULL) + IPADBG("failed to create IPC ipa_clk log, continue...\n"); + /* ipa3_ctx->pdev and ipa3_ctx->uc_pdev will be set in the smmu probes*/ ipa3_ctx->master_pdev = ipa_pdev; for (i = 0; i < IPA_SMMU_CB_MAX; i++) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h index b979156eb14e..82902d0e1c80 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h @@ -103,6 +103,14 @@ DRV_NAME " %s:%d " fmt, ## args); \ } while (0) +#define IPADBG_CLK(fmt, args...) \ + do { \ + pr_debug(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\ + if (ipa3_ctx) \ + IPA_IPC_LOGGING(ipa3_ctx->logbuf_clk, \ + DRV_NAME " %s:%d " fmt, ## args); \ + } while (0) + #define IPAERR(fmt, args...) \ do { \ pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args);\ @@ -1913,6 +1921,7 @@ struct ipa3_app_clock_vote { * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules * @logbuf: ipc log buffer for high priority messages * @logbuf_low: ipc log buffer for low priority messages + * @logbuf_clk: ipc log buffer for ipa clock messages * @ipa_wdi2: using wdi-2.0 * @ipa_fltrt_not_hashable: filter/route rules not hashable * @use_64_bit_dma_mask: using 64bits dma mask @@ -2052,6 +2061,7 @@ struct ipa3_context { void *smem_pipe_mem; void *logbuf; void *logbuf_low; + void *logbuf_clk; struct ipa3_controller *ctrl; struct idr ipa_idr; struct platform_device *master_pdev; From 75044ebe4b9dd76b46cb39fe29563744c6a2fa38 Mon Sep 17 00:00:00 2001 From: Avinash Kumar Date: Mon, 11 Sep 2023 12:17:20 +0530 Subject: [PATCH 2/2] msm: ipa: Null terminated interface name string argument received from ioctl WAN MTU IOCTL received NULL terminated the interface name string to prevent out of bound memory access while printing interface name. Change-Id: I4ca8021e91689f2b1bf0bef7917a5fc7c2168aef Signed-off-by: Avinash Kumar (cherry picked from commit b639c459e4f7eedc361cee795489de3d379e7e0c) --- drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c index 90f04cc6b3f2..46c11fb49ea6 100644 --- a/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c +++ b/drivers/platform/msm/ipa/ipa_v3/rmnet_ipa.c @@ -4950,6 +4950,10 @@ int rmnet_ipa3_get_wan_mtu( int rmnet_index; mux_channel = rmnet_ipa3_ctx->mux_channel; + + /* prevent string buffer overflows */ + data->if_name[IPA_RESOURCE_NAME_MAX-1] = '\0'; + rmnet_index = find_vchannel_name_index(data->if_name);