Re: [PATCH] pmdomain: raspberrypi-power: add remove function
From: Ulf Hansson
Date: Fri Jul 24 2026 - 11:21:34 EST
On Mon, Jul 20, 2026 at 7:07 PM Gregor Herburger
<gregor.herburger@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>
> > > ---
> > > 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