Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2279058iof; Wed, 8 Jun 2022 01:14:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMDkckiBajl+qqJJtUrygY/6zKAlte55OjQrB0DE8aEblvP74BYr8rgBT61zNpbsOWERCt X-Received: by 2002:a17:90a:5792:b0:1e0:63f3:b3ba with SMTP id g18-20020a17090a579200b001e063f3b3bamr36658206pji.102.1654676078034; Wed, 08 Jun 2022 01:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676078; cv=none; d=google.com; s=arc-20160816; b=WdZstzzUPO64YjwtFbxojSUtQRDHk85WZFSeb4QC9c89V2UkJSEAymQqVn9vLVM3oX dYlfYUs99/NNPIYiQn7meFJIsb6dJjJVaSuLDkmcmOjAHkmalZDP44/nddhfQc749Odn NQL0n1CQ+lFbEGTcZscinayqstwGMsDx/abYBsWjC9z/9q9Y0XaWGnfgy9qVKt8sjFSW 0KUrDbKDhrOzjcXmNDumLy+a8RFfmV+yICAZI437OEsC3kJ484ww7nHxLhtLlaFJt1w7 /cxJKpEmRH009+xYYDwAqFCNbbKF1EufMhAALLFoCl4q5l8VEVRErwdt0I3SU8pjXmhV yAng== 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=+J857YNMMMQ5w3bvE9jqHH7YibIuROCxLYRf6MrAtu8=; b=hUCStHzFZgDc5fKlEtOSMX5gD8EqkUnBPn5mwyrRbdut7h4O3TrcWPy8VZ/YT7J7If T3JXpFOlx/SVQifAjY1/1jOOqfscPptQlf9nX0K2rCElgyyNgeg4Oc2nhtn9Zta9XW05 42dmWpBNwtWs9daIpQdD2+5XOzGotoN6L9g7WFV2tJwYhoPLoYnWpmwiPQeWvN0ZK+C9 aBh0XbOqhBP30dqoyUyTjGUaMRP8jb52WPShAapIjB3Zog7kBWdSMu5/16L96/4jHrvq 3GyDKiDaXWpONVk/Ee97BWq4n9v4BQfWcz0zX//bacLSFf4Vdw/6Mg0FJlP7iG81EMYe 5eQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=MDWHVEE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q14-20020a17090311ce00b0016151c9be11si6832835plh.468.2022.06.08.01.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=MDWHVEE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CEEE8279E65; Wed, 8 Jun 2022 00:46:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiFHD6Q (ORCPT + 99 others); Tue, 7 Jun 2022 23:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbiFHD54 (ORCPT ); Tue, 7 Jun 2022 23:57:56 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A28D724D79B for ; Tue, 7 Jun 2022 18:08:42 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id s8so20937185oib.6 for ; Tue, 07 Jun 2022 18:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+J857YNMMMQ5w3bvE9jqHH7YibIuROCxLYRf6MrAtu8=; b=MDWHVEE5OzY2DQyQ6red2gjy4n7vHwB0kVupUVsK5YtAByOH1rcy1BcZF0I5gThZv+ nkqWYntc7WmFACew50y/zloW9F3wE1JZ5HoLQ3mouSSvObEV1duXayqZEkqHN5kCfA4K RRQoNDbLG1un4AJqo84pbrHcHsKgQ1sDguHC+mU+NVdL+4+ptDJ7GTdV2cbmwevLdAmn NpJ/s14zJAdCCO+//dnaS1InAShvzQxwf/HUGOxvJQNiS7YNhs+dp+WPglZAhSkmS1z6 q8tCeZkOAlqB4fXjuio19j9Rjh9X/0ZIO1xaAmHFdMotm8glE9VJWJjiILw9TTXuupaJ CQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+J857YNMMMQ5w3bvE9jqHH7YibIuROCxLYRf6MrAtu8=; b=aRaIuA+UXxtEcy7On1uiwZDtg3bCaDwJ1UcwDnQYuAKXL7WCRAYGR4sHV1PkzVNFGa X6PPikJ7WSywvxFiNX4R6z1D/ItY2ukzUBLtJxZgm2F1+HTqoq9Q+zUMNC9VvQHgD5Q2 9hrAVLv8RFt9epKv65xdOKVtc/4MECRp+nQjafH7eMh+yzPozunhg6BkNk+lBvzcEjKB 2FvTYY7icq6YNQ6GpXzWD69mIoebBAXDZUdOK4+H/WEmTfhjiCD27cckFR9aMj5JfoxH pLDWCl7fRc23tPK9WMYy/zIGjmekCGey4f2EmICy0wSLuOk+JHfdVjjU3xIHToRBoUsC vRqg== X-Gm-Message-State: AOAM532na1pE/2BNuNIK5m5CgFdfYVnLA2iCwwzoKs7tw2Bn1ro3wYUH cjNV3Ra2nICMOedxgdsskNmJLg== X-Received: by 2002:a05:6808:1151:b0:32e:362f:d4b4 with SMTP id u17-20020a056808115100b0032e362fd4b4mr1052688oiu.244.1654650521895; Tue, 07 Jun 2022 18:08:41 -0700 (PDT) Received: from fedora.. ([2804:14d:8084:84c6:fe26:c42d:aab9:fa8a]) by smtp.gmail.com with ESMTPSA id c16-20020a544e90000000b0032b1b84f4e3sm10343057oiy.22.2022.06.07.18.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 18:08:41 -0700 (PDT) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , christian.koenig@amd.com, Dmytro Laktyushkin , Jun Lei , Nicholas Choi , Harrison Chiu , Mark Yacoub , Sean Paul , Daniel Vetter , Javier Martinez Canillas , Isabella Basso , magalilemes00@gmail.com, tales.aparecida@gmail.com, mwen@igalia.com, andrealmeid@riseup.net, David Gow , Daniel Latypov , brendanhiggins@google.com Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [RFC 0/3] drm/amd/display: Introduce KUnit to Display Mode Library Date: Tue, 7 Jun 2022 22:07:07 -0300 Message-Id: <20220608010709.272962-1-maira.canal@usp.br> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This RFC is a preview of the work being developed by Isabella Basso [1], Maíra Canal [2], and Tales Lelo [3], as part of their Google Summer of Code projects [4], and Magali Lemes [5], as part of her capstone project. Our main goal is to bring unit testing to the AMDPGU driver; in particular, we'll focus on the Display Mode Library (DML) for DCN2.0 and some of the DCE functions. The modern AMD Linux kernel graphics driver is the single largest driver in the mainline Linux codebase [6]. As AMD releases new GPU models, the size of AMDGPU drivers is only becoming even larger. Assuring the drivers' quality and reliability becomes a complex task without systematic testing, especially for graphic drivers - which usually involve tons of complex calculations. Also, keeping bugs away becomes an increasingly hard task with the introduction of new code. Moreover, developers might want to refactor old code without fear of the introduction of new issues. In that sense, it is possible to argue for the benefits of implementing unit testing at the AMDGPU drivers. This implementation will help developers to recognize bugs before they are merged into the mainline and also makes it possible for future code refactors of the AMDGPU driver. When analyzing the AMDGPU driver, a particular part of the driver highlights itself as a good candidate for the implementation of unit tests: the Display Mode Library (DML), as it is focused on mathematical operations. For the implementation of the tests, we decided to go with the Kernel Unit Testing Framework (KUnit). KUnit makes it possible to run test suites on kernel boot or load the tests as a module. It reports all test case results through a TAP (Test Anything Protocol) in the kernel log. Moreover, KUnit unifies the test structure and provides tools to simplify the testing for developers and CI systems. That said, we developed a little snippet on what we intend to develop in our summer. We planned the basic structure on how the tests will be introduced into the codebase and, on the concern of the CI systems, developed a structure where the unit tests can be introduced as modules and run on IGT (the IGT patch will be introduced soon). The way the modules are implemented might seem a little unusual for KUnit developers. We need to call the KUnit init function inside the AMDGPU stack, otherwise, the test won't compile as a module. So, the solution to this problem was based on the unit tests for the Thunderbolt driver, which uses KUnit and also tests a physical driver. As kunit_test_suites() defines itself as an init_module(), it conflicts with the existing one at amdgpu_drv. So, if we use kunit_test_suites(), we won't be able to compile the tests as modules and, therefore, won't be able to use IGT to run the tests. This problem with kunit_test_suites() was already discussed in the KUnit mailing list, as can be seen in [7]. The first patch configures the basic structure of the KUnit Tests, setting the proper Makefile, Kconfig, and init function. It also contains a simple test involving DML logging, which is the pretext for building the testing structure. The second patch adds KUnit tests to bw_fixed functions. This patch represents what we intend to do on the rest of the DML modules: systematic testing of the public functions of the DML, especially mathematically complicated functions. Also, it shows how simple it is to add new tests to the DML with the structure we built. Any feedback or ideas for the project are welcome! [1] https://crosscat.me [2] https://mairacanal.github.io [3] https://tales-aparecida.github.io/ [4] https://summerofcode.withgoogle.com/programs/2022/organizations/xorg-foundation [5] https://magalilemes.github.io/ [6] https://www.phoronix.com/scan.php?page=news_item&px=AMDGPU-Closing-4-Million [7] https://groups.google.com/g/kunit-dev/c/hbJbh8L37FU/m/EmszZE9qBAAJ - Isabella Basso, Magali Lemes, Maíra Canal, and Tales Lelo Magali Lemes (1): drm/amd/display: Introduce KUnit tests to the bw_fixed library Maíra Canal (2): drm/amd/display: Introduce KUnit to DML drm/amd/display: Move bw_fixed macros to header file drivers/gpu/drm/amd/display/Kconfig | 1 + .../gpu/drm/amd/display/amdgpu_dm/Makefile | 5 + .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 + .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 + .../drm/amd/display/amdgpu_dm/tests/Kconfig | 41 +++ .../drm/amd/display/amdgpu_dm/tests/Makefile | 18 + .../amdgpu_dm/tests/calcs/bw_fixed_test.c | 322 ++++++++++++++++++ .../amdgpu_dm/tests/display_mode_lib_test.c | 83 +++++ .../amd/display/amdgpu_dm/tests/dml_test.c | 26 ++ .../amd/display/amdgpu_dm/tests/dml_test.h | 21 ++ .../drm/amd/display/dc/dml/calcs/bw_fixed.c | 14 +- drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h | 14 + 12 files changed, 538 insertions(+), 13 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/Kconfig create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/calcs/bw_fixed_test.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/display_mode_lib_test.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/dml_test.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/dml_test.h -- 2.36.1