From mboxrd@z Thu Jan 1 00:00:00 1970 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 3EDB1CCD187 for ; Wed, 8 Oct 2025 19:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hf+YYeTQWrcuuCIS+3A7q4yxtZaY1yZKvZdXSJmVK88=; b=twPQ0tdXw3Gaesaw6LMoGe1ljS bUaw7Rx3rd/BeKsTmI+It0o9PjOQxlokmp0kkjrjyA1TC6DaK0gOWnVEafPPzMKiEIvFhu7sorOUz 6rw6HVNpL9Vbq5qiVMKZwvAwSLjMj7AVM9zhl1d04KrSY/+Wz+q81+b1ud3FEsndkXvHAbW878Fc0 84Esl/KItBRtcuFgxr+dv2xcpotO/RzEVJBtveXxTosw6q21Elet25Tq4c+RM5n3IaLn5ZuFrinL2 bX7pdgPlxvJ4PnRuZXYqGze7rBse9RBCp+GieENinFKdRttG97+MTQwVodzl43rikc45CF6k0VlW6 O2nfcusA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v6ZYG-00000004XNm-1uU0; Wed, 08 Oct 2025 19:10:16 +0000 Received: from mail-southcentralusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c10d::3] helo=SN4PR0501CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1v6ZYE-00000004XMO-3CA0 for linux-arm-kernel@lists.infradead.org; Wed, 08 Oct 2025 19:10:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oAvMTj6ORZGkazNOgyTDK8IBgw9QSUupByvGAogESWzwdx2oCiOAjcP9kxqNlHXD4KX3ZIU/uOe7oxDNvuHp3gkBmzBFeGIsz9QZqDw1etFZhrWf64ahSugI01977P9/Gk1WlW/680TB1Emuz/0vT4b3jbSayZm8pB1pzaJ3JulzTYu+avhMY1il1qknEu1a1+fiZDPOiucTBM2Wt5Cya6fcq5xlBWibixka+cCX0JG6ovGbSO4vMSOynDMSrqLfBFHJpJIQSiEDH3vGJkMxwNoN4ZuPW1tIPKPKTAmqg5b+YDQP5Qjgazjv2URr7zIcan0vSzK+CD7r2OHrawx0UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hf+YYeTQWrcuuCIS+3A7q4yxtZaY1yZKvZdXSJmVK88=; b=ZtjKz/rEz/JYURnAG4kyf1mYpCe+0i03a0m6ZhNpz9ucGkpDyabHKfynNSeAUT7dRLg6mryy8TFcJ3f1+pZROKam38oLs3yyW9K0KZIWXx1cXUJTWGbzxV9vH6x7lFgVdiAQZggZ0Vuo8ARiSMIJCjILqysKIHQL0Set7AerNRF4yE9YP4u5FjjpPRFVxaSkXyNWadfGspH9816H4vvsG/XZJZa3qlBA9puq9AazeeJ3feJIiGqlCJJVNdh9HydJVnEGUHz9Q3bPmOcl5QAvpiffqNl/kwOU3tNXlG3rhFz3bB2DrK407gpjSgL0n8gP9n2Vszo3ZsyVj9rAq/xDHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=arm.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hf+YYeTQWrcuuCIS+3A7q4yxtZaY1yZKvZdXSJmVK88=; b=Xy84jaOzHWjVg3MNKgCFE8GwR9/oLyrUepUc1o7oyj4pK2ed2UGztoBhyL5VAYoa8sOUqdHoILZSwCSYxRvfyWzcnUbdlxxdzJM5NDg1UaJ4RppIBzX2Qxj5G8/E5hG5eLbkTEkbNxRlZSIbkwXEHFbpEfzQdSt0I9/HTFlhbBu08YUsSZ/tWD20X7a/02EHy1N4Rz2Wvm3L1XdCnWfFi8DTc9kMsscQqV9r/FOjSOv7FR9lAvcR8S8HjR9WW4VDGTg33c2Cak0FbrLx13m7dMiBvxorCp7gAUp49s8b2geoRC8RWM2Ljbmx9udZAI2qiiUfoD984wksUylOa4LcJA== Received: from BN1PR14CA0013.namprd14.prod.outlook.com (2603:10b6:408:e3::18) by SA1PR12MB5640.namprd12.prod.outlook.com (2603:10b6:806:23e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 19:09:58 +0000 Received: from BL02EPF0001A0FE.namprd03.prod.outlook.com (2603:10b6:408:e3:cafe::8c) by BN1PR14CA0013.outlook.office365.com (2603:10b6:408:e3::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9182.20 via Frontend Transport; Wed, 8 Oct 2025 19:09:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BL02EPF0001A0FE.mail.protection.outlook.com (10.167.242.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9 via Frontend Transport; Wed, 8 Oct 2025 19:09:58 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Wed, 8 Oct 2025 12:09:42 -0700 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 8 Oct 2025 12:09:42 -0700 Received: from build-vvidwans-focal-20250627.internal (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Wed, 8 Oct 2025 12:09:42 -0700 From: Vedashree Vidwans To: , , , , Subject: [RFC PATCH 3/3] firmware: smccc: LFA: modify activation approach Date: Wed, 8 Oct 2025 19:09:07 +0000 Message-ID: <20251008190907.181412-4-vvidwans@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251008190907.181412-1-vvidwans@nvidia.com> References: <20251008190907.181412-1-vvidwans@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FE:EE_|SA1PR12MB5640:EE_ X-MS-Office365-Filtering-Correlation-Id: ae2d9bda-9bf8-40bd-b97e-08de069e4603 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?feks78hQxOLJFxzPx07hjww9a6xWEEIRC9UzdmwRujUJ9+088E1m4CMkocwN?= =?us-ascii?Q?r+Nd+XUoI7hR+d45FNryut0VXaJPRs/vJGlzqpSbrE80kx/TL3sQ3Irj1ixf?= =?us-ascii?Q?i8VJA7ctrqAhqxVEMfqgXVsLwc2EtUG1uFUXCzW9Sk9d5PdSoO9TbwcESMO4?= =?us-ascii?Q?/bY2QihVIkflxuriuFqNzAYOknFqOtG5VylttqVkGkMSC4S0O+Tyvc+l+Wad?= =?us-ascii?Q?Qw4RiqI9AA0WfZfa/2TZ5TkzSnY+6QNq/h3ZSIbJ92rXw1FLaBYxhXmk2tp4?= =?us-ascii?Q?n8oqtlh+9wsC70xFHD01cWzryp6c1KP4kg6Pufimb14QjVeMsKSh7MoU5j/g?= =?us-ascii?Q?cvnqMJsFlANns6VYTkEzaeCOQPeusDTmegZeXmvRH6/4gbQCYuEr+rZquwMC?= =?us-ascii?Q?rpjSpBjvDcxjp369acby+ThqM3Zk+PosUy0kK0++cwzV66eJYTQAzaJC1yQb?= =?us-ascii?Q?Ul59c8ZC2Nmyx/MTCft1rC6tkL/QcVjRtqiA2A30lWpClg1UHMuTb3DSQ852?= =?us-ascii?Q?Sxf0DYpqn0Ok5WyYy7DHWpcZGuHfNyiN0iTARo8TmHq6OL3shxW9kxsGkhh3?= =?us-ascii?Q?J7UcVRX4sfl/q5LI0oaFnyCkk7tJPH9lxZuTO6xHnVCdu17bJmlhiYTw+Fg6?= =?us-ascii?Q?3itf0Mj/LbFTpQF/4L9dfhqZzdomRpMMsmOL1fwOkTfpEh90Pv1JyH6pz0oO?= =?us-ascii?Q?fNEVQnJOoF+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232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 19:09:58.0700 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae2d9bda-9bf8-40bd-b97e-08de069e4603 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5640 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251008_121014_806261_FA8CFDFD X-CRM114-Status: GOOD ( 19.17 ) 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: , Cc: linux-kernel@vger.kernel.org, vwadekar@nvidia.com, sdonthineni@nvidia.com, vsethi@nvidia.com, linux-coco@lists.linux.dev, ardb@kernel.org, linux-arm-kernel@lists.infradead.org, chao.gao@intel.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, on a LFA IRQ, all activable firmware components are primed activated sequentially. Modify the approach to prime all firmware components followed by activation of all components sequentially. This approach will minimize the time where old and new firmware component images co-exist. Signed-off-by: Vedashree Vidwans --- drivers/firmware/smccc/lfa_fw.c | 74 +++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c index b36b8d7457c30..dead2282cd04b 100644 --- a/drivers/firmware/smccc/lfa_fw.c +++ b/drivers/firmware/smccc/lfa_fw.c @@ -46,6 +46,10 @@ #define LFA_PRIME_CALL_AGAIN BIT(0) #define LFA_ACTIVATE_CALL_AGAIN BIT(0) +/* PRIME COMPLETE status */ +#define LFA_PRIME_COMPLETE_FALSE false +#define LFA_PRIME_COMPLETE_TRUE true + /* Prime loop limits, TODO: tune after testing */ #define LFA_PRIME_BUDGET_US 30000000 /* 30s cap */ #define LFA_PRIME_POLL_DELAY_US 10 /* 10us between polls */ @@ -104,6 +108,7 @@ struct image_props { bool may_reset_cpu; bool cpu_rendezvous; bool cpu_rendezvous_forced; + bool prime_complete; struct kobject *image_dir; struct kobj_attribute image_attrs[LFA_ATTR_NR_IMAGES]; }; @@ -229,6 +234,27 @@ static int call_lfa_activate(void *data) } static int activate_fw_image(struct image_props *attrs) +{ + int ret; + + /* + * We want to force CPU rendezvous if either cpu_rendezvous or + * cpu_rendezvous_forced is set. The flag value is flipped as + * it is called skip_cpu_rendezvous in the spec. + */ + if (!(attrs->cpu_rendezvous_forced || attrs->cpu_rendezvous)) { + pr_warn("CPU rendezvous is expected to be selected."); + return -EAGAIN; + } + + ret = stop_machine(call_lfa_activate, attrs, cpu_online_mask); + if (ret != 0) + return lfa_cancel(attrs); + + return ret; +} + +static int prime_fw_image(struct image_props *attrs) { struct arm_smccc_1_2_regs args = { 0 }; struct arm_smccc_1_2_regs res = { 0 }; @@ -285,10 +311,6 @@ static int activate_fw_image(struct image_props *attrs) return ret; } - ret = stop_machine(call_lfa_activate, attrs, cpu_online_mask); - if (ret != 0) - return lfa_cancel(attrs); - return ret; } @@ -396,6 +418,17 @@ static ssize_t activate_store(struct kobject *kobj, struct kobj_attribute *attr, return -EAGAIN; } + ret = prime_fw_image(attrs); + if (ret) { + pr_err("Firmware prime failed: %s\n", + lfa_error_strings[-ret]); + mutex_unlock(&lfa_lock); + return -ECANCELED; + } + + /* Update prime complete status */ + attrs->prime_complete = LFA_PRIME_COMPLETE_TRUE; + ret = activate_fw_image(attrs); if (ret) { pr_err("Firmware activation failed: %s\n", @@ -469,6 +502,8 @@ static int create_fw_inventory(char *fw_uuid, int seq_id, u32 image_flags) INIT_LIST_HEAD(&attrs->image_node); attrs->image_name = image_name; attrs->cpu_rendezvous_forced = 1; + /* Reset prime complete status */ + attrs->prime_complete = LFA_PRIME_COMPLETE_FALSE; set_image_flags(attrs, seq_id, image_flags); /* @@ -573,16 +608,39 @@ static irqreturn_t lfa_irq_thread(int irq, void *data) if (ret != 0) goto exit_unlock; - /* - * Execute PRIME and ACTIVATE for each FW component - * Start from first FW component - */ + /* Execute PRIME for all FW components */ list_for_each_entry(attrs, &lfa_fw_images, image_node) { if ((!attrs->activation_capable) || (!attrs->activation_pending)) { /* LFA not applicable for this FW component, continue to next component */ continue; } + ret = prime_fw_image(attrs); + if (ret) { + pr_err("Firmware %s prime failed: %s\n", + attrs->image_name, lfa_error_strings[-ret]); + goto exit_unlock; + } + + /* Update prime complete status */ + attrs->prime_complete = LFA_PRIME_COMPLETE_TRUE; + } + + /* Execute ACTIVATE for all FW components */ + list_for_each_entry(attrs, &lfa_fw_images, image_node) { + if ((!attrs->activation_capable) || (!attrs->activation_pending)) { + /* LFA not applicable for this FW component, continue to next component */ + continue; + } + + if (!attrs->prime_complete) { + /* + * ACTIVATE not applicable for this FW component, + * continue to next component + */ + continue; + } + ret = activate_fw_image(attrs); if (ret) { pr_err("Firmware %s activation failed: %s\n", -- 2.25.1