From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v4 01/11] drm/xe: Simplify module initialization code
Date: Mon, 28 Jul 2025 16:00:06 -0400 [thread overview]
Message-ID: <aIfWxg3F4D6LaYbo@intel.com> (raw)
In-Reply-To: <f7dcd9c0-8bfc-4355-a568-0b411006893c@intel.com>
On Mon, Jul 28, 2025 at 09:47:39PM +0200, Michal Wajdeczko wrote:
>
>
> On 7/28/2025 9:35 PM, Rodrigo Vivi wrote:
> > On Sun, Jul 27, 2025 at 07:19:58PM +0200, Michal Wajdeczko wrote:
> >> There is no need to have extra checks and WARN() in the helpers
> >> as instead of an index of the entry with function pointers, we
> >> can pass pointer to the entry which we prepare directly in the
> >> main loop, that is guaranteed to be valid.
> >>
> >> add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-180 (-180)
> >> Function old new delta
> >> xe_exit 109 79 -30
> >> cleanup_module 109 79 -30
> >> xe_init 248 188 -60
> >> init_module 248 188 -60
> >> Total: Before=2774145, After=2773965, chg -0.01%
> >>
> >> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> >> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> >> ---
> >> drivers/gpu/drm/xe/xe_module.c | 27 ++++++++++-----------------
> >> 1 file changed, 10 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/xe/xe_module.c b/drivers/gpu/drm/xe/xe_module.c
> >> index d9391bd08194..593bc9e5851a 100644
> >> --- a/drivers/gpu/drm/xe/xe_module.c
> >> +++ b/drivers/gpu/drm/xe/xe_module.c
> >> @@ -135,24 +135,17 @@ static const struct init_funcs init_funcs[] = {
> >> },
> >> };
> >>
> >> -static int __init xe_call_init_func(unsigned int i)
> >> +static int __init xe_call_init_func(const struct init_funcs *func)
> >> {
> >> - if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
> >> - return 0;
> >> - if (!init_funcs[i].init)
> >> - return 0;
> >> -
> >> - return init_funcs[i].init();
> >> + if (func->init)
> >> + return func->init();
> >> + return 0;
> >> }
> >>
> >> -static void xe_call_exit_func(unsigned int i)
> >> +static void xe_call_exit_func(const struct init_funcs *func)
> >> {
> >> - if (WARN_ON(i >= ARRAY_SIZE(init_funcs)))
> >> - return;
> >> - if (!init_funcs[i].exit)
> >> - return;
> >> -
> >> - init_funcs[i].exit();
> >> + if (func->exit)
> >> + func->exit();
> >> }
> >>
> >> static int __init xe_init(void)
> >> @@ -160,10 +153,10 @@ static int __init xe_init(void)
> >> int err, i;
> >>
> >> for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
> >> - err = xe_call_init_func(i);
> >> + err = xe_call_init_func(&init_funcs[i]);
> >
> > perhaps we can go further and avoid this extra function calling
> > directly here:
> >
> > err = init_funcs[i].init();
>
> it depends if we want to preserve support for unset .init
> (I assumed it was added on purpose)
>
> >
> >> if (err) {
> >> while (i--)
> >> - xe_call_exit_func(i);
> >> + xe_call_exit_func(&init_funcs[i]);
> >
> > and
> > init_funcs[i].exit();
> > here ?
>
> .exit is optional, so this will have to be:
>
> if (init_funcs[i].exit)
> init_funcs[i].exit();
>
> but likely compiler will do the same with current code
>
> >
> >> return err;
> >> }
> >> }
> >> @@ -176,7 +169,7 @@ static void __exit xe_exit(void)
> >> int i;
> >>
> >> for (i = ARRAY_SIZE(init_funcs) - 1; i >= 0; i--)
> >> - xe_call_exit_func(i);
> >> + xe_call_exit_func(&init_funcs[i]);
> >
> > and here
> > init_funcs[i].exit();
>
> since .exit is optional, better to keep one helper than
> duplicate code here
agreed... keep the helpers than and the rv-b
>
> >
> > But either way is fine I guess... up to you:
> >
> > Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>
> thanks!
> >
> >> }
> >>
> >> module_init(xe_init);
> >> --
> >> 2.47.1
> >>
>
next prev parent reply other threads:[~2025-07-28 20:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-27 17:19 [PATCH v4 00/11] Updates for drm/xe/configfs Michal Wajdeczko
2025-07-27 17:19 ` [PATCH v4 01/11] drm/xe: Simplify module initialization code Michal Wajdeczko
2025-07-28 19:35 ` Rodrigo Vivi
2025-07-28 19:47 ` Michal Wajdeczko
2025-07-28 20:00 ` Rodrigo Vivi [this message]
2025-07-28 23:52 ` John Harrison
2025-07-29 8:39 ` Michal Wajdeczko
2025-07-27 17:19 ` [PATCH v4 02/11] drm/xe: Print module init abort code Michal Wajdeczko
2025-07-28 19:39 ` Rodrigo Vivi
2025-07-28 19:51 ` Michal Wajdeczko
2025-07-28 19:59 ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 03/11] drm/xe/configfs: Destroy xe_configfs.su_mutex on exit/error Michal Wajdeczko
2025-07-28 19:42 ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 04/11] drm/xe/configfs: Use mutex from xe_configfs subsystem Michal Wajdeczko
2025-07-28 19:50 ` Rodrigo Vivi
2025-07-28 19:55 ` Michal Wajdeczko
2025-07-27 17:20 ` [PATCH v4 05/11] drm/xe/configfs: Rename struct xe_config_device Michal Wajdeczko
2025-07-28 19:54 ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 06/11] drm/xe/configfs: Rename configfs_find_group() helper Michal Wajdeczko
2025-07-28 19:57 ` Rodrigo Vivi
2025-07-27 17:20 ` [PATCH v4 07/11] drm/xe/configfs: Reintroduce struct xe_config_device Michal Wajdeczko
2025-07-29 0:06 ` John Harrison
2025-07-27 17:20 ` [PATCH v4 08/11] drm/xe/configfs: Keep default device config settings together Michal Wajdeczko
2025-07-29 0:07 ` John Harrison
2025-07-27 17:20 ` [PATCH v4 09/11] drm/xe/configfs: Check if device was preconfigured Michal Wajdeczko
2025-07-29 0:11 ` John Harrison
2025-07-27 17:20 ` [PATCH v4 10/11] drm/xe/configfs: Only allow configurations for supported devices Michal Wajdeczko
2025-07-27 17:20 ` [PATCH v4 11/11] drm/xe/configfs: Allow adding configurations for future VFs Michal Wajdeczko
2025-07-27 17:28 ` ✓ CI.KUnit: success for Updates for drm/xe/configfs (rev5) Patchwork
2025-07-27 18:07 ` ✓ Xe.CI.BAT: " Patchwork
2025-07-27 19:09 ` ✓ Xe.CI.Full: " 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=aIfWxg3F4D6LaYbo@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=michal.wajdeczko@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox