Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: xhci-mtk: fix random remote wakeup

Some platforms, e.g. 8183/8192, use low level latch way to keep
wakeup signal, it may latch a wrong signal if debounce more time,
and enable wakeup function earlier.
____________________
ip_sleep ____/ \_____________
___________________
wakeup_signal ____________/ \______
_______________________________
wakeup_en _______/
^ ^
|(1) |(2)
latch wakeup_signal mistakenly at (1), should latch it at (2);

Workaround: delay about 100us to enable wakeup, meanwhile decrease
debounce time.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20211102025004.29156-2-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
0d8cfeee 38269d2f

+6 -5
+6 -5
drivers/usb/host/xhci-mtk.c
··· 245 245 /* wait for host ip to sleep */ 246 246 ret = readl_poll_timeout(&ippc->ip_pw_sts1, value, 247 247 (value & STS1_IP_SLEEP_STS), 100, 100000); 248 - if (ret) { 248 + if (ret) 249 249 dev_err(mtk->dev, "ip sleep failed!!!\n"); 250 - return ret; 251 - } 252 - return 0; 250 + else /* workaound for platforms using low level latch */ 251 + usleep_range(100, 200); 252 + 253 + return ret; 253 254 } 254 255 255 256 static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) ··· 301 300 case SSUSB_UWK_V1_1: 302 301 reg = mtk->uwk_reg_base + PERI_WK_CTRL0; 303 302 msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; 304 - val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; 303 + val = enable ? (WC0_IS_EN | WC0_IS_C(0x1)) : 0; 305 304 break; 306 305 case SSUSB_UWK_V1_2: 307 306 reg = mtk->uwk_reg_base + PERI_WK_CTRL0;