From patchwork Wed Mar 29 19:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "maxime@cerno.tech" X-Patchwork-Id: 13193158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50A52C761AF for ; Wed, 29 Mar 2023 19:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbjC2Tku (ORCPT ); Wed, 29 Mar 2023 15:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbjC2Tkg (ORCPT ); Wed, 29 Mar 2023 15:40:36 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC2B61AB; Wed, 29 Mar 2023 12:40:27 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id CDF553200970; Wed, 29 Mar 2023 15:40:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 29 Mar 2023 15:40:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :sender:subject:subject:to:to; s=fm3; t=1680118823; x= 1680205223; bh=2f5rYYd0tlnULsG95qckYDb8lBBCrzn8vdFiBpBskrI=; b=N DjnjQioxravOwTiq91yztIm1lN0V9CX2/jADRcbJ0ZBkr1M3tjp4dX2usXG0fqqO iE3NCrxJo9xTBxLpPz5Q8fu/JAvKIW6qh1MyRpgHq3Qb8I62YYWvmDUAb9ppl/Tr da2o0XYqOHVspIWsEIhxvsKzS2sbD9aNWZRXa9aXDGOMLXH0Xg9vjhds8XyzvOvz 4b3QZPpEHmEzDK9TX+7oZk2TkiieeZtpKvO9WYHQkryrhfsP37nckakRoJm1mA5z il1gpuaVrkav/wX8FiKyKs2BW3M/0guY13wWu+0NrEmTz2pYHw8Yd8Y0Gz9g6kmW lMRTzkFZ2IbPNwF+alGrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1680118823; x=1680205223; bh=2 f5rYYd0tlnULsG95qckYDb8lBBCrzn8vdFiBpBskrI=; b=uyB+3G5WVug9wiQJ3 wBmGqvwq1Y0nG2zLdy4Z3EIeQihQQOAgDKTDzX3RjCUzV0VKfe54cb+B6mAS1Am7 ZG8ZVDgtSX6gwpb5lsg5llXoSOoq7USDKl/pV6ERmaRCjEMzRjCAbbH405I1FktX rp8IxJBak3RTt+urxRVtP3Siq2fcpHPB7/rzvfwsTW0mTg0ZnHpeAQNa8d66zPjT gSC/lVFbxqfgtJfIyad9Jb7LBk++DJe9WG8xL6HhZ5Az79fHRRbANyfjJ9aTSuRV rafkyUyyPsdQ9EvSqZBbmB6QBsFhq1V7gZz/96lKsMuVTqBdPg9S2I0Yn5HWGQ4L bGHaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehiedgudegvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhufffkfggtgfgvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpefguedtjedvieehffevteeijedthfelkeelffehjedthfekheefkeegvdeg iedttdenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggt hh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Mar 2023 15:40:22 -0400 (EDT) From: Maxime Ripard Subject: [PATCH 0/2] drivers: base: Add tests showing devm handling inconsistencies Date: Wed, 29 Mar 2023 20:38:30 +0100 Message-Id: <20230329-kunit-devm-inconsistencies-test-v1-0-c33127048375@cerno.tech> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALaTJGQC/x3NwQ6CMBCE4Vche3aTUoJGX8V4KO0oG3Ex3UJIC O9u4/Gfwzc7GbLA6NbslLGKyaw12lNDcQz6AkuqTd75znX+yu9FpXDC+mHROKuJFWisBhdY4R5 9uCTX4uwSVWUIBh5y0DhWR5dpquM34ynb//b+OI4fTB2fkoYAAAA= To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Brendan Higgins , David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1519; i=maxime@cerno.tech; h=from:subject:message-id; bh=JFmIiuIgbQg8/mhZab8A/LJP1D9dGdFGvbtghkhMhpU=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCkqk3dtrFtfvGp912q5/0vkI/UYvZ5utz1z7nXwo9r3T GsidetrOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRShWGn4yJqmYmgmHMDaLX Q59V1x/4KHmE/ZHxHbXw+jOM+x4/Oc7I0NtytSArOXHlYwc7xUNxq39a8d95b1MszJ63Qlc6f90 eBgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Hi, This follows the discussion here: https://lore.kernel.org/linux-kselftest/20230324123157.bbwvfq4gsxnlnfwb@houat/ This shows a couple of inconsistencies with regard to how device-managed resources are cleaned up. Basically, devm resources will only be cleaned up if the device is attached to a bus and bound to a driver. Failing any of these cases, a call to device_unregister will not end up in the devm resources being released. We had to work around it in DRM to provide helpers to create a device for kunit tests, but the current discussion around creating similar, generic, helpers for kunit resumed interest in fixing this. This can be tested using the command: ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/base/test/ Let me know what you think, Maxime Signed-off-by: Maxime Ripard --- Maxime Ripard (2): drivers: base: Add basic devm tests for root devices drivers: base: Add basic devm tests for platform devices drivers/base/test/.kunitconfig | 2 + drivers/base/test/Kconfig | 4 + drivers/base/test/Makefile | 3 + drivers/base/test/platform-device-test.c | 278 +++++++++++++++++++++++++++++++ drivers/base/test/root-device-test.c | 120 +++++++++++++ 5 files changed, 407 insertions(+) --- base-commit: a6faf7ea9fcb7267d06116d4188947f26e00e57e change-id: 20230329-kunit-devm-inconsistencies-test-5e5a7d01e60d Best regards,