From patchwork Thu Sep 10 08:21:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01D25618 for ; Thu, 10 Sep 2020 08:31:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1573208A9 for ; Thu, 10 Sep 2020 08:31:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ImSM/DOG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730410AbgIJIbA (ORCPT ); Thu, 10 Sep 2020 04:31:00 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:22256 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730386AbgIJIYe (ORCPT ); Thu, 10 Sep 2020 04:24:34 -0400 X-UUID: 8a453c210c5846adb62cae5a4badafcf-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=n+pceR4RMgmAMEAt4bZLKvLzwP+bC0iCUPc31NQ9+9s=; b=ImSM/DOG0HuougE7y2Iw0kLbkvBSDrLp0w3PiAWAaJoHLFYJOcHJ9+IM8EzFtOp6xq9o21XQhgXgfW4Fyq5DyuKYFcf4ugNrigbKdeBMBPhMJXnm030ui//nkStYY/dgz8udDldPiuCDwDK6Y0EFQ3jN2tnBXmrhkVP6oAUm1wQ=; X-UUID: 8a453c210c5846adb62cae5a4badafcf-20200910 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1609855164; Thu, 10 Sep 2020 16:23:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:23:58 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:23:56 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Lu Baolu , Mathias Nyman Subject: [PATCH RESEND v3 01/11] usb: early: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:42 +0800 Message-ID: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: 3CEDF1C9E1989338AB07B01DC590B9649CEE54B7EB8B0190A82F837BF91D34932000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Cc: Lu Baolu Cc: Mathias Nyman Signed-off-by: Chunfeng Yun Reviewed-by: Jann Horn --- v2~v3: no changes --- drivers/usb/early/xhci-dbc.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index c050776..be4ecba 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -135,16 +136,9 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay) { u32 result; - do { - result = readl(ptr); - result &= mask; - if (result == done) - return 0; - udelay(delay); - wait -= delay; - } while (wait > 0); - - return -ETIMEDOUT; + return readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done), + delay, wait); } static void __init xdbc_bios_handoff(void) From patchwork Thu Sep 10 08:21:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA89C618 for ; Thu, 10 Sep 2020 08:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B66F920BED for ; Thu, 10 Sep 2020 08:33:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="N1yfkH3W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730339AbgIJIdb (ORCPT ); Thu, 10 Sep 2020 04:33:31 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:22807 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730383AbgIJIYe (ORCPT ); Thu, 10 Sep 2020 04:24:34 -0400 X-UUID: 815a4b2562534e99882e822c9115cae9-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=J3BiqWxfV1+Z3aDvfR83RogHjSnqeDdQl3tqJBLcqsI=; b=N1yfkH3WlUUIQZeetodgAdzUspqrvn46lPxvvFh0ATzymaKRt5nJxqfCcU7oV7ia3PR844vaHZQkQgl2D1EbwHTjHJKvmvQpA4Nml0noG020XkQMkovGIWsb0dqjp5QlSNMNbywZkXRcvtn7rBwhZ62UYPaIjBZ0vRv6s00XLPI=; X-UUID: 815a4b2562534e99882e822c9115cae9-20200910 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1942603470; Thu, 10 Sep 2020 16:24:01 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:00 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:23:58 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Petr Mladek Subject: [PATCH RESEND v3 02/11] usb: early: ehci-dbgp: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:43 +0800 Message-ID: <1599726112-4439-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: AFF16CD37DCA3267BBDFA7FEB25A7875F550A782E36CA49A37CE082BE0907E122000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Cc: "Eric W. Biederman" Cc: Petr Mladek Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/early/ehci-dbgp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index b075dbf..45b42d8 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -161,17 +162,11 @@ static inline u32 dbgp_pid_read_update(u32 x, u32 tok) static int dbgp_wait_until_complete(void) { u32 ctrl; - int loop = DBGP_TIMEOUT; - - do { - ctrl = readl(&ehci_debug->control); - /* Stop when the transaction is finished */ - if (ctrl & DBGP_DONE) - break; - udelay(1); - } while (--loop > 0); + int ret; - if (!loop) + ret = readl_poll_timeout_atomic(&ehci_debug->control, ctrl, + (ctrl & DBGP_DONE), 1, DBGP_TIMEOUT); + if (ret) return -DBGP_TIMEOUT; /* From patchwork Thu Sep 10 08:21:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767055 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29B0614F6 for ; Thu, 10 Sep 2020 08:31:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0619A20872 for ; Thu, 10 Sep 2020 08:31:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="K/IUHLwN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730426AbgIJIbC (ORCPT ); Thu, 10 Sep 2020 04:31:02 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:32736 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730394AbgIJIYf (ORCPT ); Thu, 10 Sep 2020 04:24:35 -0400 X-UUID: 4143ed2616294f21b32a495ddb00ebd0-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=vQDriCyMjYjM6pnqq6iAk0QyjJohTMSr6/4Cj53MUf4=; b=K/IUHLwNzVVXGw1qbAR659zWN1Fx3FbcxTAXnoNrvCt1f6h0QI3GBYrHordWtIK56V82efgkCBa2HXRPKMmS7yQIZO8CntYmYhkpNuGQiBChZPgnAZu2h4YjkM/2QDbsnTeaXMLgGQTTmz+ZEE9JgjJNSSh6p530Gc2mPn0HMqc=; X-UUID: 4143ed2616294f21b32a495ddb00ebd0-20200910 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1186567138; Thu, 10 Sep 2020 16:24:02 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:01 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:00 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Mathias Nyman Subject: [PATCH RESEND v3 03/11] usb: pci-quirks: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:44 +0800 Message-ID: <1599726112-4439-3-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: D8E101BFE2F788B63AD5617A9332290E2362D4EC28CE6A38C9B5E42E2FA50F632000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Cc: Mathias Nyman Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/host/pci-quirks.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index b8961c0..8920566 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -1012,15 +1013,9 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, { u32 result; - do { - result = readl(ptr); - result &= mask; - if (result == done) - return 0; - udelay(delay_usec); - wait_usec -= delay_usec; - } while (wait_usec > 0); - return -ETIMEDOUT; + return readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done), + delay_usec, wait_usec); } /* From patchwork Thu Sep 10 08:21:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767015 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A8B2618 for ; Thu, 10 Sep 2020 08:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 167432075B for ; Thu, 10 Sep 2020 08:25:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="mVeJpvz+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730374AbgIJIZi (ORCPT ); Thu, 10 Sep 2020 04:25:38 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:2671 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730393AbgIJIYi (ORCPT ); Thu, 10 Sep 2020 04:24:38 -0400 X-UUID: 4d03c4db00bb4a5e8236d13890d71c84-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=F4mzGda76Rx36DNHSGEKqplD8yql9lIdY7JyMYhES0w=; b=mVeJpvz+f1x62p2saZatnh61UwBArI54BYT7HBIyxwmappQKZ1QuRXs9NIH+JatHQNZBtZOn7seayfT1q8ExdfmYGJZevsqgworTA5J/GN26qfrq6mWCLaeYoAPqApJkbjlHRaVk0D9y59br5g8E0GAF+HL/mrQAYfC24Viftvc=; X-UUID: 4d03c4db00bb4a5e8236d13890d71c84-20200910 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 297554876; Thu, 10 Sep 2020 16:24:04 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:04 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:02 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Mathias Nyman , Yoshihiro Shimoda Subject: [PATCH RESEND v3 04/11] usb: xhci-rcar: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:45 +0800 Message-ID: <1599726112-4439-4-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: D551D691DB25F07A367A51FC77988420B16EE09204599E6579A68152A513AEC42000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Cc: Mathias Nyman Cc: Yoshihiro Shimoda Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/host/xhci-rcar.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index c1025d3..74f836f 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -127,8 +128,7 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) void __iomem *regs = hcd->regs; struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); const struct firmware *fw; - int retval, index, j, time; - int timeout = 10000; + int retval, index, j; u32 data, val, temp; u32 quirks = 0; const struct soc_device_attribute *attr; @@ -166,32 +166,19 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) temp |= RCAR_USB3_DL_CTRL_FW_SET_DATA0; writel(temp, regs + RCAR_USB3_DL_CTRL); - for (time = 0; time < timeout; time++) { - val = readl(regs + RCAR_USB3_DL_CTRL); - if ((val & RCAR_USB3_DL_CTRL_FW_SET_DATA0) == 0) - break; - udelay(1); - } - if (time == timeout) { - retval = -ETIMEDOUT; + retval = readl_poll_timeout_atomic(regs + RCAR_USB3_DL_CTRL, + val, !(val & RCAR_USB3_DL_CTRL_FW_SET_DATA0), + 1, 10000); + if (retval < 0) break; - } } temp = readl(regs + RCAR_USB3_DL_CTRL); temp &= ~RCAR_USB3_DL_CTRL_ENABLE; writel(temp, regs + RCAR_USB3_DL_CTRL); - for (time = 0; time < timeout; time++) { - val = readl(regs + RCAR_USB3_DL_CTRL); - if (val & RCAR_USB3_DL_CTRL_FW_SUCCESS) { - retval = 0; - break; - } - udelay(1); - } - if (time == timeout) - retval = -ETIMEDOUT; + retval = readl_poll_timeout_atomic((regs + RCAR_USB3_DL_CTRL), + val, (val & RCAR_USB3_DL_CTRL_FW_SUCCESS), 1, 10000); release_firmware(fw); @@ -200,18 +187,12 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) static bool xhci_rcar_wait_for_pll_active(struct usb_hcd *hcd) { - int timeout = 1000; + int retval; u32 val, mask = RCAR_USB3_AXH_STA_PLL_ACTIVE_MASK; - while (timeout > 0) { - val = readl(hcd->regs + RCAR_USB3_AXH_STA); - if ((val & mask) == mask) - return true; - udelay(1); - timeout--; - } - - return false; + retval = readl_poll_timeout_atomic(hcd->regs + RCAR_USB3_AXH_STA, + val, ((val & mask) == mask), 1, 1000); + return !!retval; } /* This function needs to initialize a "phy" of usb before */ From patchwork Thu Sep 10 08:21:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 472A0618 for ; Thu, 10 Sep 2020 08:33:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2150620C09 for ; Thu, 10 Sep 2020 08:33:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kNTHCv3b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730154AbgIJIdY (ORCPT ); Thu, 10 Sep 2020 04:33:24 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:22870 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730381AbgIJIYe (ORCPT ); Thu, 10 Sep 2020 04:24:34 -0400 X-UUID: 83d501ad5656476d869246c8f3a0fce2-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=glUu4ILa56NmCzEya+FLhC/5JYoRtBGd30upHM8qMX0=; b=kNTHCv3bsP1phVyVcMnw2YdaoXCHZqhRcfa9vrGnKg8IHatDrzKu+eqZuZL2iTvAwUQ+WaCowX71PJmp1XZQ3W1UJZ2MOUaXZ+sYw3NHV2u1r/Q/KrCfAnNSTiAu1e5l3Ra50mtnxTGWRaXEZWpdkm3lTbgyZRKYZF6xMIs+zAw=; X-UUID: 83d501ad5656476d869246c8f3a0fce2-20200910 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 244888743; Thu, 10 Sep 2020 16:24:06 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:05 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:04 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 05/11] usb: oxu210hp-hcd: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:46 +0800 Message-ID: <1599726112-4439-5-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: C5A2AC489B45A0F990228762FA8A7204B6D8C1A944092FAC6D1DCAFFC99CC7D52000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/host/oxu210hp-hcd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index cfa7dd2..27dbbe1 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -748,18 +749,16 @@ static int handshake(struct oxu_hcd *oxu, void __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = readl(ptr); - if (result == ~(u32)0) /* card removed */ - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + ret = readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done || + result == U32_MAX), + 1, usec); + if (result == U32_MAX) /* card removed */ + return -ENODEV; + + return ret; } /* Force HC to halt state from unknown (EHCI spec section 2.3) */ From patchwork Thu Sep 10 08:21:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89BAA618 for ; Thu, 10 Sep 2020 08:33:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 646A1208CA for ; Thu, 10 Sep 2020 08:33:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="qwHNt0hG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730358AbgIJIa7 (ORCPT ); Thu, 10 Sep 2020 04:30:59 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:33661 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730400AbgIJIYg (ORCPT ); Thu, 10 Sep 2020 04:24:36 -0400 X-UUID: fda48862335f4b32a0516abfad076fe2-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=mVw3k7m+HfgDDtgies2lv1Zs9zfJ0QocsJ5+s8RXmlU=; b=qwHNt0hGWcxf+pjlXCFOt4v4FI2rS+w36mWj6Y9o8BUNKtJyTj06gNViehdKrAfUrEwb1obm80V1VSFclGjfD7gdUEYDlPi0K5XgOCVs/i55Cw4IFzxJG8M9fxQHxsNCf9U4rSpC7gzhVxyOr6IV3KJnDnsHPHxPhQkwt488k6E=; X-UUID: fda48862335f4b32a0516abfad076fe2-20200910 Received: from mtkcas34.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1693113807; Thu, 10 Sep 2020 16:24:07 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:07 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:05 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 06/11] usb: fotg210-hcd: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:47 +0800 Message-ID: <1599726112-4439-6-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 2157792CED1FA9CBAAC8C672C145BEFB20C5C2929A9E6CCCCF5D75191B6C95362000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/host/fotg210-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 194df82..1d94fcf 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -883,18 +884,15 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = fotg210_readl(fotg210, ptr); - if (result == ~(u32)0) /* card removed */ - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + ret = readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done || + result == U32_MAX), 1, usec); + if (result == U32_MAX) /* card removed */ + return -ENODEV; + + return ret; } /* Force HC to halt state from unknown (EHCI spec section 2.3). From patchwork Thu Sep 10 08:21:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E831F618 for ; Thu, 10 Sep 2020 08:33:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C503620872 for ; Thu, 10 Sep 2020 08:33:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ov+rb94F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728443AbgIJIaz (ORCPT ); Thu, 10 Sep 2020 04:30:55 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:24474 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730358AbgIJIYn (ORCPT ); Thu, 10 Sep 2020 04:24:43 -0400 X-UUID: 4b14aed620984003b8f9042eae41b42d-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=o9gRtfphL7oKzKpDTA0u+KvZoZmDOCuBnG5TsFQzD7k=; b=ov+rb94FRihrrIkSN8UEbnNJqmo2SJiH70Eqv9K/afekkbmWocscsa51bdhFhaSqiX8J6xWVHkeyZQHlMHGPMW4QIuwFnULjovZ5QPTfzNbinwap1h+AeymHMYmG3PtKSMwVKrtbHMdHXApqclZolCDOpS7vAWTGboj+Glygn7E=; X-UUID: 4b14aed620984003b8f9042eae41b42d-20200910 Received: from mtkcas34.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1558554770; Thu, 10 Sep 2020 16:24:10 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:08 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:07 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 07/11] usb: isp1760-hcd: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:48 +0800 Message-ID: <1599726112-4439-7-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: AE382C1EA462680E25491CE36EF7D6C38BC8928087A10E97E194B6FC703E2C2E2000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/isp1760/isp1760-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index dd74ab7a..33ae656 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -380,18 +381,15 @@ static int handshake(struct usb_hcd *hcd, u32 reg, u32 mask, u32 done, int usec) { u32 result; + int ret; + + ret = readl_poll_timeout_atomic(hcd->regs + reg, result, + ((result & mask) == done || + result == U32_MAX), 1, usec); + if (result == U32_MAX) + return -ENODEV; - do { - result = reg_read32(hcd->regs, reg); - if (result == ~0) - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + return ret; } /* reset a non-running (STS_HALT == 1) controller */ From patchwork Thu Sep 10 08:21:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38AF3618 for ; Thu, 10 Sep 2020 08:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17962214F1 for ; Thu, 10 Sep 2020 08:26:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="TzlolGJj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730433AbgIJIZw (ORCPT ); Thu, 10 Sep 2020 04:25:52 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:24230 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730412AbgIJIYh (ORCPT ); Thu, 10 Sep 2020 04:24:37 -0400 X-UUID: 5e76e5d89b0f4a5da4c1d25555c79537-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=alOtbDy8sNebdE7u73c0CBOo4U8QiV6rJoaa+rnc/yY=; b=TzlolGJjnKElZdgaXcrNDRlRqueyhjY2DKRU0wdiG/7bcesAgIRDiKRTkzMp7gZbKCKjFAmnxRit4Xb23eVS/+lmZEfTEhWD4zKrbpNMnm65efTa4FUFdYZOyBjGv8IFjU1R34jPq0rnwUPa6ILDb0gen2egrWDhwyyDJuXAjU4=; X-UUID: 5e76e5d89b0f4a5da4c1d25555c79537-20200910 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1316339729; Thu, 10 Sep 2020 16:24:10 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:10 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:09 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 08/11] usb: phy-ulpi-viewport: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:49 +0800 Message-ID: <1599726112-4439-8-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 0F0E5AEE4A43A08AF82FBC584F94AC36F0023DD0166A4C8724EEB7840B8A51B02000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/phy/phy-ulpi-viewport.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-ulpi-viewport.c b/drivers/usb/phy/phy-ulpi-viewport.c index 7a14e0e..0f61e32 100644 --- a/drivers/usb/phy/phy-ulpi-viewport.c +++ b/drivers/usb/phy/phy-ulpi-viewport.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -20,16 +21,9 @@ static int ulpi_viewport_wait(void __iomem *view, u32 mask) { - unsigned long usec = 2000; + u32 val; - while (usec--) { - if (!(readl(view) & mask)) - return 0; - - udelay(1); - } - - return -ETIMEDOUT; + return readl_poll_timeout_atomic(view, val, !(val & mask), 1, 2000); } static int ulpi_viewport_read(struct usb_phy *otg, u32 reg) From patchwork Thu Sep 10 08:21:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62D13618 for ; Thu, 10 Sep 2020 08:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40D7E20C09 for ; Thu, 10 Sep 2020 08:33:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="UypEheTd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgIJIa7 (ORCPT ); Thu, 10 Sep 2020 04:30:59 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:34211 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730397AbgIJIYh (ORCPT ); Thu, 10 Sep 2020 04:24:37 -0400 X-UUID: 127c51fee3154bd9a5212ba8b0bc5617-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=RiKpsCZJex/4PNC9PXP3CBjdPJWYcy6TOG9QBDJhfJg=; b=UypEheTd03Zs7dYGpSOC8vGgcuuSQf8HEoyn65/jadsDBEwHF+u3ZHD4MZnhby4YvfLCmE7ESmJ2UhqzbCw3muUCOh/ZFDJwpWbSyqYjXn1n0cWEGJlhSwJX/kxBIdHPbmdAbOGdp0mMylbmU4Wkr+lYwCYvi/Z1QyM+o4uRN2c=; X-UUID: 127c51fee3154bd9a5212ba8b0bc5617-20200910 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 111676909; Thu, 10 Sep 2020 16:24:12 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:11 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:10 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 09/11] usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:50 +0800 Message-ID: <1599726112-4439-9-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 9E9FC7DF85F7DECF1FBA81FC92D4B5528B3C18E67E2F8B37039BCCB0CD400C822000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v3: re-align argument of log suggested by Sergei v2: udelay 10us instead of 20us according to kerneldoc --- drivers/usb/phy/phy-mv-usb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index ce767ec..576d925 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -135,8 +136,8 @@ static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id, static int mv_otg_reset(struct mv_otg *mvotg) { - unsigned int loops; u32 tmp; + int ret; /* Stop the controller */ tmp = readl(&mvotg->op_regs->usbcmd); @@ -146,15 +147,12 @@ static int mv_otg_reset(struct mv_otg *mvotg) /* Reset the controller to get default values */ writel(USBCMD_CTRL_RESET, &mvotg->op_regs->usbcmd); - loops = 500; - while (readl(&mvotg->op_regs->usbcmd) & USBCMD_CTRL_RESET) { - if (loops == 0) { - dev_err(&mvotg->pdev->dev, - "Wait for RESET completed TIMEOUT\n"); - return -ETIMEDOUT; - } - loops--; - udelay(20); + ret = readl_poll_timeout_atomic(&mvotg->op_regs->usbcmd, tmp, + (tmp & USBCMD_CTRL_RESET), 10, 10000); + if (ret < 0) { + dev_err(&mvotg->pdev->dev, + "Wait for RESET completed TIMEOUT\n"); + return ret; } writel(0x0, &mvotg->op_regs->usbintr); From patchwork Thu Sep 10 08:21:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AF9F698 for ; Thu, 10 Sep 2020 08:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7FFB214F1 for ; Thu, 10 Sep 2020 08:26:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="n1F+Z4OM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729691AbgIJIZs (ORCPT ); Thu, 10 Sep 2020 04:25:48 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:34841 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729988AbgIJIYh (ORCPT ); Thu, 10 Sep 2020 04:24:37 -0400 X-UUID: 4f4507b6949c4952b75b4b6bf8bb933a-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=LsbK3aFahnUwEjBrSyDBs20PI2uINsZC3CgcxYtUvus=; b=n1F+Z4OMPrzN1crhvk9ajNgkr92aVqNjMuL9h3HkEJV6+wypgq37vTFB3ppEZrsQaB+YdiC3kG9Nj+9h2txC4dxIel8yBDnb81mZcMc1DIM2uADk/lixSO8zTvR6Gwibx+Fhg2JWVuIbC8SaBTJICZP2OJ7E2zScoFQ2APIlWdE=; X-UUID: 4f4507b6949c4952b75b4b6bf8bb933a-20200910 Received: from mtkcas35.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1473391881; Thu, 10 Sep 2020 16:24:14 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:13 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:12 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Alan Stern Subject: [PATCH RESEND v3 10/11] usb: udc: net2280: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:51 +0800 Message-ID: <1599726112-4439-10-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: BE6E2F2B92070E6D9ADDB1909749E3B84BAB997B565150EDC2B09943C0C282692000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Cc: Alan Stern Cc: Felipe Balbi Signed-off-by: Chunfeng Yun Acked-by: Alan Stern --- v3: no changes v2: add Acked-by Alan --- drivers/usb/gadget/udc/net2280.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 7530bd9..f1a21f4 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -360,18 +361,16 @@ static inline void enable_pciirqenb(struct net2280_ep *ep) static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = readl(ptr); - if (result == ~(u32)0) /* "device unplugged" */ - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + ret = readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done || + result == U32_MAX), + 1, usec); + if (result == U32_MAX) /* device unplugged */ + return -ENODEV; + + return ret; } static const struct usb_ep_ops net2280_ep_ops; From patchwork Thu Sep 10 08:21:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11767017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8035698 for ; Thu, 10 Sep 2020 08:25:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F5AE2074B for ; Thu, 10 Sep 2020 08:25:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="WUGjKqHF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730432AbgIJIZt (ORCPT ); Thu, 10 Sep 2020 04:25:49 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:35086 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730415AbgIJIYh (ORCPT ); Thu, 10 Sep 2020 04:24:37 -0400 X-UUID: 81ce557efefa4b81b14a5bbf3e039ab4-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=1f1GqktsmoCBBHY58Mnms9zF6E9zoWUyHkZ1qxBjj5A=; b=WUGjKqHF/rU4d0DaafZU4+Eropte60wAguG6gICrKcnl11XoVXNd6ewqk10l/rej3xM5y+d8nhh2MS40GyCKZ5wMkNz2JjGunhxtAEBl8si//z9QN4bYeh5OWD89sCtJfJ578m0ex+R31i1hrcHhA0g40/IPkVhQ+A4ID8Uq/nc=; X-UUID: 81ce557efefa4b81b14a5bbf3e039ab4-20200910 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 284505523; Thu, 10 Sep 2020 16:24:15 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:15 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:13 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , , Alan Stern Subject: [PATCH RESEND v3 11/11] iopoll: update kerneldoc of read_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:52 +0800 Message-ID: <1599726112-4439-11-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 678F10287C6AD8F68C030FC275638F71D4820C79F8C8E8D12FB532F6D55A8D832000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Arguments description of read_poll_timeout_atomic() is out of date, update it. Cc: Alan Stern Signed-off-by: Chunfeng Yun --- v3: fix typo in commit message suggested by Sergei v2: new patch, suggested by Alan --- include/linux/iopoll.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index bc89ac6..2c8860e 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -60,8 +60,7 @@ /** * read_poll_timeout_atomic - Periodically poll an address until a condition is * met or a timeout occurs - * @op: accessor function (takes @addr as its only argument) - * @addr: Address to poll + * @op: accessor function (takes @args as its arguments) * @val: Variable to read the value into * @cond: Break condition (usually involving @val) * @delay_us: Time to udelay between reads in us (0 tight-loops). Should @@ -69,6 +68,7 @@ * Documentation/timers/timers-howto.rst). * @timeout_us: Timeout in us, 0 means never timeout * @delay_before_read: if it is true, delay @delay_us before read. + * @args: arguments for @op poll * * Returns 0 on success and -ETIMEDOUT upon a timeout. In either * case, the last read value at @args is stored in @val.