diff options
author | Guan-Yu Lin <guanyulin@google.com> | 2023-08-25 14:57:32 +0800 |
---|---|---|
committer | Guan-Yu Lin <guanyulin@google.com> | 2023-10-26 02:01:47 +0000 |
commit | 2bab5d7f5fb674771d63e08a425e6ae29316d63d (patch) | |
tree | ef278425300bb9a92ed641abceadd8d5a580467a | |
parent | 098be2b40275e1318ff461b9fdc931563e296d1d (diff) | |
download | aoc-2bab5d7f5fb674771d63e08a425e6ae29316d63d.tar.gz |
aoc: usb: improve usb recovery during aoc ssr
The original recovery flow didn't cover the case when usb connection
changes during AoC SSR. Instead of changing id to turn on/off host mode,
this fix uses fsm_reset so we can monitor id information during aoc
restart. (Additional patch for aligning implementation in kernel 6.1)
Bug: 297480242
Test: The following 6 tests passed:
1. AoC SSR during USB_ROLE_NONE.
2. AoC SSR during USB_ROLE_HOST.
3. AoC SSR during USB_ROLE_DEVICE.
4. Role changed during AoC SSR.
5. Restart pixel with USB_ROLE_HOST engaged.
6. Restart pixel with USB_ROLE_DEVICE engaged.
Change-Id: I9b0475a0d75181cbf09cea7dc2ae34511c0a0bc1
Signed-off-by: Guan-Yu Lin <guanyulin@google.com>
-rw-r--r-- | usb/aoc_usb.h | 4 | ||||
-rw-r--r-- | usb/aoc_usb_dev.c | 25 | ||||
-rw-r--r-- | usb/xhci_hooks_impl_whi.c | 5 |
3 files changed, 5 insertions, 29 deletions
diff --git a/usb/aoc_usb.h b/usb/aoc_usb.h index 82f3130..e1d589c 100644 --- a/usb/aoc_usb.h +++ b/usb/aoc_usb.h @@ -76,12 +76,10 @@ int usb_host_mode_state_notify(enum aoc_usb_state usb_state); int xhci_set_isoc_tr_info(u16 ep_id, u16 dir, struct xhci_ring *ep_ring); int xhci_get_usb_audio_count(void); -bool is_aoc_usb_probe_done(void); - int xhci_offload_helper_init(void); int usb_vendor_helper_init(void); -extern int dwc3_otg_fsm_try_reset(bool enabled); +extern int dwc3_otg_host_ready(bool ready); extern bool aoc_alsa_usb_capture_enabled(void); extern bool aoc_alsa_usb_playback_enabled(void); diff --git a/usb/aoc_usb_dev.c b/usb/aoc_usb_dev.c index 54b6067..3feec5c 100644 --- a/usb/aoc_usb_dev.c +++ b/usb/aoc_usb_dev.c @@ -355,12 +355,6 @@ static void usb_host_mode_checking_work(struct work_struct *ws) return; } -/* - * This variable used to present if aoc_usb module was probed done. If offload - * is enabled, the controller needs to wait for the aoc_usb probe done and then - * continue the controller's probe. - */ -static bool aoc_usb_probe_done; static int aoc_usb_probe(struct aoc_service_dev *adev) { struct device *dev = &adev->dev; @@ -384,15 +378,11 @@ static int aoc_usb_probe(struct aoc_service_dev *adev) drvdata->service_timeout = msecs_to_jiffies(100); drvdata->nb.notifier_call = aoc_usb_notify; register_aoc_usb_notifier(&drvdata->nb); - dev_set_drvdata(dev, drvdata); - - aoc_usb_probe_done = true; - schedule_work(&usb_host_mode_checking_ws); - // Clear the fsm_reset flag to resume otg_fsm for host/gadget mode bring up. - dwc3_otg_fsm_try_reset(false); + /* USB host mode needs support from AoC. */ + dwc3_otg_host_ready(true); return 0; } @@ -401,9 +391,8 @@ static int aoc_usb_remove(struct aoc_service_dev *adev) { struct aoc_usb_drvdata *drvdata = dev_get_drvdata(&adev->dev); - // If gadget mode is engaged, we raise the fsm_reset flag and wait. - // Otherwise, we reset otg_fsm directly. - dwc3_otg_fsm_try_reset(true); + /* USB host mode needs support from AoC. */ + dwc3_otg_host_ready(false); unregister_aoc_usb_notifier(&drvdata->nb); wakeup_source_unregister(drvdata->ws); @@ -411,16 +400,10 @@ static int aoc_usb_remove(struct aoc_service_dev *adev) kfree(drvdata); - aoc_usb_probe_done = false; return 0; } -bool is_aoc_usb_probe_done(void) -{ - return aoc_usb_probe_done; -} - static const char *const aoc_usb_service_names[] = { "usb_control", NULL, diff --git a/usb/xhci_hooks_impl_whi.c b/usb/xhci_hooks_impl_whi.c index df8ca03..610b95d 100644 --- a/usb/xhci_hooks_impl_whi.c +++ b/usb/xhci_hooks_impl_whi.c @@ -200,11 +200,6 @@ static int usb_audio_offload_init(struct xhci_hcd *xhci) int ret; u32 out_val; - if (!is_aoc_usb_probe_done()) { - dev_dbg(dev, "deferring the probe\n"); - return -EPROBE_DEFER; - } - offload_data = kzalloc(sizeof(struct xhci_offload_data), GFP_KERNEL); if (!offload_data) { return -ENOMEM; |