From patchwork Mon Nov 27 14:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13469723 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 3FE8AC4167B for ; Mon, 27 Nov 2023 14:17:28 +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=cN2frEUUZRzhv4xSQJAL3SKkBRmMFeqL3p+hGVRfbOE=; b=xtKt6KK0Io4WrD OZvFZCZJZhVtLj90P8zKqWKMUebRhR1QrGeiiuHiiDnATt8MHfyY5oV/QpapdpCW5qIZWkVc/kx1A J0BYV8kihFAsJTGbqIDu+k3EFSm6ZnVX6MJccPkvyeJOjQ7KfON4/XCKEajnC4uu7+SwtktctUnJA tS9VbevOejScl7oVbRWMzxpkpGrh/2T0fFTQELiOxZAySwIZvQcUEFBMunFFQa+AwivAoCDSAMWZV SKwD4tIkjSkUcuyHmnMMGQ4oTApGyDmw/Mf5z46LthbNFfM3izefHISvBsJPj2KP9G1pCV8ey7Yzx ykx0TFn77b4QkrM757oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPw-002fTn-2E; Mon, 27 Nov 2023 14:16:56 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPN-002fJv-35 for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 14:16:23 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40b472f99a0so6017355e9.3 for ; Mon, 27 Nov 2023 06:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094580; x=1701699380; 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=WkxpnfZSZT5EN0UFZSvV8zs0Wwv4/j6hiBpdKDk1HxA=; b=hAYfPTuGsmTb7ipB/9rvEjHcIbLUpCkNIrZB2Egf039frzAxj+z/8PJNBjzc/DpZuF SuyEGO/yypT5mh7i1fvWki9DmV1dHak8iZNTLWDYwD6MWodAWbc1HE3lpBSWkeDixQzS Z4gzbHtuhbnZEMlpOJZzUFfi2cpPly7DJnio4nU0jXsdN18iz20M+j4qih2KYARWgTiQ GQAAS8jFPEY5hBVUxFk27L6wJ05QOymZKbTk2to1grYS+iJ9ZvXKk6Vl7bCNAQPYj+KQ mBVuH1Sfru2Rm4x2wJNTFPn6b3IzS5W/blYnSNqtWwN2qwr2sZkwneBScLWM9RrBrJR6 8LyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094580; x=1701699380; 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=WkxpnfZSZT5EN0UFZSvV8zs0Wwv4/j6hiBpdKDk1HxA=; b=gN7IkD7etOMJB/MFVA099a6p2ykoksUmPOFj8YGpQMuNyoWmy3UKCHzGcHvArQnO1S s1Z6UulX0qwUo2khznk0brqxPsGwDu7BC3xCWkxuKk9hhoEIsBzII8Imt1YJ46h2Mbup kVR1vdXU37FaMlaNAK1h55owcY6/RiF/9YXircPjeWvVHaRiWwQrYbbYfSH/I66V5GkZ gqF+rT1GAltGjFRoIF3T7tiYcn5fuLzfJpu/GM35HpYpp2NgsvOwRS/R5Q9aNvwkrBw0 06BdaDTQy7FmTHPI6ylvMwdBAukiTnqL8W4dPCWMTqZlZgQ/xeIf5tsoNo5CVaxvjnzQ 1sfQ== X-Gm-Message-State: AOJu0Ywj8JN69JFg0IzcnXQI30HRj51WbFRybe25PMrwcHpmN37tLspP /jFiNGNHiJWILETok9fjWNiuiw== X-Google-Smtp-Source: AGHT+IHVgZ20gEmhmev1RX2eoTA9+8mg2/svsRYqUISptDWvOxDB3DOBPlKuaLgRVJ814cwcmx9shQ== X-Received: by 2002:a05:600c:444b:b0:40a:3e41:7df1 with SMTP id v11-20020a05600c444b00b0040a3e417df1mr8884896wmn.37.1701094578887; Mon, 27 Nov 2023 06:16:18 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:bf33:77c7:8131:5e64]) by smtp.gmail.com with ESMTPSA id be7-20020a05600c1e8700b00405442edc69sm14658830wmb.14.2023.11.27.06.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:18 -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 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 v6 08/13] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 27 Nov 2023 15:15:55 +0100 Message-Id: <20231127141600.20929-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127141600.20929-1-brgl@bgdev.pl> References: <20231127141600.20929-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_061622_054239_ABB9A0A0 X-CRM114-Status: GOOD ( 10.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 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;