From e51018b92cb1a893bc034a8be00d0601a54b177e Mon Sep 17 00:00:00 2001 From: Nilaan Gunabalachandran Date: Thu, 4 Nov 2021 15:55:23 -0400 Subject: [PATCH] disp: msm: use vzalloc for large allocations Large allocations using kzalloc can lead to timeouts. This updates the allocation calls accordingly to use vzalloc to remove requirements on contiguous memory. Change-Id: I86fa0ae13277d97477210a082703514df792d8a9 Signed-off-by: Nilaan Gunabalachandran --- msm/sde/sde_color_processing.c | 9 +++++---- msm/sde/sde_connector.c | 5 +++-- msm/sde/sde_crtc.c | 6 +++--- msm/sde/sde_plane.c | 6 +++--- msm/sde_dbg.c | 26 +++++++++++++------------- msm/sde_dbg_evtlog.c | 9 +++++---- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/msm/sde/sde_color_processing.c b/msm/sde/sde_color_processing.c index 9bf8ad582b..94918015a2 100644 --- a/msm/sde/sde_color_processing.c +++ b/msm/sde/sde_color_processing.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ @@ -4865,7 +4866,7 @@ void sde_cp_crtc_enable(struct drm_crtc *drm_crtc) if (!num_mixers) return; mutex_lock(&crtc->crtc_cp_lock); - info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); + info = vzalloc(sizeof(struct sde_kms_info)); if (info) { for (i = 0; i < ARRAY_SIZE(dspp_cap_update_func); i++) dspp_cap_update_func[i](crtc, info); @@ -4874,7 +4875,7 @@ void sde_cp_crtc_enable(struct drm_crtc *drm_crtc) info->data, SDE_KMS_INFO_DATALEN(info), CRTC_PROP_DSPP_INFO); } - kfree(info); + vfree(info); mutex_unlock(&crtc->crtc_cp_lock); } @@ -4889,7 +4890,7 @@ void sde_cp_crtc_disable(struct drm_crtc *drm_crtc) } crtc = to_sde_crtc(drm_crtc); mutex_lock(&crtc->crtc_cp_lock); - info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); + info = vzalloc(sizeof(struct sde_kms_info)); if (info) msm_property_set_blob(&crtc->property_info, &crtc->dspp_blob_info, @@ -4900,7 +4901,7 @@ void sde_cp_crtc_disable(struct drm_crtc *drm_crtc) crtc->skip_blend_plane_h = 0; crtc->skip_blend_plane_w = 0; mutex_unlock(&crtc->crtc_cp_lock); - kfree(info); + vfree(info); } void sde_cp_clear_state_info(struct drm_crtc_state *state) diff --git a/msm/sde/sde_connector.c b/msm/sde/sde_connector.c index 89ce80fedd..b11183a139 100644 --- a/msm/sde/sde_connector.c +++ b/msm/sde/sde_connector.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ @@ -2912,7 +2913,7 @@ int sde_connector_set_blob_data(struct drm_connector *conn, return -EINVAL; } - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = vzalloc(sizeof(*info)); if (!info) return -ENOMEM; @@ -2970,7 +2971,7 @@ int sde_connector_set_blob_data(struct drm_connector *conn, SDE_KMS_INFO_DATALEN(info), prop_id); exit: - kfree(info); + vfree(info); return rc; } diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index e5097a1c73..4ec7eccc00 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved. * Copyright (C) 2013 Red Hat * Author: Rob Clark @@ -5823,7 +5823,7 @@ static void sde_crtc_install_properties(struct drm_crtc *crtc, return; } - info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); + info = vzalloc(sizeof(struct sde_kms_info)); if (!info) { SDE_ERROR("failed to allocate info memory\n"); return; @@ -5927,7 +5927,7 @@ static void sde_crtc_install_properties(struct drm_crtc *crtc, msm_property_install_range(&sde_crtc->property_info, "frame_data", 0x0, 0, ~0, 0, CRTC_PROP_FRAME_DATA_BUF); - kfree(info); + vfree(info); } static int _sde_crtc_get_output_fence(struct drm_crtc *crtc, diff --git a/msm/sde/sde_plane.c b/msm/sde/sde_plane.c index f198ecbf7b..16dabee984 100644 --- a/msm/sde/sde_plane.c +++ b/msm/sde/sde_plane.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (C) 2014-2021 The Linux Foundation. All rights reserved. * Copyright (C) 2013 Red Hat * Author: Rob Clark @@ -3818,7 +3818,7 @@ static void _sde_plane_install_properties(struct drm_plane *plane, psde->catalog = catalog; is_master = !psde->is_virtual; - info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); + info = vzalloc(sizeof(struct sde_kms_info)); if (!info) { SDE_ERROR("failed to allocate info memory\n"); return; @@ -3900,7 +3900,7 @@ static void _sde_plane_install_properties(struct drm_plane *plane, if (psde->pipe_hw->ops.set_ubwc_stats_roi) msm_property_install_range(&psde->property_info, "ubwc_stats_roi", 0, 0, 0xFFFFFFFF, 0, PLANE_PROP_UBWC_STATS_ROI); - kfree(info); + vfree(info); } static inline void _sde_plane_set_csc_v1(struct sde_plane *psde, diff --git a/msm/sde_dbg.c b/msm/sde_dbg.c index 76f36915b5..96bd7e918b 100755 --- a/msm/sde_dbg.c +++ b/msm/sde_dbg.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved. */ @@ -1060,7 +1060,7 @@ static void _sde_dbg_dump_sde_dbg_bus(struct sde_dbg_sde_debug_bus *bus, u32 ena SDE_DBG_LOG_MARKER(name, SDE_DBG_LOG_START, in_log); if (in_mem && (!(*dump_mem))) { - *dump_mem = kvzalloc(list_size, GFP_KERNEL); + *dump_mem = vzalloc(list_size); bus->cmn.content_size = list_size / sizeof(u32); } dump_addr = *dump_mem; @@ -1104,7 +1104,7 @@ static void _sde_dbg_dump_dsi_dbg_bus(struct sde_dbg_sde_debug_bus *bus, u32 ena mutex_lock(&sde_dbg_dsi_mutex); if (in_mem && (!(*dump_mem))) { - *dump_mem = kvzalloc(list_size, GFP_KERNEL); + *dump_mem = vzalloc(list_size); bus->cmn.content_size = list_size / sizeof(u32); } dump_addr = *dump_mem; @@ -1139,7 +1139,7 @@ static void _sde_dump_array(bool do_panic, const char *name, bool dump_secure, u reg_dump_size = _sde_dbg_get_reg_dump_size(); if (!dbg_base->reg_dump_base) - dbg_base->reg_dump_base = kvzalloc(reg_dump_size, GFP_KERNEL); + dbg_base->reg_dump_base = vzalloc(reg_dump_size); dbg_base->reg_dump_addr = dbg_base->reg_dump_base; @@ -1624,7 +1624,7 @@ static ssize_t sde_recovery_regdump_read(struct file *file, char __user *ubuf, if (!rbuf->dump_done && !rbuf->cur_blk) { if (!rbuf->buf) - rbuf->buf = kvzalloc(DUMP_BUF_SIZE, GFP_KERNEL); + rbuf->buf = vzalloc(DUMP_BUF_SIZE); if (!rbuf->buf) { len = -ENOMEM; goto err; @@ -2431,7 +2431,7 @@ static void sde_dbg_reg_base_destroy(void) list_del(&blk_base->reg_base_head); kfree(blk_base); } - kvfree(dbg_base->reg_dump_base); + vfree(dbg_base->reg_dump_base); } static void sde_dbg_dsi_ctrl_destroy(void) @@ -2450,12 +2450,12 @@ static void sde_dbg_buses_destroy(void) { struct sde_dbg_base *dbg_base = &sde_dbg_base; - kvfree(dbg_base->dbgbus_sde.cmn.dumped_content); - kvfree(dbg_base->dbgbus_vbif_rt.cmn.dumped_content); - kvfree(dbg_base->dbgbus_dsi.cmn.dumped_content); - kvfree(dbg_base->dbgbus_lutdma.cmn.dumped_content); - kvfree(dbg_base->dbgbus_rsc.cmn.dumped_content); - kvfree(dbg_base->dbgbus_dp.cmn.dumped_content); + vfree(dbg_base->dbgbus_sde.cmn.dumped_content); + vfree(dbg_base->dbgbus_vbif_rt.cmn.dumped_content); + vfree(dbg_base->dbgbus_dsi.cmn.dumped_content); + vfree(dbg_base->dbgbus_lutdma.cmn.dumped_content); + vfree(dbg_base->dbgbus_rsc.cmn.dumped_content); + vfree(dbg_base->dbgbus_dp.cmn.dumped_content); } /** @@ -2463,7 +2463,7 @@ static void sde_dbg_buses_destroy(void) */ void sde_dbg_destroy(void) { - kvfree(sde_dbg_base.regbuf.buf); + vfree(sde_dbg_base.regbuf.buf); memset(&sde_dbg_base.regbuf, 0, sizeof(sde_dbg_base.regbuf)); _sde_dbg_debugfs_destroy(); sde_dbg_base_evtlog = NULL; diff --git a/msm/sde_dbg_evtlog.c b/msm/sde_dbg_evtlog.c index 1c945205a4..abd57cba80 100644 --- a/msm/sde_dbg_evtlog.c +++ b/msm/sde_dbg_evtlog.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ @@ -211,7 +212,7 @@ struct sde_dbg_evtlog *sde_evtlog_init(void) { struct sde_dbg_evtlog *evtlog; - evtlog = kvzalloc(sizeof(*evtlog), GFP_KERNEL); + evtlog = vzalloc(sizeof(*evtlog)); if (!evtlog) return ERR_PTR(-ENOMEM); @@ -229,7 +230,7 @@ struct sde_dbg_reglog *sde_reglog_init(void) { struct sde_dbg_reglog *reglog; - reglog = kvzalloc(sizeof(*reglog), GFP_KERNEL); + reglog = vzalloc(sizeof(*reglog)); if (!reglog) return ERR_PTR(-ENOMEM); @@ -337,7 +338,7 @@ void sde_evtlog_destroy(struct sde_dbg_evtlog *evtlog) list_del(&filter_node->list); kfree(filter_node); } - kvfree(evtlog); + vfree(evtlog); } void sde_reglog_destroy(struct sde_dbg_reglog *reglog) @@ -345,5 +346,5 @@ void sde_reglog_destroy(struct sde_dbg_reglog *reglog) if (!reglog) return; - kvfree(reglog); + vfree(reglog); }