From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161151AbcE3IA0 (ORCPT ); Mon, 30 May 2016 04:00:26 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54010 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161091AbcE3IAY (ORCPT ); Mon, 30 May 2016 04:00:24 -0400 From: Arnd Bergmann To: "Baranowska, BeataX" Cc: "Hunter, Adrian" , Ulf Hansson , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Dong, Chuanxiao" , "Jarosz, SebastianX" Subject: Re: [PATCH] mmc: sdhci: use udelay instead of mdelay Date: Mon, 30 May 2016 10:00:42 +0200 Message-ID: <6616684.XTKejIxGbJ@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:MIQ9Lus/mPGIrQtY/rRPphakDTR8dqKjuyYK2PkpaLKpqMaf4QJ E3gJVeJcO68DPcYPYBxgBm46aYFtCceL9RjB3Zpo/IIjBFA0xRysipX4s1zshUNbCf3iy6H kmL9GTqg0GYjygSL8IZ+ZTLVRphPNQMwEI0dWhCPzLMlyv+HMJ8c71kolkCgnmbaGztPQsS zhw2WkHPxMtk/DpBfZpWQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:g+BLuhJKjs8=:NLTFZxmP+uj4aE+WS7FCRL gHQp7azMZ/d2hmd5ibF85Fvca1r/oUUfT0VWk4RXZPduKEfFZ8yD6pwKAuT/yjunEfmlpBCI0 Q+tWbKkbtaitUwIq+pVBn/iI8R1IFZLZB3VfdZ5/96O0fy6L/BybV1JtF5GmxI9+Qbl4StXwh DH9y6Ly8oQ11KrbzGysAYGwmzYFx0qlTtx3FAS/k+lzK5gczJ3gwQ/Cjxki5hhUbqMlhm6moc VZQu3LG6EWwPwufG5BYNc91SX2WUF/6HNvjRPVQTsVDG6GRTjumaJ/tqEnBSrjeSYwk704619 UBpHHKByi/TADbnep1WLUGh6BkrYqrDvefvWJ4QGJ2+quarbfFwEuUDccOme1Y7ZE+55WyTcF aq0RkT9thwZCxqQK4jS21mcmxJj8VQq9f0iQWQvFI9SqF6GPZu/VLxPBr2myXqLXTVidCeJm9 GoQwVkR+iIN+hO2A3ACo0z1YrQl/lLtqvDhwraRTf7sMplCq7WGRCGLJeJ9OYpUW5PipPUHAB sdFuhW++nba3pWch7sGtg20irHVyiqmbKxWQqhw3r6GAuebnFxoG4JIaRnp4byemCqT6tKwHh 3Zq/Zi4dx3XXw1nUZsPU/KM+LEnT0oFddCHB2UKUcrhUy23k88p0AzTO1MyslapNoINLoqxEc etxF7tAx7//Hcst4Q8korEW9g+g8rg+IKMT/Edgp4yiIP7Vz1EWZhcFcK+3cF+luGXPclb5Ya u648QODLxULDjc3Q Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, May 30, 2016 7:55:55 AM CEST Baranowska, BeataX wrote: > From: Chuanxiao Dong > > This patch will use udelay instead of mdelay when waiting for > SDHCI hardware to be stable. udelay can help to reduce the waiting > time when is in critical region which is protected by spinlock. > > With this patch, __sdhci_set_ios only take a few microseconds to be > done. > > Signed-off-by: Chuanxiao Dong > --- > drivers/mmc/host/sdhci.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index e010ea4eb6f5..56d2c7567d97 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -173,8 +173,8 @@ void sdhci_reset(struct sdhci_host *host, u8 mask) > sdhci_runtime_pm_bus_off(host); > } > > - /* Wait max 100 ms */ > - timeout = 100; > + /* Wait max 10000 ms */ > + timeout = 10000; > > /* hw clears the bit when it's done */ > while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) { > @@ -185,7 +185,7 @@ void sdhci_reset(struct sdhci_host *host, u8 mask) > return; > } > timeout--; > - mdelay(1); > + udelay(10); > } > } > EXPORT_SYMBOL_GPL(sdhci_reset); This can significantly increase the timeout length. I think you should instead use time_before() to see how many jiffies have passed since the start. However, the real question is why the reset function gets called under a spinlock in the first place. Can you try to rearrange the code so it doesn't need the lock at all and you can just use msleep() instead? Arnd