From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.11 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796511445; b=opZJResmmkUJ3dqjr+IqffqTPyrIAoRivt0Ik96iD69RICMYaiQTdjyPNVs5RMD5HJRL 6d/Lt9BXuGZq51y1dlCcRVmYUci3guRYqzmKOSnsB4W1vG1SZPYr7ExJEU4r42pL2s1RN wo8T6ExsiUwkgWiXngZZZmj8n9fEnRLQ6yJyg9TIp9efYLtCm0AwB7jv00IxLY5O+S553 FkbxrJrsiKfkT7gGo4IOpbXRFl5HfGAADOz4KLUssBoQUNlK5opctjpwW9VRqseylY5+V nN8QhwwjtbmdElzAjx99KyAXRQSxyqF6npIfMyACHdKv7fcfPMYnwKlALUU2rR0Anuw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511445; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-Zoho-Virus-Status:X-Zoho-AV-Stamp: X-ZohoMailClient; bh=BUg30E+InyeGjqtibw7YeLczml55kawxzUXiiw5tryc=; b=qvTpYbNLSR+vh2aYvB4kKLYlEc04kwlx5jJUPd9Ye9c2N/XZncT27uja2ejTC4o0ExTj arlL0IpY4OAlZUrGxEDEyeb4pH803sWSWMHa0vP4ixMHl6Y35r+QUrGAiOg9TMuUBjsFS veAc7s7jWW91NUvufzV7OCKr16bvI2FDnb4Wqcr7Kwd8W5nUDeWOL2WDodxlqsQ0yx580 xD+lqylKjkA4UHHECH3kx6/7vOdngVnt2DKONqA3GBDYUZgcXB3lNEE9rTl59kO7xX9+L +9fXL7iu6z1vVx4Mfpw0rRjPWPS4pSAT1HGRoknO4/MXs/FVBBzxu3PoJo9IbTQxGvw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=ZIp9RJ8J; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.180.11 Received: from sender6-op-o11.zoho.com (sender6-op-o11.zoho.com [165.173.180.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08FBF606A322 for ; Sat, 5 Dec 2026 22:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 08FBF606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=ZIp9RJ8J ARC-Seal: i=1; a=rsa-sha256; t=1796511404; cv=none; d=zohomail.com; s=zohoarc; b=fN5JgVH4a/xKnzmRhrbkcN2ncftFJ5HmMpwfUvuFRcnuksVXvEFkfJyCxn4Fn79pJGcVqPrhJdRyocqBl6st8jt0SU2GxcGjmii9F6sODvYnqcBoaiqsIItVO47gVC1wIJLL/DXke74B1a4/X7X0SA1XixxEJ4GU1cpe3fA5+pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796511404; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=BUg30E+InyeGjqtibw7YeLczml55kawxzUXiiw5tryc=; b=nZxzogmaFxIYAhqMH8Pjz3MCTy4hjaEwTqJRXE4KwjZdtKCeX1eNa0cBqphkpIPTbLyeJOlOpk7ihTQSaO/sNl7yPzGNClivY3O0uu1AsBcFzO+PnjT1sIQOKQBnfNlgiqt/aQTJoidjiWmvDWRbGsmRMb6FYfC2httCJM/dwwY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=sebastian.reichel@collabora.com; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=ZIp9RJ8J+TzworvvW2TeIYtcKeeBvJMWQEsOURgemqxsNBUu/n7CT3+OCNCbo0L97E7I7o8BOxx1274A45Buzm9I9bU9U04/Y71y54bnQLWMn41y4Gw7r7aOtJqgQm2/ufCUPyXlzzn/K47oosF94ckuEgn2HX0nIewfumB1hwQ=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=BUg30E+InyeGjqtibw7YeLczml55kawxzUXiiw5tryc=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796511403012336.58767852721166; Sat, 5 Dec 2026 14:56:43 -0800 (PST) Received: by venus (Postfix, from userid 1000) id A3DFB18205E; Sat, 05 Dec 2026 23:56:39 +0100 (CET) Date: Sat, 5 Dec 2026 23:56:39 +0100 From: Sebastian Reichel To: Tian Xuechen <202300460064@mail.sdu.edu.cn> Cc: nikita.shubin@maquefel.me, arnd@arndb.de, vkoul@kernel.org, linux@roeck-us.net, alexandre.belloni@bootlin.com, fkan@apm.com, linux-pm@vger.kernel.org, liguangshuo@mail.sdu.edu.cn Subject: Re: [PATCH 2/4] power: reset: hisi: Unregister the restart handler on unbind Message-ID: References: <20261129094744.1691778-1-202300460064@mail.sdu.edu.cn> <20261129094744.1691778-3-202300460064@mail.sdu.edu.cn> X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="b53kj35h2jd5velu" Content-Disposition: inline In-Reply-To: <20261129094744.1691778-3-202300460064@mail.sdu.edu.cn> X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.28.1.5.5/296.487.71 X-ZohoMailClient: External --b53kj35h2jd5velu Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 2/4] power: reset: hisi: Unregister the restart handler on unbind MIME-Version: 1.0 Hi, On Sun, Nov 29, 2026 at 05:47:42PM +0800, Tian Xuechen wrote: > From: Tian Xuechen <202300460064@mail.sdu.edu.cn> >=20 > Removing the driver leaves its restart handler registered and the > register mapping in use. Keep both in per-device data, unregister the > handler on removal, then unmap its registers. >=20 > This issue was found by our static analysis tool under development. >=20 > Fixes: 6724534c79ea ("power/reset: hisi: Register with kernel restart han= dler") > Signed-off-by: Tian Xuechen <202300460064@mail.sdu.edu.cn> > --- > drivers/power/reset/hisi-reboot.c | 46 +++++++++++++++++++++---------- > 1 file changed, 32 insertions(+), 14 deletions(-) >=20 > diff --git a/drivers/power/reset/hisi-reboot.c b/drivers/power/reset/hisi= -reboot.c > index 34409340528f..e106e9f0acaf 100644 > --- a/drivers/power/reset/hisi-reboot.c > +++ b/drivers/power/reset/hisi-reboot.c > @@ -15,16 +15,22 @@ > #include > #include > #include > +#include > =20 > #include > =20 > -static void __iomem *base; > -static u32 reboot_offset; > +struct hisi_reboot { > + struct notifier_block nb; > + void __iomem *base; > + u32 offset; > +}; > =20 > static int hisi_restart_handler(struct notifier_block *this, > unsigned long mode, void *cmd) > { > - writel_relaxed(0xdeadbeef, base + reboot_offset); > + struct hisi_reboot *reboot =3D container_of(this, struct hisi_reboot, n= b); > + > + writel_relaxed(0xdeadbeef, reboot->base + reboot->offset); > =20 > while (1) > cpu_do_idle(); > @@ -32,38 +38,49 @@ static int hisi_restart_handler(struct notifier_block= *this, > return NOTIFY_DONE; > } > =20 > -static struct notifier_block hisi_restart_nb =3D { > - .notifier_call =3D hisi_restart_handler, > - .priority =3D 128, > -}; > - > static int hisi_reboot_probe(struct platform_device *pdev) > { > struct device_node *np =3D pdev->dev.of_node; > + struct hisi_reboot *reboot; > int err; > =20 > - base =3D of_iomap(np, 0); > - if (!base) { > + reboot =3D devm_kzalloc(&pdev->dev, sizeof(*reboot), GFP_KERNEL); > + if (!reboot) > + return -ENOMEM; > + > + reboot->base =3D of_iomap(np, 0); devm_platform_ioremap_resource() > + if (!reboot->base) { > WARN(1, "failed to map base address"); > return -ENODEV; > } > =20 > - if (of_property_read_u32(np, "reboot-offset", &reboot_offset) < 0) { > + if (of_property_read_u32(np, "reboot-offset", &reboot->offset) < 0) { > pr_err("failed to find reboot-offset property\n"); > - iounmap(base); > + iounmap(reboot->base); > return -EINVAL; > } > =20 > - err =3D register_restart_handler(&hisi_restart_nb); > + platform_set_drvdata(pdev, reboot); > + reboot->nb.notifier_call =3D hisi_restart_handler; > + reboot->nb.priority =3D 128; > + err =3D register_restart_handler(&reboot->nb); devm_register_sys_off_handler() > if (err) { > dev_err(&pdev->dev, "cannot register restart handler (err=3D%d)\n", > err); > - iounmap(base); > + iounmap(reboot->base); > } > =20 > return err; > } > =20 > +static void hisi_reboot_remove(struct platform_device *pdev) > +{ > + struct hisi_reboot *reboot =3D platform_get_drvdata(pdev); > + > + unregister_restart_handler(&reboot->nb); > + iounmap(reboot->base); > +} > + > static const struct of_device_id hisi_reboot_of_match[] =3D { > { .compatible =3D "hisilicon,sysctrl" }, > {} > @@ -72,6 +89,7 @@ MODULE_DEVICE_TABLE(of, hisi_reboot_of_match); > =20 > static struct platform_driver hisi_reboot_driver =3D { > .probe =3D hisi_reboot_probe, > + .remove =3D hisi_reboot_remove, > .driver =3D { > .name =3D "hisi-reboot", > .of_match_table =3D hisi_reboot_of_match, Greetings, -- Sebastian --b53kj35h2jd5velu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmsUlqMACgkQ2O7X88g7 +pozNg/8CWL56G4wydP6Opv2faIMtRHAwTKE6vJjn7FoJAa5jkeIMLMcBcldNVOw W0wNeSvggZGg19KWLpGEckyaRDuB7dd7rYUoFyhqfTkGnX00XBGSRbX1ykeg5ChY oRxxxm70A/MgK4LgmdDTtjVv2h8cu+fn/VdMqR9s64bCCIkjznuZX+1t+tEbc/oo KTHeZi2zNsJY8Cb3hlA5fnDz7HC6PvUt0SzZL7nS2vNnk4IbJXnTZpSfoCaCwEpH tcRaw/1XN+r4a73iYmd4vLoNQH9VqWQ9bt6pwMQBXdyqwxP/FfS8ueNwbulU2N35 duSVJ9cObYAl+JZsoWuxqaRmWCU0RpjP5i+dyHy8b1aqew3mKrMPbePpPyv6wQzV M7UZr6jwdx+oRhw31OOxd29eqJf91hWrxUa7nh5ID7v4RjxddbFYJC2RGZaZ7sK8 zRKeaRw7aadb8uKuI4CnlB17YcAc6bHAM6qcYTRtJb3+0ilc0KWF/aHaZhmAU6I2 pkIGEKMflaI+E6zf+SUixGlrLVeaF0fjxZUyGPY51CQcCoH1turpZTB/QBhg+8Rd JuZ51gw5npCCujBjN1mAsILdl9tzBALS7bYcdRBTQ0IsQZO89qcSWQekZh3HZZiQ dpaIP8xpHv9KdbV8WjATIaG6wOjRGHK/TFn7/QmeJaNViVuoofA= =0Spc -----END PGP SIGNATURE----- --b53kj35h2jd5velu--