drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
The raspberrypi-power driver registers resources with
of_genpd_add_provider_onecell and pm_genpd_init but never removes them.
When the driver gets unbound and bound again this causes error. Add a
remove function to cleanup all registered resources.
Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de>
---
drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/pmdomain/bcm/raspberrypi-power.c b/drivers/pmdomain/bcm/raspberrypi-power.c
index b87ea7adb7bea..2c2135c17afb0 100644
--- a/drivers/pmdomain/bcm/raspberrypi-power.c
+++ b/drivers/pmdomain/bcm/raspberrypi-power.c
@@ -232,6 +232,17 @@ static int rpi_power_probe(struct platform_device *pdev)
return 0;
}
+static void rpi_power_remove(struct platform_device *pdev)
+{
+ struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
+ int nr_domains = RPI_POWER_DOMAIN_COUNT - 1;
+
+ of_genpd_del_provider(pdev->dev.of_node);
+
+ for (int i = nr_domains; i >= 0; i--)
+ pm_genpd_remove(&rpi_domains->domains[i].base);
+}
+
static const struct of_device_id rpi_power_of_match[] = {
{ .compatible = "raspberrypi,bcm2835-power", },
{},
@@ -244,6 +255,7 @@ static struct platform_driver rpi_power_driver = {
.of_match_table = rpi_power_of_match,
},
.probe = rpi_power_probe,
+ .remove = rpi_power_remove,
};
builtin_platform_driver(rpi_power_driver);
---
base-commit: 58717b2a1365d06c8c64b72aa948541b53fe31eb
change-id: 20260715-rpi-pm-remove-4ce2f27b5efa
Best regards,
--
Gregor Herburger <gregor.herburger@linutronix.de>
On Wed, Jul 15, 2026 at 10:16 AM Gregor Herburger
<gregor.herburger@linutronix.de> wrote:
>
> The raspberrypi-power driver registers resources with
> of_genpd_add_provider_onecell and pm_genpd_init but never removes them.
> When the driver gets unbound and bound again this causes error. Add a
> remove function to cleanup all registered resources.
>
> Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de>
> ---
> drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/pmdomain/bcm/raspberrypi-power.c b/drivers/pmdomain/bcm/raspberrypi-power.c
> index b87ea7adb7bea..2c2135c17afb0 100644
> --- a/drivers/pmdomain/bcm/raspberrypi-power.c
> +++ b/drivers/pmdomain/bcm/raspberrypi-power.c
> @@ -232,6 +232,17 @@ static int rpi_power_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static void rpi_power_remove(struct platform_device *pdev)
> +{
> + struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
> + int nr_domains = RPI_POWER_DOMAIN_COUNT - 1;
> +
> + of_genpd_del_provider(pdev->dev.of_node);
> +
> + for (int i = nr_domains; i >= 0; i--)
> + pm_genpd_remove(&rpi_domains->domains[i].base);
> +}
> +
> static const struct of_device_id rpi_power_of_match[] = {
> { .compatible = "raspberrypi,bcm2835-power", },
> {},
> @@ -244,6 +255,7 @@ static struct platform_driver rpi_power_driver = {
> .of_match_table = rpi_power_of_match,
> },
> .probe = rpi_power_probe,
> + .remove = rpi_power_remove,
In general it's not a good idea to allow unbinding power domain
drivers, as it will probably break consumers and their drivers.
Although, I don't know whether it makes sense in this particular case.
Another option is to prevent user-space from unbinding by adding the below here:
".suppress_bind_attrs = true,"
> };
> builtin_platform_driver(rpi_power_driver);
>
Kind regards
Uffe
On Thu, Jul 16, 2026 at 02:28:15PM +0200, Ulf Hansson wrote:
> On Wed, Jul 15, 2026 at 10:16 AM Gregor Herburger
> <gregor.herburger@linutronix.de> wrote:
> >
> > The raspberrypi-power driver registers resources with
> > of_genpd_add_provider_onecell and pm_genpd_init but never removes them.
> > When the driver gets unbound and bound again this causes error. Add a
> > remove function to cleanup all registered resources.
> >
> > Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de>
> > ---
> > drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/pmdomain/bcm/raspberrypi-power.c b/drivers/pmdomain/bcm/raspberrypi-power.c
> > index b87ea7adb7bea..2c2135c17afb0 100644
> > --- a/drivers/pmdomain/bcm/raspberrypi-power.c
> > +++ b/drivers/pmdomain/bcm/raspberrypi-power.c
> > @@ -232,6 +232,17 @@ static int rpi_power_probe(struct platform_device *pdev)
> > return 0;
> > }
> >
> > +static void rpi_power_remove(struct platform_device *pdev)
> > +{
> > + struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
> > + int nr_domains = RPI_POWER_DOMAIN_COUNT - 1;
> > +
> > + of_genpd_del_provider(pdev->dev.of_node);
> > +
> > + for (int i = nr_domains; i >= 0; i--)
> > + pm_genpd_remove(&rpi_domains->domains[i].base);
> > +}
> > +
> > static const struct of_device_id rpi_power_of_match[] = {
> > { .compatible = "raspberrypi,bcm2835-power", },
> > {},
> > @@ -244,6 +255,7 @@ static struct platform_driver rpi_power_driver = {
> > .of_match_table = rpi_power_of_match,
> > },
> > .probe = rpi_power_probe,
> > + .remove = rpi_power_remove,
>
> In general it's not a good idea to allow unbinding power domain
> drivers, as it will probably break consumers and their drivers.
> Although, I don't know whether it makes sense in this particular case.
>
Ok. I stumbled on this when I was trying to fix an error in the remove path of
the raspberrypi-firmware driver. I have not checked if all the drivers still
work so you are probably right.
> Another option is to prevent user-space from unbinding by adding the below here:
> ".suppress_bind_attrs = true,"
That would be the simpler solution. If I add this for this driver, it should
also be added to raspberrypi-firmware and to bcm2835-mbox. Because without those
drivers this driver wouldn't work anyways. Should I add this to those drivers?
And remove the remove callbacks?
>
> > };
> > builtin_platform_driver(rpi_power_driver);
> >
>
> Kind regards
> Uffe
--
Gregor Herburger
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 35; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/legal/data-protection.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Dr. Wilfried Wessner,
Katharina Kopp, Alexander Gieringer
On Mon, Jul 20, 2026 at 7:07 PM Gregor Herburger
<gregor.herburger@linutronix.de> wrote:
>
> On Thu, Jul 16, 2026 at 02:28:15PM +0200, Ulf Hansson wrote:
> > On Wed, Jul 15, 2026 at 10:16 AM Gregor Herburger
> > <gregor.herburger@linutronix.de> wrote:
> > >
> > > The raspberrypi-power driver registers resources with
> > > of_genpd_add_provider_onecell and pm_genpd_init but never removes them.
> > > When the driver gets unbound and bound again this causes error. Add a
> > > remove function to cleanup all registered resources.
> > >
> > > Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de>
> > > ---
> > > drivers/pmdomain/bcm/raspberrypi-power.c | 12 ++++++++++++
> > > 1 file changed, 12 insertions(+)
> > >
> > > diff --git a/drivers/pmdomain/bcm/raspberrypi-power.c b/drivers/pmdomain/bcm/raspberrypi-power.c
> > > index b87ea7adb7bea..2c2135c17afb0 100644
> > > --- a/drivers/pmdomain/bcm/raspberrypi-power.c
> > > +++ b/drivers/pmdomain/bcm/raspberrypi-power.c
> > > @@ -232,6 +232,17 @@ static int rpi_power_probe(struct platform_device *pdev)
> > > return 0;
> > > }
> > >
> > > +static void rpi_power_remove(struct platform_device *pdev)
> > > +{
> > > + struct rpi_power_domains *rpi_domains = platform_get_drvdata(pdev);
> > > + int nr_domains = RPI_POWER_DOMAIN_COUNT - 1;
> > > +
> > > + of_genpd_del_provider(pdev->dev.of_node);
> > > +
> > > + for (int i = nr_domains; i >= 0; i--)
> > > + pm_genpd_remove(&rpi_domains->domains[i].base);
> > > +}
> > > +
> > > static const struct of_device_id rpi_power_of_match[] = {
> > > { .compatible = "raspberrypi,bcm2835-power", },
> > > {},
> > > @@ -244,6 +255,7 @@ static struct platform_driver rpi_power_driver = {
> > > .of_match_table = rpi_power_of_match,
> > > },
> > > .probe = rpi_power_probe,
> > > + .remove = rpi_power_remove,
> >
> > In general it's not a good idea to allow unbinding power domain
> > drivers, as it will probably break consumers and their drivers.
> > Although, I don't know whether it makes sense in this particular case.
> >
> Ok. I stumbled on this when I was trying to fix an error in the remove path of
> the raspberrypi-firmware driver. I have not checked if all the drivers still
> work so you are probably right.
>
> > Another option is to prevent user-space from unbinding by adding the below here:
> > ".suppress_bind_attrs = true,"
>
> That would be the simpler solution. If I add this for this driver, it should
> also be added to raspberrypi-firmware and to bcm2835-mbox. Because without those
> drivers this driver wouldn't work anyways. Should I add this to those drivers?
> And remove the remove callbacks?
Yes, that seems reasonable to me.
[...]
Kind regards
Uffe
© 2016 - 2026 Red Hat, Inc.