From: Daniel Santos <danielfsantos@att.net>
To: Mark Brown <broonie@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Daniel Santos <daniel.santos@pobox.com>,
linux-spi <linux-spi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: spidev: fix hang when transfer_one_message fails
Date: Thu, 23 Jan 2014 20:21:39 -0600 [thread overview]
Message-ID: <52E1CE33.7040309@att.net> (raw)
In-Reply-To: <20140123181737.GA11727@sirena.org.uk>
On 01/23/2014 12:17 PM, Mark Brown wrote:
> On Thu, Jan 23, 2014 at 05:47:02PM +0100, Geert Uytterhoeven wrote:
>
>> Probably your transfer_one_message() forgot to call
>> spi_finalize_current_message()? Is this allowed in case of failure?
> Probably not, or at least we should be consistent about requiring it or
> not.
Hmm, well it sounds like the core problem is a lack of specificity about
the interface.
1. When a message is being rejected, who is responsible for finalizing
it, the spi subsystem or the master driver?
2. What does a non-zero return value from transfer() or
transfer_one_message() mean? transfer() is supposed to just queue the
message and not sleep, so it would seem appropriate that it would mean
that the message was rejected due to something being invalid or
unsupported (or an OOM), etc. , but transfer_one_message() is also where
*most but not all* drivers transmit the message, so should it mean the
message was rejected outright for being invalid/unsupported/OOM or
should it mean a failure, such as EIO while xmitting or both?
3. Is there ever a reason to set the message's status to anything other
than the return value of transfer()/transfer_one_message()? From a
cursory review of mainline spi drivers, this appears to vary. Some
drivers are always returning zero while setting the status upon error,
some return the status and others still will set the status to one
value, but return a different error code.
So if a non-zero return value from transfer() or transfer_one_message()
should also be the status, I'm thinking we can have a small reduction in
the code footprint if it's done in the spi core. However, I suppose that
I can't properly discuss this without delving into an almost unrelated
issue, which may render the point moot.
The only reason I'm using transfer_one_message() at all is because
transfer() is being deprecated. My driver (currently out-of-tree)
supports both but will prefer transfer() as long as it hasn't been
removed or become broken ( which I'm managing via a #if
LINUX_VERSION_CODE >= KERNEL_VERSION(4,99,99) check:
https://github.com/daniel-santos/mcp2210-linux/blob/master/mcp2210-spi.c#L143).
The reason is for this is that the mcp2210 driver has an internal
command queue that manages (per its requirements) spi messages as well
as other types of commands to the remote (via USB) device (which is both
an spi master and gpio chip). From a cursory review of other spi drivers
in the mainline, I can see that at least two of them do this as well:
spi-pxa2xx and spi-bfin-v3. So perhaps we need a non-deprecated
mechanism to do our own queuing and avoid the overhead of the spi core
providing a thread & queue which we'll just ignore. Then, the core can
take care of setting status and finalizing when calls to transfer() fail
(since there should be no ambiguity about this here), but leave that up
to the driver when calling transfer_one_message()?
Either way, I think that we need to decide and spell it out in the
kerneldocs.
Daniel
next prev parent reply other threads:[~2014-01-24 2:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 23:39 spidev: fix hang when transfer_one_message fails danielfsantos-fOdFMYwuEsI
2014-01-05 23:39 ` danielfsantos
[not found] ` <1388965166-27334-1-git-send-email-daniel.santos-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
2014-01-05 23:52 ` *[PATCH]* " Daniel Santos
2014-01-05 23:52 ` Daniel Santos
2014-01-06 12:53 ` Mark Brown
2014-01-06 12:53 ` Mark Brown
2014-01-23 16:47 ` Geert Uytterhoeven
2014-01-23 16:47 ` Geert Uytterhoeven
2014-01-23 18:17 ` Mark Brown
2014-01-24 2:21 ` Daniel Santos [this message]
[not found] ` <52E1CE33.7040309-fOdFMYwuEsI@public.gmane.org>
2014-01-24 13:01 ` Mark Brown
2014-01-24 13:01 ` Mark Brown
[not found] ` <20140124130135.GX11727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-01-27 23:16 ` Daniel Santos
2014-01-27 23:16 ` Daniel Santos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52E1CE33.7040309@att.net \
--to=danielfsantos@att.net \
--cc=broonie@kernel.org \
--cc=daniel.santos@pobox.com \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.