From: "Gupta, Anshuman" <anshuman.gupta@intel.com>
To: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"Nilawar, Badal" <badal.nilawar@intel.com>,
"Wilson, Chris P" <chris.p.wilson@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib: Add silent __igt_i915_driver_unload
Date: Wed, 16 Feb 2022 11:41:00 +0000 [thread overview]
Message-ID: <dcc295675e7c49c7837030005ad97356@intel.com> (raw)
In-Reply-To: <877da01zro.wl-ashutosh.dixit@intel.com>
> -----Original Message-----
> From: Dixit, Ashutosh <ashutosh.dixit@intel.com>
> Sent: Saturday, February 12, 2022 9:51 AM
> To: Gupta, Anshuman <anshuman.gupta@intel.com>
> Cc: igt-dev@lists.freedesktop.org; Wilson, Chris P <chris.p.wilson@intel.com>;
> Nilawar, Badal <badal.nilawar@intel.com>; janusz.krzysztofik@linux.intel.com
> Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib: Add silent __igt_i915_driver_unload
>
> On Mon, 25 Oct 2021 02:23:04 -0700, Anshuman Gupta wrote:
> >
> > Add silent __igt_i915_driver_unload(), which will not print any
> > warning in case of passed argument is NULL.
>
> I think we need to add a "why" to this commit message and that is "so that we
> can test scenarios when module unload is expected to fail".
>
> >
> > Cc: Chris Wilson <chris.p.wilson@intel.com>
> > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > ---
> > lib/igt_kmod.c | 86
> > ++++++++++++++++++++++++++++++--------------------
> > lib/igt_kmod.h | 1 +
> > 2 files changed, 52 insertions(+), 35 deletions(-)
> >
> > diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index
> > 10e983844..ce9bfc07a 100644
> > --- a/lib/igt_kmod.c
> > +++ b/lib/igt_kmod.c
> > @@ -369,56 +369,72 @@ igt_i915_driver_load(const char *opts)
> > return IGT_EXIT_SUCCESS;
> > }
> >
> > -/**
> > - * igt_i915_driver_unload:
> > - *
> > - * Unloads the i915 driver and its dependencies.
> > - *
> > - */
> > -int
> > -igt_i915_driver_unload(void)
> > +int __igt_i915_driver_unload(const char **whom)
>
> I prefer s/whom/who/ as in "Who failed to unload?".
>
> > {
> > + const char *sound[] = {
> > + "snd_hda_intel",
> > + "snd_hdmi_lpe_audio",
> > + NULL,
> > + };
> > +
> > + const char *aux[] = {
> > + /* gen5: ips uses symbol_get() so only a soft module
> dependency */
> > + "intel_ips",
> > + NULL,
> > + };
> > +
> > /* unbind vt */
> > bind_fbcon(false);
> >
> > - if (igt_kmod_is_loaded("snd_hda_intel")) {
> > - igt_terminate_process(SIGTERM, "alsactl");
> > -
> > - /* unbind snd_hda_intel */
> > - kick_snd_hda_intel();
> > -
> > - if (igt_kmod_unload("snd_hda_intel", 0)) {
> > - igt_warn("Could not unload snd_hda_intel\n");
> > - igt_kmod_list_loaded();
> > - igt_lsof("/dev/snd");
> > - return IGT_EXIT_FAILURE;
> > + for (const char **m = sound; *m; m++) {
> > + if (igt_kmod_is_loaded(*m)) {
> > + igt_terminate_process(SIGTERM, "alsactl");
> > + kick_snd_hda_intel();
> > + if (igt_kmod_unload(*m, 0)) {
> > + if (whom)
> > + *whom = *m;
>
> This seems like a bug. The sound and aux arrays above should be static
> otherwise these strings go out of scope after the function exits.
>
> > + return IGT_EXIT_FAILURE;
> > + }
> > }
> > }
> >
> > - if (igt_kmod_is_loaded("snd_hdmi_lpe_audio")) {
> > - igt_terminate_process(SIGTERM, "alsactl");
> > -
> > - if (igt_kmod_unload("snd_hdmi_lpe_audio", 0)) {
> > - igt_warn("Could not unload snd_hdmi_lpe_audio\n");
> > - igt_kmod_list_loaded();
> > - igt_lsof("/dev/snd");
> > - return IGT_EXIT_FAILURE;
> > - }
> > + for (const char **m = aux; *m; m++) {
> > + if (igt_kmod_is_loaded(*m))
> > + igt_kmod_unload(*m, 0);
>
> This issue exists in previous code too but why not return an error here (and also
> populate 'whom' or 'who')?
>
> > }
> >
> > - /* gen5: ips uses symbol_get() so only a soft module dependency */
> > - if (igt_kmod_is_loaded("intel_ips"))
> > - igt_kmod_unload("intel_ips", 0);
> > -
> > if (igt_kmod_is_loaded("i915")) {
> > if (igt_kmod_unload("i915", 0)) {
> > - igt_warn("Could not unload i915\n");
> > - igt_kmod_list_loaded();
> > - igt_lsof("/dev/dri");
> > + if (whom)
> > + *whom = "i915";
> > return IGT_EXIT_SKIP;
> > }
> > }
> >
> > + return IGT_EXIT_SUCCESS;
>
> The issue exists in previous code but to me it seems highly unusual that we are
> using process exit codes as return values from these functions (both load and
> unload).
>
> Note that after we have introduced and populated 'whom' or 'who', we just
> return the value retured from igt_kmod_unload() from here (and similarly in
> igt_i915_driver_load()) and let the caller figure out who failed to unload from
> 'whom' or 'who'. That is we don't need separate return values for other drivers
> vs. i915. Thoughts?
Actually I missed this earlier while sending v2, perf_pmu test expect i915 module to be busy in
certain cases and returning IGT_EXIT_FAILIURE will fail the perf_pmu test.
https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6626/shard-tglb8/igt@perf_pmu@module-unload.html
So in case of *who is NULL , __igt_i915_driver_unload() should return IGT_EXIT_SKIP,
whenever igt module fails to unload.
Thanks,
Anshuman Gupta.
>
>
> > +}
> > +
> > +/**
> > + * igt_i915_driver_unload:
> > + *
> > + * Unloads the i915 driver and its dependencies.
> > + *
> > + */
> > +int
> > +igt_i915_driver_unload(void)
> > +{
> > + const char *whom;
> > + int ret;
> > +
> > + ret = __igt_i915_driver_unload(&whom);
> > + if (ret) {
> > + igt_warn("Could not unload %s\n", whom);
> > + igt_kmod_list_loaded();
> > + igt_lsof("/dev/dri");
> > + igt_lsof("/dev/snd");
> > + return ret;
> > + }
> > +
> > if (igt_kmod_is_loaded("intel-gtt"))
> > igt_kmod_unload("intel-gtt", 0);
> >
> > diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h index
> > 04c87516f..0898122b3 100644
> > --- a/lib/igt_kmod.h
> > +++ b/lib/igt_kmod.h
> > @@ -38,6 +38,7 @@ int igt_kmod_unload(const char *mod_name, unsigned
> > int flags);
> >
> > int igt_i915_driver_load(const char *opts); int
> > igt_i915_driver_unload(void);
> > +int __igt_i915_driver_unload(const char **whom);
> >
> > int igt_amdgpu_driver_load(const char *opts); int
> > igt_amdgpu_driver_unload(void);
> > --
> > 2.26.2
> >
next prev parent reply other threads:[~2022-02-16 11:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 9:23 [igt-dev] [PATCH i-g-t 0/2] Nuke unload_i915 Anshuman Gupta
2021-10-25 9:23 ` [igt-dev] [PATCH i-g-t 1/2] lib: Add silent __igt_i915_driver_unload Anshuman Gupta
2022-02-12 4:20 ` Dixit, Ashutosh
2022-02-14 10:23 ` Gupta, Anshuman
2022-02-14 18:08 ` Dixit, Ashutosh
2022-02-16 11:41 ` Gupta, Anshuman [this message]
2021-10-25 9:23 ` [igt-dev] [PATCH i-g-t 2/2] perf/perf_pmu: Nuke unload_i915 Anshuman Gupta
2021-10-25 10:19 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2021-10-25 12:54 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dcc295675e7c49c7837030005ad97356@intel.com \
--to=anshuman.gupta@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=badal.nilawar@intel.com \
--cc=chris.p.wilson@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.