The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image()
@ 2024-07-15 11:48 Markus Elfring
  2024-07-15 13:15 ` Ilia Mirkin
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2024-07-15 11:48 UTC (permalink / raw)
  To: nouveau, dri-devel, kernel-janitors, Christophe Jaillet,
	Daniel Vetter, Danilo Krummrich, David Airlie, Karol Herbst,
	Lyude Paul
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 Jul 2024 13:36:54 +0200

Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc” for one selected call.

This issue was transformed by using the Coccinelle software.

Suggested-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e83db051e851..931b62097366 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -42,7 +42,7 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
 	int i;

 	for (i = 0; i < drm->vbios.length; i++)
-		seq_printf(m, "%c", drm->vbios.data[i]);
+		seq_putc(m, drm->vbios.data[i]);
 	return 0;
 }

--
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image()
  2024-07-15 11:48 [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image() Markus Elfring
@ 2024-07-15 13:15 ` Ilia Mirkin
  2024-07-23 16:23   ` [PATCH v2] drm/nouveau/debugfs: Optimise data " Markus Elfring
  2024-07-23 16:57   ` [PATCH] drm/nouveau/debugfs: Simplify character " Christophe JAILLET
  0 siblings, 2 replies; 6+ messages in thread
From: Ilia Mirkin @ 2024-07-15 13:15 UTC (permalink / raw)
  To: Markus Elfring
  Cc: nouveau, dri-devel, kernel-janitors, Christophe Jaillet,
	Daniel Vetter, Danilo Krummrich, David Airlie, Karol Herbst,
	Lyude Paul, LKML

On Mon, Jul 15, 2024 at 7:49 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 15 Jul 2024 13:36:54 +0200
>
> Single characters should be put into a sequence.
> Thus use the corresponding function “seq_putc” for one selected call.
>
> This issue was transformed by using the Coccinelle software.
>
> Suggested-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> index e83db051e851..931b62097366 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> @@ -42,7 +42,7 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
>         int i;
>
>         for (i = 0; i < drm->vbios.length; i++)
> -               seq_printf(m, "%c", drm->vbios.data[i]);
> +               seq_putc(m, drm->vbios.data[i]);

Is there some reason this whole thing isn't just

seq_write(m, drm->vbios.data, drm->vbios.length)

>         return 0;
>  }
>
> --
> 2.45.2
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] drm/nouveau/debugfs: Optimise data output in nouveau_debugfs_vbios_image()
  2024-07-15 13:15 ` Ilia Mirkin
@ 2024-07-23 16:23   ` Markus Elfring
  2024-07-23 16:57   ` [PATCH] drm/nouveau/debugfs: Simplify character " Christophe JAILLET
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-07-23 16:23 UTC (permalink / raw)
  To: nouveau, dri-devel, kernel-janitors, Christophe Jaillet,
	Daniel Vetter, Danilo Krummrich, David Airlie, Ilia Mirkin,
	Karol Herbst, Lyude Paul
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 23 Jul 2024 18:08:15 +0200

Some characters should be put into a sequence.

* Thus print all data by the corresponding function “seq_write” at once.

* Return also the value from this function call.

* Omit a local variable which became redundant with this refactoring.


This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

V2:
A patch review suggestion from Ilia Mirkin was integrated.

 drivers/gpu/drm/nouveau/nouveau_debugfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e83db051e851..980cff265060 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -39,11 +39,8 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct nouveau_drm *drm = nouveau_drm(node->minor->dev);
-	int i;

-	for (i = 0; i < drm->vbios.length; i++)
-		seq_printf(m, "%c", drm->vbios.data[i]);
-	return 0;
+	return seq_write(m, drm->vbios.data, drm->vbios.length);
 }

 static int
--
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image()
  2024-07-15 13:15 ` Ilia Mirkin
  2024-07-23 16:23   ` [PATCH v2] drm/nouveau/debugfs: Optimise data " Markus Elfring
@ 2024-07-23 16:57   ` Christophe JAILLET
  2024-07-23 17:03     ` Ilia Mirkin
  2024-07-24  9:30     ` Markus Elfring
  1 sibling, 2 replies; 6+ messages in thread
From: Christophe JAILLET @ 2024-07-23 16:57 UTC (permalink / raw)
  To: Ilia Mirkin
  Cc: nouveau, dri-devel, kernel-janitors, Daniel Vetter,
	Danilo Krummrich, David Airlie, Karol Herbst, Lyude Paul, LKML,
	Markus Elfring

Le 15/07/2024 à 15:15, Ilia Mirkin a écrit :
> On Mon, Jul 15, 2024 at 7:49 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>>
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Mon, 15 Jul 2024 13:36:54 +0200
>>
>> Single characters should be put into a sequence.
>> Thus use the corresponding function “seq_putc” for one selected call.
>>
>> This issue was transformed by using the Coccinelle software.
>>
>> Suggested-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>   drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> index e83db051e851..931b62097366 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> @@ -42,7 +42,7 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
>>          int i;
>>
>>          for (i = 0; i < drm->vbios.length; i++)
>> -               seq_printf(m, "%c", drm->vbios.data[i]);
>> +               seq_putc(m, drm->vbios.data[i]);
> 
> Is there some reason this whole thing isn't just
> 
> seq_write(m, drm->vbios.data, drm->vbios.length)

