<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:15pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">> I see the i915 equivalent
test having 2 more subtests, are those gonna</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">> be added in a follow
up?</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">No. We do not have those
tests yet. </span></div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
-- Anson</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Mark Yacoub <markyacoub@chromium.org><br>
<b>Sent:</b> Monday, June 14, 2021 11:55 AM<br>
<b>To:</b> Jacob, Anson <Anson.Jacob@amd.com><br>
<b>Cc:</b> igt-dev@lists.freedesktop.org <igt-dev@lists.freedesktop.org>; Wentland, Harry <Harry.Wentland@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Mark Yacoub <markyacoub@google.com>; Lu, Victor Cheng Chi (Victor) <VictorChengChi.Lu@amd.com><br>
<b>Subject:</b> Re: [igt-dev] [PATCH i-g-t 1/2] tests/amdgpu: Introduced new amdgpu module reload test</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On Mon, Jun 14, 2021 at 11:36 AM Anson Jacob <Anson.Jacob@amd.com> wrote:<br>
><br>
> From: Victor Lu <victorchengchi.lu@amd.com><br>
><br>
> Based off of i915/i915_module_load, unloads and loads the<br>
> amdgpu module.<br>
><br>
> Signed-off-by: Victor Lu <victorchengchi.lu@amd.com><br>
> Acked-by: Anson Jacob <Anson.Jacob@amd.com><br>
> ---<br>
> lib/igt_kmod.c | 41 ++++++++++++++++++<br>
> lib/igt_kmod.h | 3 ++<br>
> tests/amdgpu/amd_module_load.c | 77 ++++++++++++++++++++++++++++++++++<br>
> tests/amdgpu/meson.build | 1 +<br>
> 4 files changed, 122 insertions(+)<br>
> create mode 100644 tests/amdgpu/amd_module_load.c<br>
><br>
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c<br>
> index 55295fa5..69bdc810 100644<br>
> --- a/lib/igt_kmod.c<br>
> +++ b/lib/igt_kmod.c<br>
> @@ -433,6 +433,47 @@ igt_i915_driver_unload(void)<br>
> return IGT_EXIT_SUCCESS;<br>
> }<br>
><br>
> +int<br>
> +igt_amdgpu_driver_load(const char *opts)<br>
> +{<br>
> + if (opts)<br>
> + igt_info("Reloading amdgpu with %s\n\n", opts);<br>
> +<br>
> + if (igt_kmod_load("amdgpu", opts)) {<br>
> + igt_warn("Could not load amdgpu\n");<br>
> + return IGT_EXIT_FAILURE;<br>
> + }<br>
> +<br>
> + bind_fbcon(true);<br>
> +<br>
> + return IGT_EXIT_SUCCESS;<br>
> +}<br>
> +<br>
> +int<br>
> +igt_amdgpu_driver_unload(void)<br>
> +{<br>
> + bind_fbcon(false);<br>
> +<br>
> + if (igt_kmod_is_loaded("amdgpu")) {<br>
> + if (igt_kmod_unload("amdgpu", 0)) {<br>
> + igt_warn("Could not unload amdgpu\n");<br>
> + igt_kmod_list_loaded();<br>
> + igt_lsof("/dev/dri");<br>
> + return IGT_EXIT_SKIP;<br>
> + }<br>
> + }<br>
> +<br>
> + igt_kmod_unload("drm_kms_helper", 0);<br>
> + igt_kmod_unload("drm", 0);<br>
> +<br>
> + if (igt_kmod_is_loaded("amdgpu")) {<br>
> + igt_warn("amdgpu.ko still loaded!\n");<br>
> + return IGT_EXIT_FAILURE;<br>
> + }<br>
> +<br>
> + return IGT_EXIT_SUCCESS;<br>
> +}<br>
> +<br>
> static void kmsg_dump(int fd)<br>
> {<br>
> char record[4096 + 1];<br>
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h<br>
> index c71ec147..04c87516 100644<br>
> --- a/lib/igt_kmod.h<br>
> +++ b/lib/igt_kmod.h<br>
> @@ -39,6 +39,9 @@ int igt_kmod_unload(const char *mod_name, unsigned int flags);<br>
> int igt_i915_driver_load(const char *opts);<br>
> int igt_i915_driver_unload(void);<br>
><br>
> +int igt_amdgpu_driver_load(const char *opts);<br>
> +int igt_amdgpu_driver_unload(void);<br>
> +<br>
> void igt_kselftests(const char *module_name,<br>
> const char *module_options,<br>
> const char *result_option,<br>
> diff --git a/tests/amdgpu/amd_module_load.c b/tests/amdgpu/amd_module_load.c<br>
> new file mode 100644<br>
> index 00000000..e682d2c5<br>
> --- /dev/null<br>
> +++ b/tests/amdgpu/amd_module_load.c<br>
> @@ -0,0 +1,77 @@<br>
> +/*<br>
> + * Copyright 2020 Advanced Micro Devices, Inc.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be included in<br>
> + * all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + */<br>
> +<br>
> +#include "igt.h"<br>
> +#include "igt_kmod.h"<br>
> +<br>
> +#include <amdgpu.h><br>
> +#include <amdgpu_drm.h><br>
> +#include <sys/ioctl.h><br>
> +<br>
> +/**<br>
> + * Adapted from /tests/i915/i915_module_load.c<br>
> + */<br>
> +static void<br>
> +sanity_check(void)<br>
> +{<br>
> + int err = 0;<br>
> + int fd;<br>
> + int arg_ret;<br>
> + struct drm_amdgpu_info args = {0};<br>
> + args.return_pointer = (uintptr_t) &arg_ret;<br>
> + args.return_size = sizeof(int);<br>
> + args.query = AMDGPU_INFO_HW_IP_INFO;<br>
> +<br>
> + fd = drm_open_driver(DRIVER_AMDGPU);<br>
> + igt_set_timeout(1, "Module reload timeout!");<br>
> +<br>
> + if (ioctl(fd, DRM_IOCTL_AMDGPU_INFO, &args) < 0)<br>
> + err = -errno;<br>
> +<br>
> + igt_set_timeout(0, NULL);<br>
> + close(fd);<br>
> +<br>
> + igt_assert_f(err, 0);<br>
> +}<br>
> +<br>
> +igt_main<br>
> +{<br>
> + igt_subtest("reload") {<br>
I see the i915 equivalent test having 2 more subtests, are those gonna<br>
be added in a follow up?<br>
> + int err;<br>
> + igt_amdgpu_driver_unload();<br>
> +<br>
> + err = igt_amdgpu_driver_load(NULL);<br>
> +<br>
> + igt_assert_eq(err, 0);<br>
> +<br>
> + sanity_check();<br>
> +<br>
> + igt_amdgpu_driver_unload();<br>
> + }<br>
> +<br>
> + igt_fixture<br>
> + {<br>
> + /* load the module back in */<br>
> + igt_amdgpu_driver_load(NULL);<br>
> + }<br>
> +}<br>
> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build<br>
> index b92aa22b..84179410 100644<br>
> --- a/tests/amdgpu/meson.build<br>
> +++ b/tests/amdgpu/meson.build<br>
> @@ -9,6 +9,7 @@ if libdrm_amdgpu.found()<br>
> 'amd_cs_nop',<br>
> 'amd_info',<br>
> 'amd_prime',<br>
> + 'amd_module_load',<br>
> ]<br>
> amdgpu_deps += libdrm_amdgpu<br>
> endif<br>
> --<br>
> 2.25.1<br>
><br>
> _______________________________________________<br>
> igt-dev mailing list<br>
> igt-dev@lists.freedesktop.org<br>
> <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Figt-dev&data=04%7C01%7CAnson.Jacob%40amd.com%7C6748889419fa450691e308d92f4cd022%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637592829230568891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RFYYdhHiC5Ixzg20hK3UYdYXDgwdf8nbmTLpnXkcjAU%3D&reserved=0">
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Figt-dev&data=04%7C01%7CAnson.Jacob%40amd.com%7C6748889419fa450691e308d92f4cd022%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637592829230568891%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RFYYdhHiC5Ixzg20hK3UYdYXDgwdf8nbmTLpnXkcjAU%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>