usb: Keep async schedule running only across mass storage xfers
Subsystems (2)
PATCH 1/1 usb: Keep async schedule running only across mass storage xfers
Rather than keeping the asynchronous schedule running always, keep it running only across USB mass storage transfers for now, as it seems that keeping it running all the time interferes with certain control transfers during device enumeration.
Note that running the async schedule all the time should not be an issue, especially on EHCI HCD, as that one implements most of the transfers using async schedule.
Note that we have usb_disable_asynch(), which however is utterly broken. The usb_disable_asynch() blocks the USB core from doing async transfers by setting a global flag. The async schedule should however be disabled per USB controller. Moreover, setting a global flag does not prevent the controller from using the async schedule, which e.g. the EHCI HCD does.
This patch implements additional callback to the controller, which permits it to lock the async schedule and keep it running across multiple transfers. Once the schedule is unlocked, it must also be disabled. This thus prevents the async schedule from running outside of the USB mass storage transfers.
--- common/usb.c | 5 ++ common/usb_storage.c | 4 ++ drivers/usb/host/ehci-hcd.c | 91 +++++++++++++++++++++++++++++------ drivers/usb/host/ehci.h | 1 + drivers/usb/host/usb-uclass.c | 11 +++++ include/usb.h | 11 +++++ 6 files changed, 109 insertions(+), 14 deletions(-)
common/usb.c +5 -0
@@ -172,6 +172,11 @@ int usb_detect_change(void)return change; } +/* Lock or unlock async schedule on the controller */ +__weak int usb_lock_async (struct usb_device *dev,int lock) +{ +} +/* * disables the asynch behaviour of the control message. This is used for data * transfers that uses the exclusiv access to the control and bulk messages.
common/usb_storage.c +4 -0
@@ -1157,6 +1157,7 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr, ss = (struct us_data *)udev->privptr;usb_disable_asynch (1 );/* asynch transfer not allowed */ +usb_lock_async (udev,1 ); srb->lun = block_dev->lun; buf_addr = (uintptr_t )buffer; start = blknr;
@@ -1195,6 +1196,7 @@ retry_it:debug ("usb_read: end startblk " LBAF ", blccnt %x buffer %lx\n" , start, smallblks, buf_addr); +usb_lock_async (udev,0 );usb_disable_asynch (0 );/* asynch transfer allowed */ if (blkcnt >= ss->max_xfer_blk)debug ("\n" );
@@ -1239,6 +1241,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr, ss = (struct us_data *)udev->privptr;usb_disable_asynch (1 );/* asynch transfer not allowed */ +usb_lock_async (udev,1 ); srb->lun = block_dev->lun; buf_addr = (uintptr_t )buffer;
@@ -1280,6 +1283,7 @@ retry_it:debug ("usb_write: end startblk " LBAF ", blccnt %x buffer %lx\n" , start, smallblks, buf_addr); +usb_lock_async (udev,0 );usb_disable_asynch (0 );/* asynch transfer allowed */ if (blkcnt >= ss->max_xfer_blk)debug ("\n" );
drivers/usb/host/ehci-hcd.c +77 -14
139 lines not on this page · raw message
drivers/usb/host/ehci.h +1 -0
@@ -255,6 +255,7 @@ struct ehci_ctrl {int periodic_schedules;int ntds;bool has_fsl_erratum_a005275;/* Freescale HS silicon quirk */ +bool async_locked;struct ehci_ops ops;void *priv;/* client's private data */ };
drivers/usb/host/usb-uclass.c +11 -0
@@ -22,6 +22,17 @@ struct usb_uclass_priv {int companion_device_count; }; +int usb_lock_async (struct usb_device *udev,int lock) +{ +struct udevice *bus = udev->controller_dev; +struct dm_usb_ops *ops =usb_get_ops (bus); + +if (!ops->lock_async) +return -ENOSYS ; + +return ops->lock_async (bus, lock); +} +int usb_disable_asynch (int disable) {int old_value = asynch_allowed;
include/usb.h +11 -0
@@ -269,6 +269,7 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout);int usb_int_msg (struct usb_device *dev,unsigned long pipe,void *buffer,int transfer_len,int interval,bool nonblock); +int usb_lock_async (struct usb_device *dev,int lock);int usb_disable_asynch (int disable);int usb_maxpacket (struct usb_device *dev,unsigned long pipe); int usb_get_configuration_no(struct usb_device *dev, int cfgno,
@@ -791,6 +792,16 @@ struct dm_usb_ops {* in a USB transfer. USB class driver needs to be aware of this. */ int (*get_max_xfer_size)(struct udevice *bus,size_t *size); + +/** +* lock_async() - Keep async schedule after a transfer +* +* It may be desired to keep the asynchronous schedule running even +* after a transfer finishes, usually when doing multiple transfers +* back-to-back. This callback allows signalling the USB controller +* driver to do just that. +*/ +int (*lock_async)(struct udevice *udev,int lock); };#define usb_get_ops (dev) ((struct dm_usb_ops *)(dev)->driver->ops)
Signature · 1 line
2.25.1
PATCH 1/1 usb: Keep async schedule running only across mass storage xfers
Quoted 21 lines · Marek Vasut
Rather than keeping the asynchronous schedule running always, keep it running only across USB mass storage transfers for now, as it seems that keeping it running all the time interferes with certain control transfers during device enumeration.
Note that running the async schedule all the time should not be an issue, especially on EHCI HCD, as that one implements most of the transfers using async schedule.
Note that we have
usb_disable_asynch(), which however is utterly broken. Theusb_disable_asynch()blocks the USB core from doing async transfers by setting a global flag. The async schedule should however be disabled per USB controller. Moreover, setting a global flag does not prevent the controller from using the async schedule, which e.g. the EHCI HCD does.This patch implements additional callback to the controller, which permits it to lock the async schedule and keep it running across multiple transfers. Once the schedule is unlocked, it must also be disabled. This thus prevents the async schedule from running outside of the USB mass storage transfers.
Quoted 3 lines
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Tom Rini <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200406/59f68a95/attachment.sig>
PATCH 1/1 usb: Keep async schedule running only across mass storage xfers
In reply to Marek VasutQuoted 21 lines · Marek Vasut
Rather than keeping the asynchronous schedule running always, keep it running only across USB mass storage transfers for now, as it seems that keeping it running all the time interferes with certain control transfers during device enumeration.
Note that running the async schedule all the time should not be an issue, especially on EHCI HCD, as that one implements most of the transfers using async schedule.
Note that we have
usb_disable_asynch(), which however is utterly broken. Theusb_disable_asynch()blocks the USB core from doing async transfers by setting a global flag. The async schedule should however be disabled per USB controller. Moreover, setting a global flag does not prevent the controller from using the async schedule, which e.g. the EHCI HCD does.This patch implements additional callback to the controller, which permits it to lock the async schedule and keep it running across multiple transfers. Once the schedule is unlocked, it must also be disabled. This thus prevents the async schedule from running outside of the USB mass storage transfers.
Quoted 4 lines
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200409/4e5aa72c/attachment.sig>
PATCH 1/1 usb: Keep async schedule running only across mass storage xfers
Quoted 24 lines · On Thu, 9 Apr 2020 19:23:26 -0400 Tom Rini <[email protected]> wrote:
Quoted 22 lines · Marek Vasut
Rather than keeping the asynchronous schedule running always, keep it running only across USB mass storage transfers for now, as it seems that keeping it running all the time interferes with certain control transfers during device enumeration.
Note that running the async schedule all the time should not be an issue, especially on EHCI HCD, as that one implements most of the transfers using async schedule.
Note that we have
usb_disable_asynch(), which however is utterly broken. Theusb_disable_asynch()blocks the USB core from doing async transfers by setting a global flag. The async schedule should however be disabled per USB controller. Moreover, setting a global flag does not prevent the controller from using the async schedule, which e.g. the EHCI HCD does.This patch implements additional callback to the controller, which permits it to lock the async schedule and keep it running across multiple transfers. Once the schedule is unlocked, it must also be disabled. This thus prevents the async schedule from running outside of the USB mass storage transfers.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Tom Rini <[email protected]>failing]
Applied to u-boot/master, thanks!
It is a really short time between posting the patch (Monday) and being applied (midnight on Friday).
It is the Pre-Easter period with some other world-wide issues... and not all of us have enough time now to review and test patches.
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/20200410/7d8e1d42/attachment.sig>
PATCH 1/1 usb: Keep async schedule running only across mass storage xfers
Quoted 33 lines · Lukasz Majewski
Quoted 30 lines · On Thu, 9 Apr 2020 19:23:26 -0400 Tom Rini <[email protected]> wrote:
Quoted 27 lines · Marek Vasut
Rather than keeping the asynchronous schedule running always, keep it running only across USB mass storage transfers for now, as it seems that keeping it running all the time interferes with certain control transfers during device enumeration.
Note that running the async schedule all the time should not be an issue, especially on EHCI HCD, as that one implements most of the transfers using async schedule.
Note that we have
usb_disable_asynch(), which however is utterly broken. Theusb_disable_asynch()blocks the USB core from doing async transfers by setting a global flag. The async schedule should however be disabled per USB controller. Moreover, setting a global flag does not prevent the controller from using the async schedule, which e.g. the EHCI HCD does.This patch implements additional callback to the controller, which permits it to lock the async schedule and keep it running across multiple transfers. Once the schedule is unlocked, it must also be disabled. This thus prevents the async schedule from running outside of the USB mass storage transfers.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>Cc Tom Rini <[email protected]>failing]
Quoted 8 lines
Quoted 2 lines
Applied to u-boot/master, thanks!
It is a really short time between posting the patch (Monday) and being applied (midnight on Friday).
It is the Pre-Easter period with some other world-wide issues... and not all of us have enough time now to review and test patches.
So, I took this patch at this point in the cycle as it fixes a regression that we've had reported for a while and because the custodian asked me to grab it directly. All things considered, it is unlikely to make the situation worse and may fix some of the other regressions we've had in the area. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200410/f9e645c8/attachment.sig>