From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [RFT PATCH v1 4/5] usb: Provide code to handle spinup of USB usb devices (mostly HDDs)
Date: Mon, 23 Mar 2020 08:53:30 +0100 [thread overview]
Message-ID: <20200323085330.729956f6@jawa> (raw)
In-Reply-To: <248b9452-ee12-d1f8-0a0e-fc1b0b232c2e@denx.de>
Hi Marek,
> On 3/22/20 2:00 PM, Lukasz Majewski wrote:
> [...]
> > diff --git a/common/usb_storage.c b/common/usb_storage.c
> > index 92e1e54d1c..3c2324fa1a 100644
> > --- a/common/usb_storage.c
> > +++ b/common/usb_storage.c
> > @@ -729,6 +729,7 @@ static int usb_stor_BBB_transport(struct
> > scsi_cmd *srb, struct us_data *us) pipeout =
> > usb_sndbulkpipe(us->pusb_dev, us->ep_out); /* DATA phase + error
> > handling */ data_actlen = 0;
> > + mdelay(10); /* Like linux does. */
>
> Does this add delay to every single transfer ?
It brings the slowdown, yes.
However, without it I very often see the error that the USB address
couldn't be assigned.
> That would mean a massive slowdown if you use short data transfers,
> which is needed for old/limited USB sticks.
>
> > /* no data, go immediately to the STATUS phase */
> > if (srb->datalen == 0)
> > goto st;
> > @@ -1023,9 +1024,32 @@ static int usb_request_sense(struct scsi_cmd
> > *srb, struct us_data *ss) return 0;
> > }
> >
> > +/*
> > + * This spins up the disk and also consumes the time that the
> > + * disk takes to become active and ready to read data.
> > + * Some drives (like Western Digital) can take more than 5 seconds.
> > + * The delay occurs on the 1st data read from the disk.
> > + * Extending the timeout here works better than handling the
> > timeout
> > + * as an error on a "real" read.
> > + */
> > +static int usb_spinup(struct scsi_cmd *srb, struct us_data *ss)
> > +{
> > + memset(&srb->cmd[0], 0, 12);
> > + srb->cmd[0] = SCSI_START_STP;
> > + srb->cmd[1] = srb->lun << 5;
> > + srb->cmd[4] = 1; /* Start spinup. */
> > + srb->datalen = 0;
> > + srb->cmdlen = 6;
> > + ss->pusb_dev->extra_timeout = 9876;
>
> What is this magic number ?
This number is added to the timeout up to which ehci controller waits
for EHCI TD to be sent.
Why there is 9876 - I do guess that it was took from Linux in some
point in time.
>
> > + ss->transport(srb, ss);
> > + ss->pusb_dev->extra_timeout = 0;
> > + return 0;
> > +}
>
> [...]
>
> > diff --git a/include/usb.h b/include/usb.h
> > index efb67ea33f..5b0f5ce5d6 100644
> > --- a/include/usb.h
> > +++ b/include/usb.h
> > @@ -140,6 +140,7 @@ struct usb_device {
> > int act_len; /* transferred bytes */
> > int maxchild; /* Number of ports if
> > hub */ int portnr; /* Port number, 1=first */
> > + int extra_timeout; /* Add to timeout in ehci_submit_async
> > or spinup */
>
> Does this work with xhci too ?
Yes, it is used in patch 5/5.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200323/d7fd11d3/attachment.sig>
next prev parent reply other threads:[~2020-03-23 7:53 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 13:00 [RFT PATCH v1 0/5] usb: Improve robustness of ehci-hcd controller operation Lukasz Majewski
2020-03-22 13:00 ` [RFT PATCH v1 1/5] Revert "usb: ehci-hcd: Keep async schedule running" Lukasz Majewski
2020-03-22 13:18 ` Marek Vasut
2020-03-23 6:57 ` Lukasz Majewski
2020-03-23 11:46 ` Marek Vasut
2020-03-23 12:41 ` Lukasz Majewski
2020-03-24 0:58 ` Marek Vasut
2020-03-24 7:06 ` Lukasz Majewski
2020-03-24 15:07 ` Marek Vasut
2020-03-24 18:11 ` Lukasz Majewski
2020-03-24 18:33 ` Marek Vasut
2020-03-22 13:00 ` [RFT PATCH v1 2/5] usb: Handle XACTERR error in DATA phase of USB storage Lukasz Majewski
2020-03-22 13:23 ` Marek Vasut
2020-03-23 7:00 ` Lukasz Majewski
2020-03-23 11:50 ` Marek Vasut
2020-03-23 13:03 ` Lukasz Majewski
2020-03-24 1:01 ` Marek Vasut
2020-03-22 13:00 ` [RFT PATCH v1 3/5] usb: Add some delay to wait for slow USB devices to be operational Lukasz Majewski
2020-03-22 13:29 ` Marek Vasut
2020-03-23 7:04 ` Lukasz Majewski
2020-03-23 11:52 ` Marek Vasut
2020-03-22 13:00 ` [RFT PATCH v1 4/5] usb: Provide code to handle spinup of USB usb devices (mostly HDDs) Lukasz Majewski
2020-03-22 13:32 ` Marek Vasut
2020-03-23 7:53 ` Lukasz Majewski [this message]
2020-03-23 11:57 ` Marek Vasut
2020-03-23 12:54 ` Lukasz Majewski
2020-03-24 1:04 ` Marek Vasut
2020-03-22 13:00 ` [RFT PATCH v1 5/5] usb: Handle QT_TOKEN_STATUS_XACTERR error when sending data Lukasz Majewski
2020-03-22 13:45 ` Marek Vasut
2020-03-23 7:18 ` Lukasz Majewski
2020-03-23 11:59 ` Marek Vasut
2020-03-23 12:58 ` Lukasz Majewski
2020-03-24 1:06 ` Marek Vasut
2020-03-23 20:58 ` [RFT PATCH v1 0/5] usb: Improve robustness of ehci-hcd controller operation Tom Rini
2020-03-23 22:11 ` Lukasz Majewski
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=20200323085330.729956f6@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/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