Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2818478rwl; Mon, 27 Mar 2023 05:52:17 -0700 (PDT) X-Google-Smtp-Source: AK7set88UEaBlV0CqIw9uV46rmkVgszbVIb0zEITzUxJ1crA/gjOZ7O9NXernCqqDUu858jsAFgV X-Received: by 2002:a05:6402:1c95:b0:4af:7bdc:188e with SMTP id cy21-20020a0564021c9500b004af7bdc188emr19821512edb.16.1679921537189; Mon, 27 Mar 2023 05:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679921537; cv=none; d=google.com; s=arc-20160816; b=e9sLp+sSJp5oct2cz7bmyDx7OMdZiu/eSx7HM3i2W2w6rA7V2B9Nx9psXCnivXi6TL 8b3mnVZpNjoL0+1z0XD7WwJsS7CPHfOI79IvCSXfV4+DFq3OuQuZUFJYkGTmt3SLJ8Dw 8o/z2uqioaxBZXEcUmM0Y66+AAHf2z9+Y6ENOi6lmfB+UWiA0ckuIwBt34/MILuxmpt3 oHvgcSDeiVfeWq43lRFcKEjr53zW19zUfftOfQvlVBCWAgJnWbR7tFkCUc0Rs+JeOFMQ r/IGqH+HsxsZr4ByflvdTzIvKpaFN2Kx/VVWNPoNchhJRGZBiUF2QIaexxzOsaX4bFrq EfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1iYHOK9KNTbcJXLxdhM7myZv2+5ROceMFwk094WPuyI=; b=XyhgxA2KqCISKNUCTI6qBZYh8eXVUS29KHwEZ99YVR0KyL2SuVvb+PeV3G9/2gYP9A Sbedliav1UpeYQoMukjV5khaAPOPk5pGrc/6d6sDDIsKj6AXgVcZgADpZoqObRPXMDTj tj69OZHR2lJ7rH268q3qc2UIv7nLaehD9Mq3c1cL9OuR1F9Qhtme0Ny5cOySn6+rFgub k2dbRN5CpBP67jo+Kcux/4hdITZ62SPeWbBABCu4/D/wSFn5f6Yk0Eu1nejC3Lc/NVQU 7Y3Mhfs3Mpn1ID//sF4Hv7mHgvx/x0u0tjJm6Z5j1xJUWTWCaNTZZEIbmKi3KH9Iakot 0aWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cad8Xbf1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020aa7c24e000000b004ad15de0646si6893220edo.591.2023.03.27.05.51.52; Mon, 27 Mar 2023 05:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cad8Xbf1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232479AbjC0MiW (ORCPT + 99 others); Mon, 27 Mar 2023 08:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjC0MiU (ORCPT ); Mon, 27 Mar 2023 08:38:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37BECAF; Mon, 27 Mar 2023 05:38:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF5B861206; Mon, 27 Mar 2023 12:38:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 916B3C433D2; Mon, 27 Mar 2023 12:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1679920697; bh=KxbO7jAho7Gxlmbj4qdAOWGx1lnUEAI6qIGD0FU9SII=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cad8Xbf1NAyZ5Rbhr2WBgcGtsvzvKx+StVK+y4x0TGIEQIcbR4YnaZPA5jcRVMgXN PXDjBbg94fIVx75JUxTqYvUpWs+oa0kfL1aJzpjDBKSBcyxtnUYm9ASAWFuIt/bZDh SDNHWnFLsw8Nzjtd8DXgbL4pIjjoHc1p33GUkb9E= Date: Mon, 27 Mar 2023 14:38:14 +0200 From: Greg Kroah-Hartman To: Matti Vaittinen Cc: Matti Vaittinen , Brendan Higgins , David Gow , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Stephen Boyd , Jonathan Cameron , linux-iio@vger.kernel.org Subject: Re: [PATCH v6 3/7] kunit: Add kunit wrappers for (root) device creation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 27, 2023 at 03:20:06PM +0300, Matti Vaittinen wrote: > On 3/27/23 15:01, Greg Kroah-Hartman wrote: > > On Mon, Mar 27, 2023 at 02:34:02PM +0300, Matti Vaittinen wrote: > > > A few tests need to have a valid struct device. One such example is > > > tests which want to be testing devm-managed interfaces. > > > > > > Add kunit wrapper for root_device_[un]register(), which create a root > > > device and also add a kunit managed clean-up routine for the device > > > destruction upon test exit. > > > > I really do not like this as a "root device" is a horrible hack and > > should only be used if you have to hang other devices off of it and you > > don't have a real device to tie those devices to. > > > > Here you are abusing it and attempting to treat it as a real device, > > which it is not at all, because: > > > > > Special note: In some cases the device reference-count does not reach > > > zero and devm-unwinding is not done if device is not sitting on a bus. > > > The root_device_[un]register() are dealing with such devices and thus > > > this interface may not be usable by all in its current form. More > > > information can be found from: > > > https://lore.kernel.org/dri-devel/20221117165311.vovrc7usy4efiytl@houat/ > > > > See, not a real device, doesn't follow normal "struct device" rules and > > lifetimes, don't try to use it for a test as it will only cause problems > > and you will be forced to work around that in a test. > > Ok. I understood using the root-device has been a work-around in some other > tests. Thus continuing use it for tests where we don't need the bus until we > have a proper alternative was suggested by David. > > > Do the right thing here, create a fake bus and add devices to it. > > > > Heck, I'll even write that code if you want it, what's the requirement, > > something like: > > struct device *kunit_device_create(struct kunit *test, const char *name); > > void kunit_device_destroy(struct device *dev); > > Thanks for the offer Greg. This, however, is being already worked on by > David. I don't want to step on his toes by writing the same thing, nor do I > think I should be pushing him to rush on his work. Ok, David, my offer stands, if you want me to write this I will be glad to do so. thanks, greg k-h