linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Purpose of the  "msg->status"
@ 2010-03-15 10:13 Centelles, Sylvain
       [not found] ` <2A84145621092446B6659B8A0F28E26F4245B483E9-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Centelles, Sylvain @ 2010-03-15 10:13 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Hi,
I'm currently working on a spi driver for Intel platform, and when reading the various other spi drivers available in the kernel, I saw the msg->status was often updated (EINPROGRESS for example), but could not figure out who checks this status. I would have thought it would be needed to prevent concurrent access for example, but I didn't see anything in the core, nore in any driver. If it's not needed, then I would not like to carry some useless status updates in the driver I'm currently working on.
Maybe I missed something... So if someone can please give some info on this, it would be great!

Regards,
Sylvain
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the  "msg->status"
       [not found] ` <2A84145621092446B6659B8A0F28E26F4245B483E9-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2010-03-15 11:05   ` Baruch Siach
       [not found]     ` <20100315110553.GC11196-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Baruch Siach @ 2010-03-15 11:05 UTC (permalink / raw)
  To: Centelles, Sylvain
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Hi Sylvain,

On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> I'm currently working on a spi driver for Intel platform, and when reading 
> the various other spi drivers available in the kernel, I saw the msg->status 
> was often updated (EINPROGRESS for example), but could not figure out who 
> checks this status. I would have thought it would be needed to prevent 
> concurrent access for example, but I didn't see anything in the core, nore 
> in any driver. If it's not needed, then I would not like to carry some 
> useless status updates in the driver I'm currently working on.
> Maybe I missed something... So if someone can please give some info on this, it would be great!

See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from 
this function:

        if (status == 0) {
                wait_for_completion(&done);
                status = message->status;
        }
        message->context = NULL;
        return status;

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the  "msg->status"
       [not found]     ` <20100315110553.GC11196-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
@ 2010-03-15 13:06       ` Centelles, Sylvain
       [not found]         ` <2A84145621092446B6659B8A0F28E26F4245B4844E-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Centelles, Sylvain @ 2010-03-15 13:06 UTC (permalink / raw)
  To: Baruch Siach
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Hi Baruch,
Thx for your fast answer.
I had seen this piece of code. But if this is the only purpose of the msg->status, then it means it's only used to give return status of the transfer after the completion.
That mean that the only possible value will be an error code or success. The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a chance to be returned at this place, as any completion will overwrite it. Right? 
That what was confusing me...

Regards,
Sylvain


-----Original Message-----
From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
Sent: Monday, March 15, 2010 12:06 PM
To: Centelles, Sylvain
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [spi-devel-general] Purpose of the "msg->status"

Hi Sylvain,

On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> I'm currently working on a spi driver for Intel platform, and when reading 
> the various other spi drivers available in the kernel, I saw the msg->status 
> was often updated (EINPROGRESS for example), but could not figure out who 
> checks this status. I would have thought it would be needed to prevent 
> concurrent access for example, but I didn't see anything in the core, nore 
> in any driver. If it's not needed, then I would not like to carry some 
> useless status updates in the driver I'm currently working on.
> Maybe I missed something... So if someone can please give some info on this, it would be great!

See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from 
this function:

        if (status == 0) {
                wait_for_completion(&done);
                status = message->status;
        }
        message->context = NULL;
        return status;

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the  "msg->status"
       [not found]         ` <2A84145621092446B6659B8A0F28E26F4245B4844E-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2010-03-15 13:18           ` Baruch Siach
       [not found]             ` <20100315131822.GA32236-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
  2010-03-15 13:53           ` jassi brar
  1 sibling, 1 reply; 9+ messages in thread
From: Baruch Siach @ 2010-03-15 13:18 UTC (permalink / raw)
  To: Centelles, Sylvain
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Hi Sylvain,

On Mon, Mar 15, 2010 at 01:06:33PM +0000, Centelles, Sylvain wrote:
> Thx for your fast answer.
> I had seen this piece of code. But if this is the only purpose of the 
> msg->status, then it means it's only used to give return status of the 
> transfer after the completion.
> That mean that the only possible value will be an error code or success.  
> The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a 
> chance to be returned at this place, as any completion will overwrite it.  
> Right?  That what was confusing me...

No. Any caller of the spi_async() routine must check the msg->status field on 
return.  See for example the spidev_sync() function in drivers/spi/spidev.c.  
Snippet follows:

        spin_lock_irq(&spidev->spi_lock);
        if (spidev->spi == NULL)
                status = -ESHUTDOWN;
        else
                status = spi_async(spidev->spi, message);
        spin_unlock_irq(&spidev->spi_lock);

        if (status == 0) {
                wait_for_completion(&done);
                status = message->status;
                if (status == 0)
                        status = message->actual_length;
        }

baruch

> -----Original Message-----
> From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
> Sent: Monday, March 15, 2010 12:06 PM
> To: Centelles, Sylvain
> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject: Re: [spi-devel-general] Purpose of the "msg->status"
> 
> Hi Sylvain,
> 
> On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> > I'm currently working on a spi driver for Intel platform, and when reading 
> > the various other spi drivers available in the kernel, I saw the msg->status 
> > was often updated (EINPROGRESS for example), but could not figure out who 
> > checks this status. I would have thought it would be needed to prevent 
> > concurrent access for example, but I didn't see anything in the core, nore 
> > in any driver. If it's not needed, then I would not like to carry some 
> > useless status updates in the driver I'm currently working on.
> > Maybe I missed something... So if someone can please give some info on this, it would be great!
> 
> See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from 
> this function:
> 
>         if (status == 0) {
>                 wait_for_completion(&done);
>                 status = message->status;
>         }
>         message->context = NULL;
>         return status;
> 
> baruch
> 
> -- 
>                                                      ~. .~   Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
>    - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris, 
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the  "msg->status"
       [not found]             ` <20100315131822.GA32236-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
