From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 C284944A724 for ; Tue, 31 Mar 2026 18:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774980031; cv=none; b=O61f+J5WyFtIfV3pGX8I1dMm5uqbXRlVcRp86/Hdk7cDhEK3XzmfGgwH6tSzRGAStjpFgWBEqft1rto50tohLiATwOqon9nGxlk93GycwecyO0DwxRpRRqQ45qgwsn0riFqhm9G758eeb28ivhkCza78a7dU9mJsD48VXNkM1NY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774980031; c=relaxed/simple; bh=qkF7LCy5dw2bwyara7za2iN2mL7PefiNtH+7ums/WFg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mj0VixSWNVHePVgOs68YfxbgEsbQzO24jP07Nwf2UjVxg/svJwkzHuyGEmw/0HFiuoI+G4tL+OJiOcx++7XDDmzCa59cgUW8VODlqauyQOmmkS4qMKr534LKo2UaBwXh21yWH7iwbFr70i4iOXIhGvq3mWLbIfRELNtucsdpY64= 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=mJGBOu7c; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZrbXZkJ9; arc=none smtp.client-ip=205.220.180.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="mJGBOu7c"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZrbXZkJ9" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62VGdQsG2724145 for ; Tue, 31 Mar 2026 18:00:27 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= TS3a+ptOlcMaz3jbXy49Anmk6ZAeQ1zF4OuWWpLrnuI=; b=mJGBOu7cmnVlWToe p26xjkmWqNlEUU2kL0ft4DSZNw7b9Aaj8gs5oNf8YbiYGW3yTT5x1UeRAjrFDMjb pnK0neiAJtrjjZAW7sEByzwzTFG7pdwiUWfLo/wRI+e8X1sYCWriQ9oc5kDIsUFp iT+1BumGzjRS4V/eUzFo8oRuBRFKtjfxDFsEwv+4HP/gNREeWEs1B0rYggtqWFwc esIy7WDvb8/IZV3fnslc2mbnRnOEE294HdCQdkUtBK2w9zYY8Vw3060w/yX8Oxes Dx9l83OddKeHGS2/8ndTiwzPp0ktwKp/1M082bqPAArGMEXHwT4IzB+yMWsQLJb6 x1Ba0w== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d84bfm0an-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 31 Mar 2026 18:00:26 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-82c9364612fso9854554b3a.2 for ; Tue, 31 Mar 2026 11:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774980026; x=1775584826; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TS3a+ptOlcMaz3jbXy49Anmk6ZAeQ1zF4OuWWpLrnuI=; b=ZrbXZkJ9sdx+VqXCH0SkZaOxqgVJ7zuAlGPpXYvg51mUqDI7UL6d04+cnH8sdjVTMe ij1jO8H2KDrWh0SxxXvoipEezTONg1LJRos7EhgE5G3UYnLxGxjzRVEzmRpbA7a5rgXO rk3b4LD6QcIqXKH6i/+rBN/WjI/4SMFP3MsjdSyL35vQXDJh2p7ZYbT7y4cCXobdZnaO cDnSFrjKQgNNLY51wKfrA2bz099YAvoiTc0ybbdy3z5a0OR6hBH1UbpNvv3qDoI+8qa8 16csO/nYhP6W6YwgUw6IkEf4829Nkjc58izvUAwvaPlmIJGLtBO+A/n3NK0yy2lEdG3u nbaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774980026; x=1775584826; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TS3a+ptOlcMaz3jbXy49Anmk6ZAeQ1zF4OuWWpLrnuI=; b=cz1u8jNeXwQ1i4vxIjTsInZXSRpC0aRInVnMDe53R+v9aU8Ur/k53KMdNMOuSDVuR3 2Iukq8rETX9MpTtwmZJ08/OOhxtbMa6t1SJFFiCuTaEEZVTkKcvyHVduBY+eZFtASjGk n4XzxZp3wQaPCBqvM8WUoItjbffFcKzeshWEdoe8MdJIrqQYpFLtRKhXC7DLHtm1PukW yuazpCDAGxwjb3nxEkVpRYDxPvRRddLB8uQXsH/PvTEjw0QDZMD+4RndB3S7VvElY4Nc PAAM8a+x3SWYW+nTSFsmbloDcDktYVZfwrXJX1xp8RBnLZaroxe4Bed8jZTus84C29VM HfsQ== X-Forwarded-Encrypted: i=1; AJvYcCXkXBpQlivsACTjppPNgH214f2dZ1tORuXiu/luClVZWq4PEQuQm+VIxTxXgrwzFJdedFAfobRrwI1S@vger.kernel.org X-Gm-Message-State: AOJu0Yx2iAzRtWLQAEfQhr9ebraema6bPaufSf2CSXG6YUQkz1AV+3zG kdmAN4+8sBWYriyyqD9/6hAwQH3UffIzrXKj7tkjVJiQ2ahVkQumb7p1splKqysnVvjqJJJY1BQ fvv+aHCsAqYdhXc+1Tb7q25HW+9ipJs8IyZVsOpMxdkgciLCAJSuiTQwBlPdRlR4n X-Gm-Gg: ATEYQzyJYichBCTmoORIW6j5Qseh9HGqiyEC2kVHbRl7Nv8Te5PrAfpvK70p0B796Lg 2/Q466Lhylb0xSwI6wdZPldk6d+16duiYwVxO3zdfr+XzaL4C+oYYpHj2WV3p/uTnrqeL8OTTrx 2+Nc7ItWR3Ro0my3oafwuMv9VNvZl54W2HBKeI6QlU8Yp0OztN82AWUfoTMSrxX/ILfC1BPLIUY vYpt6VcuRfGzHiiY8EIL6PCkc/b9X71OZ45XUR6C5oV/nNh2MirwMhZZz0MPAf+AozeqclygAf/ BSOCw5d83HYmFYBSJ+erIPbI8jzTFJ57CoKleJFljU17mzKrZ322F1yzJ+4TZgdNIHrTwFOBnhg u+1mUJ/IYVL+tUKpBM3RlWOc+LSx8Iqi7N5N9OwmHMzx7/jFoI8Qu1fs= X-Received: by 2002:a05:6a00:278a:b0:82a:6e7f:4c14 with SMTP id d2e1a72fcca58-82ce89b58c1mr495082b3a.27.1774980020651; Tue, 31 Mar 2026 11:00:20 -0700 (PDT) X-Received: by 2002:a05:6a00:278a:b0:82a:6e7f:4c14 with SMTP id d2e1a72fcca58-82ce89b58c1mr495025b3a.27.1774980019787; Tue, 31 Mar 2026 11:00:19 -0700 (PDT) Received: from [192.168.29.31] ([49.43.225.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82ca85fc72asm11012404b3a.48.2026.03.31.11.00.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2026 11:00:19 -0700 (PDT) Message-ID: <93a78bc2-4fd1-41bd-bf4a-b433b06fc218@oss.qualcomm.com> Date: Tue, 31 Mar 2026 23:30:09 +0530 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v20 06/10] power: reset: Add psci-reboot-mode driver To: Lorenzo Pieralisi Cc: Arnd Bergmann , Bjorn Andersson , Sebastian Reichel , Rob Herring , Souvik Chakravarty , Krzysztof Kozlowski , Andy Yan , Matthias Brugger , Mark Rutland , Conor Dooley , Konrad Dybcio , John Stultz , Moritz Fischer , Bartosz Golaszewski , Sudeep Holla , 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, Srinivas Kandagatla References: <20260304-arm-psci-system_reset2-vendor-reboots-v20-0-cf7d346b8372@oss.qualcomm.com> <20260304-arm-psci-system_reset2-vendor-reboots-v20-6-cf7d346b8372@oss.qualcomm.com> Content-Language: en-US From: Shivendra Pratap In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=INwPywvG c=1 sm=1 tr=0 ts=69cc0bba cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=mO+zk3XXGlxjkZV6yCQMJw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=xx8M9eIzLlJJCfGiN1QA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzMxMDE3MiBTYWx0ZWRfX4Xf1p0KmgqoK XjbBLDhz55GEfmDLY424FVOp80YvzdqzOIZTco/1MhaAy8XDdfJfQpKcP+IA3RvyET81bQyeswI hgDjcuh8poGgfWqXqi/L3u1+Dq1+dLfezkwOWTf3pGHz8eE8WvDjqzOGW4HsODDePbg1SWWPbQJ j7kkb/3m2XkAtqpXcSTwdqz2Of3gnZlkBlSvLykj8XGnz7eVy2LZ7ioQ6+axvEr8QUrFAptyfOK /I5g5jwwwWCtIEgNsn3Li8jrSwM7K8oTwH9XBNF7IHAfYdKGiBxVvQMIgXbkwiubOewhsnEdMqb P7ycBZbEu4Tp9o7fwNDhjgfEyFd+naYxkuhbW4X+mF4eXQnI5xsOOK3DHtGyeuxfO+B0x0eglKq QGzVxKlliHZVxL/Jia7SCrAH4J1aNnPjrAqxZ/Ih6ShCvySPsK7MHtfZb/tKGdXvWNEP4Lxqarw 1sXTXfz+842J4fvn6Og== X-Proofpoint-GUID: YQSrCnoKmcrf-OuB0yVyZTBk9h1oGfaY X-Proofpoint-ORIG-GUID: YQSrCnoKmcrf-OuB0yVyZTBk9h1oGfaY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-31_04,2026-03-31_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310172 On 27-03-2026 19:25, Lorenzo Pieralisi wrote: > On Wed, Mar 04, 2026 at 11:33:06PM +0530, Shivendra Pratap wrote: >> 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 | 119 +++++++++++++++++++++++++++++++++ >> 3 files changed, 130 insertions(+) >> >> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig >> index f6c1bcbb57deff3568d6b1b326454add3b3bbf06..529d6c7d3555601f7b7e6199acd29838030fcef2 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. >> >> +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..49774b42cdf61fd57a5b70f286c65c9d66bbc0cb 100644 >> --- a/drivers/power/reset/Makefile >> +++ b/drivers/power/reset/Makefile >> @@ -40,4 +40,5 @@ obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o >> obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o >> obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o >> obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o >> +obj-$(CONFIG_PSCI_REBOOT_MODE) += psci-reboot-mode.o >> obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o >> diff --git a/drivers/power/reset/psci-reboot-mode.c b/drivers/power/reset/psci-reboot-mode.c >> new file mode 100644 >> index 0000000000000000000000000000000000000000..86bef195228b0924704c2936b99f6801c14ff1b1 >> --- /dev/null >> +++ b/drivers/power/reset/psci-reboot-mode.c >> @@ -0,0 +1,119 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. >> + */ >> + >> +#include >> +#include > > Nit: swap the two. Ack. thanks. >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/* >> + * Predefined reboot-modes are defined as per the values >> + * of enum reboot_mode defined in the kernel: reboot.c. >> + */ >> +static struct mode_info psci_resets[] = { >> + { .mode = "warm", .magic = REBOOT_WARM}, >> + { .mode = "soft", .magic = REBOOT_SOFT}, >> + { .mode = "cold", .magic = REBOOT_COLD}, >> +}; >> + >> +static void psci_reboot_mode_set_predefined_modes(struct reboot_mode_driver *reboot) >> +{ >> + INIT_LIST_HEAD(&reboot->predefined_modes); >> + for (u32 i = 0; i < ARRAY_SIZE(psci_resets); i++) { >> + /* Prepare the magic with arg1 as 0 and arg2 as per pre-defined mode */ >> + psci_resets[i].magic = REBOOT_MODE_MAGIC(0, psci_resets[i].magic); > > This looks weird to me, why can't we just initialize the array with the values > directly ? Ack. The idea was to avoid Typecasting. Will check on this. >> + INIT_LIST_HEAD(&psci_resets[i].list); >> + list_add_tail(&psci_resets[i].list, &reboot->predefined_modes); >> + } >> +} >> + >> +/* >> + * arg1 is reset_type(Low 32 bit of magic). >> + * arg2 is cookie(High 32 bit of magic). >> + * If reset_type is 0, cookie will be used to decide the reset command. >> + */ >> +static int psci_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic) >> +{ >> + u32 reset_type = REBOOT_MODE_ARG1(magic); >> + u32 cookie = REBOOT_MODE_ARG2(magic); >> + >> + if (reset_type == 0) { >> + if (cookie == REBOOT_WARM || cookie == 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); >> + } > > I don't think that psci_set_reset_cmd() has the right interface (and this > nested if is too complicated for my taste). All we need to pass is reset-type > and cookie (and if the reset is one of the predefined ones, reset-type is 0 > and cookie is the REBOOT_* cookie). > > Then the PSCI firmware driver will take the action according to what > resets are available. > > How does it sound ? So we mean these checks will move to the psci driver? Sorry for re-iterating the question. >> + >> + return NOTIFY_DONE; >> +} >> + >> +static int psci_reboot_mode_register_device(struct faux_device *fdev) >> +{ >> + struct reboot_mode_driver *reboot; >> + int ret; >> + >> + reboot = devm_kzalloc(&fdev->dev, sizeof(*reboot), GFP_KERNEL); >> + if (!reboot) >> + return -ENOMEM; >> + >> + psci_reboot_mode_set_predefined_modes(reboot); >> + reboot->write = psci_reboot_mode_write; >> + reboot->dev = &fdev->dev; >> + >> + ret = devm_reboot_mode_register(&fdev->dev, reboot); >> + if (ret) { >> + dev_err_probe(&fdev->dev, ret, "devm_reboot_mode_register failed %d\n", ret); >> + return ret; >> + } >> + >> + return 0; >> +} >> + >> +static int __init psci_reboot_mode_init(void) >> +{ >> + struct device_node *psci_np; >> + struct faux_device *fdev; >> + struct device_node *np; >> + int ret; >> + >> + psci_np = of_find_compatible_node(NULL, NULL, "arm,psci-1.0"); >> + if (!psci_np) >> + return -ENODEV; >> + /* >> + * Look for reboot-mode in the psci node. Even if the reboot-mode >> + * node is not defined in psci, continue to register with the >> + * reboot-mode driver and let the dev.ofnode be set as NULL. >> + */ >> + np = of_find_node_by_name(psci_np, "reboot-mode"); >> + >> + fdev = faux_device_create("psci-reboot-mode", NULL, NULL); > > Same comment as Bartosz (have you picked up his work and working towards > a solution) ? Working on this via MFD. Some issue as again MFD framework does not allows a fwnode based driver registration. Will update. thanks, Shivendra