public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: John Calixto <john.calixto@modsystems.com>
To: Andrei Warkentin <andreiw@motorola.com>
Cc: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH v3] mmc: Add ioctl to let userspace apps send ACMDs
Date: Fri, 8 Apr 2011 14:25:39 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.1104081404210.15584@peruna> (raw)
In-Reply-To: <BANLkTi=wPYkrj72ixpN52WewVwsb9Ar-Vg@mail.gmail.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 4041 bytes --]

Hi Andrei,

On Fri, 8 Apr 2011, Andrei Warkentin wrote:
> Is the timeout fixed or variable (I've seen all timeouts in the
> simplified ASSD to be specified in units of 250ms in fields of
> ASSD-PR)? Are you using this force_timeout_ns for DAT-transfer
> commands also, or just for R1B commands?

Actually, ASSD is a different-but-similarly-named-so-it's-confusing set
of functionality from that which I am using.  Do you have access to
"Part 3, Security Specification"?  There is no "simplified" version of
this spec.

As for the usage of the force_timeout_ns, yes, it is also used for
DAT-transfer commands.

> 
> Do you always invoke commands that only involve transfers?

No.

> If not, I can see how your code handles R1B command timeouts correctly
> (always pretends it's a data transfer, even if 0-byte sized - thus
> host driver sets timeout correctly). In my boot partition patch set,
> there are two changes that add cmd_timeout (for DAT-busy commands) and
> enable proper handling of it for SDHCI. Obviously, none of the other

I'll have a look.

> hosts are fixed, so I guess what you are doing is okay for now. Could
> you add a "cmd_timeout" field to your ioctl, however, so in the future
> this is not a breaking change? Then right now you could add something
> like -
> 
> if (blksz * blocks == 0) {
> 
>     /*
>      * We're doing a R1B command and relying on the host driver to
> compute timeout as if
>      * we were doing a data transfer. When all host drivers are fixed
> to handle R1B right, we won't have to rely
>      * on this behavior, and can make mrq.data NULL in this case, and
> pass the timeout
>      * through cmd.cmd_timeout.
>      */
>     data.timeout_ns = idata->cmd_timeout;
> }
> 
> and in the future it can be changed to -
> 
> if (blksz * blocks == 0) {
>    mrq.data = NULL;
>    cmd.cmd_timeout = idata->cmd_timeout;
> }
> 
> 

Sure.  Like you said, this sounds reasonable while there's still
variation in timeout setting between the host drivers.

> >
> > In practice, 100 us.  Borderline?  Note that this sleep is separate from
> > the timeout above.  This one is specifically for read operations where
> > there is no such thing as "busy".
> >
> 
> You mean 'write'? I don't know. Nasty, really, in my opinion. If

Unfortunately, I really do mean "read".  I suspect it's meant to give
the card enough time to do the crypto <shrug>.

> you're doing ASSD operations then you know if the card is busy or not
> (via ASSD-state) . As in something like this paragraph from the
> simplified ASSD?
> 
>          "The card shall not assert the BUSY signal for time periods
> longer then the WR_SEC_BUS_BUSY as
>          defined in the card properties register. The only indication
> for completion of a secure Token execution is
>          the ASSD_STATE field in the card status register. The host
> shall validate that the card is in the correct
>          state before attempting any ASSD command."
> 
> If so, maybe it's worthwhile to just make your user code use SEND_PSI
> to get the ASSD_STATE registers and verify that previous secure
> operation completed before sending another one.
> 
> Anyone else have an opinion on this?
> 
> If this is not ASSD but something else, maybe you have a status
> register to query someplace?
> 
> >> I'm not sure I understand why blksz is passed. If you needed to set
> >> the block size (via CMD16) prior to some command (like MMC password
> >> protection) I could kind of get it, but then all I see the blk size
> >> getting used for is calculating the data amount in bytes, so you're
> >> not doing that. So why not just infer it from the card queue?
> >>

I can't quote directly from this spec (it would be nice if some other
SDA member could corroborate here... Part 3, anybody???), but it is
clear that there is nothing to do but wait.  However, speaking to your
initial question about usleep() vs. udelay(), I'll try testing with
usleep().

John

  reply	other threads:[~2011-04-08 21:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08  1:18 [PATCH v3] mmc: Add ioctl to let userspace apps send ACMDs John Calixto
2011-04-08  8:22 ` Andrei Warkentin
2011-04-08  8:46   ` Andrei Warkentin
2011-04-08 19:20   ` John Calixto
2011-04-08 19:58     ` Andrei Warkentin
2011-04-08 21:25       ` John Calixto [this message]
2011-04-08 21:39         ` Andrei Warkentin
2011-04-08 21:46           ` Chris Ball
2011-04-08 22:17           ` John Calixto
2011-04-11 21:23 ` Chris Ball
2011-04-11 23:32   ` John Calixto

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=alpine.DEB.2.00.1104081404210.15584@peruna \
    --to=john.calixto@modsystems.com \
    --cc=andreiw@motorola.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox