From bb0f9e965f406d00229703a1b93dc150f3280843 Mon Sep 17 00:00:00 2001 From: Grace An Date: Wed, 30 Nov 2022 09:06:24 -0800 Subject: [PATCH 1/2] mm-drivers: hw_fence: share hw fence driver mem pool always When hw fencing is disabled via kernel command line argument, allow probing of hw fence driver and perform memory sharing during probe. This ensures that the carved out memory region for hw fences is always shared with hypervisor regardless of hw-fencing feature enablement. Change-Id: I7723fd61860e0d6b8dc374a054c8519d98d700a6 Signed-off-by: Grace An --- hw_fence/src/msm_hw_fence.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw_fence/src/msm_hw_fence.c b/hw_fence/src/msm_hw_fence.c index e81a4dd457..dcbe4cd80c 100644 --- a/hw_fence/src/msm_hw_fence.c +++ b/hw_fence/src/msm_hw_fence.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -500,15 +500,26 @@ static int msm_hw_fence_probe_init(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, hw_fence_drv_data); hw_fence_drv_data->dev = &pdev->dev; - /* Initialize HW Fence Driver resources */ - rc = hw_fence_init(hw_fence_drv_data); - if (rc) - goto error; + if (hw_fence_driver_enable) { + /* Initialize HW Fence Driver resources */ + rc = hw_fence_init(hw_fence_drv_data); + if (rc) + goto error; - mutex_init(&hw_fence_drv_data->clients_register_lock); + mutex_init(&hw_fence_drv_data->clients_register_lock); - /* set ready ealue so clients can register */ - hw_fence_drv_data->resources_ready = true; + /* set ready value so clients can register */ + hw_fence_drv_data->resources_ready = true; + } else { + /* Allocate hw fence driver mem pool and share it with HYP */ + rc = hw_fence_utils_alloc_mem(hw_fence_drv_data); + if (rc) { + HWFNC_ERR("failed to alloc base memory\n"); + goto error; + } + + HWFNC_DBG_INFO("hw fence driver not enabled\n"); + } HWFNC_DBG_H("-\n"); @@ -534,11 +545,6 @@ static int msm_hw_fence_probe(struct platform_device *pdev) return -EINVAL; } - if (!hw_fence_driver_enable) { - HWFNC_DBG_INFO("hw fence driver not enabled\n"); - return -EOPNOTSUPP; - } - if (of_device_is_compatible(pdev->dev.of_node, "qcom,msm-hw-fence")) rc = msm_hw_fence_probe_init(pdev); if (rc) From 0219a76630381851656354bdf9640eb0b8f29829 Mon Sep 17 00:00:00 2001 From: Ingrid Gallardo Date: Tue, 24 Jan 2023 11:02:46 -0800 Subject: [PATCH 2/2] mm-drivers: hw_fence: silently fail registration when feature disabled Current hw-fencing feature is disabled by default through kernel command line argument, therefore it is expected that clients receive an error when trying to register a client while feature is disabled. This change silence any print error messages during the clients registration when feature is disabled. Change-Id: Ie57adb52a975f9541e485039a582407cf21c11cd Signed-off-by: Ingrid Gallardo --- hw_fence/src/msm_hw_fence.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw_fence/src/msm_hw_fence.c b/hw_fence/src/msm_hw_fence.c index dcbe4cd80c..424c84662b 100644 --- a/hw_fence/src/msm_hw_fence.c +++ b/hw_fence/src/msm_hw_fence.c @@ -24,6 +24,9 @@ void *msm_hw_fence_register(enum hw_fence_client_id client_id_ext, enum hw_fence_client_id client_id; int ret; + if (!hw_fence_driver_enable) + return ERR_PTR(-ENODEV); + HWFNC_DBG_H("++ client_id_ext:%d\n", client_id_ext); if (IS_ERR_OR_NULL(hw_fence_drv_data) || !hw_fence_drv_data->resources_ready) {