From patchwork Mon Oct 9 15:34:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413934 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 BEBDFE95A9F for ; Mon, 9 Oct 2023 15:35:31 +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=54teT0YAV07Dq4me/nGyDaZ1Bx+hdWoelFDxfrElBRc=; b=LR+9hxfNV9fSBs CTvDqb4Sz77FjXQHcTFCYX87DQ7XLIJgnewpV2z9X2CaYUSpSjx4WvonNcFO98gLEqydl6A/4T0rH gFURm8Up1DTm/MgyJKpTC8t1MeyWhpoQrsXlD4j0AMxPho+ww8G0rIDwozz3qz5KmDLVujfvIBa/i FsblbhOKGD4dLlxGoh2IM4RSVuq4qCsV5zjUfw9foyDYKnyuTeLDHeXKvRBO/W217loCT3nxtObO3 y1sHIJunCQkroM5mJpIuoJd+Tm4GxswaDbnZyNmToi0y/uFRZenkc+JoHJZtq1DJa8GWgE7yywzFr 9rhlCs3S0+9zh/enITcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHg-00B48t-1V; Mon, 09 Oct 2023 15:35:04 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHW-00B41j-1w for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:57 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso4490635f8f.0 for ; Mon, 09 Oct 2023 08:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865693; x=1697470493; 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=Nb4tcSfQ92DzRQCExn+0+N39FtrJHx6Q4bK89f1YGng=; b=tnLSTH0hjniQg+/Fw9p9/V1LEQouGaZdSeSns8aAbIZh0cx0B/NqumFepId0pq1LiS oZfsf0b7fMCLz5zaL48NYK2t7YFzELgYR+wAGa/CBDaWmU1AL+VeZjnJEi1FWag87fuV NuVtaZXFrdO1nmx9Avlx6g+RWcWeHFf53xND0i36AG+JY+24RI7iPjP073TmP8Suq8C6 7mWMP6rcQtLzQ44aBIuFA1kwyIpFGnCrg5IVLO1bGfKyXB9v8MvQleXk96bOySw0jhvz 69PzBscxYUy0JHi88mrnwUbC1MScvIlrXhvFuBhJkS6RdYntJ6YBui/XyExUiKW+jzCu vsoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865693; x=1697470493; 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=Nb4tcSfQ92DzRQCExn+0+N39FtrJHx6Q4bK89f1YGng=; b=t7csCPQQWzRHK+lrMS6IFAngVGz7GAinv9U7DLDrv9Fv3iL8AnFBKz85TM82399wds xDbnFA74FGtf686GOtMSwoH2jZCSHp/q222q9eCwqmeTHeBSzjioc4ap7mlB8mxf9ORi BgvU6H0mI6fWV0lg9bHlluUJjo8eobk8yy2fVV6l8NhZM5HmPBNf8HX6pRKSb8TVae0o 6U6SSm6Nb53EiD9hq7DdJJPbVXcHuaNeUQ9dUz1+nCPV1IbL+gV/luC4z2fmM0QcPHsw ypM1HynHRynXnt/Qg4zmuKD3bkVTpUyXFsAmwKhOKZqA27puR/luEaVAjP6iptowtB4n snBg== X-Gm-Message-State: AOJu0YwxSqcFlXnufT/KvDaejMFZXZbrgkWNGFtasGet+8gAugrV9DAW peF0//Obfv0zn2X7qfYDSClDhQ== X-Google-Smtp-Source: AGHT+IF/ATwNhgOWfbF6ffkoc4v5R/7+WBbSX0OpK95f8UD7VXSz1nm9Y6NL0KGaM1loMPbeBPKrCQ== X-Received: by 2002:a05:6000:1815:b0:317:e1fb:d56a with SMTP id m21-20020a056000181500b00317e1fbd56amr13467982wrh.40.1696865692794; Mon, 09 Oct 2023 08:34:52 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f20d:2959:7545:e99f]) by smtp.gmail.com with ESMTPSA id b3-20020adff243000000b0031431fb40fasm10016521wrp.89.2023.10.09.08.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:52 -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 v3 10/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 9 Oct 2023 17:34:22 +0200 Message-Id: <20231009153427.20951-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009153427.20951-1-brgl@bgdev.pl> References: <20231009153427.20951-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_083454_640617_8E0ABB46 X-CRM114-Status: GOOD ( 11.70 ) 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 --- 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;