All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal
Date: Wed, 31 Jul 2019 10:29:50 -0600	[thread overview]
Message-ID: <CAPnjgZ3x44bgR6XQRQD5unvdF7vTE4HqceLWZczBvn_nK1ar4A@mail.gmail.com> (raw)
In-Reply-To: <20190731180150.3927cd20@crub>

Hi Anatolij,

On Wed, 31 Jul 2019 at 10:01, Anatolij Gustschin <agust@denx.de> wrote:
>
> Hi Simon,
>
> On Thu, 18 Jul 2019 09:22:20 -0600
> Simon Glass sjg at chromium.org wrote:
> ...
> > > >  drivers/core/device-remove.c | 9 +++++++++
> > > >  include/dm/device.h          | 6 ++++++
> > > >  2 files changed, 15 insertions(+)
> >
> > Unfortunately this causes a test failure (make qcheck). Can you please
> > take a look?
>
> The dm power_domain test worked, but later when
>  dm_test_destroy()
>   -> uclass_destroy()
> removes devices, first 'power-domain' device is removed, then
> the 'power-domain-test' device. When removing the latter, we run
>
>  if (!power_domain_get(dev, &pd))
>        power_domain_off(&pd);
>
> and this probes sandbox_power_domain driver for 'power-domain' device
> activating this device again. Then 'power-domain-test' device is removed,
> but 'power-domain' is active. When unbinding it later, we get this error
> in device_unbind():
>
>         if (dev->flags & DM_FLAG_ACTIVATED)
>                 return -EINVAL;

This is because you are not allowed to unbind an active device. You
must deactivate it (device_remove()) first.

>
> Following will fix it:
>
> diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
> index 586fadee0a..fadb05c944 100644
> --- a/drivers/core/device-remove.c
> +++ b/drivers/core/device-remove.c
> @@ -64,7 +64,8 @@ int device_unbind(struct udevice *dev)
>         if (!dev)
>                 return -EINVAL;
>
> -       if (dev->flags & DM_FLAG_ACTIVATED)
> +       if (dev->flags & DM_FLAG_ACTIVATED &&
> +           device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN)
>                 return -EINVAL;
>
>         if (!(dev->flags & DM_FLAG_BOUND))
>
> But I'm not sure if this it the correct approach. What do you think?

That doesn't look right to me. Power supplies should be removed before
being unbound, just like any other device.

Regards,
Simon

  reply	other threads:[~2019-07-31 16:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-14 19:57 [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal Anatolij Gustschin
2019-07-14 19:57 ` [U-Boot] [PATCH v2 2/2] serial: lpuart: request dm device removal when booting OS Anatolij Gustschin
2019-07-15  3:02   ` Peng Fan
2019-07-31 13:11     ` Anatolij Gustschin
2019-07-15  2:59 ` [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal Peng Fan
2019-07-18 15:22   ` Simon Glass
2019-07-31 16:01     ` Anatolij Gustschin
2019-07-31 16:29       ` Simon Glass [this message]
2019-07-31 17:02         ` Anatolij Gustschin
2019-07-23 14:05 ` Lokesh Vutla
2019-07-31 13:13   ` Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPnjgZ3x44bgR6XQRQD5unvdF7vTE4HqceLWZczBvn_nK1ar4A@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.