From patchwork Mon Mar 25 10:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13601739 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 210B1C54E64 for ; Mon, 25 Mar 2024 10:04:54 +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=hVz3ugP0PyIKlfL4m7Ei6Ecli6OeHgcuZDxTagrjvlg=; b=PwBUPRKT+8e6rM 6JSCGsRGQJ04Um4DuvAksCkiyTHhVA9RszqlGBRJcfYFnJzytlZoIEju9mSO00t0fS6uGr7ft2K3n qZJugqhGatsmdTDT+mVUO3OCCr8WO4FH9qecXng4cQeEqDjuZRbrmQUxvtK5XpDL7A/tiszWl/Uav xCTsNfEk/acPzKBFBu54YQTNeJ6CTCE1nQRYxkEwTkUMscNvMePGC/Gck8ZRKI3PRjjxRS5z1ZgvW xrHIzZOBfIkQtTWRCx8RGu907UMm5TXITSC4yjaz05KuygT8VSEmI9TkHmmGl9UG2T+tugTU/al7s 0UNmw9elS0T91ZAxW2Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rohC1-0000000GchR-1A0d; Mon, 25 Mar 2024 10:04:37 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rohBf-0000000GcS0-2fWM for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2024 10:04:17 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-512e39226efso2832230e87.0 for ; Mon, 25 Mar 2024 03:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1711361053; x=1711965853; 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=xufcXpqu9meZgvOhjobiZ3mAJVgm6XQHol02lU9mgVE=; b=0py0rf5ldZTNiaSC1yR2jjK6EtIi/MKBPmswrIFtjKZhL+VHp8ecldhzPl8ssy9Lzh UMrx1cFVduiBy53UrL9kciUqQ/icAqhq/OT1kdH4Kt3eBnCfcpfJSM6pTW/VQazDgX0D op44YHIgwhWQudSkAUu1tqBxnLWScDWic/7re9+y+NKkJGbcg1RcqqMnemgpeEiA6iOD bAMPQhbsYOIT2kmQZumAn8pCPnlx3S9UnC64/orlIg1dID2ALdEwhMgmVEHyOl9vFv4g fSh/nH3riT18DgBbbbgw7B+hoME+4uf7KiMJ7ZOa95iwBnCRsuGMFOiKslqzs74MXnfB 75Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711361053; x=1711965853; 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=xufcXpqu9meZgvOhjobiZ3mAJVgm6XQHol02lU9mgVE=; b=Un86FN3QYtmgnclgU53Vq8hRp9FThUrr2XF9N+C6gaIMMrby0sphUBzRft9L39vAez uixGn2SeH5kkig6MvIAPCyjHb5+YS7Jr8xaMWO3sTL6WEbnA3MwmxKgUVmPZ3nssHQvh Ry/DpcC8uilGYgMuShdenl1nDDz2k6ZWVlqGfYY4qiWGi8Ey+fkjUVfANx3hlXwzHwNe 2iYBhWEb5EY7H5aA9EL87dcyRe7L5erw7HlXdd4ronl3oDuiGCNfOVqhn2322cQh9Qvl bSsMqOxxkaHVhRLHWmJYWEsYifi+HNN6oD8+Ewy8BMVhUG+SCqwA+RqigQBVu3jHwuhp wa3Q== X-Forwarded-Encrypted: i=1; AJvYcCWs5/HZgMM8Swj7pxNNxqGw8+FtEv0eYyEs3jjMz/tJVtF7+Z+P/jaH49aBrGBJgKDikaqZvLQ/KR1ipak+06QZ+STm1Qd46hcr4IykU2UMhraRdBs= X-Gm-Message-State: AOJu0Yx5IKzm60dKFRcRiZMs9UsfdJB+7rvmfEMcBTOgOdYXfsGNIxug 42FqlOn8u88XEoYIwoQdfeuE8/QCtKFY7MgNIpHphrATtqyaCIoX01mcG2V05V0= X-Google-Smtp-Source: AGHT+IHgBg0LWLPO99YeuP7Xyyt0H7oIgeUw1/SglAJPFnHodW8TAuxRmmG2jkvBpFOO8T2o3jhO6w== X-Received: by 2002:a05:6512:3282:b0:515:a8c9:6ec0 with SMTP id p2-20020a056512328200b00515a8c96ec0mr2202428lfe.36.1711361052810; Mon, 25 Mar 2024 03:04:12 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:75a:e000:861d:8b72:a859:4ce9]) by smtp.gmail.com with ESMTPSA id dv13-20020a0560000d8d00b0033e25c39ac3sm9086874wrb.80.2024.03.25.03.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:04:12 -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 , 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 v9 07/13] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 25 Mar 2024 11:03:53 +0100 Message-Id: <20240325100359.17001-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240325100359.17001-1-brgl@bgdev.pl> References: <20240325100359.17001-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240325_030415_730711_DD67D3B9 X-CRM114-Status: GOOD ( 11.62 ) 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 feb44cc03d2c..d9b189632e61 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1528,37 +1528,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;