From patchwork Sun Mar 3 15:01:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13579823 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 6FA19C5475B for ; Sun, 3 Mar 2024 15:01:51 +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=4ZgLaMmtGfO/iQ49ZjFG2mRyvrF1e4Y/TYfEEPEKV3Y=; b=wU+CUSLCU19Ms8 HwLUi73ObL7ZxkOanjCw/fjus3ZgqHxJYgeAlOhPOWu1MJiNwtNb/+p3Tn7gicLs13fY5VvIf/zSL WdrbTlf9MjYoW32ruIgDNX289qij9MBPRn4tWTH88aspqM8g3kgmcaWHCfbSmRACv9ilvd1oZ1EPq tPqeQ7Z0NapToeySYp6YXR4N/50QzFRzqME1ARJpRfWwwB5zBKMzBZOj71wqcO/8meHQ+IbXqJQYt b2KmZpKWh2VElOs2SYTg9fXhV8ZUWE5uX6jvsINwZQWHqCS2sJoMHOhLixk0W+XVrc+0kFFIipjFp DJ+imLQtU+jaeTBew+OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgnLM-000000068JJ-0erF; Sun, 03 Mar 2024 15:01:36 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgnLF-000000068Ds-00jZ for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2024 15:01:30 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a3122b70439so572516266b.3 for ; Sun, 03 Mar 2024 07:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1709478087; x=1710082887; 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=nzSTJ0rdnj8Y8S9Xc/5yNamLOwhLIILlmWUgX3JwXEY=; b=ElsVeZZq/HK0nhjePMt0wZ+usFZW/TmZGd1U9vQ05iYG3zcsEEiGlmGul3V3iXuVKK x7Irw0iYBeaMw3U8Pw1z9E0pReYttfvhhU8V2cHxYZkFrQG/jWUanVwsKM0x9yQ0qVu7 y9WjyrQ4Bowa40XHJZ+5x4OfV5OJ24KxHqMHtNnu9laerEHGYYqPa0vV2fmmsegHN0o3 9Gddb6fDb6YWrKoMI+kuTkNkv1DEz3FZ/74+HETdq+/55wv9PuKylPj1yF2g+vHXJ5cP qci6t4Uju+Ev1a0ZTY+NaVGQclfkkj0mO/YOfma6fb2rltjaose3pXhYcvGcMSsYZnXx cOAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709478087; x=1710082887; 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=nzSTJ0rdnj8Y8S9Xc/5yNamLOwhLIILlmWUgX3JwXEY=; b=wjakGX5h4E3flMR++/hprVx/W3mM2b8Uaz0kTZZR3JKs0qcTri6IvH1FjhrhpZWhOR BJ9R4MgbLfxDo+uBAWuz8GP2WxmR7VvRIqPE7/ZAMJ0NdKE+4r5Dx7L92lnmyUla19nE 55lYj6E6gfBb4PBx6TpG6p+xBfXE6Oc5sADPhUpbJ2uFmsj/YTIVIP22ymbQNV9rOBBk +3Pt2rdELDF1qz9RgRd/2hSWPHRCEPzQC171nWWHjSICzuBthmky/qaLyWJeeg0CMqpd 29zaRanAM3N7yYkJHMjXrlYwqR2KQVX6a3PNRDqYym2hJUWe2eMAAVHfAgAQcpasTqrk do+g== X-Forwarded-Encrypted: i=1; AJvYcCWoJTSZAm4HCFlJ2qfP0m1NSSUUyQ7Pw6UFqcJP28crtc7Led/JvMEgbLya42ncUpRlVfjw1OnHVOuS6gOUYq0UjWasueV5kHhXIV349Ond4alys/0= X-Gm-Message-State: AOJu0YxZEY1e2hCTu4wFPymDg40wqKL+Uo+xLzrHdZR0ulp3Xa7Y/SWd +hHVe8RLH5TVS5JzJlwOAWCx4jPTgzW35+fnHlSjAGEQo5JgOg7AlDb510Ro3h19M5EV4hjUzrx N+RxYLw== X-Google-Smtp-Source: AGHT+IELTVpJwgFZ6SW6fstDB0Y1lIR0GrHp4KSOgdjkJcUeO5vl1ra+4gBL3VDeUw40ofJY2F9+og== X-Received: by 2002:a17:906:3846:b0:a3d:ed30:11c8 with SMTP id w6-20020a170906384600b00a3ded3011c8mr5033827ejc.15.1709478087088; Sun, 03 Mar 2024 07:01:27 -0800 (PST) Received: from brgl-uxlite.. ([77.241.232.10]) by smtp.gmail.com with ESMTPSA id ch14-20020a170906c2ce00b00a42ea946917sm3740293ejb.130.2024.03.03.07.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 07:01:26 -0800 (PST) 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 v8 04/12] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Sun, 3 Mar 2024 16:01:07 +0100 Message-Id: <20240303150115.133633-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240303150115.133633-1-brgl@bgdev.pl> References: <20240303150115.133633-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240303_070129_093806_CDB29A82 X-CRM114-Status: GOOD ( 11.86 ) 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 c1c4809b154c..054b538828d5 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -998,14 +999,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; @@ -1015,10 +1015,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; @@ -1047,7 +1050,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);