From: Alexandru Dadu <Alexandru.Dadu@imgtec.com>
To: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"rosenp@gmail.com" <rosenp@gmail.com>
Cc: Luigi Santivetti <Luigi.Santivetti@imgtec.com>,
"imagination@lists.freedesktop.org"
<imagination@lists.freedesktop.org>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"airlied@gmail.com" <airlied@gmail.com>,
Alessio Belle <Alessio.Belle@imgtec.com>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"mripard@kernel.org" <mripard@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] drm/imagination: simplify pvr_fw_trace_seq_data
Date: Wed, 21 Oct 2026 10:02:25 +0000 [thread overview]
Message-ID: <9aeac8004ff8b360b7ab8261ca2d849ac25b53aa.camel@imgtec.com> (raw)
In-Reply-To: <20261005194127.151181-1-rosenp@gmail.com>
Hi Rosen,
On Mon, 2026-10-05 at 12:41 -0700, Rosen Penev wrote:
> The trace buffer copy always has
> ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS
> entries, so embed it in struct pvr_fw_trace_seq_data as a fixed-size
> array instead of allocating it separately. This removes one
> allocation
> and its error handling, and lets FORTIFY_SOURCE and UBSAN_BOUNDS see
> the
> real size of the buffer.
>
> At about 48KB, the struct needs an order-4 page allocation, which can
> fail under memory fragmentation. Allocate it with kvzalloc_obj() so
> it
> falls back to vmalloc in that case, and free it with kvfree().
>
> Assisted-by: LLM
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Alexandru Dadu <alexandru.dadu@imgtec.com>
Thanks,
Alexandru Dadu
> ---
> v2: use kvzalloc_obj()
> drivers/gpu/drm/imagination/pvr_fw_trace.c | 25 ++++++--------------
> --
> 1 file changed, 7 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c
> b/drivers/gpu/drm/imagination/pvr_fw_trace.c
> index 6fe478f64f02..27bbc62114b1 100644
> --- a/drivers/gpu/drm/imagination/pvr_fw_trace.c
> +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c
> @@ -240,9 +240,6 @@ update_logtype(struct pvr_device *pvr_dev, u32
> group_mask)
> }
>
> struct pvr_fw_trace_seq_data {
> - /** @buffer: Pointer to copy of trace data. */
> - u32 *buffer;
> -
> /** @start_offset: Starting offset in trace data, as
> reported by FW. */
> u32 start_offset;
>
> @@ -251,6 +248,9 @@ struct pvr_fw_trace_seq_data {
>
> /** @assert_buf: Trace assert buffer, as reported by FW. */
> struct rogue_fwif_file_info_buf assert_buf;
> +
> + /** @buffer: Copy of trace data. */
> + u32 buffer[ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS];
> };
>
> static u32 find_sfid(u32 id)
> @@ -454,17 +454,10 @@ static int fw_trace_open(struct inode *inode,
> struct file *file)
> struct pvr_fw_trace_seq_data *trace_seq_data;
> int err;
>
> - trace_seq_data = kzalloc_obj(*trace_seq_data);
> + trace_seq_data = kvzalloc_obj(*trace_seq_data);
> if (!trace_seq_data)
> return -ENOMEM;
>
> - trace_seq_data->buffer =
> kcalloc(ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS,
> - sizeof(*trace_seq_data-
> >buffer), GFP_KERNEL);
> - if (!trace_seq_data->buffer) {
> - err = -ENOMEM;
> - goto err_free_data;
> - }
> -
> /*
> * Take a local copy of the trace buffer, as firmware may
> still be
> * writing to it. This will exist as long as this file is
> open.
> @@ -477,17 +470,14 @@ static int fw_trace_open(struct inode *inode,
> struct file *file)
>
> err = seq_open(file, &pvr_fw_trace_seq_ops);
> if (err)
> - goto err_free_buffer;
> + goto err_free_data;
>
> ((struct seq_file *)file->private_data)->private =
> trace_seq_data;
>
> return 0;
>
> -err_free_buffer:
> - kfree(trace_seq_data->buffer);
> -
> err_free_data:
> - kfree(trace_seq_data);
> + kvfree(trace_seq_data);
>
> return err;
> }
> @@ -498,8 +488,7 @@ static int fw_trace_release(struct inode *inode,
> struct file *file)
> ((struct seq_file *)file->private_data)->private;
>
> seq_release(inode, file);
> - kfree(trace_seq_data->buffer);
> - kfree(trace_seq_data);
> + kvfree(trace_seq_data);
>
> return 0;
> }
prev parent reply other threads:[~2026-10-21 10:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 19:41 Rosen Penev
2026-10-21 10:02 ` Alexandru Dadu [this message]
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=9aeac8004ff8b360b7ab8261ca2d849ac25b53aa.camel@imgtec.com \
--to=alexandru.dadu@imgtec.com \
--cc=Alessio.Belle@imgtec.com \
--cc=Luigi.Santivetti@imgtec.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=imagination@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=rosenp@gmail.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®