Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3287294rdh; Thu, 28 Sep 2023 07:45:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8wW+0okc63+nrenSR339EAmh6t3VfDzq1DXap9lN8v662TMZnI+UTy0bo51zEBEF4t74t X-Received: by 2002:a05:6358:713:b0:135:499a:382b with SMTP id e19-20020a056358071300b00135499a382bmr1477096rwj.7.1695912300219; Thu, 28 Sep 2023 07:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695912300; cv=none; d=google.com; s=arc-20160816; b=hbtm+SYuh4eybtzyYHW2ml/K9ya+D40fKDYxHchpomXIHvlJ92OZ6zKJ+jgHziSqvg VcShwSYycHZuZ7ryeh0Ql9zfRTEjY6diLTmIWDrG6Ce3/W4LikBJNmhpqMc0rc70gBGy s/RuRKAvIv6Ppand/69kt9sQE+0VBpYLyU08klIoKKMIQpcmQVuTBh2f5O4hQD79PECk fuJl93AucEIKgIvywyMuLPGc+gfAhQsyVa+TZ37NxIwQvD/cW5/USft9CnjdgVScQ0xY smPov76JIf5gOY+bukaQOwFItgPeybi1WM1lZXGxMJX0JB7T4yhQYoM89cwnqTD6fylw STPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nxuIylgD4O5skgVzMv0zVAkT/q/ETWmaZKIykuazMpk=; fh=qciho/xsTxNUsKJZ3hehiaQZTIzl+I3IMsnaV40iMRE=; b=XpCvL9hqst6ZrJxLtiugOIhleX8B/6d7SWetaGAfju14TFQUg9WOBgM99RJDfaNQOZ fS7EQ9cVSm7tcYlGVvmgazH/x7KXpruBI5mYCHuBYoT6/W8GrS1o3UNmyFrMx3muBOdF avO7O/5RYeT5xkikNy7zwosGvOSo0t2TgDU4bRO15hgWJqJJJBJQOpNX63M+SQlZ50qa RSMcoGrCxrCKg8m64bLoSErmHF/obmLLKKrjwjWJK+qvNOFKComeMRS3TGzQm9/kWPPR p1fUFtZBHn6Q8uWMcVHKtnsJDfbz4mLleD7momhW57KtoyEf9ZXtdxklVZctwMPTg9c7 POsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=QsZQMhMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y18-20020a63ce12000000b00565e42df278si17884659pgf.759.2023.09.28.07.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 07:45:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=QsZQMhMR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 980EE82E27FA; Thu, 28 Sep 2023 02:21:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjI1JV2 (ORCPT + 99 others); Thu, 28 Sep 2023 05:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbjI1JVJ (ORCPT ); Thu, 28 Sep 2023 05:21:09 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7BA8E for ; Thu, 28 Sep 2023 02:21:08 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40566f8a093so96296255e9.3 for ; Thu, 28 Sep 2023 02:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1695892866; x=1696497666; darn=vger.kernel.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=nxuIylgD4O5skgVzMv0zVAkT/q/ETWmaZKIykuazMpk=; b=QsZQMhMR3GBlsKJ7Hh7RI2aRGHO/11F+Zwd3LGwooLhEF9xpYgSdM3YZKHCuA3LTH0 pY3AuWOHLJmI3j/pyBmu5avFSn9jqc6wUDK5UmCDZ3vE6OeoC51UGWYj4lz8HHH7zqhv 1Y3FnQImB+qkBxQNrbPKvsRchdc9j+z43X9h/yVD++PpY9SX3O/f6u1OPiYpU5jnX7Jm lw74P8IZDMlNPlk73nRG896X8r4SuyqB8s1bRccr6oINpNlge11A4BVeoMfhqGBWAH+6 Kgqz1kN8uU3gDZxTA7M91vFsL15dZMKb07d1SqRCAAMyFXKoJDiDcw+PeJAeMy4Y9zAe oJbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695892866; x=1696497666; 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=nxuIylgD4O5skgVzMv0zVAkT/q/ETWmaZKIykuazMpk=; b=rPLl241Zxd+Pt+ZnxzUYJ2Mp/Ew1tFYTzJkMeBidpZDja8d0uGkYBcV/tDTHZHYdGQ dC0EHcD8Rhk+JhxcS+mPMlNfd6ucjsPmDWKOdSK0KW90l5C+/PvDywL9myJ872OMmggJ gkMR/Nl9AHIRWQT9cmLZiwqoPPjXxirvSzj7l6hFMnb0m3VdPiM1Z8poYdZ5PS2L+MIX eivFKxKKuvzwGm9hL+6XoMpuXll9UAa2VM8VELnuuyCckKp+NvqYxzJQd1QoDw1BDKRU JJYdd8yIHtXikjiPSa2XfISDCgRBextILhyjVySwiwNc6tbbCY98s4jqMeVGbQ7hdJKf xA8Q== X-Gm-Message-State: AOJu0Yw7MG9qKJzo4nTTSdIwuXh3PVQoyy63RQ9BFKY+ttItC2ELFOYi 8uulIwuZni8G4kx7AxbGgtglGA== X-Received: by 2002:a05:6000:11c7:b0:321:6005:8979 with SMTP id i7-20020a05600011c700b0032160058979mr787869wrx.17.1695892866569; Thu, 28 Sep 2023 02:21:06 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:6e4c:e3c1:5cb8:b60e]) by smtp.gmail.com with ESMTPSA id e9-20020adfe7c9000000b003197efd1e7bsm5009156wrn.114.2023.09.28.02.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:21:06 -0700 (PDT) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Maximilian Luz , Krzysztof Kozlowski Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@quicinc.com, Bartosz Golaszewski Subject: [PATCH v2 06/11] firmware: qcom: scm: make qcom_scm_pas_init_image() use the SCM allocator Date: Thu, 28 Sep 2023 11:20:35 +0200 Message-Id: <20230928092040.9420-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928092040.9420-1-brgl@bgdev.pl> References: <20230928092040.9420-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 28 Sep 2023 02:21:39 -0700 (PDT) From: Bartosz Golaszewski Let's use the new SCM memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 02a773ba1383..c0eb81069847 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -532,7 +532,7 @@ static void qcom_scm_set_download_mode(bool enable) int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, struct qcom_scm_pas_metadata *ctx) { - dma_addr_t mdata_phys; + phys_addr_t mdata_phys; void *mdata_buf; int ret; struct qcom_scm_desc desc = { @@ -544,13 +544,7 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, }; struct qcom_scm_res res; - /* - * During the scm call memory protection will be enabled for the meta - * data blob, so make sure it's physically contiguous, 4K aligned and - * non-cachable to avoid XPU violations. - */ - mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, - GFP_KERNEL); + mdata_buf = qcom_scm_mem_alloc(size, GFP_KERNEL); if (!mdata_buf) { dev_err(__scm->dev, "Allocation of metadata buffer failed.\n"); return -ENOMEM; @@ -574,10 +568,10 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, out: if (ret < 0 || !ctx) { - dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); + qcom_scm_mem_free(mdata_buf); } else if (ctx) { ctx->ptr = mdata_buf; - ctx->phys = mdata_phys; + ctx->phys = qcom_scm_mem_to_phys(mdata_buf); ctx->size = size; } @@ -594,7 +588,7 @@ void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx) if (!ctx->ptr) return; - dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys); + qcom_scm_mem_free(ctx->ptr); ctx->ptr = NULL; ctx->phys = 0; -- 2.39.2