Netdev List
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Heyang Tan <thy15333007817@163.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<sgoutham@marvell.com>, <gakula@marvell.com>,
	<sbhatta@marvell.com>
Subject: Re: [PATCH] octeontx2-af: use seq_file for rsrc_alloc debugfs
Date: Mon, 7 Sep 2026 08:37:35 +0530	[thread overview]
Message-ID: <ap4qd9c-givSLVwW@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260906141129.1730-1-thy15333007817@163.com>

On 2026-09-06 at 19:41:29, Heyang Tan (thy15333007817@163.com) wrote:
> The rsrc_status debugfs reader writes rows directly to userspace without
> respecting the caller's read count. It also uses the current row length as
> the userspace stride, which can corrupt output when rows have different
> widths.
>
> Build each row in the existing kernel buffer and use seq_file to handle
> userspace buffer sizes, offsets, and partial reads.
>
> Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
> Signed-off-by: Heyang Tan <thy15333007817@163.com>
> ---
>  .../marvell/octeontx2/af/rvu_debugfs.c        | 71 ++++++-------------
>  1 file changed, 22 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> index 22ee99676879..a222998482fa 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> @@ -714,52 +714,39 @@ static int get_max_column_width(struct rvu *rvu)
>  }
>
>  /* Dumps current provisioning status of all RVU block LFs */
> -static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
> -					  char __user *buffer,
> -					  size_t count, loff_t *ppos)
> +static int rvu_dbg_rsrc_attach_status(struct seq_file *filp, void *unused)
>  {
> -	int index, off = 0, flag = 0, len = 0, i = 0;
> -	struct rvu *rvu = filp->private_data;
> -	int bytes_not_copied = 0;
> +	int index, off, flag, pf, vf, pcifunc;
> +	struct rvu *rvu = filp->private;
>  	struct rvu_block block;
> -	int pf, vf, pcifunc;
>  	int buf_size = 2048;
>  	int lf_str_size;
>  	char *lfs;
>  	char *buf;
>
> -	/* don't allow partial reads */
> -	if (*ppos != 0)
> -		return 0;
> -
>  	buf = kzalloc(buf_size, GFP_KERNEL);
>  	if (!buf)
>  		return -ENOMEM;
>
> -	/* Get the maximum width of a column */
>  	lf_str_size = get_max_column_width(rvu);
> +	if (lf_str_size < 0) {
> +		kfree(buf);
> +		return lf_str_size;
> +	}
>
>  	lfs = kzalloc(lf_str_size, GFP_KERNEL);
>  	if (!lfs) {
>  		kfree(buf);
>  		return -ENOMEM;
>  	}
> -	off +=	scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
> -			  "pcifunc");
Can we get rid of scnprintf() ? each column can go straight to the seq buffer.

      reply	other threads:[~2026-09-07  3:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 14:11 [PATCH] octeontx2-af: use seq_file for rsrc_alloc debugfs Heyang Tan
2026-09-07  3:07 ` Ratheesh Kannoth [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=ap4qd9c-givSLVwW@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=gakula@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=thy15333007817@163.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