Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp899007rdg; Fri, 13 Oct 2023 04:51:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjWAQy4plz8Aj0nQqy2sw6XQLFbArG4E9/yvMcuDBBEImAj3LNuB7wLjg1V8OhdS6ETHbW X-Received: by 2002:a05:6a00:1a8a:b0:68f:c865:5ba8 with SMTP id e10-20020a056a001a8a00b0068fc8655ba8mr27536043pfv.18.1697197910374; Fri, 13 Oct 2023 04:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697197910; cv=none; d=google.com; s=arc-20160816; b=Bi/knKg4ryzmLzeMYAjSkm06d852fT3dmiOmFN7INgbThoSzEyy3KywNHHga1aFmBi jniwcyDyDBVZu2wBD3RS7DhXhHyEL7jG/LPap8MQXkD3EOmHXUGMPQ7fT1lkFsu/WKHh bhj+Zxki9hQOcrCrCAHmXQHoN+QnDKkV1hKhmtKGT5jRFSG6CYtRJH8+zIPEEoZzdvxo OfAzSyDPa0ssNn56BEPCmVRKoCv3QhGhxGHUL/3rS2K9+gDTU7Yvcnow+i2ELim7o8cE EX3YiJwk5hqfVVR0LQsJ95aWcrok5xiS1yqXUxXwSF3Ca4Dio9lD16nXZva1XpRoUofA Z9cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bV1cLbdTk/GE2Km4ovXWtuC2kb2GNoS6blKXRgh+nGM=; fh=lirm1ccAeXZZB1cIo+N1DqklpgcFmD/vJ7PCWNIL0HU=; b=BsvuQ7PdhRlysQtQpmidxA4TkTxB86UBC26zhGqJmgSnRFOg0uiyO2tQw8XXP4B0HH t6XxEkdk7iPGvd4g1EULJlrgX4BeFzQ0XMQ4Y4PgXkIuUmVNOzRwGYBX6E5ch2KRqN63 cN/QzhyXAYU/D3TdNF/wMXAmBA9bpNc1+Uh/w1XTS+gxkQGF2Uw5lEtSQDIEVVuSIFH9 Bd8fTFdkhsokkTmqHmuFhi/3A/oKa4R/4lVpermhVEYBazJ3xPyU4aLL6MCMmfo37CG1 Z+1z6j6DVFsL6EBxghWullmIcHW9deZud8HFsbXvBaf0RCDafatLPM+NLnut27CRisx/ F5Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=JIoef3sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id cn7-20020a056a00340700b0068a4ba92eafsi16636285pfb.54.2023.10.13.04.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=JIoef3sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0661C83CDA62; Fri, 13 Oct 2023 04:50:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbjJMLt1 (ORCPT + 99 others); Fri, 13 Oct 2023 07:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjJMLtC (ORCPT ); Fri, 13 Oct 2023 07:49:02 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44787BE for ; Fri, 13 Oct 2023 04:49:01 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40572aeb673so21336285e9.0 for ; Fri, 13 Oct 2023 04:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197739; x=1697802539; darn=vger.kernel.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=bV1cLbdTk/GE2Km4ovXWtuC2kb2GNoS6blKXRgh+nGM=; b=JIoef3sS+L2OYH7a3A8dB3I83w/96L9XaQ9M3/x8/7TgSCWCcTmicpB8gM3J5gOqbC mOnfd5fdrBgjDup/Sh5/JdbVdQJ3/GLgz8dkc6AvsOwMoUpVKZ6N3S7GAXWXId4YRGoe UQbbIpVJt37S1b1g3kLrWL73hqwXNxMG+5QZF2TGwcDwTN2iKcHsueIbmSYrMz/MEMqU ZQGR8r8Z3BlhyqpeKXPfn9rYNwuZS4q9Yfxtk4IPTsrYx3DTp5+xQNMTuxTJU0xvynZc yZjSiMGEAvT3fY78HKY6MOzhmTPBgoJllZi8+crMbztVN3Cu6nXXC2DFN6EeoA8xZAkm TGqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197739; x=1697802539; 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=bV1cLbdTk/GE2Km4ovXWtuC2kb2GNoS6blKXRgh+nGM=; b=ji8eWmhWChKi4gClykGCZ1+DNqlqm1JibPyfNE8q+SiIhl4KPRs8yk3oK3xVm9rs0o RMyKAVFNo7UwPy7n42CaWzWIWJJBxkN0a6t/K0OBDXiOTJ0l78R2NQjyxh5AWqfRSz0/ +ZXtm3fT4c8xgSRiof2QEk4CijHYzUIr/cD0DOz/lL5zL/e7jbHj5+HEsnKmd10U2kn7 m815XmDaIlMluEY+frUgbLWJAL1q/bX4GpmJg5YRbKWenyf2i6VkvoiTRnOKdo+e4OFe F/FwhOzq+KxUOOQO2kzASZe4o+N3KTCq+d42Ul7BG7zwTiG/ov0A/s7qIHUr9cQLxixo a1Cg== X-Gm-Message-State: AOJu0Yw/m2d2arYwcBlqZyuoqvlDYDoVFeVE/RXCgF31p6dbvwYu85/F VpZjvMYfCOaM71PsPKxUsGxfLA== X-Received: by 2002:a05:600c:2197:b0:406:5227:86f0 with SMTP id e23-20020a05600c219700b00406522786f0mr22042117wme.5.1697197739744; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48:59 -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 v4 07/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:35 +0200 Message-Id: <20231013114843.63205-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 04:50:03 -0700 (PDT) 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 --- 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); -- 2.39.2