From patchwork Mon Sep 21 06:13:25 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: 258493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A76C3C43463 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67C6E20866 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="DO28peqW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgIUGRQ (ORCPT ); Mon, 21 Sep 2020 02:17:16 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:31781 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726395AbgIUGRN (ORCPT ); Mon, 21 Sep 2020 02:17:13 -0400 X-UUID: 1af28c60b7d143c0887bfb09408e1f3d-20200921 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=6ZOWN7ki1sN531xAD52X8GiFWf24OghgpbzynrNkwy8=; b=DO28peqW8B399qNluQEyUPGAjNa5QATl1rkGpuuGLhRKMsXwT1ihgN8MfXdXk/f4orOX+V6K1VjgFYBvJOVW8vkwAKZfAiIUIU4xNe/WHdeX321xyDFZMKmzZSqohYuuRsi3EyExdZ5zGqmVy8ve2vJeRlQb3w3JrytM+CrKj6Q=; X-UUID: 1af28c60b7d143c0887bfb09408e1f3d-20200921 Received: from mtkcas36.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 300474815; Mon, 21 Sep 2020 14:16:57 +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; Mon, 21 Sep 2020 14:16:56 +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; Mon, 21 Sep 2020 14:16:54 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Lu Baolu , Mathias Nyman Subject: [PATCH v4 01/11] usb: early: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:25 +0800 Message-ID: <1600668815-12135-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: 2F03555C4872A9C51584CA060F9A514A5CB38BC9E5EB911970C0BACFA9D73A672000:8 X-MTK: N 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 --- v4: add reviewed-by Jann v2~v3: no changes --- drivers/usb/early/xhci-dbc.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:26 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: 297581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F1E6C43466 for ; Mon, 21 Sep 2020 06:17:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43F872084C for ; Mon, 21 Sep 2020 06:17:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="dMYOzZlA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726326AbgIUGRG (ORCPT ); Mon, 21 Sep 2020 02:17:06 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:63798 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726149AbgIUGRF (ORCPT ); Mon, 21 Sep 2020 02:17:05 -0400 X-UUID: 76199e3959b24f03ba6d17f8da1ed900-20200921 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=Xo5rf9xp9Q898V4NrJeKvL/NbIN1YvfdZlom51aDk10=; b=dMYOzZlAtRAPxAFM4lM+xpxev+mOaJjz8MoQcDuHI/7chEd3NHWJc94oR8awYOuaFRAR33A0PAeRtxI9X4sWfra+4Ed/fXeIgWNK3iSr/bEj1bVhAMvfwT2GogU4TuU8o++T5dyESf+0WXqFV4dLVYfxaGHo48GBdPaNTew9KnQ=; X-UUID: 76199e3959b24f03ba6d17f8da1ed900-20200921 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 1399888662; Mon, 21 Sep 2020 14:16:59 +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; Mon, 21 Sep 2020 14:16:57 +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; Mon, 21 Sep 2020 14:16:56 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Petr Mladek Subject: [PATCH v4 02/11] usb: early: ehci-dbgp: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:26 +0800 Message-ID: <1600668815-12135-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 08E2723B77F099582DC762E959887646B7F9FDFF59FD8B41E444D08844B116772000:8 X-MTK: N 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~v4: no changes --- drivers/usb/early/ehci-dbgp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:27 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: 297576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE519C43464 for ; Mon, 21 Sep 2020 06:17:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8792020719 for ; Mon, 21 Sep 2020 06:17:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kbJ4MNvs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbgIUGRF (ORCPT ); Mon, 21 Sep 2020 02:17:05 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:32638 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726011AbgIUGRF (ORCPT ); Mon, 21 Sep 2020 02:17:05 -0400 X-UUID: cefb740919664e95868c211ba93a897d-20200921 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=qI3X9MwE9sMRTnQRdhPZhEZddjHAueHKnEny+Zk541Y=; b=kbJ4MNvsBOgJQ+AIltUz3w/dMmKx8/gWAgYwmGoOFMj4CJv5aGc6tMaLJ/80FMTgtRHZaQk/OLv4cUufCMfE8bHiBPtnat86dgJkSlgGNKfCKpu1GvjhrzJKtv8DUz8CUnYbFsHPFV8rWFHjaP1WECK6J9YheAKhtoUmXdqjPuI=; X-UUID: cefb740919664e95868c211ba93a897d-20200921 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 2077247481; Mon, 21 Sep 2020 14:17:00 +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; Mon, 21 Sep 2020 14:16:59 +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; Mon, 21 Sep 2020 14:16:57 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Mathias Nyman Subject: [PATCH v4 03/11] usb: pci-quirks: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:27 +0800 Message-ID: <1600668815-12135-3-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 421069FA6C9AA675FB54CB2DE9B79D16F9C9FB5D8FC8F7F833225D52AF36DAA72000:8 X-MTK: N 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~v4: no changes --- drivers/usb/host/pci-quirks.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:28 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: 297579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44A70C43465 for ; Mon, 21 Sep 2020 06:17:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F22E7214F1 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="bnGMdywG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbgIUGRT (ORCPT ); Mon, 21 Sep 2020 02:17:19 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:33827 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726360AbgIUGRK (ORCPT ); Mon, 21 Sep 2020 02:17:10 -0400 X-UUID: a1b094b5ca854b2cbb26a0c061b1d1e1-20200921 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=U22axENSaSmKHtYTwm1iMGOTpOJkveZ+Ct8IXMXHsKI=; b=bnGMdywG97ACJCIzqKN4MCGrpDnMvG6eFt0ci/rD/fsFW/9uINbUeB1gVe7ra+ddOZfxJcZxO2RRbL88WUfQ1IA5KMkILOk1Lv7+YF8lttbgz0XmpKzY7QGqeEiTbuEREScnODGkqQ1LMhEI9jBvpH+MqvsvPyw44GjgVYOAzXY=; X-UUID: a1b094b5ca854b2cbb26a0c061b1d1e1-20200921 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 1774809618; Mon, 21 Sep 2020 14:17:02 +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; Mon, 21 Sep 2020 14:17:02 +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; Mon, 21 Sep 2020 14:16:59 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Mathias Nyman , Yoshihiro Shimoda Subject: [PATCH v4 04/11] usb: xhci-rcar: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:28 +0800 Message-ID: <1600668815-12135-4-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: F0016E84F75B6688BB13CF221D2E328E07E6887A003D1587A8EF7C2F36539F9F2000:8 X-MTK: N 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 --- v4: changes 1. remove unnecessary parentheses suggested by Yoshihiro 2. fix the wrong return value suggested by Yoshihiro & Daniel v2~v3: no changes --- drivers/usb/host/xhci-rcar.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) -- 1.9.1 Reviewed-by: Yoshihiro Shimoda diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index c1025d3..1bc4fe7 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 Mon Sep 21 06:13:29 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: 258494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75D44C43463 for ; Mon, 21 Sep 2020 06:17:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C4722084C for ; Mon, 21 Sep 2020 06:17:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="nkPEa13K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbgIUGRK (ORCPT ); Mon, 21 Sep 2020 02:17:10 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:42163 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726149AbgIUGRI (ORCPT ); Mon, 21 Sep 2020 02:17:08 -0400 X-UUID: 8a75d16a3c1f4e118f9597f83e281977-20200921 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=iytLVyfwsqCD1g9UEuz02b2x3mx6gFmM96o8N8uXFCw=; b=nkPEa13Kx7DLe7rhGyBwYIL4BvhJ7xl68aY7+tcn/gPXaennJShaOnIOaikNLTrQSPieYcyyNEueRQsXicJ4bygdh1UE7WWag/tQyC+ARbfnUKe/IBSnYKnB/gmnDtBD2dJdLNpyBCyELFt3Opstqh41ZvPDaqldsrQwbXSmrog=; X-UUID: 8a75d16a3c1f4e118f9597f83e281977-20200921 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 2038064824; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:01 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 05/11] usb: oxu210hp-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:29 +0800 Message-ID: <1600668815-12135-5-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 980D8799D31CC841754718C45ED7A1AE8DFE241777DE81837D9B0AEB06BE52E02000:8 X-MTK: N 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~v4: no changes --- drivers/usb/host/oxu210hp-hcd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:30 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: 297580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C08C5C43464 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D6172151B for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="gotV4TnD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726428AbgIUGRT (ORCPT ); Mon, 21 Sep 2020 02:17:19 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:42163 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726365AbgIUGRL (ORCPT ); Mon, 21 Sep 2020 02:17:11 -0400 X-UUID: 7d6a59728f09409a9bd29d77974c7ab0-20200921 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=eXo3ZNdSOv7o75Rg1veepw4qxn8TsYpXE6uoKVo5ls8=; b=gotV4TnDTm2El8gyBVp2VKdGqYhNmg/KAAIK7J0HG87g61RmpIaxUxGvHbuJcd9HCyVzbxTYjftHmlzaBES1dbTpRUvqzx62wG7ckhxZNOto0iTHo1F+UeGCTbHFdM3TLJGWOJHyVVUGVsN6Bddfxwa6nTuBJVg424bgEzTf46w=; X-UUID: 7d6a59728f09409a9bd29d77974c7ab0-20200921 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 2029283798; Mon, 21 Sep 2020 14:17:05 +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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:03 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 06/11] usb: fotg210-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:30 +0800 Message-ID: <1600668815-12135-6-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: CE95345C94FC4573D10D501B0ECEFF2EE20D259A0C306BD28181E09C342AD6FE2000:8 X-MTK: N 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~v4: no changes --- drivers/usb/host/fotg210-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:31 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: 258490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56464C43463 for ; Mon, 21 Sep 2020 06:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2040B20719 for ; Mon, 21 Sep 2020 06:17:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ftScSwB5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgIUGRR (ORCPT ); Mon, 21 Sep 2020 02:17:17 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:6170 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726359AbgIUGRL (ORCPT ); Mon, 21 Sep 2020 02:17:11 -0400 X-UUID: 33aa4d5624de4657a8d0625bdefb4ac1-20200921 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=03QgLwsgOisVZbDGtPu7Lgll5Hbd3GQyWS3uWvzNTQ0=; b=ftScSwB5IevXsojNb5+KzWkvK0BxLBFxuN1gka1qezFAwetWLA4uK2/tdsNboz2HrMY2jXa4XY41FMp5rktbkvxzkApgXaEp19uPNPQz9fez4viXZ5yyechPmnHEtjKdgPlDQ2mudjethQATl+IIJuDX+QXHsEefeK5vQemPGXA=; X-UUID: 33aa4d5624de4657a8d0625bdefb4ac1-20200921 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 625568464; Mon, 21 Sep 2020 14:17:07 +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; Mon, 21 Sep 2020 14:17:06 +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; Mon, 21 Sep 2020 14:17:04 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 07/11] usb: isp1760-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:31 +0800 Message-ID: <1600668815-12135-7-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 7DBBB53265D7247BC7A4B0C82379CA3038943C4CC4771CF8CE69B2F2BB86AEE32000:8 X-MTK: N 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~v4: no changes --- drivers/usb/isp1760/isp1760-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:32 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: 258492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2750C43465 for ; Mon, 21 Sep 2020 06:17:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB7052084C for ; Mon, 21 Sep 2020 06:17:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="oEKDVb1y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgIUGRh (ORCPT ); Mon, 21 Sep 2020 02:17:37 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:35367 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726427AbgIUGRW (ORCPT ); Mon, 21 Sep 2020 02:17:22 -0400 X-UUID: 7f02da13606d4d42859f4c6eed9e5405-20200921 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=M+jMphpitAdQKmTgncue8DLUuiChzBueaSc64a9GuJ4=; b=oEKDVb1ynNUmgwwumG1tbZhg/AEzW8wczkOk5ummn+zbFmYHaL7LgRZ4yEHKhbCi+YaUZgnsbL0Geggub5OqdjPvF9cod1g+nXqyscNneMZhMQwOyfulLLbQQAHlINpvXCoMYYPFJAxjFhGpZgXi2dX5g+AVUCaJBZABrRYzeSM=; X-UUID: 7f02da13606d4d42859f4c6eed9e5405-20200921 Received: from mtkcas36.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 1933687756; Mon, 21 Sep 2020 14:17:09 +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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:06 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 08/11] usb: phy-ulpi-viewport: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:32 +0800 Message-ID: <1600668815-12135-8-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: EEA5F66F385D1C22FDC9CCE0641F47060E3C27892C8F6ED0949B2FA6AC1DA61E2000:8 X-MTK: N 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~v4: no changes --- drivers/usb/phy/phy-ulpi-viewport.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:33 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: 297577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F169C43465 for ; Mon, 21 Sep 2020 06:17:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49EE920735 for ; Mon, 21 Sep 2020 06:17:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ar2WyMZz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbgIUGRU (ORCPT ); Mon, 21 Sep 2020 02:17:20 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:44379 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726149AbgIUGRQ (ORCPT ); Mon, 21 Sep 2020 02:17:16 -0400 X-UUID: 9b8aeb5f100842b88219cd125606aac5-20200921 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=fhoC7nd4R36M3issGh+SxVPkb1Qjg4iuhqpKgwaNaKE=; b=ar2WyMZzX2bOPL47+URojAsnd8qASu3pjqCCyQCTaqvuXRJMR+9fW7EXGUmn8P8ispWphQYabRcdzgtN70lqNH71mBtADueARgUzO5PTcmz+4IVjG4lXxVsm8fhu+OCsjJfSeM4kYC2rX2fOhAWGutJE6WdTwDi4NUmk61diOzg=; X-UUID: 9b8aeb5f100842b88219cd125606aac5-20200921 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 50010507; Mon, 21 Sep 2020 14:17:11 +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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:08 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 09/11] usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:33 +0800 Message-ID: <1600668815-12135-9-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 2F9FBD9981B001EA895A14F6E8D251A0B594F6BC5073CA2F55F375A17B5E66502000:8 X-MTK: N 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 --- v4: no changes 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(-) -- 1.9.1 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 Mon Sep 21 06:13:34 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: 258491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95AD6C43463 for ; Mon, 21 Sep 2020 06:17:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 435F92084C for ; Mon, 21 Sep 2020 06:17:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kr3A7pHi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbgIUGRV (ORCPT ); Mon, 21 Sep 2020 02:17:21 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:36361 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726415AbgIUGRS (ORCPT ); Mon, 21 Sep 2020 02:17:18 -0400 X-UUID: c41bba5b92564aa6b15e6e98606b2327-20200921 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=oHk1JU2NeVe2tWWWIBxMvDXUuKUJJvTa4oJY401uQng=; b=kr3A7pHiT2VOl6Or4lFA26n1fJwuqNl7m5qs2BO/+L5WPM/YryCsUL31ahINuzxYGSRzMr0yt9KmeVGehCxus1dt+Q+wEXM4DTNZEYZCiNY+xqsz1qec0ZUnlpQyq7891IdlDW41hO02I4hbKKMqKaoIR26WQoqzcryrwZOwvnc=; X-UUID: c41bba5b92564aa6b15e6e98606b2327-20200921 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 1094818918; Mon, 21 Sep 2020 14:17:13 +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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:10 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Alan Stern Subject: [PATCH v4 10/11] usb: udc: net2280: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:34 +0800 Message-ID: <1600668815-12135-10-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: F315BAB8ED3B30B9B6DF2791A863E3E70DFCD786BE5E8679004EC738121DABED2000:8 X-MTK: N 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~v4: no changes v2: add Acked-by Alan --- drivers/usb/gadget/udc/net2280.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 1.9.1 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 Mon Sep 21 06:13:35 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: 297578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A67DC43466 for ; Mon, 21 Sep 2020 06:17:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B986520735 for ; Mon, 21 Sep 2020 06:17:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="EEQXTdPa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgIUGRg (ORCPT ); Mon, 21 Sep 2020 02:17:36 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:37159 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726444AbgIUGRW (ORCPT ); Mon, 21 Sep 2020 02:17:22 -0400 X-UUID: 847c506cef2040d1ac54569fed59b031-20200921 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=6qZ3MFCp67LQIehQWoxsg/JhWq3n6ohpU0YiOM2IRh4=; b=EEQXTdPab/7sy/TBuVvayjO/SjldcuWGvOAXt1oxM8Dn2WfqdG4PHT6vemaX2A+svzCkDhoZhrrPjBQzLYbxPSK7Welhl8fNtwlO1HLqYsvhNziPihxNTji+Q6O3z3z+vY49bmfmt7AaQpQYAlw46eEP47+9tnA/TZ/w4jWrb1s=; X-UUID: 847c506cef2040d1ac54569fed59b031-20200921 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 937722441; Mon, 21 Sep 2020 14:17:14 +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; Mon, 21 Sep 2020 14:17:14 +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; Mon, 21 Sep 2020 14:17:12 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson , Alan Stern Subject: [PATCH v4 11/11] iopoll: update kerneldoc of read_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:35 +0800 Message-ID: <1600668815-12135-11-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 12B795415FC0ED3118BA475BA2E81ADE4E49B603F95922E5AACB3B2F03B46E0A2000:8 X-MTK: N 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 --- v4: no changes 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(-) -- 1.9.1 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.