Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp622715rdg; Thu, 10 Aug 2023 13:50:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjR/2dTNiMBMAbvtqE+/yQPtsOdzT6CIzuE6fTZz/VMc9gbLdglXL3P0A9NFAoEne5PY8K X-Received: by 2002:a05:6a00:15d6:b0:63d:260d:f9dd with SMTP id o22-20020a056a0015d600b0063d260df9ddmr3977604pfu.33.1691700656424; Thu, 10 Aug 2023 13:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691700656; cv=none; d=google.com; s=arc-20160816; b=h0cPUh7B0g2d7R3e17iRvr6N/TLL4Qr5QCwxeDNrR6EznWDqr0oXrNefsuBEe8j7RY 6EvKKo5R5i7CZdgqDQOe7Aj/y42J6la7iIQ5OfXWvQwfLiFgk4CMpjlFRQA+loDo2QYD a3diO96M+XqXzVSp+RcNKOxuDIJPntfr1S8QlKeH3d8ppeo7N6Ug7mLFoe/2Kn9XhFSY z+lLz5vGEpWH/urQE/YSnELa5N4hw0XJ6GwNT60ee0XFLl1otsyK5MoecJC0q9rQ9SYs PDmDFAE7Hev1Fq6NhAiAEialwdNEwgfzq9rSMHP+WYHvzVnj9In2oPc0kd5VyP/zUTxq N+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nBJ9UhRIjG48zu1mTMyk63nh2JV7PG3+MifRrnnzCfg=; fh=ywlmh1bYh1Do4oyw4xtkw0FSLSabsw5CuKMNebDIQXk=; b=p/nek1rEkVrI9lTHeINRkqBGDzMbvvuYccZka78np0Q6ZzBiZ4mAhXpu5zcgvjZ9N1 Vh3ItSU4ojAGYL8S8bJKw7hcSgckV6GspWhnF2QZpSjAQUeCTBDp53F1RzFejARrLvse NOW/dUro3q0BRAEIuXXQCzO7IbirQ2MoyfQHx1XdePBe4Kad9oigwhoZaCZlLtcTcivp iem3an4246OSoq4Qh9W1ocKIYm6KclQ2j0vfyJJvPIWTdeGIGr+cjDDBBw1m2x/ny01M jOyIPYObJ9g2xKzcAQq7dy9XzqcXroEwJViid7yZY2J/2nLGkVCbi/3esJwb0QxzL214 CwHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bTQUuyaT; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j17-20020a056a00235100b006872dd77e47si2170971pfj.155.2023.08.10.13.50.43; Thu, 10 Aug 2023 13:50:56 -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=@collabora.com header.s=mail header.b=bTQUuyaT; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235397AbjHJUY0 (ORCPT + 99 others); Thu, 10 Aug 2023 16:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjHJUYZ (ORCPT ); Thu, 10 Aug 2023 16:24:25 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8E112136; Thu, 10 Aug 2023 13:24:22 -0700 (PDT) Received: from notapiano.myfiosgateway.com (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id F0BD46607234; Thu, 10 Aug 2023 21:24:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691699061; bh=mfSXUsLYLqVGYNrw2dZQqMTMToZ4UamGbospLR4IvHs=; h=From:To:Cc:Subject:Date:From; b=bTQUuyaTsT4EW5uT9OWjFc8TsukuzocVCxxs9n7j/GmeMBx2LLhm6jgXKjgYLMaCz ZljCRyzgyBMvdz2eRnnUPFyWLTQDH1OI27p8Xnxb19S9h0dybbnyc7LQRRvKQY7G3X y2Izdgt26uuhj0vssozDzgG+G7biJDBpGT/Nch1NkZm55YNWqUIKhLRZ8HnnZGuqU5 q1+S87MJaAuVUhJ8iHenz++PbiZsLxaYLjYPBrEJkiPo+d7nF3q4x2pTWmjmp+au0D /mx986LwBtszj9tEdB8ruQLIQ4scrw0enrywTFIETmKeedCSZbLJB8WDecqBTTAD7Q 79ghEnvWiapkg== From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Rob Herring , Frank Rowand , Shuah Khan Cc: cocci@inria.fr, Mark Brown , Nicolas Palix , kernelci@lists.linux.dev, Julia Lawall , Bjorn Andersson , kernel@collabora.com, Guenter Roeck , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH 0/2] Add a test to catch unprobed Devicetree devices Date: Thu, 10 Aug 2023 16:23:49 -0400 Message-ID: <20230810202413.1780286-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org Regressions that cause a device to no longer be probed by a driver can have a big impact on the platform's functionality, and despite being relatively common there isn't currently any generic test to detect them. As an example, bootrr [1] does test for device probe, but it requires defining the expected probed devices for each platform. Given that the Devicetree already provides a static description of devices on the system, it is a good basis for building such a test on top. This series introduces a test to catch regressions that prevent devices from probing. Patch 1 introduces a script to parse the kernel source using Coccinelle and extract all compatibles that can be matched by a Devicetree node to a driver. Patch 2 adds a kselftest that walks over the Devicetree nodes on the current platform and compares the compatibles to the ones on the list, and on an ignore list, to point out devices that failed to be probed. A compatible list is needed because not all compatibles that can show up in a Devicetree node can be used to match to a driver, for example the code for that compatible might use "OF_DECLARE" type macros and avoid the driver framework, or the node might be controlled by a driver that was bound to a different node. An ignore list is needed for the few cases where it's common for a driver to match a device but not probe, like for the "simple-mfd" compatible, where the driver only probes if that compatible is the node's first compatible. Even though there's already scripts/dtc/dt-extract-compatibles that does a similar job, it didn't seem to find all compatibles, returning ~3k, while Coccinelle found ~11k. Besides that, Coccinelle actually parses the C files, so it should be a more robust solution than relying on regexes. The reason for parsing the kernel source instead of relying on information exposed by the kernel at runtime (say, looking at modaliases or introducing some other mechanism), is to be able to catch issues where a config was renamed or a driver moved across configs, and the .config used by the kernel not updated accordingly. We need to parse the source to find all compatibles present in the kernel independent of the current config being run. Feedback is very much welcome. Thanks, NĂ­colas [1] https://github.com/kernelci/bootrr NĂ­colas F. R. A. Prado (2): scripts/dtc: Add script to extract matchable DT compatibles kselftest: Add Devicetree unprobed devices test scripts/dtc/extract-matchable-dt-compatibles | 33 +++++++++++ scripts/dtc/matchable_dt_compatibles.cocci | 58 +++++++++++++++++++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/dt/.gitignore | 1 + tools/testing/selftests/dt/Makefile | 17 ++++++ .../selftests/dt/compatible_ignore_list | 3 + .../selftests/dt/test_unprobed_devices.sh | 58 +++++++++++++++++++ 7 files changed, 171 insertions(+) create mode 100755 scripts/dtc/extract-matchable-dt-compatibles create mode 100644 scripts/dtc/matchable_dt_compatibles.cocci create mode 100644 tools/testing/selftests/dt/.gitignore create mode 100644 tools/testing/selftests/dt/Makefile create mode 100644 tools/testing/selftests/dt/compatible_ignore_list create mode 100755 tools/testing/selftests/dt/test_unprobed_devices.sh -- 2.41.0