@ 2010-03-15 13:49               ` Centelles, Sylvain
       [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B4846D-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Centelles, Sylvain @ 2010-03-15 13:49 UTC (permalink / raw)
  To: Baruch Siach
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Baruch,
Sorry to bother you agin, but I still don't see the EINPROGRESS value being checked, as it's set before the completion.

As it's stated in the definition of the spi_async in spi.h:
 * The completion callback is invoked in a context which can't sleep.
 * Before that invocation, the value of message->status is undefined.
 * When the callback is issued, message->status holds either zero (to
 * indicate complete success) or a negative error code.

The EINPROGRESS value (in the pxa driver) is set at the beginning of the transfer function, prior to any completion, then, I don't understand how it could be checked in the spi core, as the message->status seems always checked after a wait_for_completion.

The only meaning of setting this value at this stage, would be to let another caller the possibility to check the status of this message, for whatever reason. But I don't see such check or call in the current spi core.
Anyways, if this was the case, it would invalidate the comment above " Before that invocation, the value of message->status is undefined."
Nevertheless, my understanding is that it could also be needed, as you said, by any caller checking the message->status after a call to spi_async, but not waiting for a completion. But is it a realistic use case?

Maybe it's a lot of questions for something not so important, but I really want to make sure I understand exactly the way this msg->status is used...

Regards,
Sylvain


-----Original Message-----
From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
Sent: Monday, March 15, 2010 2:18 PM
To: Centelles, Sylvain
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [spi-devel-general] Purpose of the "msg->status"

Hi Sylvain,

On Mon, Mar 15, 2010 at 01:06:33PM +0000, Centelles, Sylvain wrote:
> Thx for your fast answer.
> I had seen this piece of code. But if this is the only purpose of the 
> msg->status, then it means it's only used to give return status of the 
> transfer after the completion.
> That mean that the only possible value will be an error code or success.  
> The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a 
> chance to be returned at this place, as any completion will overwrite it.  
> Right?  That what was confusing me...

No. Any caller of the spi_async() routine must check the msg->status field on 
return.  See for example the spidev_sync() function in drivers/spi/spidev.c.  
Snippet follows:

        spin_lock_irq(&spidev->spi_lock);
        if (spidev->spi == NULL)
                status = -ESHUTDOWN;
        else
                status = spi_async(spidev->spi, message);
        spin_unlock_irq(&spidev->spi_lock);

        if (status == 0) {
                wait_for_completion(&done);
                status = message->status;
                if (status == 0)
                        status = message->actual_length;
        }

baruch

> -----Original Message-----
> From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
> Sent: Monday, March 15, 2010 12:06 PM
> To: Centelles, Sylvain
> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject: Re: [spi-devel-general] Purpose of the "msg->status"
> 
> Hi Sylvain,
> 
> On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> > I'm currently working on a spi driver for Intel platform, and when reading 
> > the various other spi drivers available in the kernel, I saw the msg->status 
> > was often updated (EINPROGRESS for example), but could not figure out who 
> > checks this status. I would have thought it would be needed to prevent 
> > concurrent access for example, but I didn't see anything in the core, nore 
> > in any driver. If it's not needed, then I would not like to carry some 
> > useless status updates in the driver I'm currently working on.
> > Maybe I missed something... So if someone can please give some info on this, it would be great!
> 
> See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from 
> this function:
> 
>         if (status == 0) {
>                 wait_for_completion(&done);
>                 status = message->status;
>         }
>         message->context = NULL;
>         return status;
> 
> baruch
> 
> -- 
>                                                      ~. .~   Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
>    - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris, 
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the "msg->status"
       [not found]         ` <2A84145621092446B6659B8A0F28E26F4245B4844E-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  2010-03-15 13:18           ` Baruch Siach
@ 2010-03-15 13:53           ` jassi brar
       [not found]             ` <1b68c6791003150653g6f58fbd7u4c0077f01605610d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 9+ messages in thread
From: jassi brar @ 2010-03-15 13:53 UTC (permalink / raw)
  To: Centelles, Sylvain
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

On Mon, Mar 15, 2010 at 10:06 PM, Centelles, Sylvain
<sylvain.centelles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> Hi Baruch,
> Thx for your fast answer.
> I had seen this piece of code. But if this is the only purpose of the msg->status, then it means it's only used to give return status of the transfer after the completion.
> That mean that the only possible value will be an error code or success. The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a chance to be returned at this place, as any completion will overwrite it. Right?
> That what was confusing me...
When a xfer is submitted, the status is set by default should the xfer
exit via some un-tested path.
If the driver state machine has only fixed and tested exit points, you
perhaps don't need to set
the default status.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the  "msg->status"
       [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B4846D-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2010-03-15 14:09                   ` Baruch Siach
  0 siblings, 0 replies; 9+ messages in thread
