From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatolij Gustschin Date: Wed, 31 Jul 2019 18:01:50 +0200 Subject: [U-Boot] [PATCH v2 1/2] dm: core: device: switch off power domain after device removal In-Reply-To: References: <20190714195732.31232-1-agust@denx.de> Message-ID: <20190731180150.3927cd20@crub> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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; 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? Thanks, Anatolij