El jue, 23-11-2023 a las 21:47 -0300, Maíra Canal escribió: > We want to allow the IOCTLs to allocate the job without initiating > it. > This will be useful for the CPU job submission IOCTL, as the CPU job > has > the need to use information from the user extensions. Currently, the > user extensions are parsed before the job allocation, making it > impossible to fill the CPU job when parsing the user extensions. > Therefore, decouple the job allocation from the job initiation. > > Signed-off-by: Maíra Canal <mca...@igalia.com> > --- > drivers/gpu/drm/v3d/v3d_submit.c | 23 ++++++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/v3d/v3d_submit.c > b/drivers/gpu/drm/v3d/v3d_submit.c > index fe46dd316ca0..ed1a310bbd2f 100644 > --- a/drivers/gpu/drm/v3d/v3d_submit.c > +++ b/drivers/gpu/drm/v3d/v3d_submit.c > @@ -135,6 +135,21 @@ void v3d_job_put(struct v3d_job *job) > kref_put(&job->refcount, job->free); > } > > +static int > +v3d_job_allocate(void **container, size_t size) > +{ > + if (*container) > + return 0;
Mmm... is this really what we want? At least right now we expect v3d_job_allocate to always allocate memory, is there any scenario in which we would expect to call this with an already allocated container? Iago > + > + *container = kcalloc(1, size, GFP_KERNEL); > + if (!*container) { > + DRM_ERROR("Cannot allocate memory for V3D job.\n"); > + return -ENOMEM; > + } > + > + return 0; > +} > + > static int > v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv, > void **container, size_t size, void (*free)(struct kref > *ref), > @@ -145,11 +160,9 @@ v3d_job_init(struct v3d_dev *v3d, struct > drm_file *file_priv, > bool has_multisync = se && (se->flags & > DRM_V3D_EXT_ID_MULTI_SYNC); > int ret, i; > > - *container = kcalloc(1, size, GFP_KERNEL); > - if (!*container) { > - DRM_ERROR("Cannot allocate memory for v3d job."); > - return -ENOMEM; > - } > + ret = v3d_job_allocate(container, size); > + if (ret) > + return ret; > > job = *container; > job->v3d = v3d;