From: Baruch Siach @ 2010-03-15 14:09 UTC (permalink / raw)
  To: Centelles, Sylvain
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Hi Sylvain,

On Mon, Mar 15, 2010 at 01:49:05PM +0000, Centelles, Sylvain wrote:
> Sorry to bother you agin, but I still don't see the EINPROGRESS value being 
> checked, as it's set before the completion.
> 
> As it's stated in the definition of the spi_async in spi.h:
>  * The completion callback is invoked in a context which can't sleep.
>  * Before that invocation, the value of message->status is undefined.
>  * When the callback is issued, message->status holds either zero (to
>  * indicate complete success) or a negative error code.
> 
> The EINPROGRESS value (in the pxa driver) is set at the beginning of the 
> transfer function, prior to any completion, then, I don't understand how it 
> could be checked in the spi core, as the message->status seems always 
> checked after a wait_for_completion.
> 
> The only meaning of setting this value at this stage, would be to let 
> another caller the possibility to check the status of this message, for 
> whatever reason. But I don't see such check or call in the current spi core.
> Anyways, if this was the case, it would invalidate the comment above " 
> Before that invocation, the value of message->status is undefined."
> Nevertheless, my understanding is that it could also be needed, as you said, 
> by any caller checking the message->status after a call to spi_async, but 
> not waiting for a completion. But is it a realistic use case?

I guess that the rationale for this is to make non-blocking IO easier. You may 
send an SPI message asynchronously and then poll the status field for 
completion. This may have a performance benefit in situations where in most 
cases by the time you check the status field the SPI transfer has completed.  
This way you can avoid a context switch.

Just a guess.

baruch

