From nobody Tue Feb 10 10:20:34 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A052922D7A5 for ; Sun, 28 Dec 2025 17:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766942483; cv=none; b=e4ZW/pNUstih3d1XlUYgabdIeE/4VNJHS1jAL2env0D7EmyHSsCkkurr95CN4ny0/iP9QzItlCwDpo7m5PzR8GFpi/hyUGyM4EapvaeGL8lU0dMzU6+XRTHyGGzQ3uk0EQOhnsyUe6W8Jikv7cs/RSjXL85z6dGRrGLFBZ4qaOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766942483; c=relaxed/simple; bh=r+dClbF+NRAB6/JduYUiH5LaoOpV4jm0Feyp3PXQ6Ss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WYjta5wqMOkyfL77OQu/Bm7DRhs+0fuNf1/OXRL7l/q3Th25EqEAOxmQtL3vxshAcRaAKtYqKqeK9z3UwgGmWCEPRTtfQ3YnvZ86Tk5fiA8Unu2zBcoe2ZHZAvPBfbOsTMcmruW0OD7L0LjbL2O/jjJrY13T/Ngo6l40ozu/UQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=L96jH8/S; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eV5B+Wc0; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="L96jH8/S"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eV5B+Wc0" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BSFiH843066586 for ; Sun, 28 Dec 2025 17:21:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= r831Wd4WfqmDnI6RCOW6V71GyT3JAOrlUY36xWWaPTo=; b=L96jH8/Sle24++tD fyembebuOrw6A4GhBp6YSQIuHXcRkDGbSf49XttFBM+noF1CJYkwHCc908lsdBHS GIsZ54T/SPOlOwe8kSG5i5zMOouO5lFkaCbDAGCdjcVcDXD19xts7yYZy++c6stb 6Mnq58t1JhDxA/LNEd9OSqiGILMG+Gu+F0SORnmNo+FSYHBBZz9yoD43m7CReUfK XYWwYLmdpAJ7KndowWlMmYV9FbaEq3v6g470QPdVpytHbcBAcTc+zbsoUE8/+98H xSSAq1SKWjec++v7LwDBxgsXCIsg7fdR5FHKpc6abMem1nj+zIyKrj6AWlNMS9JH Oj0Pyw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ba6dr2m6n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 28 Dec 2025 17:21:20 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2a0bb1192cbso174295535ad.1 for ; Sun, 28 Dec 2025 09:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1766942480; x=1767547280; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=r831Wd4WfqmDnI6RCOW6V71GyT3JAOrlUY36xWWaPTo=; b=eV5B+Wc0YzNb6ZSorySH5hLY9QEqRHXt8aUr1q0BrP7RxThF0LMfbLO/+kuJVfegT5 B4txUDnCWWyIlb64bkDUWHpX6zxgyHe3J8iFVNccg+NdtgHuKz4cuAVInqmzrLym3tjG hDYczNDMzAX7khrfPlwWwwmdTC130SaHsnmfKodH8Dm9SMp1GaGylG/N5mIdrqNprlaI JhkbQpee9AqTOaXwv4vsPI9kqZ7QYQGpmaVvA4mXfvTsOJ44gy6LI4hpVbU2Bq0d9stX osAsmg4CUF2nhsb9RhQwSS4fVtsNvupmrrddjSRkG5vCIxQkuYSRxKyEz2eWietd+FLt lgKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766942480; x=1767547280; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=r831Wd4WfqmDnI6RCOW6V71GyT3JAOrlUY36xWWaPTo=; b=v4mPVvXUsBcqChKK9Pz22fYchE1x2UAvlTk2YXaHXRZX8v0IOI7KccCcCyOtWjWZv2 TAeymut5qwzJYMDW+PWV4kUvafPXAMa1Otw/vo5tvIbHynQzCjyhoZI4fRrPbbnlrbf0 hK0Z+frMBbxBrMq8zPNBKGkAQiaoYTknCQ1bscN4Tzxjo1CcQ2zLrY/RhKhYDjnNmAfI CO4ghO9EMpLSoC1iIRWG9tUZZ8eVvnGvWIUnq13HN3zY3+zm9qfguffgnh8LyD5WfoW5 gn1DmtU3SJ0SwSNAO5R4EuECfjaQgvTV2jCZ8cF9Ro9g+c70GplkTGytyE48xRyWsC7q aHZQ== X-Forwarded-Encrypted: i=1; AJvYcCVfcOyOTOMz8j5C19JnvMt+Mo2A45+5OnPjjCgY/YElTmYHE5vQMzh3+Am7nqi6Mzs/G4vH12OMuSyA6Xo=@vger.kernel.org X-Gm-Message-State: AOJu0YxgFZfAwMIpzZ7wlRt2ToETHCr1tVD7ApiKeeiX8UXZep1ohVfh Mms+9UNQwg8HGslRPb1dNKIvwsE60OFvuCFg91G3Z0sdGCqS3n7eslgCxdUPH4GRsh5PldiJwRz d84lCdomkk90lHSobz2i7bFSDDneKxswDuEpanMwDuv7BqrAVg1wgXWAhlJLjELv5vLPClVj0uR s= X-Gm-Gg: AY/fxX5bPqRvWLsRfiqJGLpcUEhFqxAlwXNnCYHq/90nuAyn0CWh6lu7V5NyJZYF3Uc KOuK7SYwg9MFbhcxBuXWoHYtREg75tDuepUGGEgVv9aNSWLu8iDR0oCG1GSZz6pfvibbJ4EMI+5 BIYUrLj3oPECkb2As2Njqhe2cALnPNR6zvkUJIAiLI9Z5l6OXJ1Q5RcMdDqax9esWHCNVN5zZtO NlAzqmh9SXG0hDwGjHZT+knrMRUvcPr/9BXQOFuv267PUPs6fV3wN9XYylg3FCEYM/3iBt5M5is zyARh02e+T392Rw1IBMIbsQk+2GI43PQLOE0sBZKhb1iMvs39BckvVSr8TyTv3813qRWc+Qj98f Lvs/uuRmEF0CbER0tfq+vD1cLikxGVfKbLSx0Am5e7uKQ2A== X-Received: by 2002:a17:903:40cb:b0:29d:6b8e:d565 with SMTP id d9443c01a7336-2a2f283116emr270372955ad.38.1766942479715; Sun, 28 Dec 2025 09:21:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNm8WGC06B1FKTNVYdyJiBEjBvRjJVuKyQlWvsvW6gJg2hb0zwXirKd2N8S1aHugfgFW/jkg== X-Received: by 2002:a17:903:40cb:b0:29d:6b8e:d565 with SMTP id d9443c01a7336-2a2f283116emr270372515ad.38.1766942479191; Sun, 28 Dec 2025 09:21:19 -0800 (PST) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d776ebsm255743965ad.99.2025.12.28.09.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Dec 2025 09:21:18 -0800 (PST) From: Shivendra Pratap Date: Sun, 28 Dec 2025 22:50:24 +0530 Subject: [PATCH v19 06/10] power: reset: Add psci-reboot-mode driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251228-arm-psci-system_reset2-vendor-reboots-v19-6-ebb956053098@oss.qualcomm.com> References: <20251228-arm-psci-system_reset2-vendor-reboots-v19-0-ebb956053098@oss.qualcomm.com> In-Reply-To: <20251228-arm-psci-system_reset2-vendor-reboots-v19-0-ebb956053098@oss.qualcomm.com> To: Lorenzo Pieralisi , Arnd Bergmann , Bjorn Andersson , Sebastian Reichel , Rob Herring , Sudeep Holla , Souvik Chakravarty , Krzysztof Kozlowski , Andy Yan , John Stultz , Matthias Brugger , Moritz Fischer , Mark Rutland , Conor Dooley , Konrad Dybcio , Bartosz Golaszewski Cc: Florian Fainelli , Krzysztof Kozlowski , Dmitry Baryshkov , Mukesh Ojha , Andre Draszik , Kathiravan Thirumoorthy , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Shivendra Pratap , Srinivas Kandagatla X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766942426; l=6151; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=r+dClbF+NRAB6/JduYUiH5LaoOpV4jm0Feyp3PXQ6Ss=; b=SAQAVmKond6JYVMJWPVVSbiXzghlRYtVI0aO9I3/UVBMMxZKlh9A9EHYM/50aWS7uYcgPtCYO FndiecgWngfADMhwW5sLopxoK4h6PDsfALXlCK56xyN1P1vxebbnwI8 X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjI4MDE1OSBTYWx0ZWRfX6KF4PNIH7/qB R4nTKPsCHuDz2T5G/NsZTb/9XSD4ulYdIn9i8tlVi7rfUo32MnXYIpQOUJoXnGHPc6LPO8KKymP j3TOwV8rMBVwhlBcyxoJbAvXwjQSDzQNltqQ9FORKXV+ICOIwc7cfADpvWAWtSY/GukN7T3JEsn HahvmFq7Dy01g/2LlruF+8y2k7nphdR8bvOEY+G97MWXFEj9+dnD9bEl1pvr3HclVdAVoVpD92m 0WQV0xkcqdPy5hUyynTZ8Y9dY2QIvUQLZ6jAAZFtbym17JhnqJOqyIa2xYRanrQ73XLbMx9BWGK ba6Hx2VbkS5JbswtCzxZAUdDExan/noErTpiA92jYu8NOG1/pvT+QJXUyxnysuK3ccYs5Ds3c8p g05B+MbqTkXoCN/md0eOHDo9pfiEp4OMOYIK87zQraydRkjC+6g+VvMwxJYQuu+tKJtyEK0hwxO NRT5GXivgDMGvqdyY+Q== X-Authority-Analysis: v=2.4 cv=VdP6/Vp9 c=1 sm=1 tr=0 ts=69516710 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=y0Vp-ry0QnGiofiFOe0A:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-GUID: _cJ9F0M_VDJKsHNs3w_pXfj0Ehnx-vLl X-Proofpoint-ORIG-GUID: _cJ9F0M_VDJKsHNs3w_pXfj0Ehnx-vLl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-28_06,2025-12-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 malwarescore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512280159 PSCI supports different types of resets like COLD reset, ARCH WARM reset, vendor-specific resets. Currently there is no common driver that handles all supported psci resets at one place. Additionally, there is no common mechanism to issue the supported psci resets from userspace. Add a PSCI reboot mode driver and define two types of PSCI resets in the driver as reboot-modes: predefined resets controlled by Linux reboot_mode and customizable resets defined by SoC vendors in their device tree under the psci:reboot-mode node. Register the driver with the reboot-mode framework to interface these resets to userspace. When userspace initiates a supported command, pass the reset arguments to the PSCI driver to enable command-based reset. This change allows userspace to issue supported PSCI reset commands using the standard reboot system calls while enabling SoC vendors to define their specific resets for PSCI. Signed-off-by: Shivendra Pratap --- drivers/power/reset/Kconfig | 10 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/psci-reboot-mode.c | 111 +++++++++++++++++++++++++++++= ++++ 3 files changed, 122 insertions(+) diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index f6c1bcbb57deff3568d6b1b326454add3b3bbf06..529d6c7d3555601f7b7e6199acd= 29838030fcef2 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -348,6 +348,16 @@ config NVMEM_REBOOT_MODE then the bootloader can read it and take different action according to the mode. =20 +config PSCI_REBOOT_MODE + bool "PSCI reboot mode driver" + depends on OF && ARM_PSCI_FW + select REBOOT_MODE + help + Say y here will enable PSCI reboot mode driver. This gets + the PSCI reboot mode arguments and passes them to psci + driver. psci driver uses these arguments for issuing + device reset into different boot states. + config POWER_MLXBF tristate "Mellanox BlueField power handling driver" depends on (GPIO_MLXBF2 || GPIO_MLXBF3) && ACPI diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 0e4ae6f6b5c55729cf60846d47e6fe0fec24f3cc..49774b42cdf61fd57a5b70f286c= 65c9d66bbc0cb 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -40,4 +40,5 @@ obj-$(CONFIG_REBOOT_MODE) +=3D reboot-mode.o obj-$(CONFIG_SYSCON_REBOOT_MODE) +=3D syscon-reboot-mode.o obj-$(CONFIG_POWER_RESET_SC27XX) +=3D sc27xx-poweroff.o obj-$(CONFIG_NVMEM_REBOOT_MODE) +=3D nvmem-reboot-mode.o +obj-$(CONFIG_PSCI_REBOOT_MODE) +=3D psci-reboot-mode.o obj-$(CONFIG_POWER_MLXBF) +=3D pwr-mlxbf.o diff --git a/drivers/power/reset/psci-reboot-mode.c b/drivers/power/reset/p= sci-reboot-mode.c new file mode 100644 index 0000000000000000000000000000000000000000..499cf504071e88022fa5b5b32e2= 6b7a674da8691 --- /dev/null +++ b/drivers/power/reset/psci-reboot-mode.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Predefined reboot-modes: + * reset_type(arg1) is zero; cookie(arg2) is stored in magic. + * psci_reboot_mode_set_predefined_modes to move values to higher 32 bit o= f magic. + */ +static struct mode_info psci_resets[] =3D { + { .mode =3D "warm", .magic =3D REBOOT_WARM}, + { .mode =3D "soft", .magic =3D REBOOT_SOFT}, + { .mode =3D "cold", .magic =3D REBOOT_COLD}, +}; + +static void psci_reboot_mode_set_predefined_modes(struct reboot_mode_drive= r *reboot) +{ + INIT_LIST_HEAD(&reboot->predefined_modes); + for (u32 i =3D 0; i < ARRAY_SIZE(psci_resets); i++) { + /* Move values to higher 32 bit of magic */ + psci_resets[i].magic =3D FIELD_PREP(GENMASK_ULL(63, 32), psci_resets[i].= magic); + INIT_LIST_HEAD(&psci_resets[i].list); + list_add_tail(&psci_resets[i].list, &reboot->predefined_modes); + } +} + +/* + * magic is 64 bit. + * arg1 - reset_type(Low 32 bit of magic). + * arg2 - cookie(High 32 bit of magic). + * arg2(cookie) decides the mode, If arg1(reset_type) is 0; + */ +static int psci_reboot_mode_write(struct reboot_mode_driver *reboot, u64 m= agic) +{ + u32 reset_type =3D FIELD_GET(GENMASK_ULL(31, 0), magic); + u32 cookie =3D FIELD_GET(GENMASK_ULL(63, 32), magic); + + if (reset_type =3D=3D 0) { + if (cookie =3D=3D REBOOT_WARM || cookie =3D=3D REBOOT_SOFT) + psci_set_reset_cmd(true, 0, 0); + else + psci_set_reset_cmd(false, 0, 0); + } else { + psci_set_reset_cmd(true, reset_type, cookie); + } + + return NOTIFY_DONE; +} + +static int psci_reboot_mode_probe(struct faux_device *fdev) +{ + struct reboot_mode_driver *reboot; + struct device_node *psci_np; + struct device_node *np; + int ret; + + psci_np =3D of_find_compatible_node(NULL, NULL, "arm,psci-1.0"); + if (!psci_np) + return -ENODEV; + + /* + * Find the psci:reboot-mode node. + * If NULL, continue to register predefined modes. + * np refcount to be handled by dev; + * psci_np refcount is decremented by of_find_node_by_name; + */ + np =3D of_find_node_by_name(psci_np, "reboot-mode"); + fdev->dev.of_node =3D np; + + reboot =3D devm_kzalloc(&fdev->dev, sizeof(*reboot), GFP_KERNEL); + if (!reboot) + return -ENOMEM; + + psci_reboot_mode_set_predefined_modes(reboot); + reboot->write =3D psci_reboot_mode_write; + reboot->dev =3D &fdev->dev; + + ret =3D devm_reboot_mode_register(&fdev->dev, reboot); + if (ret) { + dev_err(&fdev->dev, "devm_reboot_mode_register failed %d\n", ret); + return ret; + } + + return 0; +} + +static struct faux_device_ops psci_reboot_mode_ops =3D { + .probe =3D psci_reboot_mode_probe, +}; + +static int __init psci_reboot_mode_init(void) +{ + struct faux_device *fdev; + + fdev =3D faux_device_create("psci-reboot-mode", NULL, &psci_reboot_mode_o= ps); + if (!fdev) + return -ENODEV; + + return 0; +} +device_initcall(psci_reboot_mode_init); --=20 2.34.1