From patchwork Mon Aug 28 19:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13368237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B149AC71153 for ; Mon, 28 Aug 2023 19:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LliNLA8Tpkge0eLJL0jMxLcRKFd9O3K72fzs1fpw+tU=; b=PriMEO4W1rKNxB o4IF/DSBlG+u1pCMaAjQEZkO03h+CjfunWaD/vjxwXVP4GbJQJL4ZjxQDoZ1F2QhU7LxkP8K5NJh6 0BxP8Kkx3kaoqoAGJnjECkhL9f6JtFpKXXD/u7+D5hNFvtXRwB0CupC2gjpsG/hUVsU6MEuDwfkqc paUWqgmIJmHSHPlnA7zAC7i8U/NmwgZKqYShtcqMis4v0YDODKZiOesrxcDTHUBQg9h9VRyTd74W8 k1FbI4Mgp0W0yjTODOdx/3nAyGkDPhr0ef3+Rtm5bsTaLb9cnIkwgKd5Lwofsu+78xn8O/2YyieQI S1PDrs6Z64ZCQKX5f6BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qahtf-00A97R-2b; Mon, 28 Aug 2023 19:27:35 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qahtK-00A8y9-1C for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2023 19:27:17 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31c8a710545so1865301f8f.3 for ; Mon, 28 Aug 2023 12:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693250831; x=1693855631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5cFxADGOERyNFN7lTVtP33aE4fUtIdh4yla5Ms0ctiE=; b=EoXzrnanHjxRlCVdFNR3jEL/xRmfXMhI4RzAOrNmLf3G2biAWlM7vvmO7zLkPHT4iK 5Le0KJNfMSWSAwMlhFthLroTME9MfrlZuNQF5utevteIrmy0/Av5ZCo33of6uVD6MzZw A1KumZvLrH7LkMecujD0FPIYUstS5WpuDS37Ojb2nzciYE9Xh5rv0wqiVRJgNyR/eYOw epjjDQD+dBqlNcb4kQb7Sa60JXJvr7soJSrAuFyOkgWHC0Dit3u6CO0PaVO6+PsJ0nTy zKUet+A0wII8xV9lzUXPhMgXlFMm113iHCOpFEQhZhKXxSt/ZxNZqwZ+GN5YszttspJ7 Ks9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693250831; x=1693855631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5cFxADGOERyNFN7lTVtP33aE4fUtIdh4yla5Ms0ctiE=; b=l+LsMpCqAWl3GqdZjBWVSBaKfrGojpX1E+D1HJ/kjaT47uMilBAsKigMAqlQe70NgR /sCA98qMk4HHivozHRJDC822r4urCA5wos1E1hjcLsBpshAHkSnF1T5Tjcw0ZW7oIhS/ 5OAweia1sY96XIFDKUQxouD3cdMnYAUMRkEefOfOnYpIQR/oVB7kVvK5hnN4dG0PmM2y 9nabeMgy+zdQwqaDMPJYc1WfVnzouqGmHvkQ8P+3hXBSjdQR/gAr8M4p0N913b2RE/2k woYmKZ6iqeOEWXZY2EzOLkTH/jNuZ22TkRSeHr/Lw6or8jxHWlAKynOA2nejjnJmI2K+ 9bXA== X-Gm-Message-State: AOJu0YwWxA2nitcsZ7XiG6rrEpZ0Blr3nbcbWbQJ4gFH9gauKTBlHgjB 0bxsLxNp8Jct1kny9iVKvVeueA== X-Google-Smtp-Source: AGHT+IFTdl/tQdMkT1arHw9DxZMr0l64zUqWz+qHpOkaOVV+i2xMx+CKkBv3fHfRzh8d+Cw4kcZ+EQ== X-Received: by 2002:a5d:4d02:0:b0:317:5a9b:fcec with SMTP id z2-20020a5d4d02000000b003175a9bfcecmr19670541wrt.14.1693250830785; Mon, 28 Aug 2023 12:27:10 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:8bd:7f16:d368:115f]) by smtp.gmail.com with ESMTPSA id i20-20020a5d5234000000b003141f96ed36sm11435319wra.0.2023.08.28.12.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 12:27:10 -0700 (PDT) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Arnd Bergmann , Alex Elder , Srini Kandagatla Cc: kernel@quicinc.com, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [PATCH 07/11] firmware: qcom-scm: use SHM bridge if available Date: Mon, 28 Aug 2023 21:25:03 +0200 Message-Id: <20230828192507.117334-8-bartosz.golaszewski@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> References: <20230828192507.117334-1-bartosz.golaszewski@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230828_122714_424446_CA072F9E X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate the memory for SCM call arguments from the Shared Memory Bridge if it's available. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom_scm-smc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/qcom_scm-smc.c b/drivers/firmware/qcom_scm-smc.c index 16cf88acfa8e..6045be600c2a 100644 --- a/drivers/firmware/qcom_scm-smc.c +++ b/drivers/firmware/qcom_scm-smc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "qcom_scm.h" @@ -161,6 +162,7 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, ARM_SMCCC_SMC_32 : ARM_SMCCC_SMC_64; struct arm_smccc_res smc_res; struct arm_smccc_args smc = {0}; + bool using_shm_bridge = qcom_scm_shm_bridge_available(); smc.args[0] = ARM_SMCCC_CALL_VAL( smccc_call_type, @@ -173,8 +175,12 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, if (unlikely(arglen > SCM_SMC_N_REG_ARGS)) { alloc_len = SCM_SMC_N_EXT_ARGS * sizeof(u64); - args_virt = kzalloc(PAGE_ALIGN(alloc_len), flag); - + if (using_shm_bridge) + args_virt = qcom_shm_bridge_alloc(NULL, + PAGE_ALIGN(alloc_len), + flag); + else + args_virt = kzalloc(PAGE_ALIGN(alloc_len), flag); if (!args_virt) return -ENOMEM; @@ -196,7 +202,10 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, DMA_TO_DEVICE); if (dma_mapping_error(dev, args_phys)) { - kfree(args_virt); + if (using_shm_bridge) + qcom_shm_bridge_free(args_virt); + else + kfree(args_virt); return -ENOMEM; } @@ -208,7 +217,10 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, if (args_virt) { dma_unmap_single(dev, args_phys, alloc_len, DMA_TO_DEVICE); - kfree(args_virt); + if (using_shm_bridge) + qcom_shm_bridge_free(args_virt); + else + kfree(args_virt); } if (ret)