Re: [PATCH v2 1/3] drivers: base: Add basic devm tests for root devices

From: Maxime Ripard
Date: Thu Jul 20 2023 - 07:29:29 EST


Hi David,

On Wed, Jul 19, 2023 at 05:13:45PM +0800, David Gow wrote:
> On Wed, 28 Jun 2023 at 17:49, Maxime Ripard <mripard@xxxxxxxxxx> wrote:
> >
> > 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.
> >
> > Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>
> > ---
>
> Reviewed-by: David Gow <davidgow@xxxxxxxxxx>

Thanks!

> There's definitely an argument that root devices are not supposed to
> be like regular devices, and so devm_ managed resources aren't
> supposed to work with them. Either way:
> - It needs to be documented somewhere (and this test makes for good
> documentation, IMO).
> - It should be consistent: if devm_ isn't to be used with root
> devices, it should fail everywhere, and if it is, it should work in
> all the cases below.
>
> So I'm all in favour of including this test and making root devices work.

I agree 100%. I've reworded the commit log a bit to make it clearer
that's what we should strive for, and that this is what this patch is
doing.

> That being said, I am planning to send out a patchset adding a struct
> kunit_device for use in tests, which will be attached to a "kunit"
> bus. I think the combination of "fix devm_ with root devices" and
> "don't recommend root devices as a 'fake' device for testing" is
> probably the longer-term solution everyone can agree upon?

Yeah, that sounds reasonable to me

Maxime