From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7E521624D5 for ; Fri, 24 Jul 2026 06:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784873861; cv=none; b=tdEzwhl3OBBZ4BIRRv/WpcdRvAIRi//KzruiXuHBt3qTig9Sits4kMCrgXIqtrG5jp4o5JZUFAGiighZ2rvzG6WgYDGUs6a4raz2C4mPPMa61eeezlXtmNWfKdPrys2powRz+0itC74dQ3/N9Qmj8MPWJhQmUDuWanqjhb6LbgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784873861; c=relaxed/simple; bh=rA7aSnLXHqPcp2csIE5lbdG5fKGHStAkvVq9b1W5uQc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MQy48JfHNf3dPlfl7UN1kWmpm/b/y98DM+97a6cM9CUq9Rspuk4lLsIIqPAlMyn9QJTm7+ohlwgPlA0mLqkY7it4yCGOprG3bPQ/nZ9IpiQDGXo7uIsG338Zob41+yIuzS8fX9CCwdAwwHlybAsPzr847YZru7YdNoJSDFKUtTY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=siWZQREj; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="siWZQREj" Received: from [10.94.177.11] (unknown [4.194.122.136]) by linux.microsoft.com (Postfix) with ESMTPSA id DA71220B7167; Thu, 23 Jul 2026 23:17:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DA71220B7167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1784873845; bh=+zdQgbqXxACDmr32xzFUqYuLmlqfobQFQNJHT7eLaFY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=siWZQREj97i+UVAMpjAIF1VgYLT4amSn7g7a7hOjo6IkdTHtPTPS6xuV+842TO+VI p6llVgZErniddfrE5jt+OCjoGG4tW/RCF3DQ669F26GKFaGHRJPMg2+lfd/ViH1XIn RxhSfuJB1MSST6jfkFElVQmPuHJnPrxNoM2wlTJo= Message-ID: <63f3e979-80c4-44c1-b17b-7f5f12882425@linux.microsoft.com> Date: Fri, 24 Jul 2026 11:47:36 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] firmware: xilinx: Add support to clear TF-A PM state To: Jay Buddhabhatti , michal.simek@amd.com, git@amd.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260723124841.2567827-1-jay.buddhabhatti@amd.com> <20260723124841.2567827-2-jay.buddhabhatti@amd.com> Content-Language: en-US From: Prasanna Kumar T S M In-Reply-To: <20260723124841.2567827-2-jay.buddhabhatti@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 23-07-2026 18:18, Jay Buddhabhatti wrote: > Currently, during a kexec restart, only the kernel is reloaded, while the > TF-A specific data remain unchanged. This leads to a mismatch between the > kernel state and the TF-A firmware state like SGI number and shutdown > scope variable. > > For example, the kernel registers an SGI number with TF-A so that TF-A can > notify the kernel of events via that SGI. TF-A stores this SGI number in > its internal state. After a kexec, the newly loaded kernel re-registers > and may request a different SGI number, but the stale value programmed in > TF-A remains, so event notifications are delivered on the old SGI and are > missed by the new kernel. The shutdown scope variable has a similar stale > state problem. > > To resolve this, the TF_A_CLEAR_PM_STATE PM API is introduced to clear > TF-A-specific state during kexec. On a graceful reboot, this API is > triggered by zynqmp_firmware_shutdown(), while in a crash kernel scenario, > it is invoked by zynqmp_firmware_probe() in the reloaded kernel. > > Signed-off-by: Jay Buddhabhatti > --- > drivers/firmware/xilinx/zynqmp.c | 48 +++++++++++++++++++++++++++- > include/linux/firmware/xlnx-zynqmp.h | 3 +- > 2 files changed, 49 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c > index af838b2dc327..95ffd8f33ce9 100644 > --- a/drivers/firmware/xilinx/zynqmp.c > +++ b/drivers/firmware/xilinx/zynqmp.c > @@ -3,7 +3,7 @@ > * Xilinx Zynq MPSoC Firmware layer > * > * Copyright (C) 2014-2022 Xilinx, Inc. > - * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc. > + * Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc. > * > * Michal Simek > * Davorin Mista > @@ -13,6 +13,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -2065,6 +2066,42 @@ static struct attribute *zynqmp_firmware_attrs[] = { > > ATTRIBUTE_GROUPS(zynqmp_firmware); > > +/** > + * zynqmp_clear_pm_state() - Clear subsystem state > + * @dev: Device pointer used for logging > + * > + * Clears PM specific data in TF-A. > + * > + * Return: Returns status, either success or error > + */ > +static int zynqmp_clear_pm_state(struct device *dev) > +{ > + u32 pm_family_code; > + int ret; > + > + /* Get the Family code of platform */ > + ret = zynqmp_pm_get_family_info(&pm_family_code); > + if (ret < 0) > + return ret; > + > + if (pm_family_code != PM_ZYNQMP_FAMILY_CODE) { > + /* Check if the TF-A supports the TF_A_CLEAR_PM_STATE */ > + ret = do_feature_check_call(TF_A_CLEAR_PM_STATE); > + if (ret >= 0 && ((ret & FIRMWARE_VERSION_MASK) >= PM_API_VERSION_1)) { > + /* Clear PM specific data in TF-A */ > + ret = zynqmp_pm_invoke_fn(TF_A_CLEAR_PM_STATE, NULL, 0); > + if (ret) > + dev_err(dev, > + "Failed to clear TF-A specific subsystem state: %d\n", ret); > + } else { > + dev_warn(dev, "TF_A_CLEAR_PM_STATE is not supported in TF-A: %d\n", ret); > + ret = 0; > + } > + } > + > + return ret; > +} > + > static int zynqmp_firmware_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -2118,6 +2155,9 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) > if (ret < 0) > return ret; > > + if (is_kdump_kernel()) > + zynqmp_clear_pm_state(dev); > + > /* Check trustzone version number */ > ret = zynqmp_pm_get_trustzone_version(&pm_tz_version); > if (ret) > @@ -2151,6 +2191,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) > return of_platform_populate(dev->of_node, NULL, NULL, dev); > } > > +static void zynqmp_firmware_shutdown(struct platform_device *pdev) > +{ > + zynqmp_clear_pm_state(&pdev->dev); > +} > + > static void zynqmp_firmware_remove(struct platform_device *pdev) > { > struct pm_api_feature_data *feature_data; > @@ -2210,5 +2255,6 @@ static struct platform_driver zynqmp_firmware_driver = { > }, > .probe = zynqmp_firmware_probe, > .remove = zynqmp_firmware_remove, > + .shutdown = zynqmp_firmware_shutdown, > }; > module_platform_driver(zynqmp_firmware_driver); > diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h > index 7e27b0f7bf7e..baaa88b0b197 100644 > --- a/include/linux/firmware/xlnx-zynqmp.h > +++ b/include/linux/firmware/xlnx-zynqmp.h > @@ -3,7 +3,7 @@ > * Xilinx Zynq MPSoC Firmware layer > * > * Copyright (C) 2014-2021 Xilinx > - * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc. > + * Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc. > * > * Michal Simek > * Davorin Mista > @@ -66,6 +66,7 @@ > #define FIRMWARE_VERSION_MASK 0xFFFFU > > /* ATF only commands */ > +#define TF_A_CLEAR_PM_STATE 0xa05 > #define TF_A_PM_REGISTER_SGI 0xa04 > #define PM_GET_TRUSTZONE_VERSION 0xa03 > #define PM_SET_SUSPEND_MODE 0xa02 Looks good to me. Reviewed-by: Prasanna Kumar T S M