From patchwork Mon May 27 12:54:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13675198 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 04B35C25B7D for ; Mon, 27 May 2024 12:57:22 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vmFF0JfC0lLfTw6I9+S37e9zgLa7vsDNBWnLMUR/ptk=; b=SxWHSX/h3Q4oBc rW0ZjW6t68h7Ks7dd2vuz9l+7FmExNDwYQtDRm/B/mrQKZkmoEXhcqVKCvidvxf/48wv2fOxwJate N6zDO3FABU5poSBMZOUDuFUUDRsYSBOFAdL+dXqnIY/6t2MMB6r8LOtiHxe3O/k51UEcE4q8XtCTY W9JvkHkB6deDZpnepWp4/uAkuQxOU5KYNnvc9fYgSb+eEUZFCedk5ko28iNAd06U7MyDE6lSk92bb g8/y2nSw/d68z3nsNMUSIsfOWKUeBIv+h7ZMVXfkQlB5FUjqQj2G6gCNcVK3j74+j1EkF7VakgOb6 HE8B0RqJb1DZPlfLxEBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBZuZ-0000000Exp4-1UyY; Mon, 27 May 2024 12:57:11 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBZuI-0000000Exce-3dvQ for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2024 12:56:56 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4211249fdf4so9169855e9.3 for ; Mon, 27 May 2024 05:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814612; x=1717419412; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+c046Bdr0ynwyOgSln2Tc+VCr+O70Cxi2mOC+fx0Sgc=; b=dundWlXPp/L2v6m3L9seS8yoYgFBC6LM77JAIhL44urlXHnFjKSI+FMIMMnK4WgwqC llFZm70CfR/rIO2mimVRvNIRULB6ZFxeVdOSaaIZqEMz2cy3uOXHkWZGa5iZndJsCf1A qYyAX2kmv5/1yMgRWI79z3B4BEHXFmy56647qFMhjN9rvKDquCe4rZ6iojRFZ2S8Z/Is bDwtZCnPJ66G/hPe2X58f2x63So2AsBzdj7IzXQuncrZEbI8IFJyEocUniCKfo5j5Zww iB0BS+9a6j4yM/B21yuVuQnQbAPUTTvEKh4wwlYxfj2l05hQBlcRzqL/jAQyRFTP3WzJ 9FXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814612; x=1717419412; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+c046Bdr0ynwyOgSln2Tc+VCr+O70Cxi2mOC+fx0Sgc=; b=d3y5VVWC6wAhdmuXHt2cpFWG/VaeIMGL70XJeX9iKQC1LnGje8668sQ50DuH/ARn6H XlGa3qh1apRwPwyFjbh7653AVlfRyhS93FzmSGj5pEdmbv+H6QoNDtZJRq8DzXC58Who END6gmZ3JDEvfd+IMFA4MAWOScaRZY2eZsiuUoF3KeACdqOHBAmOqAJNR6wmfzNU534H 8Txe4DlrYvyhYHAkGH4fK37HST1qfw66YHd2jdNDCPg96NLpXsDbTGASIyWsGAUgTFld o9FaIarEFWBRT7g9gGUUScVdWi8yCjiC+eV2up/A8/bc+fd89sWHmWILE+VAJoACXInJ C1Xw== X-Forwarded-Encrypted: i=1; AJvYcCUIMldEGzmUbYsMPyVR8Pd8Qb2h4kzwyDzD+ydt984Qk3OrSXBDf85F+XJbRITuPwL2Rq7FSyyG0b4fEtXqeAVTY2kIhLMBUPGGsCU/OVXizt0iG04= X-Gm-Message-State: AOJu0YwLUk11TwENF1tPFgQY/FOknNxtEZ5lye0zE68bIBBYwFr0jfI5 /JyEu5kXMazPDXzSpFEKODh8WNHFhq1GfDoDNgeNtAXaNarHOPo4HQphOLMVdxI= X-Google-Smtp-Source: AGHT+IE2gTcbDyOT3LtBhlMuLEGMxzOENkdyS3LSefkGRJfYypqkDhxXggWJr/I1ETWNNNhg0wfS3g== X-Received: by 2002:a05:600c:4f03:b0:41b:a8e8:3ff6 with SMTP id 5b1f17b1804b1-42108a59341mr74758545e9.11.1716814612385; Mon, 27 May 2024 05:56:52 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:52 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:58 +0200 Subject: [PATCH v10 08/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-8-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2227; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=7umXsYKArEL0srTFmXFqr8mt5W7AHZJF369g+7+Tqjc=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMJTRxwS+kt5btO67A4DzS6y415jXXLTKO3i 6DJkEALlKOJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCQAKCRARpy6gFHHX cmjKEACGXQSfVd+6Go42DHvh1gdSwWk+C2H12J4YBJDJAr9wtyrvDLFn/Ogl1RERoQgeHloq2kE cacBTADkSTFBZ9b4HRa8Bi7fgUO/E78XqzVQI/P4CDT6mh5oTVTdFdblcjEu0WqkaefaXkbmdFQ 6L9poeuuKB1Zo7wFHADzjGOovexLfNFw3MwuxAcpnz3gyhGypZal0/+BXSxvh7URKEIR0kPOdpD 4orKX/PLU0Rh5NGQNCKXoVSOFsAX7ByxbIwA/cdDa+Dsb04iAoxrFt0o4j+Dck+OdVE96t8DZD7 KixZ3PwCM7y7oRiyQOonBjBKCL+7nmN7cnhvAjGUa4mVtR0XbmpNJ4xDtuhP9OWgalKE6KXRxaG T35nBF5EsSR9IkPkIrxrRBX+ATQLg0My5SPZAxlKSNMQnbfwwAbO8tBzIjDDE7h7D0gBex996xO AOEbvu/onr9YO5iw/oRnZBod4SGIvQn/PlhRvwqhBOOwF9U5zkh++Kbzzq03V+XJ8se2TvMhAQq f1xrOCk7wgxjERoavj6FsEj+Tm/iSTK0g/WVDzPgQXIw5aNEPu3CpsYZL/kTuY/cIWArpSwnqAZ dDL0i9ET4YALX3RO9d/Y2wbAAZmSgkl008XTsbvUr0smoiY2eeZRW7Blor96VGIT5hmP3MfJm66 6b+WcP2CuQYEbRA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240527_055655_165003_56DA89E5 X-CRM114-Status: GOOD ( 11.14 ) 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 431c279df12b..1b64a4f4d07d 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1546,37 +1546,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;