From patchwork Fri Jun 2 15:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13265497 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 764CBC7EE24 for ; Fri, 2 Jun 2023 15:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236548AbjFBPUw (ORCPT ); Fri, 2 Jun 2023 11:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236245AbjFBPUv (ORCPT ); Fri, 2 Jun 2023 11:20:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2483718C; Fri, 2 Jun 2023 08:20:50 -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 B590B6176E; Fri, 2 Jun 2023 15:20:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7545C433D2; Fri, 2 Jun 2023 15:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685719249; bh=JrdWhqdwYCo5+dxpyaTBpOM09b+3lqOKw8HosotnMs0=; h=From:Subject:Date:To:Cc:From; b=h7knj2B5GdpIqG30KBjAmBUV7y4Y2EqxsA8SDIG1kJB05mbthV5F579lioekLHG59 zDnBn8LOr1eTgmCyd5BtOXiry8vkipsS7M0YyELkzh/OlkCW4k7h1X8b+ByCu/ASEa uePeEu5HrE7Pm/qd9bnB8QggpmzsrYJuf/unXWRv+2pw+AUb2QSSCIxIoUCMz8Aph0 m3FLu94JvZv/6u2JwjS39wMIyyGMAKDNoin8whj8a1Rxx6hBw/jB85G/hLlUA8Hcvl Nwt/Cts0k4s6khrOLkeGTT0dx61LjRzAUrZ97t99xcXd38fb7cWxUGYt2Z5OEHV5HI d/jK6YA4963GA== From: Maxime Ripard Subject: [PATCH RESEND 0/2] drivers: base: Add tests showing devm handling inconsistencies Date: Fri, 02 Jun 2023 17:20:42 +0200 Message-Id: <20230329-kunit-devm-inconsistencies-test-v1-0-015b1574d673@kernel.org> MIME-Version: 1.0 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.13-dev-02a79 X-Developer-Signature: v=1; a=openpgp-sha256; l=1520; i=mripard@kernel.org; h=from:subject:message-id; bh=JrdWhqdwYCo5+dxpyaTBpOM09b+3lqOKw8HosotnMs0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDClVHOdeLlF4eeoU99T1PBu/a+a6zLhmWfjOkqNW2zjkhVVv 98rzHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZhIiSXD/8grpcxXFgQ1Mi1/zT9XdP Mn4QvHJSIubRT7vOoj9yLLzgeMDBtv6m1TYXv2bTlT/ueKhqZZbS2Fh3j3GCxQsn/26aiXBwcA X-Developer-Key: i=mripard@kernel.org; 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,