From patchwork Mon Jan 22 10:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13525122 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 8A38FC47DDC for ; Mon, 22 Jan 2024 10:22:56 +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=OusOVeQSXsHBGUaRlQzGnXL15/k4J1ixlciKkMOR7rc=; b=1Cy1x7j3tN9hSk +Ip3RLZvC5GIyl5HizIbECNWqdjgUPdX9tExJa1mf2hhlBGveS+0oy3yji2ZdBuLGjaFT1nDcs0fV 7VY39HUaP5J6V4M8RErw/TFuL8Y/8SgkiaGA6ymatntvnVWxKmsYTbIJ8tQwZdK7JXUq4gkODFwRb E5lYLpE0OV2k71D3ZrC0IbytS1mrQPpVJsCY1ndUqcfx5q/0B9TKjvyVVKMNz4r2T7ukCHCo/qGkk zk09acge0d4CoKuD+quVmPhGqF8qGuysEcylo6eLwrWuhY5LQglPwEETb65Qov/C+vj8P5rFY25qX FDEnSzHROJ1nbaenP9LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRrRl-00BUhp-1f; Mon, 22 Jan 2024 10:22:29 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRrRc-00BUWN-1R for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 10:22:23 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-336c5b5c163so1745949f8f.1 for ; Mon, 22 Jan 2024 02:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1705918932; x=1706523732; 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=s0oEOKGcE5RDVKHJLOO6pZt7g+TRP+w7zOsv5ctScyA=; b=IokDV/nzNYjgdGjXcNWC0u8+pt4WC2soQ0jUGtZBQdSQd+qI2Jwc2yN6C4IYDg5NP3 E0/kbNy8QnvUH9V/dylKopBJFgebil80ZDLEecDvhhr6ei1V48aPs6SnBoyIe5zuHL+k xIwc+INqtVOgkUXtoSBD/sSyjVXkv4Zz1hx2jTu1/OUavovUSfLf12W/PzqMTvabcL95 sxkN7Hezx67HOCkberMW5b7PjFVhTEQD6ohjZlY4Tqnh405/y6XBW3B3FZ0Hk+ATwwKY 2uG8iDIXmFNnx2Vpsgkr+JwdbAs3SuAfQonYQAc5FRXPOsh0NKc31OfwFFku6Ht3Fo5U j5Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705918932; x=1706523732; 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=s0oEOKGcE5RDVKHJLOO6pZt7g+TRP+w7zOsv5ctScyA=; b=BKEJ7p5xCHV52G2sIrMPASq/gYo3soaVqFAh+jPoALi/ob2FLeHw0QzH2scotrrkNI B+XdTqsZmPMs1+6gIBLZsBMXTtfmiocWLvPaCbdBzybbEZCXKRDjPWxapTZJSW6alQML okyacoddUWaiC4lV2ptemPJIY8jo+TtQrlHR2MouOMvtr10VJ8eStgJseFPEBiWaRt3M ukfzlEp5awiOjBqwYrRnO5hBsJjU5/1grLmdvbUcxwMMRw95Skn+kjnFC1pSIQSBU9pM /V00qyUazSk4/DBpKwf6JqEb5+wIWUL+jn6c5SyQZ8kZKg0QidZoIBNNtBN3mn2RtiFj dKQQ== X-Gm-Message-State: AOJu0YycXxkKCO0fxyj37vuFSpq+8RQQoHeafZYfU8YansPTPX6MvB1J 6M4ptGwsOfWbzgiNOth5HigJv+pJW8NmiejJLVS0wxuYI2RKXDzdRPY/L5PpMyQ= X-Google-Smtp-Source: AGHT+IFToqlcKaxkiS5LUPEGDrIetlUm4/CPOggDUt+GZFmVFqwX/xwX44NKNvyf8GINsBA/qvKbHg== X-Received: by 2002:a05:6000:100b:b0:337:d8a5:32d6 with SMTP id a11-20020a056000100b00b00337d8a532d6mr1954803wrx.9.1705918932721; Mon, 22 Jan 2024 02:22:12 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:92a0:6172:d229:1898]) by smtp.gmail.com with ESMTPSA id q7-20020adffec7000000b0033926505eafsm6377904wrs.32.2024.01.22.02.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:22:12 -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 , Catalin Marinas , Will Deacon , 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: [RESEND PATCH v6 07/12] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 22 Jan 2024 11:21:52 +0100 Message-Id: <20240122102157.22761-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240122102157.22761-1-brgl@bgdev.pl> References: <20240122102157.22761-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_022220_532986_7A85D2B8 X-CRM114-Status: GOOD ( 11.78 ) 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 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;