From patchwork Wed May 15 11:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karolina Stolarek X-Patchwork-Id: 13665104 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23524C25B75 for ; Wed, 15 May 2024 11:24:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DD1E10E6B6; Wed, 15 May 2024 11:24:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XcHurmEQ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B33210E6B6 for ; Wed, 15 May 2024 11:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715772288; x=1747308288; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EWAOSW4gnvHapeXdFI3BNviznFd4a/WjWr/t8USuS1I=; b=XcHurmEQBpANk3OgreDyKFzGk8p4XQzHslNHuM0eYNXfX716AEUsww1+ IbVHZ42QS5y0eTufnPgL9pxYdbbf6paWYDEEktu87QedjqEUsIXU8ktop 2aKFtwq72QS1MRYjTI8XXfkKQm5p/mjH7sJ7Gu/cd7Tbz3wkU8yhxw80N 5PPnGXJ0bHWs4nTzQg1P+/67ZrSzX022vWZZ/H9ZZA4T/JoVjNq2xGNhZ N5DTFqCHstiEKdZp8auhNbIsxOQ0RLRt3L9YqDI0aDFikE3/Fdjq/ecwP 5JZaJM14F+3Av6hcaiaILD7ieXQGFL07HZq5MABK+N0OhkjPaZf/MA/LG w==; X-CSE-ConnectionGUID: fTpeMqHOSpW1O0+TUlJWTw== X-CSE-MsgGUID: JAxtXGSKTviXXje8JhjTMw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="22955370" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="22955370" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 04:24:48 -0700 X-CSE-ConnectionGUID: U98+K3esTe2Wy5UAfIpv9A== X-CSE-MsgGUID: 2N4i8KJMRf2gfX2I7E8l7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="30955189" Received: from maurocar-mobl2.ger.corp.intel.com (HELO kdrobnik-desk.toya.net.pl) ([10.245.245.149]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 04:24:45 -0700 From: Karolina Stolarek To: dri-devel@lists.freedesktop.org Cc: =?utf-8?q?Christian_K=C3=B6nig?= , Matthew Auld , Amaranath Somalapuram , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Karolina Stolarek Subject: [PATCH v12 00/10] Improve test coverage of TTM Date: Wed, 15 May 2024 13:24:23 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce tests for ttm_bo_validate()/ttm_bo_init_validate() that exercise simple BO placement as well as eviction (including the case where the evict domain also requires eviction to fit the incoming buffer). Prepare KUnit helpers to handle such scenarios and add a mock VRAM manager. This series also includes some updates to the helpers and more definitions used to define "special" memory domains (e.g., one that can't allocate resources or is busy), as well as drive-by fixes for the tests. There are a couple of areas in which this test suite can be improved. Suggestions for future work can be found in the TODO file. Use kunit_tool script to manually run all the tests: $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/ttm/tests To build a kernel with TTM KUnit tests, use a UML configuration, enable CONFIG_KUNIT, and then select CONFIG_DRM_TTM_KUNIT_TEST. Many thanks, Karolina v12: - Rewrite "drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk" patch to extend ttm_bo_kunit_init() helper to accept a dma_resv object and update calls to that helper (Christian) - Update drm_buddy_free_list() calls with an extra argument v11: - Delete CONFIG_DRM_KUNIT_TEST_HELPERS from .kunitconfig file, as it gets automatically selected when TTM KUnit tests are enabled - Call ttm_bo_put() in ttm_bo_validate_pinned() test case (Matt) - Fix a copy-paste mistake in ttm_mem_type_cases definition (Matt) - Update mock_move definition to do a hop on VRAM -> sysmem move and delete a dummy multihop domain. Fix the eviction tests accordingly (Matt) - Update ttm_bo_validate_swapout() to use TT domain instead of VRAM - Update eviction test cases to create TT domain, so they can perform multihop - Update TODO file, as it got outdated already v10: Many things have happened over the course of three months, so the series had to be slightly reworked and expanded to accommodate these changes: - Set DMA coherent mapping mask in the KUnit device so ttm_pool_alloc tests can be executed - Update ttm_bo_validate_invalid_placement() test case to check against the right return error. It's no longer -EINVAL (which only is returned for pinned buffers), but -ENOMEM. The behaviour has changed in commit cc941c70df39 ("drm/ttm: improve idle/busy handling v5") - Rework ttm_placement_kunit_init() to accept only one array of places and update the tests that use that helper - Set fallback flags in eviction domains defined in TTM KUnit helpers - Fix a warning raised by ttm_bo_unreserve_bulk() test case - Scrap all r-bs and tested-by, as many things were updated and should be checked again Karolina Stolarek (10): drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk drm/ttm/tests: Delete unnecessary config option drm/ttm/tests: Set DMA mask in KUnit device drm/ttm/tests: Use an init function from the helpers lib drm/ttm/tests: Test simple BO creation and validation drm/ttm/tests: Add tests with mock resource managers drm/ttm/tests: Add test cases dependent on fence signaling drm/ttm/tests: Add eviction testing drm/ttm/tests: Add tests for ttm_tt_populate drm/ttm/tests: Add TODO file drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/ttm/tests/.kunitconfig | 2 +- drivers/gpu/drm/ttm/tests/Makefile | 2 + drivers/gpu/drm/ttm/tests/TODO | 25 + drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 40 +- .../gpu/drm/ttm/tests/ttm_bo_validate_test.c | 1225 +++++++++++++++++ drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 178 ++- drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h | 13 +- drivers/gpu/drm/ttm/tests/ttm_mock_manager.c | 235 ++++ drivers/gpu/drm/ttm/tests/ttm_mock_manager.h | 33 + drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 4 +- drivers/gpu/drm/ttm/tests/ttm_resource_test.c | 2 +- drivers/gpu/drm/ttm/tests/ttm_tt_test.c | 154 ++- drivers/gpu/drm/ttm/ttm_tt.c | 3 + 14 files changed, 1862 insertions(+), 55 deletions(-) create mode 100644 drivers/gpu/drm/ttm/tests/TODO create mode 100644 drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c create mode 100644 drivers/gpu/drm/ttm/tests/ttm_mock_manager.c create mode 100644 drivers/gpu/drm/ttm/tests/ttm_mock_manager.h