From patchwork Fri Oct 13 11:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420793 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 207E1CDB482 for ; Fri, 13 Oct 2023 11:50:01 +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=H2qwdPaYZwzstIvHYl/Q2YrpR7Gb55+VkBrAHMZr/Lc=; b=tcp11XTAZwWAva iaEmKn/xKlEOoFQgH6U6yY6ekAKDfXZkVkjw14T2zuMkdKnQvnZwa5nQ2hcb3m8uJXNrUVqxuVePV x9RYFX2F+foAjja1DlUsF/7tOlDC7Y7dpvJENEv7Fug6/I/f7Nrp/miMbeRZxWRp9G3+SuPSeVN++ 7Q/STtdt5rpgSSSkyL8HzK/R/9ZXpPhFNPQFQB0CdYKcbjkFz3iC6TQ02CGnz0Bd7yfKgMlZ47If9 j4rlzWHq3o4QZV2XG2dSaYubL8HsPoqzgZSY2ZDZ1NJkgiPJ35sqHAAmXmGaEVY2qv23iVQINFZs8 Zu8R0sNMSNoK4gfoRTcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfb-003Lmm-1M; Fri, 13 Oct 2023 11:49:31 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LTo-0r for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-405524e6769so12849745e9.1 for ; Fri, 13 Oct 2023 04:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197743; x=1697802543; 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=R1+SqUu3MEUpRvP0zkJ91SMCh/hUg62w85Orn9bNfZQ=; b=3act8eEcE7i06Op07CxrYvNpOTFdQReTZ3cmXhPje+VGN5Ejl6gdRDGHJESxFfEPFG GKgUr0+uS3zHMYhdy83F2ycYy7fAGRRXBqvbCpOM+dE9/JWccPrmjH5kFyF0+XDocSC+ aM8HQpjauQeM41Tmq9Wey3SgD8L43Ew4S96aD2B8gVjrdmiO5PQRMLRgrnZGZxnZLRGj XrSxZd2JEn7SITZPtclCWyfUYkyPf1hhZynoUTsZDRbeuY5KsChiqUD+JxRXZCGxESSz uHW3AQRyMBIsqa2ZYYuB6dE5H2z+u7ic/tnOxwKOCV5/2Avgsg9vc4lirZNeZo8mz1f0 yPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197743; x=1697802543; 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=R1+SqUu3MEUpRvP0zkJ91SMCh/hUg62w85Orn9bNfZQ=; b=MwG17AyembLtYEeY+0C089Mc0V0PF5T3kc+ZgTWZb4XrwsJcmlPqvuhxtvkLDmSPW7 Jh8SCyOcblsGchLZy2wdmLXWMqZleETTeZqPCXk9XoOTD8Ko4+p52WNJiabOu/N5f5rn otMqNstZxXFCIwo0LE+ujPThgxo7H4KnMUr4FjAb8BjEk56CLkIecRdetQ2YgrJ+K3dm LWxWLA2XjwUf60XXG29f96LQ2hlS5ETYz2yxC/SGxv5qQoCUksk9vpbuh5QQkYna5cb/ 3Ih4wbTShQizw6tlosnNC7TC7BFVmBwha7WAc9EXu06sOtVJzMMmA8MXfwaMFNwkiMY9 1SmA== X-Gm-Message-State: AOJu0YzPOo3uJhC4jHiURtVxHmFN/oZstjlrBMcrvceXYZgYquvI2k2d uuWHumUnqX9uv6yylBKwDP837w== X-Google-Smtp-Source: AGHT+IHDwKNnkQ4WyyEUpEb+olLuPuuRdwsgI6TaMaTMotsUWqpHhmc5CD14COCyN8ypkhuiPDZtdg== X-Received: by 2002:a05:600c:450a:b0:401:c7ec:b930 with SMTP id t10-20020a05600c450a00b00401c7ecb930mr18683731wmo.10.1697197743011; Fri, 13 Oct 2023 04:49:03 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:02 -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 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 v4 10/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:38 +0200 Message-Id: <20231013114843.63205-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044908_327875_D0AF4F69 X-CRM114-Status: GOOD ( 11.18 ) 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 --- 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;