From patchwork Tue Oct 17 09:27:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13424897 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 248CFCDB474 for ; Tue, 17 Oct 2023 09:28:42 +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=Zj9EWGvYrvbYuxfjCDPlV/OFvHtXhHnDHBBqYqcvKsA=; b=zAaA3Tpcco84c7 5tPD7XW8/jydhRF1/d1vE2lwOqe7x96QnCJ8ro6moNSuGUXRnb3tCDChk0ozZ5pjoZ3QmOFUoM51N uix3oHDLbKi6vnz6Mstc4YMFoXXuotRfFY5HjJucWFg7/AhE60xuZeLlr+gCL4x+HCmrD12+4Vvoi C6ojK4gYFzlinlD99KsSs0rnSbuux8lyHNgKsZbvf8J2plicGqu/lxzk01YkPcGVtHwBtA+8BjRNz 84Nn/HDh+5WBy9U73+dIUuW3Z4mrCjp9YWWPtlgLlDLsnFYE9f2BEVw5Z0YMl3up8i6q0fIY12h1k lgeMN2Q9+2JihjEnbtvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qsgN2-00BoUM-1z; Tue, 17 Oct 2023 09:28:12 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qsgMj-00BoIb-0Z for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2023 09:27:55 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bfed7c4e6dso67530881fa.1 for ; Tue, 17 Oct 2023 02:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697534870; x=1698139670; 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=bXDfrkRFjIjR94nZZSpkfzNz1jI2kgyWWuq0UTG9XIg=; b=RucBZspU3fag77vlKCFX3QPY5ye70HF9jhxIzF/+pB0Xlir+OvXW0o55Dh4+vgA4TR upKsQluKIA3bHdu93Mi+Qm5Bo2UvyMK5Xeuhz+L2TLcgKP9KsW0pQU3o+oI36lrsFzZx ffowjPORGU4/tLyJhL9mnwWiK9/6Aua4Al/v4Q4oXciy4l+Z3lw95Q6c9NiylOpnWz5g r7HW6f2FlX21FBUVBwn8IPK3VA364+/i3Eg4foz8l75kNsRHrgLP5bMeHlD4DEHwCkFy l3saiuXTEMj+1O4kzkHibvmcyJcs+2YRng4VIPGFWXbt3pyVl3+iZZbNJ4kArXfZpbYC 5akA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697534870; x=1698139670; 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=bXDfrkRFjIjR94nZZSpkfzNz1jI2kgyWWuq0UTG9XIg=; b=hHi63LaJJIVi3a7cgG+VhBWwuwPYsKp2wQwYfaZD4IaA9BKWbnZzdPg8BiDCvRop9D wl7gZx5RSr9v0WTEN1dzsSULdicRFkS+VmKaiR+pbozDmi5BlOwut+/cIl4OD3YOUI6e XMh86xraZi1TjBndM39/ENuU2tyOZNknZCAHm4+BA+BBigkqHr3zGw3ctB3P6OKGIOQI YqTgJZ7OcYOyX73HwCKC44Ldtv/QTAeSPdKHpITLOhREQEYnEs6CH3waCs6prO0oVZ6E 9lXeuPZW/uQIOoP3vLm7TSkzgJKRPvrXxF1koZxM5E2kPrYHeoK5yTpGTESxlQlAazTo 025Q== X-Gm-Message-State: AOJu0YyqN91xxl0Uq9y10nLXw0hYPlHnGCcj6lPgGaCgnu9HC0ub6PMs xF/XzmE5cf7tGhKRYko/ziVe7A== X-Google-Smtp-Source: AGHT+IGLmNP5+XZewXTAdQODfI913sRUMiSt/+BJzdFG2wKbktbbnDW3qD15k7xWtoEZ82RCoT1mXg== X-Received: by 2002:a2e:2e19:0:b0:2c5:4a0:f3cb with SMTP id u25-20020a2e2e19000000b002c504a0f3cbmr1254873lju.11.1697534870285; Tue, 17 Oct 2023 02:27:50 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f1ee:b000:ce90:ed14]) by smtp.gmail.com with ESMTPSA id j5-20020a05600c1c0500b003fe1c332810sm9460787wms.33.2023.10.17.02.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:27:49 -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 v5 10/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Tue, 17 Oct 2023 11:27:27 +0200 Message-Id: <20231017092732.19983-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017092732.19983-1-brgl@bgdev.pl> References: <20231017092732.19983-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231017_022753_246304_9F476352 X-CRM114-Status: GOOD ( 11.01 ) 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 manually kmalloc()ing it and then mapping to physical space. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Maximilian Luz Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s --- drivers/firmware/qcom/qcom_scm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 11638daa2fe5..3a6cefb4eb2e 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1525,37 +1525,27 @@ int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id) unsigned long app_name_len = strlen(app_name); struct qcom_scm_desc desc = {}; struct qcom_scm_qseecom_resp res = {}; - dma_addr_t name_buf_phys; - char *name_buf; int status; if (app_name_len >= name_buf_size) return -EINVAL; - name_buf = kzalloc(name_buf_size, GFP_KERNEL); + char *name_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + name_buf_size, + GFP_KERNEL); if (!name_buf) return -ENOMEM; memcpy(name_buf, app_name, app_name_len); - name_buf_phys = dma_map_single(__scm->dev, name_buf, name_buf_size, DMA_TO_DEVICE); - status = dma_mapping_error(__scm->dev, name_buf_phys); - if (status) { - kfree(name_buf); - dev_err(__scm->dev, "qseecom: failed to map dma address\n"); - return status; - } - desc.owner = QSEECOM_TZ_OWNER_QSEE_OS; desc.svc = QSEECOM_TZ_SVC_APP_MGR; desc.cmd = QSEECOM_TZ_CMD_APP_LOOKUP; desc.arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_RW, QCOM_SCM_VAL); - desc.args[0] = name_buf_phys; + desc.args[0] = qcom_tzmem_to_phys(name_buf); desc.args[1] = app_name_len; status = qcom_scm_qseecom_call(&desc, &res); - dma_unmap_single(__scm->dev, name_buf_phys, name_buf_size, DMA_TO_DEVICE); - kfree(name_buf); if (status) return status;