Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1358581pxb; Sat, 29 Jan 2022 03:58:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhetescDKBOCQDaOW2cRNPUdUbuj0+Vcd4Y9iAqD1y9SWf3f1xLHyTZV8/mekJu7hRpRns X-Received: by 2002:a17:90b:1d88:: with SMTP id pf8mr14459272pjb.162.1643457498158; Sat, 29 Jan 2022 03:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643457498; cv=none; d=google.com; s=arc-20160816; b=Q6LRvJ4zkxH8vTxrixTpFD9tbWiarnQCLmUx5oCU4nQTbNKgoFSch9idZm4iyyVi9M tKvTRvvZrE1b6ZATgXA9OJdbKTC71cEgcypS12Ng2oZNezrpMQK8S70N1aedGDCaHE1A YTz3T0tkZei7rfyn2cd+kuXbwA+eWAKWS1hQ07KH+dwgYD1QH84D2Yb2dHOwf0Fy9LqN kKIafiVmZhq7Ihe338D1HZ93SUvOLdIQc1uOZAKKtIm7W2K/IV0ApV5NASrnjwzNCFWN Y06alOAPyRV9mgJ88MNisNSoeMBUnJiEtkEDPH696qQpMCwQHRmXxt4e3oouwYbbHvNY ZFWQ== 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=xBiCWtsGgqefLb9AuztIhrA4yfjIwqY0U6EiuLZrZUU=; b=n+1JjAUalS8eQ2K6exNWXLacdj+AdlbGPge5+FiwNvctqhUAF+PEc9ptTa7Tr4lYbQ FGEIdMBd1G+QORrwx4ebtjP45h0UOJ6V41JUgPGmhDlFkkgUiEg+AboRX3kOt8ggXata lvH07N0DW2PcqncPF5bEfLFWJFwtqf+cfdHw9kkg7hN0HqjWtW40b/jcyVwV39NQ9Mtx kMJDGr5MYgsocOAJoRWkEZqoC2yi2RHGYaohAgXiFGiguFld+j4wiPrZGHHOCI6KaOO+ FGjNk2NzgBE9KehTFjFq1W8atWTYUcYTtdGjFGiAYsypPvyT/941Jk9eVXQ5ieBp61eF yBgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TGLtGJup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si8056535plr.282.2022.01.29.03.58.07; Sat, 29 Jan 2022 03:58:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TGLtGJup; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345599AbiA1CzR (ORCPT + 99 others); Thu, 27 Jan 2022 21:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345662AbiA1Cy5 (ORCPT ); Thu, 27 Jan 2022 21:54:57 -0500 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A42A7C061714 for ; Thu, 27 Jan 2022 18:54:56 -0800 (PST) Received: by mail-oi1-x22b.google.com with SMTP id u129so9800054oib.4 for ; Thu, 27 Jan 2022 18:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xBiCWtsGgqefLb9AuztIhrA4yfjIwqY0U6EiuLZrZUU=; b=TGLtGJupeZIo9t/IRGxXa/frN+pcYKpu6BHt4TovO2Hkuu41iR1o29KXFlofv+TO21 kRGrjAY8PzQIwRZBbDH3cy1Qhj4bJeGy95HO8G2Fg8R3c281/BtxOM6u3tkWZ8D1iq0g vSsQ3GSrM+RTlcvbbiE8HZR+31wevHcrSBEcpWBn+dBz6azifXJxnnosV/hM71/forXo IcpKJrX2EyhO4b8NFPzu+osqW9C86JfF+srihK9xBEWqls53QOt/22T7OVCz0eIXoOXT WTIzTVA/yt61J8Jg0K5FTyNCmYQT6a5FPGTWR2ZgDvOKHcseiX2rZk8JOIPHgvDZikJy lMKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xBiCWtsGgqefLb9AuztIhrA4yfjIwqY0U6EiuLZrZUU=; b=pfBkxfWOieW4YmggqtNZ+9+Dv/0MUoiNKjs8zcVIThGlHErVRujiOWN5jOKmyp+FKA m8tGQv/RZ5izHA+wxF6lPdB5k8NsyEyxHfbfmHNp+UpNLg7MhtwD/OMwxpiXVIK7NCuB mmLtBt/VNOOyCwXtK1NKR//sgH+erWphL0Fqg1smBISfkQj5/f2fY8cT+2FJ9MSkWdMC R2kvOMNMJZyfpZR7ztsQcqnPns7Q7Lbtm7wgnPQJVhCsEh3IUorvoTWQuzxMP57sd5aV mEbdyi2B6Wa7VDmJunA2JnCyZVljMe3USNJ3iOH+zV53iKeUMnMDTnnYOsver9N1OCep dF0g== X-Gm-Message-State: AOAM532prVNH7U1tygYPM7A9lATSFjISn94FeH+LJKlocyoNQJyNM1KA APMmv88pv5UmUqojJY0PHzKdBA== X-Received: by 2002:a05:6808:2382:: with SMTP id bp2mr727360oib.171.1643338496038; Thu, 27 Jan 2022 18:54:56 -0800 (PST) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id k6sm5677352oop.28.2022.01.27.18.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 18:54:55 -0800 (PST) From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier Cc: Rob Herring , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/13] remoteproc: qcom: pas: Carry PAS metadata context Date: Thu, 27 Jan 2022 18:55:09 -0800 Message-Id: <20220128025513.97188-10-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128025513.97188-1-bjorn.andersson@linaro.org> References: <20220128025513.97188-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Starting with Qualcomm SM8450 the metadata object shared with the secure world during authentication and booting of a remoteproc needs to be alive from init_image() until auth_and_reset(). Use the newly introduced "PAS metadata context" object to track this context from load until the firmware has been booted. In the even that load is performed but the process for some reason doesn't reach auth_and_reset the unprepare callback is used to clean up the allocated memory. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_q6v5_pas.c | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index 184bb7cdf95a..5e806f657fec 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -79,6 +79,8 @@ struct qcom_adsp { struct qcom_rproc_subdev smd_subdev; struct qcom_rproc_ssr ssr_subdev; struct qcom_sysmon *sysmon; + + struct qcom_scm_pas_metadata pas_metadata; }; static void adsp_minidump(struct rproc *rproc) @@ -126,14 +128,34 @@ static void adsp_pds_disable(struct qcom_adsp *adsp, struct device **pds, } } +static int adsp_unprepare(struct rproc *rproc) +{ + struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; + + /* + * adsp_load() did pass pas_metadata to the SCM driver for storing + * metadata context. It might have been released already if + * auth_and_reset() was successful, but in other cases clean it up + * here. + */ + qcom_scm_pas_metadata_release(&adsp->pas_metadata); + + return 0; +} + static int adsp_load(struct rproc *rproc, const struct firmware *fw) { struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; int ret; - ret = qcom_mdt_load(adsp->dev, fw, rproc->firmware, adsp->pas_id, - adsp->mem_region, adsp->mem_phys, adsp->mem_size, - &adsp->mem_reloc); + ret = qcom_mdt_pas_init(adsp->dev, fw, rproc->firmware, adsp->pas_id, + adsp->mem_phys, &adsp->pas_metadata); + if (ret) + return ret; + + ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, adsp->pas_id, + adsp->mem_region, adsp->mem_phys, adsp->mem_size, + &adsp->mem_reloc); if (ret) return ret; @@ -185,6 +207,8 @@ static int adsp_start(struct rproc *rproc) goto disable_px_supply; } + qcom_scm_pas_metadata_release(&adsp->pas_metadata); + return 0; disable_px_supply: @@ -255,6 +279,7 @@ static unsigned long adsp_panic(struct rproc *rproc) } static const struct rproc_ops adsp_ops = { + .unprepare = adsp_unprepare, .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, @@ -264,6 +289,7 @@ static const struct rproc_ops adsp_ops = { }; static const struct rproc_ops adsp_minidump_ops = { + .unprepare = adsp_unprepare, .start = adsp_start, .stop = adsp_stop, .da_to_va = adsp_da_to_va, -- 2.33.1