diff mbox

[4/9] m25p80: Introduce COLLECTING_VAR_LEN_DATA state.

Message ID 1465998071-7355-5-git-send-email-marcin.krzeminski@nokia.com (mailing list archive)
State New, archived
Headers show

Commit Message

marcin.krzeminski@nokia.com June 15, 2016, 1:41 p.m. UTC
From: Marcin Krzeminski <marcin.krzeminski@nokia.com>

Some flash allows to stop read at any time.
Allow framework to support this.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
---
 hw/block/m25p80.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Cédric Le Goater June 16, 2016, 7:13 a.m. UTC | #1
On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
> From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> 
> Some flash allows to stop read at any time.
> Allow framework to support this.
> 
> Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> ---
>  hw/block/m25p80.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 6910c52..ca1f882 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -330,6 +330,7 @@ typedef enum {
>      STATE_PAGE_PROGRAM,
>      STATE_READ,
>      STATE_COLLECTING_DATA,
> +    STATE_COLLECTING_VAR_LEN_DATA,
>      STATE_READING_DATA,
>  } CMDState;
> 
> @@ -872,6 +873,9 @@ static int m25p80_cs(SSISlave *ss, bool select)
>      Flash *s = M25P80(ss);
> 
>      if (select) {
> +        if (s->state == STATE_COLLECTING_VAR_LEN_DATA) {
> +            complete_collecting_data(s);
> +        }

So for example, we could trigger an erase without a completed address ? 

C. 

>          s->len = 0;
>          s->pos = 0;
>          s->state = STATE_IDLE;
> @@ -905,6 +909,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
>          break;
> 
>      case STATE_COLLECTING_DATA:
> +    case STATE_COLLECTING_VAR_LEN_DATA:
>          s->data[s->len] = (uint8_t)tx;
>          s->len++;
>
marcin.krzeminski@nokia.com June 16, 2016, 7:43 a.m. UTC | #2
> -----Original Message-----
> From: Cédric Le Goater [mailto:clg@kaod.org]
> Sent: Thursday, June 16, 2016 9:14 AM
> To: Krzeminski, Marcin (Nokia - PL/Wroclaw)
> <marcin.krzeminski@nokia.com>; qemu-devel@nongnu.org
> Cc: crosthwaitepeter@gmail.com; pawel.lenkow@itlen.com;
> peter.maydell@linaro.org
> Subject: Re: [PATCH 4/9] m25p80: Introduce COLLECTING_VAR_LEN_DATA
> state.
> 
> On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
> > From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> >
> > Some flash allows to stop read at any time.
> > Allow framework to support this.
> >
> > Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
> > ---
> >  hw/block/m25p80.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index
> > 6910c52..ca1f882 100644
> > --- a/hw/block/m25p80.c
> > +++ b/hw/block/m25p80.c
> > @@ -330,6 +330,7 @@ typedef enum {
> >      STATE_PAGE_PROGRAM,
> >      STATE_READ,
> >      STATE_COLLECTING_DATA,
> > +    STATE_COLLECTING_VAR_LEN_DATA,
> >      STATE_READING_DATA,
> >  } CMDState;
> >
> > @@ -872,6 +873,9 @@ static int m25p80_cs(SSISlave *ss, bool select)
> >      Flash *s = M25P80(ss);
> >
> >      if (select) {
> > +        if (s->state == STATE_COLLECTING_VAR_LEN_DATA) {
> > +            complete_collecting_data(s);
> > +        }
> 
> So for example, we could trigger an erase without a completed address ?
> 
> C.
Yes if you explicitly want that. This is new state and you need to go
into it in decode_new_cmd.
For now this is only used in WRSR command only.

Thanks,
Marcin
> 
> >          s->len = 0;
> >          s->pos = 0;
> >          s->state = STATE_IDLE;
> > @@ -905,6 +909,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss,
> uint32_t tx)
> >          break;
> >
> >      case STATE_COLLECTING_DATA:
> > +    case STATE_COLLECTING_VAR_LEN_DATA:
> >          s->data[s->len] = (uint8_t)tx;
> >          s->len++;
> >
Cédric Le Goater June 16, 2016, 8:13 a.m. UTC | #3
On 06/16/2016 09:43 AM, Krzeminski, Marcin (Nokia - PL/Wroclaw) wrote:
> 
> 
>> -----Original Message-----
>> From: Cédric Le Goater [mailto:clg@kaod.org]
>> Sent: Thursday, June 16, 2016 9:14 AM
>> To: Krzeminski, Marcin (Nokia - PL/Wroclaw)
>> <marcin.krzeminski@nokia.com>; qemu-devel@nongnu.org
>> Cc: crosthwaitepeter@gmail.com; pawel.lenkow@itlen.com;
>> peter.maydell@linaro.org
>> Subject: Re: [PATCH 4/9] m25p80: Introduce COLLECTING_VAR_LEN_DATA
>> state.
>>
>> On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote:
>>> From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
>>>
>>> Some flash allows to stop read at any time.
>>> Allow framework to support this.
>>>
>>> Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
>>> ---
>>>  hw/block/m25p80.c | 5 +++++
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index
>>> 6910c52..ca1f882 100644
>>> --- a/hw/block/m25p80.c
>>> +++ b/hw/block/m25p80.c
>>> @@ -330,6 +330,7 @@ typedef enum {
>>>      STATE_PAGE_PROGRAM,
>>>      STATE_READ,
>>>      STATE_COLLECTING_DATA,
>>> +    STATE_COLLECTING_VAR_LEN_DATA,
>>>      STATE_READING_DATA,
>>>  } CMDState;
>>>
>>> @@ -872,6 +873,9 @@ static int m25p80_cs(SSISlave *ss, bool select)
>>>      Flash *s = M25P80(ss);
>>>
>>>      if (select) {
>>> +        if (s->state == STATE_COLLECTING_VAR_LEN_DATA) {
>>> +            complete_collecting_data(s);
>>> +        }
>>
>> So for example, we could trigger an erase without a completed address ?
>>
>> C.
> Yes if you explicitly want that. This is new state and you need to go
> into it in decode_new_cmd.
> For now this is only used in WRSR command only.

OK. I see and I understand the use in that case.

Reviewed-by: Cédric Le Goater <clg@kaod.org>

C.


> 
> Thanks,
> Marcin
>>
>>>          s->len = 0;
>>>          s->pos = 0;
>>>          s->state = STATE_IDLE;
>>> @@ -905,6 +909,7 @@ static uint32_t m25p80_transfer8(SSISlave *ss,
>> uint32_t tx)
>>>          break;
>>>
>>>      case STATE_COLLECTING_DATA:
>>> +    case STATE_COLLECTING_VAR_LEN_DATA:
>>>          s->data[s->len] = (uint8_t)tx;
>>>          s->len++;
>>>
>
diff mbox

Patch

diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 6910c52..ca1f882 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -330,6 +330,7 @@  typedef enum {
     STATE_PAGE_PROGRAM,
     STATE_READ,
     STATE_COLLECTING_DATA,
+    STATE_COLLECTING_VAR_LEN_DATA,
     STATE_READING_DATA,
 } CMDState;
 
@@ -872,6 +873,9 @@  static int m25p80_cs(SSISlave *ss, bool select)
     Flash *s = M25P80(ss);
 
     if (select) {
+        if (s->state == STATE_COLLECTING_VAR_LEN_DATA) {
+            complete_collecting_data(s);
+        }
         s->len = 0;
         s->pos = 0;
         s->state = STATE_IDLE;
@@ -905,6 +909,7 @@  static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx)
         break;
 
     case STATE_COLLECTING_DATA:
+    case STATE_COLLECTING_VAR_LEN_DATA:
         s->data[s->len] = (uint8_t)tx;
         s->len++;