<div dir="ltr"><a href="https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-class-mtd#L65">https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-class-mtd#L65</a><br><div>"No erase necessary"</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 1, 2017 at 12:16 AM Suraj Jitindar Singh <<a href="mailto:sjitindarsingh@gmail.com">sjitindarsingh@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On Mon, 2017-08-28 at 23:48 -0700, William A. Kennington III wrote:<br>
> Currently, flash devices like mbox-flash ignore erase commands. This<br>
> means that issuing an erase from userspace, through the mtd device,<br>
> and<br>
> back returns a successful operation that does nothing. Unfortunately<br>
> this makes userspace tools unhappy. Linux MTD devices support the<br>
> MTD_NO_ERASE flag which conveys that writes do not require erases on<br>
> the<br>
> underlying flash devices. We should set this property on all of our<br>
> devices which do not require erases to be performed.<br>
><br>
> NOTE: This still requires a linux kernel component to set the<br>
> MTD_NO_ERASE flag from the device tree property.<br>
<br>
Can I just check, does the MTD_NO_ERASE flag mean that the mtd device<br>
doesn't have an erase function, or that an erase isn't necessary before<br>
a write?<br>
<br>
Because the V2 mbox has an erase method which mbox-flash will call when<br>
an erase is performed. So if it means there isn't an erase function<br>
then this is incorrect.<br>
<br>
If it means that an erase isn't required before a write however then I<br>
support this as the mbox protocol explicitly states this to be the<br>
case.<br>
<br>
Thanks,<br>
Suraj<br>
<br>
><br>
> Signed-off-by: William A. Kennington III <<a href="mailto:wak@google.com" target="_blank">wak@google.com</a>><br>
> ---<br>
>  core/flash.c | 4 ++++<br>
>  1 file changed, 4 insertions(+)<br>
><br>
> diff --git a/core/flash.c b/core/flash.c<br>
> index 53e6eba08..9e230174f 100644<br>
> --- a/core/flash.c<br>
> +++ b/core/flash.c<br>
> @@ -31,6 +31,7 @@<br>
>  struct flash {<br>
>       struct list_node        list;<br>
>       bool                    busy;<br>
> +     bool                    no_erase;<br>
>       struct blocklevel_device *bl;<br>
>       uint64_t                size;<br>
>       uint32_t                block_size;<br>
> @@ -199,6 +200,8 @@ static struct dt_node *flash_add_dt_node(struct<br>
> flash *flash, int id)<br>
>       dt_add_property_u64(flash_node, "reg", flash->size);<br>
>       dt_add_property_cells(flash_node, "ibm,flash-block-size",<br>
>                       flash->block_size);<br>
> +     if (flash->no_erase)<br>
> +             dt_add_property(flash_node, "no-erase", NULL, 0);<br>
>  <br>
>       /* we fix to 32-bits */<br>
>       dt_add_property_cells(flash_node, "#address-cells", 1);<br>
> @@ -281,6 +284,7 @@ int flash_register(struct blocklevel_device *bl)<br>
>  <br>
>       flash->busy = false;<br>
>       flash->bl = bl;<br>
> +     flash->no_erase = !(bl->flags & WRITE_NEED_ERASE);<br>
>       flash->size = size;<br>
>       flash->block_size = block_size;<br>
>       flash->id = num_flashes();<br>
</blockquote></div>