From nobody Sat Feb 7 05:32:30 2026 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 4D4E0295511 for ; Thu, 10 Jul 2025 09:18:19 +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=1752139100; cv=none; b=L8z4OXXFWERSM/jWNV35b8jzFXGllZzCAK+0aCJZuA1N+OroJhStpOcFWPk3KMckqAOe1cR1Xyq8+UtWtSbjBddWCwAFiRNCR+eIUGHYsBNPQy4bfNoEvT9I9736Y6Dh4g5U+32u8ANSedDZEvGsiyZ3p5wkMywozFUgQVaeh28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752139100; c=relaxed/simple; bh=Gh0wKF8f8obJZBIFY+YXRq0mvEFaXxY4KjC0e6ESP0U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PrheH7tvuS1pTOC7DIZOgwjq7/N9yQdf8bQryAs5BYf3VDPQt9zGUsTdOIh9BVX5Jwmh//aF3e4xHO5R0LhmXsE98ryau1MorQUZ7zlZKG9BfGSbXMbyip1qQzQINCpDSCLZy6dhDEDo3bkjwwPXOXi3b/FITvJiLiwfeKvOOFw= 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=WhW8TMTQ; 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="WhW8TMTQ" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56A8q2mD016847 for ; Thu, 10 Jul 2025 09:18:18 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= KEQrgZfA5rhK7t8SJQh+Tq/CWC0djSnOhUUgfmLwz64=; b=WhW8TMTQz9Or+5Ut JV77FzjSJBAAEaojl+gFV7Zt/eGLI01ypAewarNdVghtsxF2oIGT3R2uBsC4Fifz sZXNEm7OopBVSXerUVYv7zTOkEXYpRO0bqiv5AukWGyOSFdNGBm/QrajE5LLYJKM dtKH00yzERyxM/vIxhFGx7QNoKPRFkRIXXVg4r5cLhNAXPMYx9UIxBKwr5x9SS4x axJWAO4HzKZ833OVJ8Vt0OP68tWBjTFuYcg2lr4jT+qoxOOSEe/ILATnfYIsFtvW uW0iOGtC3IUBiKhfuHzJBf33uzKm1hkJg3B9OANZv2zVPByDU9gF0N7j2D60IdR0 2lv4wQ== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47smap4ctr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 10 Jul 2025 09:18:18 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-23dc7d3e708so4989805ad.3 for ; Thu, 10 Jul 2025 02:18:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752139097; x=1752743897; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KEQrgZfA5rhK7t8SJQh+Tq/CWC0djSnOhUUgfmLwz64=; b=shgJxPxm3w3KcolKsaPNBaEivE1ym54drrshHy7C4idaYMvCNaa+1ll/EV2ZHdKwEV Ej8uaR6RzPmmOHAhmghZRfK4xDINYHJEpViHGWsYOmFcl8U21a4YPULWRqFpUzUuACvJ Lcgkh/uQGSkiQOJQfjv8zo0kZuaRJTSX2UVGm6cc+DHlY/TTXrPKbPQnLUYQkjbr/xtQ fuVKzMPZogwBUZAQnC57b4uKWVPWe8oHg4Gx+Kz0KwV3ILwQZSJW//Mhr5iXqAfJv7i7 kaMqG/X/c0XmIEvSiN8cd0dDBNjn0RjyGYlKxt+7Rftu8hlErL5JTAvXHVMsl7SP4yNi xEjA== X-Forwarded-Encrypted: i=1; AJvYcCXHYn2o9YRyK6SEd9Vl3rXvSXNG4fyUL2s+FyG11wWxBHTFzHY2ZHWtk5J4JQNOd6gSODEqp3AWRhwadV0=@vger.kernel.org X-Gm-Message-State: AOJu0YzDsX8Jabba2BFKEiw8Euh7Qwy1+Yst0sr23s7rKOBisroBgCxH B3p3QxuUlNiAKpqNcUzSD5dA7yegoYIOP/KyiyaxLXwmPXSppqoYo11FjTOjZNYQ3886/7u2mbr YRxRPHMQcbaAxJUv8o742X3lhq9d4TAD6p9XAkLd8Q5mHvH8nSFlq06qPdG31Vg+guiA= X-Gm-Gg: ASbGnctC4P6fII+bF4/oy1JohvQPOfaJOv9JRjsadfiXtefa5cDDFKPwNtusxXCmL4T KL8hyMH1Tkz3xKP2rncbDKWnaqdYgXXxAeEPXTMAbTu5XiZAd90AMXFviRRhV4/9vYa+NyhuSZ+ jYn+c/jC/MNf8o/K90mwhIMAjcKg6tP+tzjW0FMm4UbFNU97hqyi7AllCgO3SNm5gjwanpYOOYm g2uoZNOEaRi/orLVPpoS2S5YIlUs+pTtrOathB6XIaOeJ1zu8hEKU3BlGZrE5o3S/Yh8bBGttlp 2v+LQ3XdDaCWGIdpPkCaec2dNUgJGtYUBuA9XMnhfHqV0R+o0qKMe4rMY5Y= X-Received: by 2002:a17:903:1103:b0:236:9d66:ff24 with SMTP id d9443c01a7336-23de480adf5mr26735145ad.8.1752139097010; Thu, 10 Jul 2025 02:18:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGJGyoIrfBA9Zxl0Ughrj3uMKfz6jdSKT0NaAjnNjMskqdtkAKMLUS8x/FzIhDGTyLMPqU7g== X-Received: by 2002:a17:903:1103:b0:236:9d66:ff24 with SMTP id d9443c01a7336-23de480adf5mr26734395ad.8.1752139096442; Thu, 10 Jul 2025 02:18:16 -0700 (PDT) Received: from hu-spratap-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23de4341d51sm14837765ad.189.2025.07.10.02.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jul 2025 02:18:16 -0700 (PDT) From: Shivendra Pratap Date: Thu, 10 Jul 2025 14:45:52 +0530 Subject: [PATCH v10 10/10] power: reset: reboot-mode: Expose sysfs for registered arguments 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: <20250710-arm-psci-system_reset2-vendor-reboots-v10-10-b2d3b882be85@oss.qualcomm.com> References: <20250710-arm-psci-system_reset2-vendor-reboots-v10-0-b2d3b882be85@oss.qualcomm.com> In-Reply-To: <20250710-arm-psci-system_reset2-vendor-reboots-v10-0-b2d3b882be85@oss.qualcomm.com> To: Bartosz Golaszewski , Bjorn Andersson , Sebastian Reichel , Rob Herring , Sudeep Holla , Souvik Chakravarty , Krzysztof Kozlowski , Conor Dooley , Andy Yan , Mark Rutland , Lorenzo Pieralisi , Arnd Bergmann , Olof Johansson , Konrad Dybcio , cros-qcom-dts-watchers@chromium.org, Vinod Koul , Catalin Marinas , Will Deacon , Florian Fainelli , Elliot Berman Cc: Stephen Boyd , 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, Andre Draszik , Alim Akhtar , linux-samsung-soc@vger.kernel.org, Wei Xu , linux-rockchip@lists.infradead.org, Baolin Wang , Sen Chu , Sean Wang , Macpaul Lin , AngeloGioacchino Del Regno , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Nicolas Ferre , Alexandre Belloni , Elliot Berman , Shivendra Pratap , Srinivas Kandagatla X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752138982; l=5404; i=shivendra.pratap@oss.qualcomm.com; s=20250710; h=from:subject:message-id; bh=Gh0wKF8f8obJZBIFY+YXRq0mvEFaXxY4KjC0e6ESP0U=; b=lw/w70/5HLBy4afjvzlsoilkn9KNGxxeob32fKCnRPLyN8EQy03rSeyCWxEC8VvLFF42hMkAU +dipiHJKDdAD9k39uxR5AmQE0RPKWUW9koD6OoeU2qqjpwjX3QrfMdd X-Developer-Key: i=shivendra.pratap@oss.qualcomm.com; a=ed25519; pk=CpsuL7yZ8NReDPhGgq6Xn/SRoa59mAvzWOW0QZoo4gw= X-Authority-Analysis: v=2.4 cv=Ar7u3P9P c=1 sm=1 tr=0 ts=686f855a cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=EUspDBNiAAAA:8 a=YvCmAYiu2kffolCFmWcA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-ORIG-GUID: Lm777GWecXA3y0UHvAT3znv-BItpkcxM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzEwMDA3OCBTYWx0ZWRfX/R6rnISYpH1O UJq2JUq4TxyH/q+B0TOm0lkcYgZ0/jc8Ii1LO7HeiH4D0COkrNzKHtWDNwqnOl+PlvmF4KejwDx kfGqVTusQPmwBVxD7vgGNpfgBloxwagleKU7fVuSwfi5tj0mRa6tsAdXPfdB8IKLF8NX1SZt/kS 0J63rblvrbIr3nByMbW7bXBBrEdIYMLKikT42YyKfh22J74xUXhf95SKsQb8B/oCj3gOlfwNNkZ //kpYNuUchm5grIsNgKSg4V2EXOtJhkbMh4HLVDcAu9OdJwTx9lcbxo2NmBlUPjKWfw7zRF5N64 Pp8PatirHoOLR+OOx/710Anetxd23Ydf0yinK1+LvqhYfRW95X+MU+HrL5XBdqEDhXDMlhtNWVe bZGp+givLmokEJMuPzXQ4B8KfE3mSm+bU88amzQMiKU9uhsmUKhduWBhSyQlP+zboIIVazsp X-Proofpoint-GUID: Lm777GWecXA3y0UHvAT3znv-BItpkcxM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-10_01,2025-07-09_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507100078 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. Create the device using the node name of the driver that registers with reboot mode driver. 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. Align the clean up path to maintain backward compatibility for existing reboot-mode based drivers. Signed-off-by: Shivendra Pratap --- drivers/power/reset/reboot-mode.c | 95 ++++++++++++++++++++++++++++++++++-= ---- include/linux/reboot-mode.h | 1 + 2 files changed, 84 insertions(+), 12 deletions(-) diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot= -mode.c index afadd823d62d0f7e7e645746b978cc8fecfb9ac4..128192d49d895beeacb180c1a92= b44a5eddccc78 100644 --- a/drivers/power/reset/reboot-mode.c +++ b/drivers/power/reset/reboot-mode.c @@ -22,6 +22,8 @@ struct mode_info { struct list_head list; }; =20 +static struct class *rb_class; + static struct mode_info *get_reboot_mode_info(struct reboot_mode_driver *r= eboot, const char *cmd) { const char *normal =3D "normal"; @@ -70,6 +72,79 @@ static int reboot_mode_notify(struct notifier_block *thi= s, return NOTIFY_DONE; } =20 +static void release_reboot_mode_device(struct device *dev, void *res); + +static ssize_t reboot_modes_show(struct device *dev, struct device_attribu= te *attr, char *buf) +{ + struct reboot_mode_driver **devres_reboot; + struct reboot_mode_driver *reboot; + struct mode_info *info; + ssize_t size =3D 0; + + devres_reboot =3D devres_find(dev, release_reboot_mode_device, NULL, 0); + reboot =3D *devres_reboot; + list_for_each_entry(info, &reboot->head, list) { + size +=3D sprintf(buf + size, "%s,", info->mode); + } + + if (size) { + size +=3D sprintf(buf + size - 1, "\n"); + return size; + } + + return -ENODATA; +} +static DEVICE_ATTR_RO(reboot_modes); + +static void release_reboot_mode_device(struct device *dev, void *res) +{ + struct reboot_mode_driver *reboot =3D *(struct reboot_mode_driver **)res; + struct mode_info *info; + struct mode_info *next; + + unregister_reboot_notifier(&reboot->reboot_notifier); + + list_for_each_entry_safe(info, next, &reboot->head, list) { + kfree_const(info->mode); + list_del(&info->list); + kfree(info); + } + + device_remove_file(reboot->dev, &dev_attr_reboot_modes); +} + +static int create_reboot_mode_device(struct reboot_mode_driver *reboot, + const char *dev_name) +{ + struct reboot_mode_driver **dr; + int ret =3D 0; + + if (!rb_class) { + rb_class =3D class_create("reboot-mode"); + if (IS_ERR(rb_class)) + return PTR_ERR(rb_class); + } + + reboot->reboot_dev =3D device_create(rb_class, NULL, 0, NULL, dev_name); + if (IS_ERR(reboot->reboot_dev)) + return PTR_ERR(reboot->reboot_dev); + + ret =3D device_create_file(reboot->reboot_dev, &dev_attr_reboot_modes); + if (ret) + return ret; + + dr =3D devres_alloc(release_reboot_mode_device, sizeof(*dr), GFP_KERNEL); + if (!dr) { + device_remove_file(reboot->reboot_dev, &dev_attr_reboot_modes); + return -ENOMEM; + } + + *dr =3D reboot; + devres_add(reboot->reboot_dev, dr); + + return ret; +} + /** * reboot_mode_register - register a reboot mode driver * @reboot: reboot mode driver @@ -84,6 +159,10 @@ int reboot_mode_register(struct reboot_mode_driver *reb= oot, struct device_node * size_t len =3D strlen(PREFIX); int ret; =20 + ret =3D create_reboot_mode_device(reboot, np->name ? np->name : "reboot-m= ode-dev"); + if (ret) + return ret; + INIT_LIST_HEAD(&reboot->head); =20 for_each_property_of_node(np, prop) { @@ -140,24 +219,16 @@ EXPORT_SYMBOL_GPL(reboot_mode_register); */ int reboot_mode_unregister(struct reboot_mode_driver *reboot) { - struct mode_info *info; - struct mode_info *next; - - unregister_reboot_notifier(&reboot->reboot_notifier); - - list_for_each_entry_safe(info, next, &reboot->head, list) { - kfree_const(info->mode); - list_del(&info->list); - kfree(info); - } - + device_unregister(reboot->reboot_dev); return 0; } EXPORT_SYMBOL_GPL(reboot_mode_unregister); =20 static void devm_reboot_mode_release(struct device *dev, void *res) { - reboot_mode_unregister(*(struct reboot_mode_driver **)res); + struct reboot_mode_driver *reboot =3D *(struct reboot_mode_driver **)res; + + device_unregister(reboot->reboot_dev); } =20 /** diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h index cfe18cdc2559be249969bba6c022940a508dd188..3aab8700a5961b90b07ed4d722c= 77484213ac6c4 100644 --- a/include/linux/reboot-mode.h +++ b/include/linux/reboot-mode.h @@ -4,6 +4,7 @@ =20 struct reboot_mode_driver { struct device *dev; + struct device *reboot_dev; struct list_head head; int (*write)(struct reboot_mode_driver *reboot, unsigned int magic); int (*write_with_cookie)(struct reboot_mode_driver *reboot, --=20 2.34.1