Re: [PATCH v5] usb-storage: Optimize scan delay more precisely

From: Alan Stern
Date: Fri Apr 26 2024 - 10:30:22 EST


On Fri, Apr 26, 2024 at 05:02:31PM +0900, Norihiko Hama wrote:
> Current storage scan delay is reduced by the following old commit.
>
> a4a47bc03fe5 ("Lower USB storage settling delay to something more reasonable")
>
> It means that delay is at least 'one second', or zero with delay_use=0.
> 'one second' is still long delay especially for embedded system but
> when delay_use is set to 0 (no delay), still error observed on some USB drives.
>
> So delay_use should not be set to 0 but 'one second' is quite long.
> Especially for embedded system, it's important for end user
> how quickly access to USB drive when it's connected.
> That's why we have a chance to minimize such a constant long delay.
>
> This patch optimizes scan delay more precisely
> to minimize delay time but not to have any problems on USB drives
> by extending module parameter 'delay_use' in milliseconds internally.
> The parameter 'delay_use' is changed to be parsed as 3 decimal point value
> if it has digit values with '.'.
> It makes the range of value to 1 / 1000 in internal 32-bit value
> but it's still enough to set the delay time.
> By default, delay time is 'one second' for backward compatibility.
>
> For example, it seems to be good by changing delay_use=0.1,
> that is 100 millisecond delay without issues for most USB pen drives.
>
> Signed-off-by: Norihiko Hama <Norihiko.Hama@xxxxxxxxxxxxxx>
> ---
> V4 -> V5: Simplify parser/formatter code and fix documentaion
> V3 -> V4: Separate parser functions from module parameter set/get
> V2 -> V3: Change to use kstrtouint only for parsing decimal point
> V1 -> V2: Extend existing module parameter 'delay_use' to support decimal points

Reviewed-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>