From patchwork Mon Nov 27 14:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13469718 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 27A7BC4167B for ; Mon, 27 Nov 2023 14:17:19 +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=6UtY82XC89iZCPqHwefDHLdBt5+bpxCGmMwgXDrN9DY=; b=N1PfB8ScexuhIr +LJovCaizQOyQ0gpHn8sfuuNLg16ASEv9SSuhOwmtWxwfs5zfV0Tz0SSl3gEjTaX/Xu7N3pL/mjeM SE+hsuQhPGgbfo9Y9scLRxqDY4KvpO39SzYjHsGB1WZC+rDF+7uAsVFUS/jYEu6HDsW3SNmsk8jOm 4iPv3BM0tsq6BwFPFNOJ0i1j4gay0zgDmR211YaRi3+ShEjV7MM9k4ZC335CJNu/8hSRkb6aSUEJK UuR/8u5jGf93A+EdC0d+/YWMZzN/8Kts66FXPKlHYO0CMHCySvPJb5sXvCWs4Z/SnHpIC0hlRgwy7 Cn1Q40oS8V9emN248eUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPr-002fRT-2n; Mon, 27 Nov 2023 14:16:52 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPK-002fHr-16 for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 14:16:21 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40b40423df8so12739985e9.0 for ; Mon, 27 Nov 2023 06:16:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094575; x=1701699375; 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=L3T+Nz29XwJpeLbYrWkBbO8epnldil1IzN2t5jt5R90=; b=fz/JPox/9vemZbqe7tnva2Sz9yYVRgMMWZVctTfafp4BDva6zpQHy/YkC/z2EjTxT0 ESwQMckNLJ4WyKRtODJkQQx3RV2OEl3h0VshnFH9vrGxNLLlV4zVUDrTkV2XSWVWZ6kS qgKEPoqvoTIuMBINzPJMk67SmNgAGd5WYy7MARiSjbT2gGn95iWB6sp8W1lL5up8Uj8n N7QJjT50rV7aTnD6VxWjNVAwDUPJhMECvtJ0t1U3TyxCTFaBgteCbuXeiSo9J7hcVWNr BtU7BUsNmhS2YajTkk3ln2Cag8FuTXR38lwqy1jbYnO8tuS4ti5u99mbg4vr0M2Djqsj 5Juw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094575; x=1701699375; 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=L3T+Nz29XwJpeLbYrWkBbO8epnldil1IzN2t5jt5R90=; b=kqVDEq60kKoDJkDXetKVZWJczYJvvLHoobSPvhGLGpBnfYMtdt4OGqAQWLmvSVMhau 7iMpa2RTyX+/VSHG6qK5XJt6DOzEYDlVvI2tTNyRFRmZO2TwJTlk9FdInPRBLuXHo+nH uIIs5zMCbs4b1zrP+WdczFrw9exWFKUk3OQEkvDWMMnqT/AmNu9Dh0IH2v3imVXQaaSG 2vSN056EmRFcpkEY7yRzYB89e5kkwmPj6tMLgA4IukD/Fc4YdZLvfcJtQySd0ntmQAwt OTlzNnKWh3uX27lIfgpu+QJLYRmaVBixtJ935ffQ1DTITih5gE9UFtO4lXfDxlfWbYaw sDeQ== X-Gm-Message-State: AOJu0YwRC9YnoJuU84J04VmDaWiZv6MGvTiQO1r4HjjB3o2VRAv4sjSd OxPCH5sel3odao1MvEF/vrbe6A== X-Google-Smtp-Source: AGHT+IGDbrSZacz5XAoXrWr2jrhzucPFPAPaLJC8jMRi9edx8SFcwpAsw3B/h6vSvvbTmocJf+BWjw== X-Received: by 2002:a05:600c:696:b0:405:1c14:9227 with SMTP id a22-20020a05600c069600b004051c149227mr8513070wmn.33.1701094575234; Mon, 27 Nov 2023 06:16:15 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:bf33:77c7:8131:5e64]) by smtp.gmail.com with ESMTPSA id be7-20020a05600c1e8700b00405442edc69sm14658830wmb.14.2023.11.27.06.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:14 -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 Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski Subject: [PATCH v6 05/13] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 27 Nov 2023 15:15:52 +0100 Message-Id: <20231127141600.20929-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127141600.20929-1-brgl@bgdev.pl> References: <20231127141600.20929-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_061618_538682_07C0AA40 X-CRM114-Status: GOOD ( 12.20 ) 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 --- 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 71e98b666391..754f6056b99f 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);