From: Philipp Stanner <phasta@mailbox.org>
To: "Maíra Canal" <mcanal@igalia.com>,
"Philipp Stanner" <phasta@kernel.org>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Xinhui Pan" <Xinhui.Pan@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Lucas Stach" <l.stach@pengutronix.de>,
"Russell King" <linux+etnaviv@armlinux.org.uk>,
"Christian Gmeiner" <christian.gmeiner@gmail.com>,
"Frank Binns" <frank.binns@imgtec.com>,
"Matt Coster" <matt.coster@imgtec.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Qiang Yu" <yuq825@gmail.com>, "Rob Clark" <robdclark@gmail.com>,
"Sean Paul" <sean@poorly.run>,
"Konrad Dybcio" <konradybcio@kernel.org>,
"Abhinav Kumar" <quic_abhinavk@quicinc.com>,
"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
"Marijn Suijten" <marijn.suijten@somainline.org>,
"Karol Herbst" <kherbst@redhat.com>,
"Lyude Paul" <lyude@redhat.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Rob Herring" <robh@kernel.org>,
"Steven Price" <steven.price@arm.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Luben Tuikov" <ltuikov89@gmail.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Melissa Wen" <mwen@igalia.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Sunil Khatri" <sunil.khatri@amd.com>,
"Lijo Lazar" <lijo.lazar@amd.com>,
"Mario Limonciello" <mario.limonciello@amd.com>,
"Ma Jun" <Jun.Ma2@amd.com>, "Yunxiang Li" <Yunxiang.Li@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org,
lima@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/sched: Use struct for drm_sched_init() params
Date: Thu, 23 Jan 2025 13:13:25 +0100 [thread overview]
Message-ID: <e7414579afbfc25d4027471bc265ee48e7d25932.camel@mailbox.org> (raw)
In-Reply-To: <ec4bb0f6-c366-40e7-a1df-332458b08eec@igalia.com>
On Thu, 2025-01-23 at 08:10 -0300, Maíra Canal wrote:
> Hi Philipp,
>
> On 23/01/25 05:10, Philipp Stanner wrote:
> > On Wed, 2025-01-22 at 19:07 -0300, Maíra Canal wrote:
> > > Hi Philipp,
> > >
> > > On 22/01/25 11:08, Philipp Stanner wrote:
> > > > drm_sched_init() has a great many parameters and upcoming new
> > > > functionality for the scheduler might add even more. Generally,
> > > > the
> > > > great number of parameters reduces readability and has already
> > > > caused
> > > > one missnaming in:
> > > >
> > > > commit 6f1cacf4eba7 ("drm/nouveau: Improve variable name in
> > > > nouveau_sched_init()").
> > > >
> > > > Introduce a new struct for the scheduler init parameters and
> > > > port
> > > > all
> > > > users.
> > > >
> > > > Signed-off-by: Philipp Stanner <phasta@kernel.org>
>
> [...]
>
> > >
> > > > diff --git a/drivers/gpu/drm/v3d/v3d_sched.c
> > > > b/drivers/gpu/drm/v3d/v3d_sched.c
> > > > index 99ac4995b5a1..716e6d074d87 100644
> > > > --- a/drivers/gpu/drm/v3d/v3d_sched.c
> > > > +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> > > > @@ -814,67 +814,124 @@ static const struct
> > > > drm_sched_backend_ops
> > > > v3d_cpu_sched_ops = {
> > > > .free_job = v3d_cpu_job_free
> > > > };
> > > >
> > > > +/*
> > > > + * v3d's scheduler instances are all identical, except for ops
> > > > and
> > > > name.
> > > > + */
> > > > +static void
> > > > +v3d_common_sched_init(struct drm_sched_init_params *params,
> > > > struct
> > > > device *dev)
> > > > +{
> > > > + memset(params, 0, sizeof(struct
> > > > drm_sched_init_params));
> > > > +
> > > > + params->submit_wq = NULL; /* Use the system_wq. */
> > > > + params->num_rqs = DRM_SCHED_PRIORITY_COUNT;
> > > > + params->credit_limit = 1;
> > > > + params->hang_limit = 0;
> > > > + params->timeout = msecs_to_jiffies(500);
> > > > + params->timeout_wq = NULL; /* Use the system_wq. */
> > > > + params->score = NULL;
> > > > + params->dev = dev;
> > > > +}
> > >
> > > Could we use only one function that takes struct v3d_dev *v3d,
> > > enum
> > > v3d_queue, and sched_ops as arguments (instead of one function
> > > per
> > > queue)? You can get the name of the scheduler by concatenating
> > > "v3d_"
> > > to
> > > the return of v3d_queue_to_string().
> > >
> > > I believe it would make the code much simpler.
> >
> > Hello,
> >
> > so just to get that right:
> > You'd like to have one universal function that switch-cases over an
> > enum, sets the ops and creates the name with string concatenation?
> >
> > I'm not convinced that this is simpler than a few small functions,
> > but
> > it's not my component, so…
> >
> > Whatever we'll do will be simpler than the existing code, though.
> > Right
> > now no reader can see at first glance whether all those schedulers
> > are
> > identically parametrized or not.
> >
>
> This is my proposal (just a quick draft, please check if it
> compiles):
>
> diff --git a/drivers/gpu/drm/v3d/v3d_sched.c
> b/drivers/gpu/drm/v3d/v3d_sched.c
> index 961465128d80..7cc45a0c6ca0 100644
> --- a/drivers/gpu/drm/v3d/v3d_sched.c
> +++ b/drivers/gpu/drm/v3d/v3d_sched.c
> @@ -820,67 +820,62 @@ static const struct drm_sched_backend_ops
> v3d_cpu_sched_ops = {
> .free_job = v3d_cpu_job_free
> };
>
> +static int
> +v3d_sched_queue_init(struct v3d_dev *v3d, enum v3d_queue queue,
> + const struct drm_sched_backend_ops *ops, const
Is it a queue, though?
How about _v3d_sched_init()?
P.
> char
> *name)
> +{
> + struct drm_sched_init_params params = {
> + .submit_wq = NULL,
> + .num_rqs = DRM_SCHED_PRIORITY_COUNT,
> + .credit_limit = 1,
> + .hang_limit = 0,
> + .timeout = msecs_to_jiffies(500),
> + .timeout_wq = NULL,
> + .score = NULL,
> + .dev = v3d->drm.dev,
> + };
> +
> + params.ops = ops;
> + params.name = name;
> +
> + return drm_sched_init(&v3d->queue[queue].sched, ¶ms);
> +}
> +
> int
> v3d_sched_init(struct v3d_dev *v3d)
> {
> - int hw_jobs_limit = 1;
> - int job_hang_limit = 0;
> - int hang_limit_ms = 500;
> int ret;
>
> - ret = drm_sched_init(&v3d->queue[V3D_BIN].sched,
> - &v3d_bin_sched_ops, NULL,
> - DRM_SCHED_PRIORITY_COUNT,
> - hw_jobs_limit, job_hang_limit,
> - msecs_to_jiffies(hang_limit_ms), NULL,
> - NULL, "v3d_bin", v3d->drm.dev);
> + ret = v3d_sched_queue_init(v3d, V3D_BIN, &v3d_bin_sched_ops,
> + "v3d_bin");
> if (ret)
> return ret;
>
> - ret = drm_sched_init(&v3d->queue[V3D_RENDER].sched,
> - &v3d_render_sched_ops, NULL,
> - DRM_SCHED_PRIORITY_COUNT,
> - hw_jobs_limit, job_hang_limit,
> - msecs_to_jiffies(hang_limit_ms), NULL,
> - NULL, "v3d_render", v3d->drm.dev);
> + ret = v3d_sched_queue_init(v3d, V3D_RENDER,
> &v3d_render_sched_ops,
> + "v3d_render");
> if (ret)
> goto fail;
>
> [...]
>
> At least for me, this looks much simpler than one function for each
> V3D queue.
>
> Best Regards,
> - Maíra
>
> > P.
> >
> >
> > >
> > > Best Regards,
> > > - Maíra
> > >
>
next prev parent reply other threads:[~2025-01-23 12:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 14:08 Philipp Stanner
2025-01-22 14:30 ` Danilo Krummrich
2025-01-22 14:34 ` Christian König
2025-01-22 14:48 ` Philipp Stanner
2025-01-22 15:02 ` Matthew Brost
2025-01-22 15:06 ` Christian König
2025-01-22 15:23 ` Philipp Stanner
2025-01-22 15:37 ` Christian König
2025-01-22 15:29 ` Matthew Brost
2025-01-22 15:51 ` Boris Brezillon
2025-01-22 16:14 ` Tvrtko Ursulin
2025-01-22 17:04 ` Boris Brezillon
2025-01-23 4:37 ` Matthew Brost
2025-01-23 7:34 ` Philipp Stanner
2025-01-22 17:16 ` Boris Brezillon
2025-01-23 7:33 ` Philipp Stanner
2025-01-23 8:23 ` Boris Brezillon
2025-01-23 9:29 ` Danilo Krummrich
2025-01-23 9:35 ` Philipp Stanner
2025-01-23 9:55 ` Danilo Krummrich
2025-01-23 10:57 ` Tvrtko Ursulin
2025-01-22 22:07 ` Maíra Canal
2025-01-23 8:10 ` Philipp Stanner
2025-01-23 8:39 ` Philipp Stanner
2025-01-23 11:10 ` Maíra Canal
2025-01-23 12:13 ` Philipp Stanner [this message]
2025-01-23 12:29 ` Maíra Canal
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=e7414579afbfc25d4027471bc265ee48e7d25932.camel@mailbox.org \
--to=phasta@mailbox.org \
--cc=Jun.Ma2@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=Yunxiang.Li@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=boris.brezillon@collabora.com \
--cc=christian.gmeiner@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dakr@kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=etnaviv@lists.freedesktop.org \
--cc=frank.binns@imgtec.com \
--cc=freedreno@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=konradybcio@kernel.org \
--cc=l.stach@pengutronix.de \
--cc=lijo.lazar@amd.com \
--cc=lima@lists.freedesktop.org \
--cc=linux+etnaviv@armlinux.org.uk \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=ltuikov89@gmail.com \
--cc=lucas.demarchi@intel.com \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marijn.suijten@somainline.org \
--cc=mario.limonciello@amd.com \
--cc=matt.coster@imgtec.com \
--cc=matthew.brost@intel.com \
--cc=mcanal@igalia.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=nouveau@lists.freedesktop.org \
--cc=phasta@kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=robdclark@gmail.com \
--cc=robh@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=sunil.khatri@amd.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
--cc=yuq825@gmail.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
all inboxes | Powered by JetHome®