Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753310AbeAKBca (ORCPT + 1 other); Wed, 10 Jan 2018 20:32:30 -0500 Received: from regular1.263xmail.com ([211.150.99.137]:38010 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753193AbeAKBc2 (ORCPT ); Wed, 10 Jan 2018 20:32:28 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: wxt@rock-chips.com X-FST-TO: wxt@rock-chips.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: wxt@rock-chips.com X-UNIQUE-TAG: <89448a6e428372962acecc968955a105> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH v2 2/2] phy: rockchip-emmc: use regmap_read_poll_timeout to poll dllrdy To: Doug Anderson , Brian Norris Cc: Heiko Stuebner , Shawn Lin , Ziyuan Xu , LKML , Kishon Vijay Abraham I , "open list:ARM/Rockchip SoC..." , Caesar Wang References: <1515581362-181200-1-git-send-email-shawn.lin@rock-chips.com> <1515581362-181200-2-git-send-email-shawn.lin@rock-chips.com> <20180110174615.GA30753@google.com> From: Caesar Wang Message-ID: Date: Thu, 11 Jan 2018 09:32:15 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: ?? 2018??01??11?? 03:36, Doug Anderson ะด??: > Hi, > > On Wed, Jan 10, 2018 at 9:46 AM, Brian Norris wrote: >>> */ >>> - timeout = jiffies + msecs_to_jiffies(50); >>> - do { >>> - udelay(1); >>> - >>> - regmap_read(rk_phy->reg_base, >>> - rk_phy->reg_offset + GRF_EMMCPHY_STATUS, >>> - &dllrdy); >>> - dllrdy = (dllrdy >> PHYCTRL_DLLRDY_SHIFT) & PHYCTRL_DLLRDY_MASK; >>> - if (dllrdy == PHYCTRL_DLLRDY_DONE) >>> - break; >>> - } while (!time_after(jiffies, timeout)); >>> - >>> - if (dllrdy != PHYCTRL_DLLRDY_DONE) { >>> - pr_err("rockchip_emmc_phy_power: dllrdy timeout.\n"); >>> - return -ETIMEDOUT; >>> + ret = regmap_read_poll_timeout(rk_phy->reg_base, >>> + rk_phy->reg_offset + GRF_EMMCPHY_STATUS, >>> + dllrdy, PHYCTRL_IS_DLLRDY(dllrdy), >>> + 1, 50 * USEC_PER_MSEC); > It seems a bit schizophrenic that one of our delay loops sleeps 1 us > between loops and the other sleeps 5 us between loops. > > ...and, in fact, both of these numbers seem a little on the silly side > of things. Assuming that the timer docs are up to date, usleep_range > is intended for sleeping "10us - 20ms". Both 1 us and 5 us below that > range and "1 us" is an order of magnitude below that range. ...your 1 > and 5 actually translate to usleep_range(1, 1) and usleep_range(3, 5). > > It seems like trying to do a sleep (the whole idea that some other > process will get to run for some fraction of the 1 us) is just wasting > cycles. > > So I'd say either: > > 1. Accept that we really expect this to be a long delay and change > your delay to 10 us > > 2. Change the delay to 0 us and accept that you're busy waiting. > > I'd vote for #2 unless you have some evidence that we often need long > delays and we've started calling this code all the time. Agreed with #2 -Caesar > > >>> + if (ret) { >>> + pr_err("%s: dllrdy failed %d.\n", __func__, ret); >>> + return ret; >>> } >>> >>> return 0; >>> -- >>> 1.9.1 >>> >>> > _______________________________________________ > Linux-rockchip mailing list > Linux-rockchip@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-rockchip