From patchwork Tue Nov 14 22:55:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10058527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E6F66056E for ; Tue, 14 Nov 2017 22:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5152B29808 for ; Tue, 14 Nov 2017 22:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45D2C29A91; Tue, 14 Nov 2017 22:55:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFCBA29A80 for ; Tue, 14 Nov 2017 22:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756957AbdKNWz0 (ORCPT ); Tue, 14 Nov 2017 17:55:26 -0500 Received: from sauhun.de ([88.99.104.3]:33100 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756626AbdKNWz0 (ORCPT ); Tue, 14 Nov 2017 17:55:26 -0500 Received: from localhost (p54B3314E.dip0.t-ipconnect.de [84.179.49.78]) by pokefinder.org (Postfix) with ESMTPSA id 1B5512C37DF; Tue, 14 Nov 2017 23:55:25 +0100 (CET) From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Simon Horman , Yoshihiro Shimoda , Wolfram Sang Subject: [PATCH RFT] mmc: core: use usleep_range rather than HZ magic in mmc_delay() Date: Tue, 14 Nov 2017 23:55:20 +0100 Message-Id: <20171114225520.6793-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Documentation/timers/timers-howto.txt recommends to use usleep_range for delays 1-20ms. Let's adhere to it. No need for messing with HZ and still do busy looping these days. Signed-off-by: Wolfram Sang --- Here is a more detailed test page for this describing my tests: https://elinux.org/Tests:mmc-delay-refactor I did mainly test the insert/eject cycle because powering up the cards seemed to trigger most delays. Transferring data did not cause any calls to mmc_delay() for me. Please let me know if someone knows a test pattern which should be included before applying this change. Works fine for me on Lager (R-Car H2) and Salvator-X (R-Car M3-W). Testing on other platforms very welcome. This should be independent of the IP core. drivers/mmc/core/core.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 71e6c6d7ceb70d..b2877e2d740fa5 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -62,12 +62,10 @@ void mmc_set_initial_state(struct mmc_host *host); static inline void mmc_delay(unsigned int ms) { - if (ms < 1000 / HZ) { - cond_resched(); - mdelay(ms); - } else { + if (ms <= 20) + usleep_range(ms * 1000, ms * 1250); + else msleep(ms); - } } void mmc_rescan(struct work_struct *work);