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 706FFCCD185 for ; Mon, 13 Oct 2025 19:52:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 225B910E136; Mon, 13 Oct 2025 19:52:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CvGW+ftA"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55E5310E136 for ; Mon, 13 Oct 2025 19:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760385150; x=1791921150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=axFmnikUDswU171fvJgzu5uv4Apq7vPxbXi7TBRgSIc=; b=CvGW+ftAFEQkzYqkKoDkCN/f+9rkV5wEyGxkUwuHgheiGPzth5VGHq1l nUO2pZOPfLD4bMLR3wgJ4JRx/AXtkGoRz0ZymmSQHuge0JMXiETgUIkBy JzQ5MMAv4IUNyiR6OdbdsO0SJYBJukU7+zYpZEygAtfPDKS3la5Hwp5vu 54sckh4aXyXXFVmW1dRzgaXym+7NCDcSS5YWLOGRTHmMRCEk1DdhgWpyI rEwu6wAnrdvK483oGeMn1fOlbJbIRV84HHprtVs27dNv0TyMXkURIyWDB KjHdAtC+7ZytMfyr8dkPCOgAUhFp79tR/tBmIgXzCe9sQ/kOxyxJHyHWX Q==; X-CSE-ConnectionGUID: sqEQwfMDRLyEz/Z0N0NMkg== X-CSE-MsgGUID: ir/ypASlSDGFNh4QHgns+A== X-IronPort-AV: E=McAfee;i="6800,10657,11581"; a="62633581" X-IronPort-AV: E=Sophos;i="6.19,226,1754982000"; d="scan'208";a="62633581" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 12:52:30 -0700 X-CSE-ConnectionGUID: mz+D7O14Sx2T4E8tbtqsUQ== X-CSE-MsgGUID: 3KvqInLBSbGvhsIkilqyBA== X-ExtLoop1: 1 Received: from anirban-z690i-a-ultra-plus.iind.intel.com ([10.190.216.83]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2025 12:52:27 -0700 From: Sk Anirban To: igt-dev@lists.freedesktop.org Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com, riana.tauro@intel.com, karthik.poosa@intel.com, raag.jadav@intel.com, soham.purkait@intel.com, mallesh.koujalagi@intel.com, Sk Anirban Subject: [i-g-t, v6, 1/3] tests/intel/xe_survivability: Add new xe_survivability test for i2c adapter Date: Tue, 14 Oct 2025 01:19:03 +0530 Message-ID: <20251013194910.1065392-6-sk.anirban@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251013194910.1065392-5-sk.anirban@intel.com> References: <20251013194910.1065392-5-sk.anirban@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=a 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 i2c adapter presence check in survivability mode to ensure the Add-In Management Controller (AMC) can receive firmware updates when the device is in survivability mode. v2: Create new file for test (Riana) v3: Update subject, description, nitpick (Kamil) Use drm_close_driver() (Kamil) v4: Update test details (Riana) Align with xe_configfs (Riana) Create separate function for sysfs (Riana) v5: Remove duplicate close(fd) (Riana) Modify fixture (Riana) Move assert to function (Riana) v6: Move VF check (Riana) Signed-off-by: Sk Anirban --- tests/intel/xe_survivability.c | 155 +++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 156 insertions(+) create mode 100644 tests/intel/xe_survivability.c diff --git a/tests/intel/xe_survivability.c b/tests/intel/xe_survivability.c new file mode 100644 index 000000000..e4418361d --- /dev/null +++ b/tests/intel/xe_survivability.c @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2025 Intel Corporation + */ +#include +#include +#include + +#include "igt.h" +#include "igt_configfs.h" +#include "igt_device.h" +#include "igt_fs.h" +#include "igt_kmod.h" +#include "igt_sriov_device.h" +#include "igt_sysfs.h" +#include "xe/xe_query.h" + +/** + * TEST: Comprehensive survivability mode testing + * Category: Core + * Mega feature: General Core features + * Sub-category: Telemetry + * Functionality: survivability mode + * Description: Validate survivability mode functionality + * Test category: Functional tests + * + * SUBTEST: i2c-functionality + * Description: Validate i2c adapter functionality in survivability mode + */ + +static char bus_addr[NAME_MAX]; + +static bool check_survivability_mode_sysfs(void) +{ + char path[PATH_MAX]; + int fd; + + snprintf(path, PATH_MAX, "/sys/bus/pci/devices/%s/survivability_mode", bus_addr); + fd = open(path, O_RDONLY); + igt_assert_f(fd >= 0, "Survivability mode not set\n"); + close(fd); + return true; +} + +static int find_i2c_adapter(struct pci_device *pci_xe) +{ + char device_path[PATH_MAX]; + struct dirent *dirent; + int i2c_adapter = -1; + DIR *device_dir; + int ret; + + igt_require(igt_kmod_load("i2c-dev", NULL) == 0); + + snprintf(device_path, sizeof(device_path), "/sys/bus/pci/devices/%s/%s.%hu", bus_addr, + "i2c_designware", (pci_xe->bus << 8) | (pci_xe->dev)); + device_dir = opendir(device_path); + + if (!device_dir) + return -1; + + while ((dirent = readdir(device_dir))) { + if (strncmp(dirent->d_name, "i2c-", 4) == 0) { + ret = sscanf(dirent->d_name, "i2c-%d", &i2c_adapter); + igt_assert_f(ret == 1, "Failed to parse i2c adapter number"); + closedir(device_dir); + return i2c_adapter; + } + } + + closedir(device_dir); + return i2c_adapter; +} + +static void restore(int sig) +{ + int configfs_fd; + + igt_kmod_unbind("xe", bus_addr); + + configfs_fd = igt_configfs_open("xe"); + if (configfs_fd >= 0) + igt_fs_remove_dir(configfs_fd, bus_addr); + close(configfs_fd); + + igt_kmod_bind("xe", bus_addr); +} + +static void set_survivability_mode(int configfs_device_fd, bool value) +{ + igt_kmod_unbind("xe", bus_addr); + igt_sysfs_set_boolean(configfs_device_fd, "survivability_mode", value); + igt_kmod_bind("xe", bus_addr); +} + +static void test_i2c_functionality(int configfs_device_fd, struct pci_device *pci_xe) +{ + if (find_i2c_adapter(pci_xe) >= 0) { + /* Enable survivability mode */ + set_survivability_mode(configfs_device_fd, true); + + /* check presence of survivability mode sysfs */ + check_survivability_mode_sysfs(); + + /* Check i2c adapter after survivability mode */ + igt_assert_f(find_i2c_adapter(pci_xe) >= 0, + "i2c not initialized\n"); + } +} + +static int create_device_configfs_group(int configfs_fd) +{ + mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + int configfs_device_fd; + + configfs_device_fd = igt_fs_create_dir(configfs_fd, bus_addr, mode); + igt_assert(configfs_device_fd); + + return configfs_device_fd; +} + +igt_main +{ + int fd, configfs_fd, configfs_device_fd; + struct pci_device *pci_xe; + bool vf_device; + + igt_fixture { + fd = drm_open_driver(DRIVER_XE); + igt_require(IS_BATTLEMAGE(intel_get_drm_devid(fd))); + vf_device = intel_is_vf_device(fd); + igt_require_f(!vf_device, "survivability mode not supported in VF\n"); + pci_xe = igt_device_get_pci_device(fd); + igt_device_get_pci_slot_name(fd, bus_addr); + configfs_fd = igt_configfs_open("xe"); + igt_require(configfs_fd != -1); + configfs_device_fd = create_device_configfs_group(configfs_fd); + igt_install_exit_handler(restore); + } + + igt_describe("Validate i2c adapter functionality in survivability mode"); + igt_subtest("i2c-functionality") { + test_i2c_functionality(configfs_device_fd, pci_xe); + restore(0); + fd = drm_open_driver(DRIVER_XE); + } + + igt_fixture { + igt_fs_remove_dir(configfs_fd, bus_addr); + close(configfs_device_fd); + close(configfs_fd); + drm_close_driver(fd); + } +} + diff --git a/tests/meson.build b/tests/meson.build index 73edd3e71..31487f62e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -329,6 +329,7 @@ intel_xe_progs = [ 'xe_sriov_auto_provisioning', 'xe_sriov_flr', 'xe_sriov_scheduling', + 'xe_survivability', 'xe_sriov_vram', 'xe_sysfs_defaults', 'xe_sysfs_preempt_timeout', -- 2.43.0