Skip to content

Commit e326c58

Browse files
tmon-nordiccarlescufi
authored andcommitted
usb: device: Do not cancel transfers on suspend
Cancelling transfers on suspend contradicts Universal Serial Bus Specification Revision 2.0, 9.1.1.6 Suspended: * When suspended, the USB device maintains any internal status, including its address and configuration. The internal status definitely includes any pending USB transfers. If there is a class that wants to cancel transfer on suspend, then the cancel should be initiated by the class, not the device stack itself. Update hal_nordic to a version that does not abort all endpoints at suspend. It seems that aborting endpoints on suspend in nrfx driver was the actual reason why transfers were canceled on suspend. Remove transfer retriggering on resume from CDC ACM and Bluetooth class implementations because transfers are no longer cancelled on suspend. Other classes do not have any suspend related workarounds implemented. Signed-off-by: Tomasz Moń <[email protected]>
1 parent 46b78bb commit e326c58

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

subsys/usb/device/class/bluetooth.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,6 @@ static void bluetooth_status_cb(struct usb_cfg_data *cfg,
340340
tmp = atomic_clear(&suspended);
341341
if (tmp) {
342342
LOG_DBG("Device resumed from suspend");
343-
if (configured) {
344-
/* Start reading */
345-
acl_read_cb(bluetooth_ep_data[HCI_OUT_EP_IDX].ep_addr,
346-
0, NULL);
347-
}
348343
} else {
349344
LOG_DBG("Spurious resume event");
350345
}

subsys/usb/device/class/bt_h4.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ static void bt_h4_status_cb(struct usb_cfg_data *cfg,
179179
if (suspended) {
180180
LOG_DBG("from suspend");
181181
suspended = false;
182-
if (configured) {
183-
/* Start reading */
184-
bt_h4_read(bt_h4_ep_data[BT_H4_OUT_EP_IDX].ep_addr,
185-
0, NULL);
186-
}
187182
} else {
188183
LOG_DBG("Spurious resume event");
189184
}

subsys/usb/device/class/cdc_acm.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,6 @@ static void cdc_acm_do_cb(struct cdc_acm_dev_data_t *dev_data,
392392
if (dev_data->suspended) {
393393
LOG_INF("from suspend");
394394
dev_data->suspended = false;
395-
if (dev_data->configured) {
396-
cdc_acm_read_cb(cfg->endpoint[ACM_OUT_EP_IDX].ep_addr,
397-
0, dev_data);
398-
}
399395
} else {
400396
LOG_DBG("Spurious resume event");
401397
}
@@ -555,7 +551,7 @@ static int cdc_acm_fifo_read(const struct device *dev, uint8_t *rx_data,
555551
if (ring_buf_space_get(dev_data->rx_ringbuf) >= CDC_ACM_BUFFER_SIZE) {
556552
struct usb_cfg_data *cfg = (void *)dev->config;
557553

558-
if (dev_data->configured && !dev_data->suspended) {
554+
if (dev_data->configured) {
559555
cdc_acm_read_cb(cfg->endpoint[ACM_OUT_EP_IDX].ep_addr, 0, dev_data);
560556
}
561557
dev_data->rx_paused = false;

subsys/usb/device/usb_device.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,13 +1246,11 @@ static void forward_status_cb(enum usb_dc_status_code status, const uint8_t *par
12461246
usb_reset_alt_setting();
12471247
}
12481248

1249-
if (status == USB_DC_DISCONNECTED || status == USB_DC_SUSPEND || status == USB_DC_RESET) {
1249+
if (status == USB_DC_DISCONNECTED || status == USB_DC_RESET) {
12501250
if (usb_dev.configured) {
12511251
usb_cancel_transfers();
1252-
if (status == USB_DC_DISCONNECTED || status == USB_DC_RESET) {
1253-
foreach_ep(disable_interface_ep);
1254-
usb_dev.configured = false;
1255-
}
1252+
foreach_ep(disable_interface_ep);
1253+
usb_dev.configured = false;
12561254
}
12571255
}
12581256

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ manifest:
8383
groups:
8484
- hal
8585
- name: hal_nordic
86-
revision: fe0be3c3546e136a67264084c0e3edfd7354645a
86+
revision: 3f7ae2320b6d348898c7b11e956a6e792d0b3724
8787
path: modules/hal/nordic
8888
groups:
8989
- hal

0 commit comments

Comments
 (0)