Message ID | 20230329-kunit-devm-inconsistencies-test-v2-0-19feb71e864b@kernel.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8804917vqr; Wed, 28 Jun 2023 03:07:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fO35JH+JU9gBNGnb24510AoUorO+5fZSjhYw2h0lee3hRIGwbC95qhvzcgJhvUvYCdtQP X-Received: by 2002:a05:6808:c2:b0:3a1:a3ea:1c8e with SMTP id t2-20020a05680800c200b003a1a3ea1c8emr15225023oic.41.1687946852573; Wed, 28 Jun 2023 03:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687946852; cv=none; d=google.com; s=arc-20160816; b=aucX+CVyRdkzJhtKA4fDrjngEHWOlTtKQ9d3uMZ16iSyu2ftHnSjLGMltbb7jfymub lwFdfZ7zxQmX+qfneyFPh5LGuIyvk5xI68cSaZ45SMM/f880OIje0eOUncffQ6AUYVoW gjS2YGx53s+nn5QBaEWEdNB0pNJOP4FR911OIKXODNBkelQJU/kDh5ain2xLSPxd9AVE p7rQpUJvfY/lF+s2FEKRxBRSSKyyWQDTiX1RfP2XSYUTqNiGMcpHIoLHyKE3jRg2chZt WPseMlAhVPGmuVhae2h7e2rt6b0WKb7zxCk9JE2VDlkCd/muBYbkUZ3Cv0ofz8O6ikNw SzZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=gUIOU41XtYDOH+JZn+XFDvxvPnh4hTNncTYixSsntUY=; fh=ecJFm7QT1PMAwV6imH2uyLFSpQA9koFc54msGfaixMY=; b=mMoKPcTzd36g7qXBgQrRfDeEGaSqDG4ZfEXKSbtCIiOIkoz+ewXs1a7DlvFIxoTc3F +Qnn9EU8kYOg8JbmqeBKyCJDAnhsfdK/cYciaBUHqACfZC41kZnzBZuY/qzkKcGLBp1l xvDEaz5AAhN6JpoGg523DkwNEotEiDX9QPZiZXeb50WEcLq8eFw3UypbHNBJyjMKq/cg Tuyp77ZAKmFHgUk7H4YJ69fdIw0YqSgu/AaRxBxNqo7NejyXhlIfjhlaIXtgER62yyEh 2kJPFgKTkMPR+46/J50vWAK84A4H/K9FnUZownnVSZ+NTjHMMO5k9BVz74ZdLvJSJONd K1CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rSouGZM4; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x191-20020a6386c8000000b0053fb768afc8si8894544pgd.748.2023.06.28.03.07.04; Wed, 28 Jun 2023 03:07:32 -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=@kernel.org header.s=k20201202 header.b=rSouGZM4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234575AbjF1J6J (ORCPT <rfc822;adanhawthorn@gmail.com> + 99 others); Wed, 28 Jun 2023 05:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233530AbjF1Jy1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 28 Jun 2023 05:54:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0F13584; Wed, 28 Jun 2023 02:50:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 56F4261275; Wed, 28 Jun 2023 09:50:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D230C433C8; Wed, 28 Jun 2023 09:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687945803; bh=TXTgGw22TRrq/yHvL8i1FsJg0CZ5aaXG0yKvftRWvJY=; h=From:Subject:Date:To:Cc:From; b=rSouGZM4ruMEOKCFF8qlJjK3eBoVDscNPwo2NBLOP3rTHuEHxwl8U+C0SQfPZFC/t wV4qM2BxhGZcoToRn7XQYgaUQe7jggMdAQAiZbdJWvOxesGWQ4k6mNG3y47iGFW2FL dq6U1jKA89W+kZPpVAImy/HPlEk/Iu6JDfICmJ6Ji1WQ9rjD2/BJH2u1qepu/eAAMl JbsneY/JcTpCrpx0C3Wkg38e8qcXQXOOGkGMi4c1HDFMGb1Dm3nGZZKN2HZ6iTYVsB Ep4YPtbYzptqPb6THvyNgxsbra0En95h4ARH89f8x19gzh8ROIPMnpzAd3+aLzL3lZ B67/DJJZKZFgg== From: Maxime Ripard <mripard@kernel.org> Subject: [PATCH v2 0/3] drivers: base: Add tests showing devm handling inconsistencies Date: Wed, 28 Jun 2023 11:49:20 +0200 Message-Id: <20230329-kunit-devm-inconsistencies-test-v2-0-19feb71e864b@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIACACnGQC/42OOw7CMBAFr4Jcs8gfQoCKe6AUjr0Qi7BGtmOBo tydJSegnFfMvFlkTAGzOG9mkbCGHCIx6O1GuMHSHSF4ZqGlNtLoEzwmCgU81icEcpFyyAXJsQM K5gINNrb1UuFBesGW3maEPllyA3toGkceXwlv4b1mrx3zwJKYPuuLqn7r/8GqQIIzRulW7o+mb S4OE8VdQS52y7J8AXP4UY/kAAAA To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev>, David Gow <davidgow@google.com>, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard <mripard@kernel.org>, Maxime Ripard <mripard@kernel.org> X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2015; i=mripard@kernel.org; h=from:subject:message-id; bh=TXTgGw22TRrq/yHvL8i1FsJg0CZ5aaXG0yKvftRWvJY=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDClzmDTUP9sEqs069Uby7N36X3usJ61a+2R306SAILvES 1ECRzx2dZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiW5IYGZ7IHj7077PP9wv5 r9+27lMsu9NufeXNQ66aFZyPF547dHwWw38P5maxi9O3rCm9M+/qlXUT7Yzjeo4tUTmheEvQx0h acTMTAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769940558926526046?= X-GMAIL-MSGID: =?utf-8?q?1769940558926526046?= |
Series |
drivers: base: Add tests showing devm handling inconsistencies
|
|
Message
Maxime Ripard
June 28, 2023, 9:49 a.m. UTC
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/
I added the fix David suggested back in that discussion which does fix
the tests. The SoB is missing, since David didn't provide it back then.
Let me know what you think,
Maxime
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
Changes in v2:
- Use an init function
- Document the tests
- Add a fix for the bugs
- Link to v1: https://lore.kernel.org/r/20230329-kunit-devm-inconsistencies-test-v1-0-c33127048375@cerno.tech
---
David Gow (1):
drivers: base: Free devm resources when unregistering a device
Maxime Ripard (2):
drivers: base: Add basic devm tests for root devices
drivers: base: Add basic devm tests for platform devices
drivers/base/core.c | 11 ++
drivers/base/test/.kunitconfig | 2 +
drivers/base/test/Kconfig | 4 +
drivers/base/test/Makefile | 3 +
drivers/base/test/platform-device-test.c | 220 +++++++++++++++++++++++++++++++
drivers/base/test/root-device-test.c | 108 +++++++++++++++
6 files changed, 348 insertions(+)
---
base-commit: 53cdf865f90ba922a854c65ed05b519f9d728424
change-id: 20230329-kunit-devm-inconsistencies-test-5e5a7d01e60d
Best regards,
Comments
On Wed, Jun 28, 2023 at 11:49:20AM +0200, Maxime Ripard wrote: > 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/ > > I added the fix David suggested back in that discussion which does fix > the tests. The SoB is missing, since David didn't provide it back then. Ping? Maxime
On Wed, 28 Jun 2023 at 17:50, Maxime Ripard <mripard@kernel.org> wrote: > > 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/ > > I added the fix David suggested back in that discussion which does fix > the tests. The SoB is missing, since David didn't provide it back then. > > Let me know what you think, > Maxime > > Signed-off-by: Maxime Ripard <maxime@cerno.tech> > --- Whoops, sorry. This managed to hide in my inbox. I think it looks good, and am happy for you to add by SoB to the patch. I've sent out reviews to the others with some small nitpicky things. Thanks a bunch, -- David > Changes in v2: > - Use an init function > - Document the tests > - Add a fix for the bugs > - Link to v1: https://lore.kernel.org/r/20230329-kunit-devm-inconsistencies-test-v1-0-c33127048375@cerno.tech > > --- > David Gow (1): > drivers: base: Free devm resources when unregistering a device > > Maxime Ripard (2): > drivers: base: Add basic devm tests for root devices > drivers: base: Add basic devm tests for platform devices > > drivers/base/core.c | 11 ++ > drivers/base/test/.kunitconfig | 2 + > drivers/base/test/Kconfig | 4 + > drivers/base/test/Makefile | 3 + > drivers/base/test/platform-device-test.c | 220 +++++++++++++++++++++++++++++++ > drivers/base/test/root-device-test.c | 108 +++++++++++++++ > 6 files changed, 348 insertions(+) > --- > base-commit: 53cdf865f90ba922a854c65ed05b519f9d728424 > change-id: 20230329-kunit-devm-inconsistencies-test-5e5a7d01e60d > > Best regards, > -- > Maxime Ripard <mripard@kernel.org> >