From mboxrd@z Thu Jan 1 00:00:00 1970 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 EE7E3C3DA7E for ; Tue, 30 Jul 2024 11:47:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B445010E510; Tue, 30 Jul 2024 11:47:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="UAWuUqt+"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A2E710E50E for ; Tue, 30 Jul 2024 11:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722340059; x=1753876059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wvqmMM2J7zOYWafLVg3Xse5rUh7btvd/dwUZD7N+hwA=; b=UAWuUqt+xCfjWWfQNugmvjNjH8I+L7TZ4lbF//8b+0uk26ErXvG4ZDYQ nG0I87ZJhK7ggeGbU55lbTm6njpDH0bV3c8Qg86DE6qWm+HJudtlaFMoX R+abVmR5fzBC9dyFEpvtasJc3OyMIREKpnVsCfEUBszOPc7v0w8jHy1Aq EWVS/Qma0h+xGsseyFWZ248yiSOlqMPumWOXHKHGtuQ3mrz33CL/HLTj7 K4QgCG9TUu2ouHRdqPqZKQkQz4xA02OYhqIQusrqTLXFMoU25LlFz1HtN 1U4tpR18tuTa/dB/MXr1i1y9HGwR7kdh+/7HLWBEPpIGMQXrH2D6XUh6w Q==; X-CSE-ConnectionGUID: uyrjeaygSQmNOO43c4cMxQ== X-CSE-MsgGUID: fRpqrM/URbqWTL//6CJvYQ== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="23937276" X-IronPort-AV: E=Sophos;i="6.09,248,1716274800"; d="scan'208";a="23937276" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2024 04:47:39 -0700 X-CSE-ConnectionGUID: kemToe00R+2/moE8Tsy38w== X-CSE-MsgGUID: cf+q5S5iRNK71v9w69Wf5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,248,1716274800"; d="scan'208";a="54216712" Received: from cpetruta-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.245.246.43]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2024 04:47:35 -0700 From: Christoph Manszewski To: igt-dev@lists.freedesktop.org Cc: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?= , Kamil Konieczny , Dominik Grzegorzek , Maciej Patelczyk , =?UTF-8?q?Dominik=20Karol=20Pi=C4=85tkowski?= , Pawel Sikora , Andrzej Hajda , Kolanupaka Naveena , Mika Kuoppala , Gwan-gyeong Mun Subject: [PATCH i-g-t v2 19/66] tests/xe_eudebug: Add basic vm-bind coverage Date: Tue, 30 Jul 2024 13:44:36 +0200 Message-Id: <20240730114523.334156-20-christoph.manszewski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730114523.334156-1-christoph.manszewski@intel.com> References: <20240730114523.334156-1-christoph.manszewski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" Add basic coverage for vm-bind event delivery mechanism that enables the user to track client vm-bind ioctl calls. Signed-off-by: Christoph Manszewski Cc: Dominik Grzegorzek --- tests/intel/xe_eudebug.c | 117 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 109 insertions(+), 8 deletions(-) diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c index 5080fdf5b..ce6c37c6d 100644 --- a/tests/intel/xe_eudebug.c +++ b/tests/intel/xe_eudebug.c @@ -22,6 +22,41 @@ #include "xe/xe_ioctl.h" #include "xe/xe_query.h" +#define CREATE_VMS (1 << 0) +#define CREATE_EXEC_QUEUES (1 << 1) +#define VM_BIND (1 << 2) +#define VM_BIND_VM_DESTROY (1 << 3) +#define VM_BIND_EXTENDED (1 << 4) + +static void basic_vm_bind_client(int fd, struct xe_eudebug_client *c) +{ + uint32_t vm = xe_eudebug_client_vm_create(c, fd, 0, 0); + size_t bo_size = xe_get_default_alignment(fd); + uint32_t bo = xe_bo_create(fd, 0, bo_size, + system_memory(fd), 0); + uint64_t addr = 0x1a0000; + + xe_eudebug_client_vm_bind(c, fd, vm, bo, 0, addr, bo_size); + xe_eudebug_client_vm_unbind(c, fd, vm, 0, addr, bo_size); + + gem_close(fd, bo); + xe_eudebug_client_vm_destroy(c, fd, vm); +} + +static void basic_vm_bind_vm_destroy_client(int fd, struct xe_eudebug_client *c) +{ + uint32_t vm = xe_eudebug_client_vm_create(c, fd, 0, 0); + size_t bo_size = xe_get_default_alignment(fd); + uint32_t bo = xe_bo_create(fd, 0, bo_size, + system_memory(fd), 0); + uint64_t addr = 0x1a0000; + + xe_eudebug_client_vm_bind(c, fd, vm, bo, 0, addr, bo_size); + xe_eudebug_client_vm_destroy(c, fd, vm); + + gem_close(fd, bo); +} + #define BO_ADDR 0x1a0000 #define BO_ITEMS 4096 #define MIN_BO_SIZE (BO_ITEMS * sizeof(uint64_t)) @@ -149,8 +184,41 @@ static void check_bind_list(struct bind_list *bl) } } -#define CREATE_VMS (1 << 0) -#define CREATE_EXEC_QUEUES (1 << 1) +static void vm_bind_client(int fd, struct xe_eudebug_client *c) +{ + uint64_t op_ref_seqno, ref_seqno; + struct bind_list *bl; + size_t bo_size = 3 * xe_get_default_alignment(fd); + uint32_t bo[2] = { + xe_bo_create(fd, 0, bo_size, system_memory(fd), 0), + xe_bo_create(fd, 0, bo_size, system_memory(fd), 0), + }; + uint32_t vm = xe_eudebug_client_vm_create(c, fd, 0, 0); + uint64_t addr[] = {0x2a0000, 0x3a0000}; + uint64_t rebind_bo_offset = 2 * bo_size / 3; + uint64_t size = bo_size / 3; + + xe_eudebug_client_vm_bind(c, fd, vm, bo[0], 0, addr[0], bo_size); + xe_eudebug_client_vm_unbind(c, fd, vm, 0, addr[0] + size, size); + + xe_eudebug_client_vm_bind(c, fd, vm, bo[1], 0, addr[1], bo_size); + xe_eudebug_client_vm_bind(c, fd, vm, bo[1], rebind_bo_offset, addr[1], size); + + bl = create_bind_list(fd, system_memory(fd), vm, 4); + do_bind_list(c, bl, NULL); + + xe_vm_unbind_all_async(fd, vm, 0, bo[1], NULL, 0); + + xe_eudebug_client_vm_bind_event(c, DRM_XE_EUDEBUG_EVENT_STATE_CHANGE, fd, vm, 0, + 1, &ref_seqno); + xe_eudebug_client_vm_bind_op_event(c, DRM_XE_EUDEBUG_EVENT_DESTROY, ref_seqno, + &op_ref_seqno, 0, 0, 0); + + gem_close(fd, bo[0]); + gem_close(fd, bo[1]); + xe_eudebug_client_vm_destroy(c, fd, vm); +} + static void run_basic_client(struct xe_eudebug_client *c) { int fd, i; @@ -216,6 +284,15 @@ static void run_basic_client(struct xe_eudebug_client *c) xe_eudebug_client_vm_destroy(c, fd, vm); } + if (c->flags & VM_BIND) + basic_vm_bind_client(fd, c); + + if (c->flags & VM_BIND_EXTENDED) + vm_bind_client(fd, c); + + if (c->flags & VM_BIND_VM_DESTROY) + basic_vm_bind_vm_destroy_client(fd, c); + xe_device_put(fd); xe_eudebug_client_close_driver(c, fd); } @@ -437,13 +514,28 @@ static void test_read_event(int fd) * Description: * Attach the debugger to process which creates and destroys a few %arg[1]. * + * SUBTEST: basic-vm-bind + * Description: + * Attach the debugger to a process that performs synchronous vm bind + * and vm unbind. + * + * SUBTEST: basic-vm-bind-vm-destroy + * Description: + * Attach the debugger to a process that performs vm bind, and destroys + * the vm without unbinding. Make sure that we don't get unbind events. + * + * SUBTEST: basic-vm-bind-extended + * Description: + * Attach the debugger to a process that performs bind, bind array, rebind, + * partial unbind, unbind and unbind all operations. + * * arg[1]: * * @vms: vms * @exec-queues: exec queues */ -static void test_basic_sessions(int fd, unsigned int flags, int count) +static void test_basic_sessions(int fd, unsigned int flags, int count, bool match_opposite) { struct xe_eudebug_session **s; int i; @@ -459,7 +551,7 @@ static void test_basic_sessions(int fd, unsigned int flags, int count) xe_eudebug_session_run(s[i]); for (i = 0; i < count; i++) - xe_eudebug_session_check(s[i], true, 0); + xe_eudebug_session_check(s[i], match_opposite, 0); for (i = 0; i < count; i++) xe_eudebug_session_destroy(s[i]); @@ -904,19 +996,28 @@ igt_main test_read_event(fd); igt_subtest("basic-client") - test_basic_sessions(fd, 0, 1); + test_basic_sessions(fd, 0, 1, true); igt_subtest("basic-vm-access") test_vm_access(fd, 0, 1); igt_subtest("multiple-sessions") - test_basic_sessions(fd, CREATE_VMS | CREATE_EXEC_QUEUES, 4); + test_basic_sessions(fd, CREATE_VMS | CREATE_EXEC_QUEUES, 4, true); igt_subtest("basic-vms") - test_basic_sessions(fd, CREATE_VMS, 1); + test_basic_sessions(fd, CREATE_VMS, 1, true); igt_subtest("basic-exec-queues") - test_basic_sessions(fd, CREATE_EXEC_QUEUES, 1); + test_basic_sessions(fd, CREATE_EXEC_QUEUES, 1, true); + + igt_subtest("basic-vm-bind") + test_basic_sessions(fd, VM_BIND, 1, true); + + igt_subtest("basic-vm-bind-vm-destroy") + test_basic_sessions(fd, VM_BIND_VM_DESTROY, 1, false); + + igt_subtest("basic-vm-bind-extended") + test_basic_sessions(fd, VM_BIND_EXTENDED, 1, true); igt_subtest("discovery-race") test_race_discovery(fd, 0, 4); -- 2.34.1