Message ID | 20240115170826.214519-2-benjamin.gaignard@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: media videobuf2: Stop direct calls to queue num_buffers field | expand |
On 15/01/2024 18:08, Benjamin Gaignard wrote: > Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. > This allows us to change how the number of buffers is computed in the > future. > > Fixes: c838530d230b ("media: media videobuf2: Be more flexible on the number of queue stored buffers") > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> > --- > drivers/media/common/videobuf2/videobuf2-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c > index 41a832dd1426..b6bf8f232f48 100644 > --- a/drivers/media/common/videobuf2/videobuf2-core.c > +++ b/drivers/media/common/videobuf2/videobuf2-core.c > @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, > bool no_previous_buffers = !q_num_bufs; > int ret = 0; > > - if (q->num_buffers == q->max_num_buffers) { > + if (q_num_bufs == q->max_num_buffers) { > dprintk(q, 1, "maximum number of buffers already allocated\n"); > return -ENOBUFS; > } There is another case in vb2_ioctl_create_bufs() where num_buffers is accessed directly. Can you fix that one as well? Regards, Hans
Le 16/01/2024 à 10:21, Hans Verkuil a écrit : > On 15/01/2024 18:08, Benjamin Gaignard wrote: >> Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. >> This allows us to change how the number of buffers is computed in the >> future. >> >> Fixes: c838530d230b ("media: media videobuf2: Be more flexible on the number of queue stored buffers") >> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> >> --- >> drivers/media/common/videobuf2/videobuf2-core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c >> index 41a832dd1426..b6bf8f232f48 100644 >> --- a/drivers/media/common/videobuf2/videobuf2-core.c >> +++ b/drivers/media/common/videobuf2/videobuf2-core.c >> @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, >> bool no_previous_buffers = !q_num_bufs; >> int ret = 0; >> >> - if (q->num_buffers == q->max_num_buffers) { >> + if (q_num_bufs == q->max_num_buffers) { >> dprintk(q, 1, "maximum number of buffers already allocated\n"); >> return -ENOBUFS; >> } > There is another case in vb2_ioctl_create_bufs() where num_buffers is accessed directly. > Can you fix that one as well? It is removed by the patch I have send just after this one: "media: core: Refactor vb2_ioctl_create_bufs() to always set capabilities flags" Regards, Benjamin > > Regards, > > Hans >
On Tue, Jan 16, 2024 at 6:32 PM Benjamin Gaignard <benjamin.gaignard@collabora.com> wrote: > > > Le 16/01/2024 à 10:21, Hans Verkuil a écrit : > > On 15/01/2024 18:08, Benjamin Gaignard wrote: > >> Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. > >> This allows us to change how the number of buffers is computed in the > >> future. > >> > >> Fixes: c838530d230b ("media: media videobuf2: Be more flexible on the number of queue stored buffers") > >> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> > >> --- > >> drivers/media/common/videobuf2/videobuf2-core.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c > >> index 41a832dd1426..b6bf8f232f48 100644 > >> --- a/drivers/media/common/videobuf2/videobuf2-core.c > >> +++ b/drivers/media/common/videobuf2/videobuf2-core.c > >> @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, > >> bool no_previous_buffers = !q_num_bufs; > >> int ret = 0; > >> > >> - if (q->num_buffers == q->max_num_buffers) { > >> + if (q_num_bufs == q->max_num_buffers) { > >> dprintk(q, 1, "maximum number of buffers already allocated\n"); > >> return -ENOBUFS; > >> } > > There is another case in vb2_ioctl_create_bufs() where num_buffers is accessed directly. > > Can you fix that one as well? > > It is removed by the patch I have send just after this one: > "media: core: Refactor vb2_ioctl_create_bufs() to always set capabilities flags" I'd prefer that to be also included in this fix, so that it's all logically grouped together. Actually Hans also ended up including that change in his patch, without the commit message mentioning it. Best regards, Tomasz
On 1/18/24 12:22, Tomasz Figa wrote: > On Tue, Jan 16, 2024 at 6:32 PM Benjamin Gaignard > <benjamin.gaignard@collabora.com> wrote: >> >> >> Le 16/01/2024 à 10:21, Hans Verkuil a écrit : >>> On 15/01/2024 18:08, Benjamin Gaignard wrote: >>>> Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. >>>> This allows us to change how the number of buffers is computed in the >>>> future. >>>> >>>> Fixes: c838530d230b ("media: media videobuf2: Be more flexible on the number of queue stored buffers") >>>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> >>>> --- >>>> drivers/media/common/videobuf2/videobuf2-core.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c >>>> index 41a832dd1426..b6bf8f232f48 100644 >>>> --- a/drivers/media/common/videobuf2/videobuf2-core.c >>>> +++ b/drivers/media/common/videobuf2/videobuf2-core.c >>>> @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, >>>> bool no_previous_buffers = !q_num_bufs; >>>> int ret = 0; >>>> >>>> - if (q->num_buffers == q->max_num_buffers) { >>>> + if (q_num_bufs == q->max_num_buffers) { >>>> dprintk(q, 1, "maximum number of buffers already allocated\n"); >>>> return -ENOBUFS; >>>> } >>> There is another case in vb2_ioctl_create_bufs() where num_buffers is accessed directly. >>> Can you fix that one as well? >> >> It is removed by the patch I have send just after this one: >> "media: core: Refactor vb2_ioctl_create_bufs() to always set capabilities flags" > > I'd prefer that to be also included in this fix, so that it's all > logically grouped together. Actually Hans also ended up including that > change in his patch, without the commit message mentioning it. Yeah, it's borderline. But I think it is better if this patch updates both places, and then I'll make a v2 for my patch on top. Regards, Hans > > Best regards, > Tomasz
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 41a832dd1426..b6bf8f232f48 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, bool no_previous_buffers = !q_num_bufs; int ret = 0; - if (q->num_buffers == q->max_num_buffers) { + if (q_num_bufs == q->max_num_buffers) { dprintk(q, 1, "maximum number of buffers already allocated\n"); return -ENOBUFS; }
Use vb2_get_num_buffers() to avoid using queue num_buffers field directly. This allows us to change how the number of buffers is computed in the future. Fixes: c838530d230b ("media: media videobuf2: Be more flexible on the number of queue stored buffers") Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> --- drivers/media/common/videobuf2/videobuf2-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)