From patchwork Mon May 27 12:54:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13675199 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 C47FBC25B7C for ; Mon, 27 May 2024 12:58:22 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qMHIFp/qwQEs+E60AU+3PjtUEpzE5tGkgLTPLmzELnQ=; b=oicdxENkJfku8J pYnThdIlLzy5Rxi3RhQj2Ynil1ke//P/mtS/FpYrWJDZOrdR0SpEw1MkHv9dWXabxojVAEqwidtxD QcFyAXGhSJwwDeS3eu99e03EHGtNPyqLlfufUhpsf1euAq6akgXoIITgxaV/r6X+snr7lrKkioKLV hpTye7wMX+iStB7zLku3KK3vhv3FLI75Bqg6gpjqnmJucnb/1hupzz6Cwr8M0LsPqSKR15MaS8JNw WpSMWmgsmAe/Zb59IDBOED9X+tjq4Ara2Q3GRPO+WguQUHL3356WOxpOZ4zwaqIMBkYnxAg6q/U6e nLDNpyrNuEWL1Ej2Toiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBZvZ-0000000EyO8-2ffg; Mon, 27 May 2024 12:58:13 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBZuI-0000000Exap-3eZs for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2024 12:56:57 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42017f8de7aso83324245e9.1 for ; Mon, 27 May 2024 05:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814609; x=1717419409; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=F2tGSXM64q5CkEofoukaYDnOH1U7xvQ9rdr6WJfwwYM=; b=LlgpgCHy/+pciMZuaRAUmE979MlCZJtf8/74mLG50taD4SUiJmhSgpJXs2uoCwH9xf E3S1Yb2xm1QRIH90BowQdbzDfbfui45XtRbMvg5tN2j+M4lUBYROtFKOXdzcrQWEFdoI d/WWUr4OD1noueujVbjDV2ptQROr/kM4u89XrFiYo3S4hVjHRKXdioDWvDginTY04cE5 PM/38Dl13Op0p0UfIHLqyjGr7wCr9MLvQsKGswIKt5QQjZcMDw8Tr6rlMptLFOW3+Zwr Zjk9PpW7I+337bypkMi7hSnaVZ1yxuaO82K6kL8FB8t6zlPy9Y/YNmoU51+6wQPRoE0F OqCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814609; x=1717419409; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F2tGSXM64q5CkEofoukaYDnOH1U7xvQ9rdr6WJfwwYM=; b=BIzR8ixaWxxPJ+rNW+FrLefRVyBiG9FDQdIL9oO8kCdZlKXzpM1UbaViRb+qOdZReR hrgQZkpFqXEBi3OffrpAeXkL1aEguUfuhDURW+Kp93P8M8TpbyzW8p9cXWdpaabiu3Pv dkCXZrgWJWN6uqhd1R/+qjw5C45KvSC9LDeRkh8nExFzZyTiQggmYar0W6sh4psm/zgw rDqzXDHsK9O+4XxA3F62kS5TnFKCBtanAUDdNlhAWU/+vfdGnb/dPP4+swpbd0zHymfJ +v04/52A6Sqz0/UhYktkxD7CFVQ8XH5Enu8IAc8djGroNQw4ugf3wEal84W8+9eon1vd f1RA== X-Forwarded-Encrypted: i=1; AJvYcCVoywF2wwrqIxanjyDj44yShQHV7djkSpwUSnBsEH5v6ZAg9F+L4nkzJsSpv6oXmNKRwfp5FVdUOItu58RJs+8bgxlMI7ictR78iwlLmydceXYgZn8= X-Gm-Message-State: AOJu0YwfKs6T+xRkDyVGiqcbt46kqHMZLvPLH6Hl6fpLRJobk3KjiWF6 UgEv+pPrShMqFWvtqAeG6n7Q8IqLEcFiTorQCR1esUdSxVKY26I4xgJ5MPRPNPc= X-Google-Smtp-Source: AGHT+IFiFkZN2ztJz4aq4ARQTndSRHhYuJJSLUpwf/uPp1OX4TcFw1jCbi8J6K1zQHHsp2lLkGM7tw== X-Received: by 2002:a05:600c:6b0e:b0:41b:285:8417 with SMTP id 5b1f17b1804b1-42108a2e796mr66785555e9.40.1716814609554; Mon, 27 May 2024 05:56:49 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:49 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:55 +0200 Subject: [PATCH v10 05/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-5-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2241; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=9Erqvqgiad5rjTJsNR0YSbu/CRguRxvgVp+lpYCpIVk=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMIKOO9v8eTMGirexp87ho1NlUlhkeO/Hz9j WAf+2zXRZeJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCAAKCRARpy6gFHHX crGMD/0YS7UnmIE3KqMGN3f/lgIUFTePpK9qvRMHBPLj2Dpag/edaQyVnec1ocNJlO8pz/bNR03 UdWI8Po0hrZN8wLxgwxiAytFfl+Sa/aJ99bbZjwnd7nk9o8icNvkBmE6wtg3OFHSx4rJspet0cf tD7cJ93DyEg8nVqzSw4anW94zC0NczKotQmHBvEmXzuITPwUmAsIVjey3it0QaXigk3k1LN4yLj pQmOTt0CINtQexASpTZAFvC++O0u708QBAU12SjPXB+9vNWpd/9OHS/P1Sp3ISzJqQP37QH+Ozz opcFF0t5siyZ5FgdRvui5YOcoIMdAmy1i4XhIqlAo5+UlhqsOqrAvV218vnNdsJFooB8Mm162Ga lqRB/8qrODadaf4jJY/5k2/mkL7jcCOZw9eFJQfnDNN8VMZdry4pcX/nnYDGMwgPV2I/1/xxCm3 qbbCV1RsuS56M2JZtdWxrbPwwvxPlAdCaRm9nmC7rPuKHPg38FoEglA7uz8iLYLSSSvw7CdUVP0 L0KLtJGnM6v8AFX0lR0wQ6ka+np8QNJYiU2/rLCL7QWAEXNgTDe2MIICEUkrR/RH05lP3cGml7a x6R0LfAwyWSeue/g49j07ahDu21bvrhvd/+tgJ63nVLSILaYCqg0v2LVevZbxkLcYmL99Ifhy3L 6DqEfDKi8bRUI8Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240527_055655_176625_D7B97320 X-CRM114-Status: GOOD ( 11.87 ) 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 1d207c14afc8..ea4d71bb0ad3 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1019,14 +1020,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; @@ -1036,10 +1036,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; @@ -1068,7 +1071,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);