From patchwork Sun Mar 3 15:01:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13579824 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 EE778C54E55 for ; Sun, 3 Mar 2024 15:01:51 +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=oHR0WnKfAgALK7oJmakmxyFQsYinczrH9mHhITFUwxE=; b=2evy42x4ERQNX0 TaTOZVApHztec+PM0/Wh482Z65C2INJd7I9ooinM3JcKcU7S1G6E47FKUI/XvcCTiuhykZTyfDZPs l6zmkhHajCEC29yznG/wrodYLro3B1sdZPcXa7TBMfGJNqe4KVqtlB4CvWF9jwnT8eX95ui5yaVb5 dLX5PRhPY2pBvtfwWtE77t7ILnV4j5Zh0Wo0d5vFT7opYNVeDS9FfHd+nLc+X1pdjxz9usX7Q1y9R 10H//OxfvjzEtODtbbr5L0a8HwKloVLI0X6oKH3XhoAMa9yrMF5Ul4CwVc2yYNcJKsQqDVbMyKKQh 0cPTzKdWarsDIFVjKoGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgnLP-000000068LT-0riD; Sun, 03 Mar 2024 15:01:39 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgnLH-000000068FA-35M7 for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2024 15:01:33 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a28a6cef709so596281066b.1 for ; Sun, 03 Mar 2024 07:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1709478090; x=1710082890; 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=objFWYLJTsCFID4bxkiF8sYIttYlyjZ7w2ytPsMa/co=; b=ZLeY0DYmR+TOrATW8cu3JoNpTZN1ud/ifayEn/pjlJsb7ssrG/Zoj4ewZX2431Ekym SwhS00tfyhRQyGI9u/6NAabQ4RsnW/Td+jZAl56zztCiQza4Ie6QHhxeDAFjFN4M/JAq POzeNFGcfGg6hxAY1BVNlm3pDVMzo+wSkSo8eN7R2pDPzcwdIm1iw8J9A+qDL7aO+ca1 xooE7Dfm31GPjxLK2zdS89qSuH/0f+F9tOIIxGVAVAi4rQCfVvC0LIFke4H6AqUAvT9W uINfyw/DCmXBcBptb3YNdb4amGqLD50zwWzojxVp1eJ7Wutv5KVx0xgWO83sH3hZfAmE 9Ypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709478090; x=1710082890; 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=objFWYLJTsCFID4bxkiF8sYIttYlyjZ7w2ytPsMa/co=; b=YJtJEAQSjz2gm7LwvU2vwAC2eK6s2GoRmRkgNqjhuvpzvmYh/p/5rlGYunhlxg9Lsv M6H/cv85/1WGgBxbcPBk/xokEZFzOWfa+EDuAxvfLZQ8E+O4bqA5dUt/0I7IF9ctKhvL NUD3oeMIj2OjGFdT+6VjzCSOAZxDrNoHf4upDRavHpdejExXE7r5sHsbGC4B2JevB6sT I3yv8RReGoOHEtM4U4VBuLci+976mx6AmubcjUagSIqGggAnqnGfuC9Ufgpm1LmcYx3f efDjVI+yMZKTlx0mdi+0HynvvCImn5lxzplJdtTdeT98puaGvR+CR99iciAGAmH+92Q9 TFWA== X-Forwarded-Encrypted: i=1; AJvYcCULNVbfal2gp63Tw5IM+DAPePx8b02JOgPJpdpnVbVTZ+EVEUznDjW9Ea/1Ap6DhpsJ51EQ13UGR0Rb6DzOhyAu3cj/s1mjgWXQPifwfZfGHylxn/Y= X-Gm-Message-State: AOJu0YyDt8B0+CLgXPmSDCa833VVwU21VYbblMHesZbMXnQKZjku6Xwp eRMjuU0wYgtLlWZ0/5S/gJx/Ajr2o8XyITxiATiDAIPlY/Zl1/Iib0VRREW078o= X-Google-Smtp-Source: AGHT+IEgUKslhbCFFA9X8FIivCaFHvZzj0Mw+hoRLlezgDrkKgO3aZB7DIdSuQrBqwbWWHQQ4Gcy0w== X-Received: by 2002:a17:906:f355:b0:a3f:da1c:ae4c with SMTP id hg21-20020a170906f35500b00a3fda1cae4cmr5201250ejb.54.1709478090047; Sun, 03 Mar 2024 07:01:30 -0800 (PST) Received: from brgl-uxlite.. ([77.241.232.10]) by smtp.gmail.com with ESMTPSA id ch14-20020a170906c2ce00b00a42ea946917sm3740293ejb.130.2024.03.03.07.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 07:01:29 -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 v8 07/12] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Sun, 3 Mar 2024 16:01:10 +0100 Message-Id: <20240303150115.133633-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240303150115.133633-1-brgl@bgdev.pl> References: <20240303150115.133633-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240303_070131_805215_00AE0707 X-CRM114-Status: GOOD ( 11.07 ) 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 Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- 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 ed2600bbd4eb..b0fc0727d090 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;