From patchwork Mon Nov 20 13:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13461305 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 48AF1C54E76 for ; Mon, 20 Nov 2023 13:23:27 +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=3OmhU3VwsG1xMm ZRVXHY6ncCnimA9EQg2S+m6j2UhlpPy24gWka66S7QqHLE+vIs3BZowyhDih7jYW/UetNChJ8jXpX G1oNkyd+xPLiI93qd/bAF9yC8MoJQXiklJoA3S76xwH25WtwKv3gMuQxiDSvxFLY+1EA6uOUKNZoL RXvvEaK+7+q2/+u0XPtwxIFIbGUmlaJIGW5b+eXOoQ+Bqe4vzoClEJ5YpX5jTz+ewpGhORBNbDTbU xCZ6vKh7chg9mGKb6T7o3oxROB/aji3Tzoa65HN7yOa33tgtbg6umJds6K5MzNPs4suEAa/vNEfCR 1nydZuftA/kcx6v3AC/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r54Eq-00C8Po-1v; Mon, 20 Nov 2023 13:22:56 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r54DX-00C86K-0X for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:21:42 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4094301d505so14265475e9.2 for ; Mon, 20 Nov 2023 05:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700486491; x=1701091291; 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=c5+C6mrOSSSV/Lh4sZqDs89ySWLSsK/tyCi0Q4LG8QxgHOULoum44YwAk3axxG9xgP 7fYzu6J5mBA4gLj5gGx9CUnKzXap8foTN64yNmR7Zdar7lraXLyVD8DS1n4wCHT9QcIN R2tk3b3JDR8fzf1GnyRLYTNXrQt5RWvazH3EiWsUK7yD+HMl3GbeQIU5DhOcGmnX+5zz cbKCaex3kvQaXl4VpxSIe3s+Dh9mUG93LDgWijpXreDh1MMwfSw8Tj/2hQL4tCzI3SRN DxD/e5C+ZXxp38jGVRhAXSanRJwYqfwoqAqqF6JkYjvlEl5UDbVSv3wkxwZXe/1hToAY PAlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700486491; x=1701091291; 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=i+AUmUDKB2PCYAg6+lvRrrsrL+WXO19Yz/Ze3djBT+QlGIAjdI0F3XzcfdOR4AHiRM AnzAQYjUOpj4WH8TFZathCSs/Ry9/Votk62JNoDW69Z7j2n3KDJkItBx3m6o8nWYMJV4 +MZsKe75NTn54mN7Lh+Fzc1LXetfvMchQb2N3hXOOenfg8eRPEby4WMJneZ8J/fDp13G a0Ww6uQ9DMAvpaoj9K55FH6YBgilVYLOtJdCwNn2MlR1EoaQU0xB0MMe0ZuwrzYaDAsy TkkhipXCjMhrM8PcfhbT3suEeMwnyEYMH1NB8kDclSAkbYoorhe5o45p6NBQkSQRhUIZ kKUA== X-Gm-Message-State: AOJu0YxzgO42Tq2O9RtJSXC8TkrzjL0/ywVYT43jHdPxIKDV0rG+CKzo 1WiUrE+fasYCCe2gv0guwXQbaA== X-Google-Smtp-Source: AGHT+IFm/Mr8qVWYLC8Ecyaod4ToK4uO5bpR7HrYGKe9vH3BqQvjYxq1eycOb42ikhp42B/Ccx7p/w== X-Received: by 2002:a05:600c:3b8c:b0:408:37aa:4766 with SMTP id n12-20020a05600c3b8c00b0040837aa4766mr6455184wms.5.1700486491352; Mon, 20 Nov 2023 05:21:31 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:c590:a7ce:883:eba3]) by smtp.gmail.com with ESMTPSA id k18-20020a05600c0b5200b004065e235417sm17329192wmr.21.2023.11.20.05.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:21:30 -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: [RESEND PATCH v5 07/12] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 20 Nov 2023 14:21:13 +0100 Message-Id: <20231120132118.30473-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231120132118.30473-1-brgl@bgdev.pl> References: <20231120132118.30473-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231120_052135_342809_8DD4A8D7 X-CRM114-Status: GOOD ( 11.24 ) 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;