All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch
Subject: Re: [PATCH net-next] netdevsim: add couple of fw_update_flash_* debugfs knobs
Date: Sun, 20 Jul 2025 15:15:02 +0100	[thread overview]
Message-ID: <20250720141502.GV2459@horms.kernel.org> (raw)
In-Reply-To: <20250719131315.353975-1-jiri@resnulli.us>

On Sat, Jul 19, 2025 at 03:13:15PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Netdevsim emulates firmware update and it takes 5 seconds to complete.
> For some usecases, this is too long and unnecessary. Allow user to
> configure the time by exposing debugfs knobs to set flash size, chunk
> size and chunk time.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>

...

> @@ -1035,20 +1040,20 @@ static int nsim_dev_flash_update(struct devlink *devlink,
>  						   params->component, 0, 0);
>  	}
>  
> -	for (i = 0; i < NSIM_DEV_FLASH_SIZE / NSIM_DEV_FLASH_CHUNK_SIZE; i++) {
> +	for (i = 0; i < flash_size / flash_chunk_size; i++) {
>  		if (nsim_dev->fw_update_status)
>  			devlink_flash_update_status_notify(devlink, "Flashing",
>  							   params->component,
> -							   i * NSIM_DEV_FLASH_CHUNK_SIZE,
> -							   NSIM_DEV_FLASH_SIZE);
> -		msleep(NSIM_DEV_FLASH_CHUNK_TIME_MS);
> +							   i * flash_chunk_size,
> +							   flash_size);
> +		msleep(flash_chunk_time_ms);
>  	}

Hi Jiri,

This loop seems to assume that flash_size is an integer number multiple
of flash_chunk_size. But with this change that may not be the case,
leading to less than flash_size bytes being written.

Perhaps the code should to guard against that, or handle it somehow.

>  
>  	if (nsim_dev->fw_update_status) {
>  		devlink_flash_update_status_notify(devlink, "Flashing",
>  						   params->component,
> -						   NSIM_DEV_FLASH_SIZE,
> -						   NSIM_DEV_FLASH_SIZE);
> +						   flash_size,
> +						   flash_size);
>  		devlink_flash_update_timeout_notify(devlink, "Flash select",
>  						    params->component, 81);
>  		devlink_flash_update_status_notify(devlink, "Flashing done",

...

  reply	other threads:[~2025-07-20 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-19 13:13 [PATCH net-next] netdevsim: add couple of fw_update_flash_* debugfs knobs Jiri Pirko
2025-07-20 14:15 ` Simon Horman [this message]
2025-07-21  9:15   ` Jiri Pirko

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=20250720141502.GV2459@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.