From patchwork Mon Feb 5 18:28:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13546017 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 1264EC48298 for ; Mon, 5 Feb 2024 18:28:40 +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=A9m2JS4zTRtDOerOiwXZS2aigxYEpYanrDOxJdyJ8gQ=; b=niVwvOEgz37HRK 80K8ozV3wEuF2Oj+PEhffBlSA3RSwkSI4VG0OW5J9upiBpXgKR7D/Fvtgu5OdG+JWAY9+mKkLmeTn 3fNHrOeLzQT1acQUt3w/kedZKsadHGDfxSxC258huFLOGQwgseshkWPaqJM2SQPG4ycKQSJ/9UXin YuctukW1PPEHZUV6RR/ca6EPq8jskAJY86TuFaaFaSfxLqU+gO1v2gKFw0C7lJ3X/Hpj4rwZJMonA SeJnBSoJzI5h0p/mRT5F9+z+ESRQ4T49YVQSORDDJK0MGJstZh/R8eV6NypH7IQ8jY0wvE6yOQUbR +qmwKuIEWgsoRyz18Kbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hn-00000004Mtn-0SmU; Mon, 05 Feb 2024 18:28:31 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hh-00000004Mq1-3lHJ for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 18:28:27 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40fdd65a9bdso7740155e9.2 for ; Mon, 05 Feb 2024 10:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707157704; x=1707762504; 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=Ky7A6Q6k7ixaopUQaNLMQkcUAky1WorEIskukk+Y5Zs=; b=SXNaj68VcTYoUTew9N7hymgjqZRV5gTVHFjbWqMyyvpfnOhZ9t/L26giqbs317Rzkf qMgZvg+f3OitGzUtq9CBXRkpi/d44Ab0YoowX1T+me1VFctl4SneneIzfWhvrWSCX2dR NkK+p5Shw5nntfoOIVG9Al1FNl1MToUZo/RBzVI0Ie3Yc07n1q3zH8EkthEx35MJWVf+ zqXB0y+ItQ6qrULphzuOUbArUb07vqzSgXxE3XjShToyTXdbD8PlhN5IGZs3kJ2rTBTR fsTgnfW4llNenGwkJKnZo1T7NV/E+v9vDWTi3Ym0tJVrxkscL3eAxHZ0J1UcKaUdNNga V5Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707157704; x=1707762504; 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=Ky7A6Q6k7ixaopUQaNLMQkcUAky1WorEIskukk+Y5Zs=; b=UORoUoO+01CGcY8ipL/oslAAQ1k06ll8EGkMo16NK1L8hXOuvnoR7etZGdY3bR0d79 r3txITnEkfyIfZeiu/MT+4eQe39RJ2BA2vN0rASy9Oq+cStElFNU/rEQSIsUpIom3/0w JEH6JCbNBHFDv2glLDD7aNp9JiIp2K6SavZx0WTDiZHbHGeXQ8v+NggD1Jp9nPOQBiBm jdAtOAJ5/kt79SSyHHtmpyqo400BDhskC5PNmSmSYdS8v9GlGqrJ6xctMNE8R2MCDkwi suKlp69UFt8gIwlKDhMEmfbGWBZZSYWqTQKwjTourK8KFrsPQ+YpSbBtXl+vyu6aLH9M ttow== X-Forwarded-Encrypted: i=1; AJvYcCWE+JdG7lR1Y7zibbmD1+smaR/ZcMuHvTJIBA0SQSZi91g8kjHElZIY/n4o7x/bDB/PufYya3GYd/eKx+S+ZrxOGFRTWTvDkDltm7t5FlrvN4vCF30= X-Gm-Message-State: AOJu0YyGG4UlhYwO3t+ETjqyTVfrYCL+7tAO3FcM08byK6gx1xjSJ/hd vCHRFEELSginc1txnkPsL43W7FnCREBHq1Rw+l5MXCXI1yGFS2R9bdUeTI+Sauw= X-Google-Smtp-Source: AGHT+IHD765uexuf9D1x8wbid5+wPG/IxGvcXWflosUmyncm2IQaH5q+GGQQo9+ALGv8/8VJY9iD7Q== X-Received: by 2002:adf:b35a:0:b0:33b:28ee:645d with SMTP id k26-20020adfb35a000000b0033b28ee645dmr226903wrd.68.1707157703922; Mon, 05 Feb 2024 10:28:23 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUdIiXSS/gpH931MfkdO0Sc5wlorS96kz6Tl+QjssTR3Qn14dYYj0MZDMg7QnloL0AiYaif6ZjjXPYRinmZ0GzAeXTEHKRNySKsblDiF+cPy2n+h6HoymfrcbFzXb1mPsiIlP+0kDmbqPbV3UYXpNKEmqqxLjoTrn2zN0a5go0tfPysE/vdgz0NZXqa6oMS9Bk96BpSPT37LC6FEB+zNmD9H0dxC5SaoODhdTZaeOXyT3o5ReqJGGbe3KVd78R1sfzt3aW7jOR3wlRWtOr89ttoWMe5M/4Y4g3zuj5C94rPv5ba1MccmdpGME5vGh0p2oy5LgcPNcVh9S/VAAsQFc753V1KWNEt51YvoqABivktphkj8v9I4RJq0X6qA6tHvCcDJKFnYQGCupXTBXfLYLZzMULI9zXIZ/0Mbbvf2KYStDUYTn4Sn7sPeNV3mDxHNE23ecKYflh/JHcS0W5OReZkwxtlXIo9XSzcs+5sL9+Ea7RH6XoPeO/+t4Yia6Hr5XCnKndftiFvABgBK50wUiYJjvoMf75DyHIdGIw5NrKskt0nT2K6KjuFYJcFYMXSUZU= Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id v15-20020a5d678f000000b0033b17e18df8sm203229wru.12.2024.02.05.10.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:28:23 -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 , Arnd Bergmann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , Deepti Jaggi Subject: [PATCH v7 04/12] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 5 Feb 2024 19:28:02 +0100 Message-Id: <20240205182810.58382-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205182810.58382-1-brgl@bgdev.pl> References: <20240205182810.58382-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_102825_968623_793CE86A X-CRM114-Status: GOOD ( 12.16 ) 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 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);