History log of /linux-master/drivers/base/test/root-device-test.c
Revision Date Author Comments
# f7bb2426 16-Aug-2023 Maxime Ripard <mripard@kernel.org>

drivers: base: test: Add missing MODULE_* macros to root device tests

Commit 06188bc80ccb ("drivers: base: Add basic devm tests for root
devices") introduced a new set of tests for root devices that could be
compiled as a module, but didn't have the usual module macros.

Make sure they're there.

Fixes: 06188bc80ccb ("drivers: base: Add basic devm tests for root devices")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230816073019.1446155-2-mripard@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 699fb50d 20-Jul-2023 David Gow <davidgow@google.com>

drivers: base: Free devm resources when unregistering a device

In the current code, devres_release_all() only gets called if the device
has a bus and has been probed.

This leads to issues when using bus-less or driver-less devices where
the device might never get freed if a managed resource holds a reference
to the device. This is happening in the DRM framework for example.

We should thus call devres_release_all() in the device_del() function to
make sure that the device-managed actions are properly executed when the
device is unregistered, even if it has neither a bus nor a driver.

This is effectively the same change than commit 2f8d16a996da ("devres:
release resources on device_del()") that got reverted by commit
a525a3ddeaca ("driver core: free devres in device_release") over
memory leaks concerns.

This patch effectively combines the two commits mentioned above to
release the resources both on device_del() and device_release() and get
the best of both worlds.

Fixes: a525a3ddeaca ("driver core: free devres in device_release")
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230720-kunit-devm-inconsistencies-test-v3-3-6aa7e074f373@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 06188bc8 20-Jul-2023 Maxime Ripard <mripard@kernel.org>

drivers: base: Add basic devm tests for root devices

The root devices show some odd behaviours compared to regular "bus" devices
that have been probed through the usual mechanism, so let's create kunit
tests to exercise those paths and odd cases.

It's not clear whether root devices are even allowed to use device
managed resources, but the fact that it works in some cases but not
others like shown in that test suite shouldn't happen either way: we
want to make it consistent and documented.

These tests will (after the following patches) ensure that consistency
and effectively document that it's allowed.

If it ever turns out to be a bad idea, we can always roll back and
modify the tests then.

Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20230720-kunit-devm-inconsistencies-test-v3-1-6aa7e074f373@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>