From patchwork Mon Jan 22 10:21:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13525119 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 D1C21C47DAF for ; Mon, 22 Jan 2024 10:22:53 +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=tswsND4rDcyNcB VOHjp48VqScjSJWz4tYZUYCt4XTeATKNDtT8tO5uhXDuAYdktcwgjx+MS/VcHrXIbGwe+ItJHOC2l vyz4+Is/x5QO5TG5uuQ7sAaAqnJ4YPFGa4eTqdDEPtq0kENXfKjfaeXUq1nJGUNe0KzXSvLibVxND +RgbGDWKPa3OA68M9d0ZiPI1lKurInAAe+vLbed7Y1U1Vn2Sj5hXzcyqyaoKWLq0MJ4AiruetPuM5 pLl2+GG3rAbaNdSM99dm7Wr19qaXS44nioSECQHP0Dbjcc/tmyVVA/OW2qcA1UvUYpV+SDaZQnDUl epby7dNNcZOMDo/V9fLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRrRh-00BUeS-2J; Mon, 22 Jan 2024 10:22:25 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRrRa-00BUUe-37 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 10:22:20 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-33931b38b65so1014623f8f.3 for ; Mon, 22 Jan 2024 02:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1705918930; x=1706523730; 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=3FPruA6aJXC4x3swXC6V9QfMjZ2Bx+nRVuVo2ZBw8nBqsbNH3aiZ+JuSPNCnvM5d4l XoyS3BHtVJ/A2c0P9u8RG/DGxymLE/EvDT0YuCAdwzOH+Vw0eWKPxK4CoEdsI/8IxgOy UE7Bjr+Nh4ZOgFClMx35nR3wAXzsqgN5JPAq8Guc7S4pFs4Y9ikO4yrim9fXCg83ezdz wam5FgEbmJvuCGvdHmYjOBW5y8EBCNRSNINMeFNW9cR917LAXpaBsQhQAowdVYCMEws2 db+2OuMJrij7Laf81W50Hu7OIAtn/yFS4bM86cjXFZAt5e87DsVl5grNqv7iOmclHlkt x/Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705918930; x=1706523730; 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=ujs5ZpBmeEEgbA+M4f5doBx8wBdL2TQEnqc92VuGdDnjDWNlA2Sq0nyr4Z5etAsK7M 7EdTshhH6MR0tzw+c80x4lBS6VccMQR5ubWUwqoa1bNdYIDIJ7Bpyblro/Zu4g8BaOqb Q7r0hq9Hc8j7Bnzpmxy+e6fKK2QWzPpESxaHtE7Gdw3hcPCOnp71x+7uVTUHcmrLSDdu 9Ic+Kadk4J+8j+wEc2jjLl2J52JAoJ2TUt94EbwtKHlvIj91nA4umJomq7eGSzhHeyuT BFtjZfHxBH3ecFDGy1KxKABEyYxc+2yyPFPhqhin5bS5Cv+5JDpveeZ4/xG4SIf4fGD+ nPGg== X-Gm-Message-State: AOJu0YzjgbBuem8dFxKhnHHXh8Kpdgv2A7QWeKXQx8Z13auafsUX8Eb5 8qNSF68CMFt2IdNk1f4f29HBiEFXcQqHoqeFu8ryKB/Prk1+Z3XMAn4HqkUJvwE= X-Google-Smtp-Source: AGHT+IGDLuCffdMW9Lj9tUJzf7vxOv7j1BC9cFUwhDhb7FRKBxSwFxj76m+ZfTa9+Lav7Ez4vfQTJw== X-Received: by 2002:adf:a381:0:b0:337:c030:aac1 with SMTP id l1-20020adfa381000000b00337c030aac1mr1124936wrb.153.1705918929832; Mon, 22 Jan 2024 02:22:09 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:92a0:6172:d229:1898]) by smtp.gmail.com with ESMTPSA id q7-20020adffec7000000b0033926505eafsm6377904wrs.32.2024.01.22.02.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:22:09 -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 , Catalin Marinas , Will Deacon , 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: [RESEND PATCH v6 04/12] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 22 Jan 2024 11:21:49 +0100 Message-Id: <20240122102157.22761-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240122102157.22761-1-brgl@bgdev.pl> References: <20240122102157.22761-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_022219_007108_36CED3F1 X-CRM114-Status: GOOD ( 12.59 ) 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);