From patchwork Mon Nov 20 13:21:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13461303 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 D73CCC54FB9 for ; Mon, 20 Nov 2023 13:23:12 +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=WRFd+qynifzn4M mSDOEcFsnf2e5yz/kByA6ods/HQa4RVOBnqUxBt7I3MvcbmE05uW9M8s9FPZYsvE1jl66RX9FVLyd ZksHmFKh3TZSRXQd/ArPfq40pfsposlTCkzfv6FvoOBUXUh+Vv2JXl9QDFRNt3X1vOyfneD0JXKvL tra7N7TBr61cXTAaka207k2XMTpmFp1CvU9K2qIf7dqqE2WqmU3SGPL58Ewuv6Duxt4M77QeUCHBL dWNX5kJyC2NXRfAkM6d29o4dyCwEXwggtEsFD2Wp/eHG9AIK9wwIfpjCaVDd+onJ3kD83shEuk8ff 9NTZx1WcnHwa2gjauMpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r54Ea-00C8Ky-0W; Mon, 20 Nov 2023 13:22:40 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r54DR-00C85k-2A for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:21:35 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4079ed65471so17139395e9.1 for ; Mon, 20 Nov 2023 05:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700486488; x=1701091288; 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=fDTKPQiX6wKtWisxAy3+45+8sIqzOKnHVSeVfB84I+yOXk5awxgVzN1oZXQQI2BbST ygfQdO1DJJ2z32J1QfMoc7cq2nMJgAcxXbKhol+srjM/Wcd9hx4NfiVr5z+TwB7KaCEw SSAXrSI7dXQ8kQum//H9oSnHrFPlSHnZ3Lfyq8nb3KhbzvQWnPBFelKLw0+gQYGhxYKz nrL+JhXK6ei8AAA3I6TxEacN8gM8CJDULn9eFdEtZ5vv/I6TpwQEy8IFl1ExDbVSbnPW gRV77mNJKm7zzA3BpxS++L/oz8y/DCJkLMZczV0S4bb4ZVGfnKIOOdWKXkucGNe06usQ TNcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700486488; x=1701091288; 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=aPojPAiU99RwJkRV/1H6Fa6/aofyUwG/Ax7rqkUGvxGowOPEwavaCid+CzVyx2DMvL Y6EAsO4bi25Z1sUB/ZVm0+louLvorMjQuX1KsJzKQd2OmafulgCLSW7jSwvTrUf4A7Ki mmlnp5Se1Tq7G2LnwkzyDdns8VKb6U6PD4an1SayxwyEQEVSyfvvb3f1p0k8AI/57UYC 3aOOpMRq0LJhm56rqdM+e64AxC3oyHlPHcZiFxOSAh3808paWOrQxQ9WLcCbQK52/zHC UWYXDLkdhlaTZAqzjdCOMlSNYwQb2UT9v0SC2Tpcf5tkROxdVUmun4M/IEM3vUu2zzub GY8Q== X-Gm-Message-State: AOJu0Yx8GKAJzVhEAoDR5ensDdtdxGKh4UnMw8lfC6bBPqyVg2VdvjHf ywSPlS7UiMB+yn9UQpj1Lsb9thJ5ZNy5NcZYGUw= X-Google-Smtp-Source: AGHT+IFRA88nEMXJKwXyYF/iRXHh9CqhMXr1fsKvoyCjONkDa+uClAulwokgGhNy/KnwbPKGcRZEMg== X-Received: by 2002:a05:600c:3d95:b0:40b:22de:b89a with SMTP id bi21-20020a05600c3d9500b0040b22deb89amr1639516wmb.31.1700486488069; Mon, 20 Nov 2023 05:21:28 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:c590:a7ce:883:eba3]) by smtp.gmail.com with ESMTPSA id k18-20020a05600c0b5200b004065e235417sm17329192wmr.21.2023.11.20.05.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:21:27 -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: [RESEND PATCH v5 04/12] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 20 Nov 2023 14:21:10 +0100 Message-Id: <20231120132118.30473-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231120132118.30473-1-brgl@bgdev.pl> References: <20231120132118.30473-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_052130_124097_9CDB9993 X-CRM114-Status: GOOD ( 12.05 ) 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);