From patchwork Mon Mar 25 10:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13601736 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 BBE22C54E58 for ; Mon, 25 Mar 2024 10:04:43 +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=9dCD1fl2JmuQgFkSEyw2lY7aoZ2mirDUopiIyv/WAag=; b=H1vAYBUjpMWku5 ZtkZ9vnXoZknzhnLhh/4JcmaHyU6JgmoaHs9iWXrnY4KGitQjY4g3GKRBUDovFcz1tUs13zyaikfK KSehpVNZcQ62O61oZOqCbP+VNQ783H5UjPNJr7kVmqQxzZRqVF7E5w0/6VR4eHHeivHEJL1srH7Jj 7LjkpsopNL6+vhrYB/waMUYJR8y2pw0Z0p8S6fjizWfxZy88iwN9ENSHXTUgkeE3VVhlVnZ5b1ySQ Wu6y5is6E3wYS56zqdVyZAAJOS3pSTMbqV4HWjyaPFdp1oJUjKzZGV2ox66OyKWjFntzNNu6ZeAjz 6owDNNHZTfaEtDmygRtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rohBr-0000000Gcb0-0xZQ; Mon, 25 Mar 2024 10:04:27 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rohBb-0000000GcPk-07MZ for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2024 10:04:12 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-33ec7e1d542so2899464f8f.1 for ; Mon, 25 Mar 2024 03:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1711361049; x=1711965849; darn=lists.infradead.org; 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=5xM9SBn4JRwG0bOMb0/BB9XkHkn86JKvqpbMlH4QUNA=; b=n6wv2g7i6/vX5fbAFURTwnk6nXHF0XLZlTzLGPpht+JxaeA0DMHRU+NhQVXggzQmDM 878VfArq5tCTWLB8nq6hTFGEl9I/Md312Egufo6E82tf90sCdTLiE4uvjh6yE91anNji kfIZNl1XpoU/tpBPEop62HrMTskQ07oeQxeBxr2AC449AJn3lmgVpZVsgccqm51l66lG 9rM4hKRfjK/ygiXnOZyDRaRszPfL2k1kHJePFudEPB3gKTvNxs/2S+Og+1fBkd8dHTXs ZkfoIU6p2iNuaBsYgla5xhwT56+C2JlrJ+3ome1/MAsPJnroAprx+xxvZq1W5YI7cDjv wZxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711361049; x=1711965849; 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=5xM9SBn4JRwG0bOMb0/BB9XkHkn86JKvqpbMlH4QUNA=; b=UisPp64TlvJHgifPsuw5/vSkM/m1OsCfIMbcrVxqErzCNuO1vJWYoiFwQJoRDzrI/h D1Wy0ULiW0y6lUAOVoU9tVsILn0Oax9yq9/dSvTnSSM4ey+XwXwkAllgCBXMWJ4yeGYE 3rk6Vife3lyY5qaZ+oNbybykB60PVOfjVzZ9z5M/bNlPoZmah7lEtihDmAYSMBKr8tVo U1DePLEZH3wJpbc/KlqYYrDkyzRT8VH30Jjt1qh98rahfxKRcPD17bmoX9s6LTak9EMG X6HwTsm2PmrNhILLD0mv1JQhEWByscmCNKoT7e7X3EAn04YmBlIsWeEcGcW8vENGKnCx vs8A== X-Forwarded-Encrypted: i=1; AJvYcCUlSAwLZD5cGonx5KP9hreDTf+v64kigoHIvcRdpkvHXg0UzuSBsYoJ1fDk+mkli3xp3c04S5jHU0QnD73yHadrDLjRQiUB8ZsDcFG+PVgbHquRIpg= X-Gm-Message-State: AOJu0YxnHLRqQaFkzc5tPjKtIYYKM7wnfFqgrjO9eEDYq+yvZ54lzvmL C2j/rdZ7WsdOtnG06PDcIIKJfeUZ7Uu8+L3geRsiSS077b1q17vZT6XZaF5uEzM= X-Google-Smtp-Source: AGHT+IEydXAKs/QNU0eg4C+NDFq7UNSX+j1Jp2smkQIoaNT+FPHMVEGEtr5Miuvb08MTKW4WyYZpsg== X-Received: by 2002:a05:6000:1ace:b0:341:cf9b:c8e with SMTP id i14-20020a0560001ace00b00341cf9b0c8emr1303987wry.50.1711361048974; Mon, 25 Mar 2024 03:04:08 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:75a:e000:861d:8b72:a859:4ce9]) by smtp.gmail.com with ESMTPSA id dv13-20020a0560000d8d00b0033e25c39ac3sm9086874wrb.80.2024.03.25.03.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:04:08 -0700 (PDT) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla , Arnd Bergmann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , Deepti Jaggi Subject: [PATCH v9 04/13] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 25 Mar 2024 11:03:50 +0100 Message-Id: <20240325100359.17001-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240325100359.17001-1-brgl@bgdev.pl> References: <20240325100359.17001-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240325_030411_101235_D4157871 X-CRM114-Status: GOOD ( 12.39 ) 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 From: Bartosz Golaszewski Let's use the new TZ memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/qcom_scm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 21c22d306aac..cd47389ac80c 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -1001,14 +1002,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, struct qcom_scm_mem_map_info *mem_to_map; phys_addr_t mem_to_map_phys; phys_addr_t dest_phys; - dma_addr_t ptr_phys; + phys_addr_t ptr_phys; size_t mem_to_map_sz; size_t dest_sz; size_t src_sz; size_t ptr_sz; int next_vm; __le32 *src; - void *ptr; int ret, i, b; u64 srcvm_bits = *srcvm; @@ -1018,10 +1018,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) + ALIGN(dest_sz, SZ_64); - ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); + void *ptr __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + ptr_sz, GFP_KERNEL); if (!ptr) return -ENOMEM; + ptr_phys = qcom_tzmem_to_phys(ptr); + /* Fill source vmid detail */ src = ptr; i = 0; @@ -1050,7 +1053,6 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, ptr_phys, src_sz, dest_phys, dest_sz); - dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); if (ret) { dev_err(__scm->dev, "Assign memory protection call failed %d\n", ret);