From patchwork Tue Oct 17 09:27:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13424901 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 C2109CDB474 for ; Tue, 17 Oct 2023 09:28:44 +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=NrsSlhKo1WeOHfXoGJnTPPjdNYnP00pM1eQYqZFvQAA=; b=TDN3nCF1IjHakV nvThQ0/ZfdhPw3yT2z2lDD9R+bSRGGvpyfJmREnj3ADh2fEX7HjYNC2BvKeM5nBIT3SLYvTI3pbGL vmL1fQWPdaI067t/brz3IylJrwexTFDvznzY9WoESkph3KW4q2aFeuFBakvvyxcYlMQCdmSq5+yJF yt04tkYMkdw4XcGrE0HaNaMUMrBz1nsB7WL+k8VIAU0Hn3/ppIisoj14BG6lOHrGlP7IRQZLBPHRV iwWnMQal4NCS7/5y5kj9Nq2BpJn0D213VL7PW5SroCZUS/Iw+oxnGVJ6wt9G8tZtUxbUC+h0Hx2fp fhIAA7IArbaPgiA8Ddtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsgN0-00BoSL-1D; Tue, 17 Oct 2023 09:28:10 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsgMf-00BoFV-0o for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 09:27:51 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40566f8a093so52937375e9.3 for ; Tue, 17 Oct 2023 02:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697534866; x=1698139666; 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=0o2Y5GCPibQO9YixuexIPFVqiPjEBVLTDTnn6eikhk4=; b=zqM6XfzEfGp75EK+rP897Khh6eak1oJHhaTAGfbFdFS09PaeSyQ6q7q78bpuBJqSLd 2xIjFlr+WfqXuh7+BgFeEJwRAfpeQ3agCL6hCOzH1Biqem0V7EPyBNTdQDo0/DLJ6MQt 0Bj1YPMSpniG/X/3Iyn6YaV4BEnCMg5pJtVX3HFdff0gmbm5VJu83p3vS+lb0oRlgXoz K3t6EBQGX7wvQ3GqJlgX/ScPBv6P8HcqV+9nxIHToxIiY5W9NhDzjS6Zg+4Zxuoj3bFJ C2+PIxV9K3ktvUxAosmUWfeBxn+h07iM4q4rFMu/tTzRq/ksxQKtEq6QJUvhGQVMgH6V pAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697534866; x=1698139666; 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=0o2Y5GCPibQO9YixuexIPFVqiPjEBVLTDTnn6eikhk4=; b=MX8WCKUsFwdDJGibLmD5kx4F4W9p2wMTiFEw0KP1JuFE64dxx3kjKz/qLxqFty01To 4KnnGmWyOH1bbJObi9GVqkJpahEuVva5A08TIOgtANEM/0zlS5f6G3vgxXoJfo/hjGd4 W3l0r+0X2EISAwDfhk2N7rBuE0OgHacGO6sbpRGPpN43GF2NCZigs7vo0lb6Th3sgHHy 4IwlIK0nczx7TowrUE/kzi58AlXfrDb5ahku9XBI5xJ3Ypr3MGQHRIXgjZVsX3rVHAsI NyVEhJpmt4uVrE4EinXXpLqZJ5xoOyIyhBvKgbmczUJrvLU6wdp/V/Y1AYQHhO/Wtmjq O1rg== X-Gm-Message-State: AOJu0Yyzy6lTRLRx803tnTWcEz0XIn7EiRX8T4cc07GB+KEojDNIl3Qz oUefRkR8Yif+UBnxPrsA5AO3mw== X-Google-Smtp-Source: AGHT+IEb82UUDsUFEpK1dLE73heNgvl9yOEHj0X0vK+TgO3qtXmsTgkkUqDR0xOUuiYuaAQSxF0RpA== X-Received: by 2002:a05:600c:46d3:b0:405:367d:4656 with SMTP id q19-20020a05600c46d300b00405367d4656mr1218401wmo.29.1697534865828; Tue, 17 Oct 2023 02:27:45 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f1ee:b000:ce90:ed14]) by smtp.gmail.com with ESMTPSA id j5-20020a05600c1c0500b003fe1c332810sm9460787wms.33.2023.10.17.02.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:27:45 -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 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 v5 07/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Tue, 17 Oct 2023 11:27:24 +0200 Message-Id: <20231017092732.19983-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017092732.19983-1-brgl@bgdev.pl> References: <20231017092732.19983-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_022749_297869_55C0EE55 X-CRM114-Status: GOOD ( 11.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 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);