Hi,

I don't know if my answer is relevant or not here but:
	for () seq_putc();	==> will fill 'm' with everything that fits in
and
	seq_write()		==> is all or nothing. So if 'm' is too small, then 
nothing will be appended.

I've not looked at the calling tree, but I would expect 'm' to be able 
to have PAGE_SIZE chars, so most probably 4096.

And having gpu + "vbios.rom", I would expect it to be bigger than 4096.

If I'm correct, then changing for seq_write() would just show... nothing.


I don't know if it can happen., but testing should be easy enough to 
figure it out.

just my 2c.

CJ



> 
>>          return 0;
>>   }
>>
>> --
>> 2.45.2
>>
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image()
  2024-07-23 16:57   ` [PATCH] drm/nouveau/debugfs: Simplify character " Christophe JAILLET
@ 2024-07-23 17:03     ` Ilia Mirkin
  2024-07-24  9:30     ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Ilia Mirkin @ 2024-07-23 17:03 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: nouveau, dri-devel, kernel-janitors, Daniel Vetter,
	Danilo Krummrich, David Airlie, Karol Herbst, Lyude Paul, LKML,
	Markus Elfring

On Tue, Jul 23, 2024 at 12:58 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 15/07/2024 à 15:15, Ilia Mirkin a écrit :
> > On Mon, Jul 15, 2024 at 7:49 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> >>
> >> From: Markus Elfring <elfring@users.sourceforge.net>
> >> Date: Mon, 15 Jul 2024 13:36:54 +0200
> >>
> >> Single characters should be put into a sequence.
> >> Thus use the corresponding function “seq_putc” for one selected call.
> >>
> >> This issue was transformed by using the Coccinelle software.
> >>
> >> Suggested-by: Christophe Jaillet <christophe.jaillet@wanadoo.fr>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>   drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> >> index e83db051e851..931b62097366 100644
> >> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> >> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
> >> @@ -42,7 +42,7 @@ nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
> >>          int i;
> >>
> >>          for (i = 0; i < drm->vbios.length; i++)
> >> -               seq_printf(m, "%c", drm->vbios.data[i]);
> >> +               seq_putc(m, drm->vbios.data[i]);
> >
> > Is there some reason this whole thing isn't just
> >
> > seq_write(m, drm->vbios.data, drm->vbios.length)
>
> Hi,
>
> I don't know if my answer is relevant or not here but:
>         for () seq_putc();      ==> will fill 'm' with everything that fits in
> and
>         seq_write()             ==> is all or nothing. So if 'm' is too small, then
> nothing will be appended.
>
> I've not looked at the calling tree, but I would expect 'm' to be able
> to have PAGE_SIZE chars, so most probably 4096.
>
> And having gpu + "vbios.rom", I would expect it to be bigger than 4096.
>
> If I'm correct, then changing for seq_write() would just show... nothing.
>
>
> I don't know if it can happen., but testing should be easy enough to
> figure it out.

The vbios can definitely be much much larger than 4k. But it does
currently work as-is, i.e. you don't just get the first 4k, you get
everything. So I think there's some internal resizing/extension/etc
going on.

But I totally agree -- testing required here. Not sure if the author
has done that.

Cheers,

  -ilia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image()
  2024-07-23 16:57   ` [PATCH] drm/nouveau/debugfs: Simplify character " Christophe JAILLET
  2024-07-23 17:03     ` Ilia Mirkin
@ 2024-07-24  9:30     ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-07-24  9:30 UTC (permalink / raw)
  To: Christophe Jaillet, Ilia Mirkin, nouveau, dri-devel,
	kernel-janitors
  Cc: Daniel Vetter, Danilo Krummrich, David Airlie, Karol Herbst,
	Lyude Paul, LKML

>> Is there some reason this whole thing isn't just
>>
>> seq_write(m, drm->vbios.data, drm->vbios.length)
> I don't know if my answer is relevant or not here but:
>     for () seq_putc();    ==> will fill 'm' with everything that fits in

I find such a discussion approach strange.


> and
>     seq_write()        ==> is all or nothing. So if 'm' is too small, then nothing will be appended.

The clarification can become more interesting for this system detail.
https://elixir.bootlin.com/linux/v6.10/source/fs/seq_file.c#L816

Was the sequence size (or the file capacity) appropriately configured?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-24  9:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-15 11:48 [PATCH] drm/nouveau/debugfs: Simplify character output in nouveau_debugfs_vbios_image() Markus Elfring
2024-07-15 13:15 ` Ilia Mirkin
2024-07-23 16:23   ` [PATCH v2] drm/nouveau/debugfs: Optimise data " Markus Elfring
2024-07-23 16:57   ` [PATCH] drm/nouveau/debugfs: Simplify character " Christophe JAILLET
2024-07-23 17:03     ` Ilia Mirkin
2024-07-24  9:30     ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox