From mboxrd@z Thu Jan 1 00:00:00 1970 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 5106A337B80 for ; Wed, 12 Nov 2025 16:57:42 +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=1762966665; cv=none; b=cODLgA5ee64uRsT/xwNX/0SeOgSemQzZFERJfypRRb6hMsaY5vat4A7Ba4jxurSsGmbkHs+9nm2og1PHcK0BRiACM6Q9QC9UW3VumJsyy9KzPpXMLnNXyYWqqJm0aZoIMFxVjmxhLu+0bM5xPgvdTLLLId91ImgG/7xThju33Fg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762966665; c=relaxed/simple; bh=NniAWjlNS156K6qgGuzy3k40wtUaszR2ayeP0JRUS/A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TlD97pYS3OqN7FIxhihkSSEIifg/aqeikSkqC4RhHMlFDm6GsTR3SILd4PgX9+eei6O6jKnnQst4cxeWbsI85LeKjHZnHOuKFPCBNLrUld+GUGj/FAWY83uzRepavRB/5GyWXZm1ggEP7xit1VBmk+r3CMBgntceDdTQepeFsQA= 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=kSI/Mko5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZX/P89Gw; 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="kSI/Mko5"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZX/P89Gw" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5ACGZVVr722118 for ; Wed, 12 Nov 2025 16:57:41 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= Mpem797IAS5zUDgun5QkAafd9U5uOGw9KKyFmkJdJVQ=; b=kSI/Mko5rQytHI4o 0UyILDIryo/oRRhS4uRJWfrTMqF1DTTwY28tuBhZmNx35QHuq8sC9pFVXhRUv0d9 r645yNYqtJ7RhujOLyW88aHPkg5kFVi5pkpL43hITAu3yWzCs2Aoto3fwOSdpd6i 9QgAgH2cVDVCDs+ht63Dh6UoF4r/W0n0BP4awqw4hAxDLoooK/xtla8lO3IL9wlV kVZT4Cb0eE4WwIBNStOzk1PNbGhEsIpvT9yAqhuyCZCWnNzMhFrT+rCvS7H8j2hN iTmpLraVW1hoxX95FBUXA5soptbq+xkiUtQ+Lrc9l8nMBvfnlcfuR11t9pwx4Zp4 vFYong== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4acqu1sdmk-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 12 Nov 2025 16:57:41 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-b6ceeea4addso1028885a12.1 for ; Wed, 12 Nov 2025 08:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1762966661; x=1763571461; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Mpem797IAS5zUDgun5QkAafd9U5uOGw9KKyFmkJdJVQ=; b=ZX/P89GwiiT67eURaATXZ08/1M8fT3aXv74mn6+IABZa2XBShSrZ35zeh3yRrTVioO C3XhIOCaM8U8ZbOeDXxgQdiJcczYww2g+xxdY23PUDlR/KIl8tOQ10WS7NIvAavnu7iA eEEHKK1MxEdbKjruspa2uOHOaq5nNAA+aJJTt7U5Ga4n9ODHced+ChMU2vuolkjSKvux X/nZYfOHUjGx9sNyO3ep8a3XBIFRQSFS8pe2Ndm91K1w2nj5Al+A6cfbw3OUwNCJOBuy QU8/6j+3tItHRx86x3qxZq3h85Qft1deMzOPn20F2Tdgn+tSB6dNefuvC9AA28CwvyTZ TplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762966661; x=1763571461; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language: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=Mpem797IAS5zUDgun5QkAafd9U5uOGw9KKyFmkJdJVQ=; b=anZQZI0aMSEF5vgLE8CGwpfhcMSOBOeUtaU4WjnQY4GZafchuTlc3YveMRJIms34Iq 8/FYpAQbUay/Uoz7tKpTxvc58jBX+RTUYCClUTce58DvWdfKBAK6p0WIUm3Pi7tL69ox A2knkEIGGUdVy4XnmvW3y1TQYrNQt11sTxgVzZZBs6eG2fv2zp9fU2/64dvUdSjAwAU6 ZIZq7+nENmW1B14FGC24k5E5acGsII2gHo4Wwr0xQ0mhg1+EuirL3IyNn2+Cu+8c8RVO 91WMSEmvsUcC5SQn1b8U6v4RVfSMEFB1GKUjCFXhQxuRtOG6AGPdJu5FG2iPO+vAIKuk ifRQ== X-Forwarded-Encrypted: i=1; AJvYcCUdzbNIVyGoJiOjp6NFcwKoJ1Fl6JsEWpcE27uBQ+Yiikg69py3YD2XBC97jUFf8qGpHFqw/x99TFB2bqI=@vger.kernel.org X-Gm-Message-State: AOJu0YxihMhOMiYL7hOl4Rti9q9PjPA/ZbQnVkEW/92z0fR8oXUlbKi0 nrhAj5IS9xy55320pG5pNrWNordB2wdwjzE4SqJZzZ8RDuCTQl3eQUrJLY4MDfwciRearjtq2dT zgXOxS1Sxg1GYtTmHFSU7AK0dWjL6oGVyxzLUixRZjs0BxtlsZNpRDr2Ia66pY0n1GDc= X-Gm-Gg: ASbGncsasWHcwM/V6f9sNuaYJ33IhCDXBjOpV3vKIVC/+jeLVzL9m2YqHf2wv1imapC VO52Tya48JleMiHp/6VfzYpYOReb5ZeObOMs0+ir7+1ngHLMptuJq+xcilXGBU66iBmfs0Q4Imy MIAGXfSuW0iu1hN1q41+wrAphTaVIPYOSVQCOKv7BddPNndWZ2x8CYuRZdsUOYNIRkYmHF7jDwT wrPlnSJsp1ZTHqqE78YHZuHhQbgJa1urNywmfuoB2Flh+JZiVMy8V8sxVLHQgDNL1ztpp57N7tW CkdpA5HGXvuAKBjBJ+iFVShddZdFQNQseSyW+U1R4YmhbVvwRX7VmKZLr40y/1VK7F1MQeV/jGG F/tOIQHYEB2ucZoVDYod6qRI42x97ZKypFRs= X-Received: by 2002:a05:6a20:7d8b:b0:343:2772:6bdf with SMTP id adf61e73a8af0-35909c72d38mr5228939637.26.1762966660469; Wed, 12 Nov 2025 08:57:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCL8LcDYnKtT117dBOx0SxrkoJoefTb8xV70qNzqs+1oeeDhNffDRFT5zulQTb9lWo8KVYhQ== X-Received: by 2002:a05:6a20:7d8b:b0:343:2772:6bdf with SMTP id adf61e73a8af0-35909c72d38mr5228883637.26.1762966659835; Wed, 12 Nov 2025 08:57:39 -0800 (PST) Received: from [192.168.29.115] ([49.43.225.99]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b0cc76c0e8sm19073083b3a.52.2025.11.12.08.57.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Nov 2025 08:57:39 -0800 (PST) Message-ID: <41725ac5-843c-0e4d-8f82-a6b7cd8ba9e0@oss.qualcomm.com> Date: Wed, 12 Nov 2025 22:27:28 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v17 05/12] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Content-Language: en-US To: Bartosz Golaszewski Cc: Bjorn Andersson , Sebastian Reichel , Rob Herring , Sudeep Holla , Souvik Chakravarty , Krzysztof Kozlowski , Conor Dooley , Andy Yan , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Konrad Dybcio , cros-qcom-dts-watchers@chromium.org, Vinod Koul , Catalin Marinas , Will Deacon , Florian Fainelli , Moritz Fischer , John Stultz , Matthias Brugger , Krzysztof Kozlowski , Dmitry Baryshkov , Mukesh Ojha , Stephen Boyd , Andre Draszik , Kathiravan Thirumoorthy , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Elliot Berman , Xin Liu , Srinivas Kandagatla References: <20251109-arm-psci-system_reset2-vendor-reboots-v17-0-46e085bca4cc@oss.qualcomm.com> <20251109-arm-psci-system_reset2-vendor-reboots-v17-5-46e085bca4cc@oss.qualcomm.com> From: Shivendra Pratap In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: hSRis30t1iM_9IbG8Pzf82J5ASSoCfZz X-Authority-Analysis: v=2.4 cv=Hpl72kTS c=1 sm=1 tr=0 ts=6914bc85 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=8+dZ2YuSHRys20a4ijOkGQ==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=JGhpyqB6T-AhYHNvuAAA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-GUID: hSRis30t1iM_9IbG8Pzf82J5ASSoCfZz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTEyMDEzNyBTYWx0ZWRfX64nHwye5clPt J7XbNh9/8k6Lic1WeIHFnebA/vNsXQYpwq5yRIhUfjcDB6FLtMRMHNLv4CSYnd+r/BLTwIJoo7Q uvQF8Gsm8KaGruoVhSvOyHjhM2aBbPbTcx4Aa5vxguzOvqpy/jwGRcgtwpTkvWJAau7tDwkMH96 Zf4i1RsA0wGT+B4bq34htjRX7nAQFTmNtsV++XffvHFj2h8Y1hBgtCVfbiEX1i676aTVxmclfVT ZNeSELX7fP1zYKXhJsyg9tlOxDLqdcOIvjLAZ558RK/rYJJgN2oMs38g4HdK4rIFbnPNMhl+KDP hIwclvbwR9SYDC3zw56Karu6WxzxrWDcT+Lv6jg9tkDPjWebQM766PKmMkCbRinDtPcYNJlW0/h W8IHRBgobZ/Ce6FAjkD6yzc3VjTz5A== 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-11-12_05,2025-11-11_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511120137 On 11/10/2025 8:44 PM, Bartosz Golaszewski wrote: > On Sun, 9 Nov 2025 at 15:38, Shivendra Pratap > wrote: >> >> Currently, there is no standardized mechanism for userspace to >> discover which reboot-modes are supported on a given platform. >> This limitation forces tools and scripts to rely on hardcoded >> assumptions about the supported reboot-modes. >> >> Create a class 'reboot-mode' and a device under it to expose a >> sysfs interface to show the available reboot mode arguments to >> userspace. Use the driver_name field of the struct >> reboot_mode_driver to create the device. For device-based >> drivers, configure the device driver name as driver_name. >> >> This results in the creation of: >> /sys/class/reboot-mode//reboot_modes >> >> This read-only sysfs file will exposes the list of supported >> reboot modes arguments provided by the driver, enabling userspace >> to query the list of arguments. >> >> Signed-off-by: Shivendra Pratap >> --- >> drivers/power/reset/reboot-mode.c | 62 ++++++++++++++++++++++++++++++++++++++- >> include/linux/reboot-mode.h | 2 ++ >> 2 files changed, 63 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c >> index 873ac45cd7659b214b7c21958f580ca381e0a63d..582aa7f8ed7fa485c5a67877558c9b15d3600ef4 100644 >> --- a/drivers/power/reset/reboot-mode.c >> +++ b/drivers/power/reset/reboot-mode.c >> @@ -6,6 +6,7 @@ >> #define pr_fmt(fmt) "reboot-mode: " fmt >> >> #include >> +#include >> #include >> #include >> #include >> @@ -23,6 +24,8 @@ struct mode_info { >> struct list_head list; >> }; >> >> +static struct class *rb_class; >> + > > I know C is a spartan language but the rb_ prefix makes me think of > the red-black tree. Please call it reboot_mode_class. sure will make it reboot_mode_class. > >> static u64 get_reboot_mode_magic(struct reboot_mode_driver *reboot, const char *cmd) >> { >> const char *normal = "normal"; >> @@ -65,6 +68,51 @@ static int reboot_mode_notify(struct notifier_block *this, >> return NOTIFY_DONE; >> } >> >> +static ssize_t reboot_modes_show(struct device *dev, struct device_attribute *attr, char *buf) >> +{ >> + struct reboot_mode_driver *reboot; >> + struct mode_info *info; >> + ssize_t size = 0; >> + >> + reboot = (struct reboot_mode_driver *)dev_get_drvdata(dev); > > No need for the cast. Ack. >> + if (!reboot) >> + return -ENODATA; >> + >> + list_for_each_entry(info, &reboot->head, list) >> + size += sysfs_emit_at(buf, size, "%s ", info->mode); >> + >> + if (size) { >> + size += sysfs_emit_at(buf, size - 1, "\n"); >> + return size; >> + } > > This is a weird logic inversion. Just do: > > if (!size) > return -ENODATA; > > return size + sysfs_emit_at(buf, size - 1, "\n"); Ack. >> + >> + return -ENODATA; >> +} >> +static DEVICE_ATTR_RO(reboot_modes); >> + >> +static int create_reboot_mode_device(struct reboot_mode_driver *reboot) >> +{ >> + int ret = 0; >> + >> + if (!rb_class) { >> + rb_class = class_create("reboot-mode"); >> + if (IS_ERR(rb_class)) >> + return PTR_ERR(rb_class); >> + } > > Why the lazy initialization here? Is there any reason you can't > statically define the class? Don't you need synchronization here if > multiple drivers try to do this? reboot-mode framework does not has a init. Should i add a inti_call here and create a class? Can you suggest a bit more. For if we at-all continue this lazy init, will add a lock. thanks, Shivendra