From patchwork Mon Feb 5 18:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13546022 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 519D8C48297 for ; Mon, 5 Feb 2024 18:28:51 +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=EIkiYfHB+0vnX9 CI8izThhIf+WeD70SbPW2Rf8U+t0YiPzydBC/mZ/pbFq8X5tOkPLtbArIkp3p8ZpwkXdPlb4eEalg zZWNkpBMiFYe0mUuuEtibTqLes3Yj4EEsaWG1Lo4GbOtHNqwqpo57Z/VVXdVwJvteb7VOfyLcRIA8 ubVnVFXCC6E1kNCdqDgptZY8/B4gsf9pgkykkV+hBuSPmeU4uEFrPWtTNsDnVfwxdvwG/YI0my9ba DNJorO66d2UiXme7/chY+u4SjxTHwYCWle+bMhISNFN/kBFqB0qzsPq6A6uyla5W5xEcJTOuM9Av4 zoMel3HwCLRxWPRetNLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hw-00000004N0X-1qgR; Mon, 05 Feb 2024 18:28:40 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hl-00000004Mrj-2hE9 for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 18:28:31 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so3535612f8f.1 for ; Mon, 05 Feb 2024 10:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707157708; x=1707762508; 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=oLL3d40y/XZEhN7GkZcoZCS1DrrlmdkkmiRN0Q/bja3KX6b1DFaZEYYFNjgJ8dEaOS 1xj1RcYjXzNCbz+sigy5H/HohC8YRdYMp95Ukg+I9OxYm0MXh68iZWXyvIXoelXwJQZR InoEXYGT9CzzVTDZDYEWYZVYk5AMml/hdhg8kupjX7eZ7SX9PoWjoU6124fEup7KHQcb 7TysZE4UGSAUcq4JTmKuCutUCs8PUg407/tNo7Nn7QdWetmN56iTFtI1eJzyOLftFNN7 VnJfvPqU0cnzKVIXgmjulYxSYP3oCdjbeAGKIW5Rbc3iEoC74Gx51jKhSwPZdCAvpKFV Vaag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707157708; x=1707762508; 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=izJ/wlBoxwk9RTw2hGkaNy+gp0MWEAzOVlV0DOjZGhcM9TFF70k/sNJvzVK6tZ0sNz mi3ynhdLtb6BOxoyWWTVeYnYAFrSne73qelsyTub/dARy9MeaQDmW/e6JPDJXQVLvM1O bQWtZFnersKB14wK6wKANwIYqeJxRLM6/Pzn9OgR9Z97Muu90y/+XQcM+iJ6rNe+pKjO sORgpD6HFDbs7yOwSqHKg2TKdiJrYLuXph8iTk39TVrKQ4q52Sog4lCMVH0T0CIpRCTu Jno6b+puOjRDQKugJQZDd38rQtfF2bJ8dnJEGvUKg0SWmzOUbwbumoUAaxgAf4+xbn4c sdvg== X-Gm-Message-State: AOJu0YwA3dMCrqw46rqNAFE8+IDQHBdRniI0L2s28ZYJznulEmCOyFBf Sg1QNTXbeVY3nDKdmMZNXi806bUeZvuFRCAvrAQsbTGNgLzg34YsBLGJuCjt/uw= X-Google-Smtp-Source: AGHT+IEbZ91ZP8juBJlYfzHEEEkyJuuPPIxG2nnGFJhu1M+wrdILW9y7zEKqJcg/Y/9qH7CgyyKmsg== X-Received: by 2002:a5d:698d:0:b0:33b:150e:627a with SMTP id g13-20020a5d698d000000b0033b150e627amr188208wru.70.1707157707812; Mon, 05 Feb 2024 10:28:27 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVnHR7MaTmuXNXpSFb/KHk62IruZCfaJyE2NhFVgsQ8v4ZKzkCNgdg8im2IA9UO//5RtflXbuaSbXfQjUOQ5Nc7rhtR/h92SOavahh3Oy/2YUvp5I3STFKS4SciONT37cPKIEXbTV3GqNEeGm/gClTT70BbN/vQ1U0oLciPqqHlTlIPFZCnz6MUZgLC/B2RPTDI+vT7/7Q1qv5JYnxA2xGUfxstrITYjexPK0F6f47jNM5OTJW9lnV/4xO3mrfvTzs4gp/+vJOP4oqThc3gNmtcoszoV9vmnBGpXpFq84LE/W9r5YAzN549zbgJnzSpiLrpVfDib/0xyE/peP37WuCPLwD8yOGBNWDt8hoRRim78eKJSAeqDGnXqmpZTBjLI6ue3aOv1OxqLxpYIYBAT6vFVYqCbfHd3LXPLdyWCY5GS3BzDyCNEQNDKA7RRiCFz22idtO4s8FUOF8eYFQrIQCJGxif2gcfpO/wJMLW98yLnsm17vSDQ9diQsWP7Sll7S2WHuLREMkK641IQLD3IlEPtVJORaEPazIyTTSA/WAwY3p/BmwmZcAvqKTsA2gL7y4= Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id v15-20020a5d678f000000b0033b17e18df8sm203229wru.12.2024.02.05.10.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:28:27 -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 , 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: [PATCH v7 07/12] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 5 Feb 2024 19:28:05 +0100 Message-Id: <20240205182810.58382-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205182810.58382-1-brgl@bgdev.pl> References: <20240205182810.58382-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_102829_750217_BBC848B2 X-CRM114-Status: GOOD ( 11.35 ) 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;