mtd: powernv: Support MTD_NO_ERASE

Message ID 20170905202339.20732-1-wak@google.com
State New
Headers show
Series
  • mtd: powernv: Support MTD_NO_ERASE
Related show

Commit Message

William A. Kennington III Sept. 5, 2017, 8:23 p.m.
As of skiboot@ba99af9b149d02438347b055e6e7d6bd15e33551, we now support
adding a device tree entry which marks a flash device as not needing
erase. This patch adds support for setting MTD_NO_ERASE on powernvflash
devices which have the property no-erase.

Signed-off-by: William A. Kennington III <wak@google.com>
---
 drivers/mtd/devices/powernv_flash.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Boris Brezillon Sept. 21, 2017, 7:59 a.m. | #1
+the DT maintainers

On Tue,  5 Sep 2017 13:23:39 -0700
"William A. Kennington III" <wak@google.com> wrote:

> As of skiboot@ba99af9b149d02438347b055e6e7d6bd15e33551, we now support

I didn't find this commit in mainline.

> adding a device tree entry which marks a flash device as not needing
> erase. This patch adds support for setting MTD_NO_ERASE on powernvflash
> devices which have the property no-erase.
> 
> Signed-off-by: William A. Kennington III <wak@google.com>
> ---
>  drivers/mtd/devices/powernv_flash.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mtd/devices/powernv_flash.c b/drivers/mtd/devices/powernv_flash.c
> index f5396f26ddb4..fab9f9121b4c 100644
> --- a/drivers/mtd/devices/powernv_flash.c
> +++ b/drivers/mtd/devices/powernv_flash.c
> @@ -196,6 +196,8 @@ static int powernv_flash_set_driver_info(struct device *dev,
>  	mtd->name = of_get_property(dev->of_node, "name", NULL);
>  	mtd->type = MTD_NORFLASH;
>  	mtd->flags = MTD_WRITEABLE;
> +	if (of_property_read_bool(dev->of_node, "no-erase"))
> +		mtd->flags |= MTD_NO_ERASE;

I don't see this property document in a DT binding doc, which is
mandatory. Actually, there's no DT bindings doc at all for the
'ibm,opal-flash' device in mainline, is this normal?

>  	mtd->size = size;
>  	mtd->erasesize = erase_size;
>  	mtd->writebufsize = mtd->writesize = 1;
Michael Ellerman Sept. 22, 2017, 4:13 a.m. | #2
William Kennington <wak@google.com> writes:

> +Cyril Bur and
>
> Not sure what you mean by mainline, but the commit is in the master branch
> at
> https://github.com/open-power/skiboot/commit/ba99af9b149d02438347b055e6e7d6bd15e33551

I suspect Boris missed that you were referring to a skiboot commit and
looked in Linux?

> I'm unsure about the documentation of the properties as I'm not really the
> maintainer of any of the code on either side. I just added this DT property
> for plumbing through the NO_ERASE flag. I added Cyril and Michael as they
> both work closely with this driver and could comment better than I could.
>
> - William
>
> On Thu, Sep 21, 2017 at 12:59 AM Boris Brezillon <
> boris.brezillon@free-electrons.com> wrote:
>
>> +the DT maintainers
>>
>> On Tue,  5 Sep 2017 13:23:39 -0700
>> "William A. Kennington III" <wak@google.com> wrote:
>>
>> > As of skiboot@ba99af9b149d02438347b055e6e7d6bd15e33551, we now support
>>
>> I didn't find this commit in mainline.
>>
>> > adding a device tree entry which marks a flash device as not needing
>> > erase. This patch adds support for setting MTD_NO_ERASE on powernvflash
>> > devices which have the property no-erase.
>> >
>> > Signed-off-by: William A. Kennington III <wak@google.com>
>> > ---
>> >  drivers/mtd/devices/powernv_flash.c | 2 ++
>> >  1 file changed, 2 insertions(+)
>> >
>> > diff --git a/drivers/mtd/devices/powernv_flash.c
>> b/drivers/mtd/devices/powernv_flash.c
>> > index f5396f26ddb4..fab9f9121b4c 100644
>> > --- a/drivers/mtd/devices/powernv_flash.c
>> > +++ b/drivers/mtd/devices/powernv_flash.c
>> > @@ -196,6 +196,8 @@ static int powernv_flash_set_driver_info(struct
>> device *dev,
>> >       mtd->name = of_get_property(dev->of_node, "name", NULL);
>> >       mtd->type = MTD_NORFLASH;
>> >       mtd->flags = MTD_WRITEABLE;
>> > +     if (of_property_read_bool(dev->of_node, "no-erase"))
>> > +             mtd->flags |= MTD_NO_ERASE;
>>
>> I don't see this property document in a DT binding doc, which is
>> mandatory. Actually, there's no DT bindings doc at all for the
>> 'ibm,opal-flash' device in mainline, is this normal?

The binding doc is here:

  https://github.com/open-power/skiboot/blob/master/doc/device-tree/ibm%2Copal/flash.rst

But that property is not documented :(

We have some of the skiboot bindings also in the kernel tree, but there
was talk of moving all the binding docs *out* of the kernel, so we never
made an effort to put more in. I've lost track of whether there are
still plans to move the binding docs out or not.

cheers

Patch

diff --git a/drivers/mtd/devices/powernv_flash.c b/drivers/mtd/devices/powernv_flash.c
index f5396f26ddb4..fab9f9121b4c 100644
--- a/drivers/mtd/devices/powernv_flash.c
+++ b/drivers/mtd/devices/powernv_flash.c
@@ -196,6 +196,8 @@  static int powernv_flash_set_driver_info(struct device *dev,
 	mtd->name = of_get_property(dev->of_node, "name", NULL);
 	mtd->type = MTD_NORFLASH;
 	mtd->flags = MTD_WRITEABLE;
+	if (of_property_read_bool(dev->of_node, "no-erase"))
+		mtd->flags |= MTD_NO_ERASE;
 	mtd->size = size;
 	mtd->erasesize = erase_size;
 	mtd->writebufsize = mtd->writesize = 1;