> -----Original Message-----
> From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
> Sent: Monday, March 15, 2010 2:18 PM
> To: Centelles, Sylvain
> Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Subject: Re: [spi-devel-general] Purpose of the "msg->status"
> 
> Hi Sylvain,
> 
> On Mon, Mar 15, 2010 at 01:06:33PM +0000, Centelles, Sylvain wrote:
> > Thx for your fast answer.
> > I had seen this piece of code. But if this is the only purpose of the 
> > msg->status, then it means it's only used to give return status of the 
> > transfer after the completion.
> > That mean that the only possible value will be an error code or success.  
> > The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a 
> > chance to be returned at this place, as any completion will overwrite it.  
> > Right?  That what was confusing me...
> 
> No. Any caller of the spi_async() routine must check the msg->status field on 
> return.  See for example the spidev_sync() function in drivers/spi/spidev.c.  
> Snippet follows:
> 
>         spin_lock_irq(&spidev->spi_lock);
>         if (spidev->spi == NULL)
>                 status = -ESHUTDOWN;
>         else
>                 status = spi_async(spidev->spi, message);
>         spin_unlock_irq(&spidev->spi_lock);
> 
>         if (status == 0) {
>                 wait_for_completion(&done);
>                 status = message->status;
>                 if (status == 0)
>                         status = message->actual_length;
>         }
> 
> baruch
> 
> > -----Original Message-----
> > From: Baruch Siach [mailto:baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org] 
> > Sent: Monday, March 15, 2010 12:06 PM
> > To: Centelles, Sylvain
> > Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > Subject: Re: [spi-devel-general] Purpose of the "msg->status"
> > 
> > Hi Sylvain,
> > 
> > On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> > > I'm currently working on a spi driver for Intel platform, and when reading 
> > > the various other spi drivers available in the kernel, I saw the msg->status 
> > > was often updated (EINPROGRESS for example), but could not figure out who 
> > > checks this status. I would have thought it would be needed to prevent 
> > > concurrent access for example, but I didn't see anything in the core, nore 
> > > in any driver. If it's not needed, then I would not like to carry some 
> > > useless status updates in the driver I'm currently working on.
> > > Maybe I missed something... So if someone can please give some info on this, it would be great!
> > 
> > See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from 
> > this function:
> > 
> >         if (status == 0) {
> >                 wait_for_completion(&done);
> >                 status = message->status;
> >         }
> >         message->context = NULL;
> >         return status;
> > 
> > baruch
> > 
> > -- 
> >                                                      ~. .~   Tk Open Systems
> > =}------------------------------------------------ooO--U--Ooo------------{=
> >    - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
> > ---------------------------------------------------------------------
> > Intel Corporation SAS (French simplified joint stock company)
> > Registered headquarters: "Les Montalets"- 2, rue de Paris, 
> > 92196 Meudon Cedex, France
> > Registration Number:  302 456 199 R.C.S. NANTERRE
> > Capital: 4,572,000 Euros
> > 
> > This e-mail and any attachments may contain confidential material for
> > the sole use of the intended recipient(s). Any review or distribution
> > by others is strictly prohibited. If you are not the intended
> > recipient, please contact the sender and delete all copies.
> > 
> 
> -- 
>                                                      ~. .~   Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
>    - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris, 
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org - tel: +972.2.679.5364, http://www.tkos.co.il -

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the "msg->status"
       [not found]             ` <1b68c6791003150653g6f58fbd7u4c0077f01605610d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-03-15 14:09               ` Centelles, Sylvain
       [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B48476-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Centelles, Sylvain @ 2010-03-15 14:09 UTC (permalink / raw)
  To: jassi brar
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

OK, that makes sense. Even if it does not follow exactly the "undefined" value mentioned in the API definition.
Anyways, you both helped me a lot to clarify this. Thx again.
Sylvain

-----Original Message-----
From: jassi brar [mailto:jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] 
Sent: Monday, March 15, 2010 2:53 PM
To: Centelles, Sylvain
Cc: Baruch Siach; spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [spi-devel-general] Purpose of the "msg->status"

On Mon, Mar 15, 2010 at 10:06 PM, Centelles, Sylvain
<sylvain.centelles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> Hi Baruch,
> Thx for your fast answer.
> I had seen this piece of code. But if this is the only purpose of the msg->status, then it means it's only used to give return status of the transfer after the completion.
> That mean that the only possible value will be an error code or success. The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a chance to be returned at this place, as any completion will overwrite it. Right?
> That what was confusing me...
When a xfer is submitted, the status is set by default should the xfer
exit via some un-tested path.
If the driver state machine has only fixed and tested exit points, you
perhaps don't need to set
the default status.
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Purpose of the "msg->status"
       [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B48476-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2010-03-15 14:15                   ` jassi brar
  0 siblings, 0 replies; 9+ messages in thread
From: jassi brar @ 2010-03-15 14:15 UTC (permalink / raw)
  To: Centelles, Sylvain
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

On Mon, Mar 15, 2010 at 11:09 PM, Centelles, Sylvain
<sylvain.centelles-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> OK, that makes sense. Even if it does not follow exactly the "undefined" value mentioned in the API definition.
> Anyways, you both helped me a lot to clarify this. Thx again.
btw, top posting is frowned upon in mailing lists.
please reply inline quoting the relevant part of mail.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-03-15 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 10:13 Purpose of the "msg->status" Centelles, Sylvain
     [not found] ` <2A84145621092446B6659B8A0F28E26F4245B483E9-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-03-15 11:05   ` Baruch Siach
     [not found]     ` <20100315110553.GC11196-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
2010-03-15 13:06       ` Centelles, Sylvain
     [not found]         ` <2A84145621092446B6659B8A0F28E26F4245B4844E-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-03-15 13:18           ` Baruch Siach
     [not found]             ` <20100315131822.GA32236-X57xyCW21FZ5l4KbKkTfamZHpeb/A1Y/@public.gmane.org>
2010-03-15 13:49               ` Centelles, Sylvain
     [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B4846D-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-03-15 14:09                   ` Baruch Siach
2010-03-15 13:53           ` jassi brar
     [not found]             ` <1b68c6791003150653g6f58fbd7u4c0077f01605610d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-15 14:09               ` Centelles, Sylvain
     [not found]                 ` <2A84145621092446B6659B8A0F28E26F4245B48476-IGOiFh9zz4x9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2010-03-15 14:15                   ` jassi brar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).