Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp960497ybt; Tue, 7 Jul 2020 04:37:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGu5I92NmN7tnl9hu6LvyrtTqQ7OwQIHBDz2HTAObyfwyEF2mPNG1rhpPA0D+i0seaL0+2 X-Received: by 2002:a50:bc03:: with SMTP id j3mr62073043edh.234.1594121855865; Tue, 07 Jul 2020 04:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594121855; cv=none; d=google.com; s=arc-20160816; b=ZSJSEhpj5V7WPZFIjMOm1VATtN1YmERlgjqaibmeWogrp16HTqm1r5jo0cBTMlzlfM eLwtnYGLYcijDJfZZAXyFYfmit48XRvcMeDYgrKDa9ALEEH9VRf/I7XK7EafZ8aa6jtb MOnku2UKcFUqE2jR4vNfiqt9qETxAUl4s43aTZE9SiFuH9uOkh8xxIho0BIPiCcwDQOZ lezYSHVRUTdyccX/7uUZ1C/jkI5Nt3JabUaSqqAvgvNYV81ZfrnFCa9olQLRwzPJNnX0 Xcv6D1iqDmDwzkP0zQWLfUdmEkKIxsYBqn4gtfpogRQwBY51NvwLdXw4PBlj0AeWe2az 9uJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=g8eYN4DcaE4cWGmQIJYjXftOZqfTHMZ6RPDgEcxyfN4=; b=l/hID2af7ecq3tUwQpwf9bNGiATbV6FGMjW6ywpyGfy8A1/JgTvLwKpz9RFpnVRdcL Aen4+d0V/56o73ISr6/TOc3H4UnVrQm1FankVzg7VocOvvrtr0qr1kCQhJdWqBTuS1JM talL/kMIon86TaYgTsoeNdRjSNUMOSH+SO82DjiD+9OKrsnD2JTo2yEil3mH0pXC3Nug htBhAGKiIN0jcFYmBi/zObXNa8MwEXgVdge0CJPanzmA4w9h6nBrP/5FW52xGeZF/8FJ u409e5z5nD0hOQIPiYsssbDSoPzTaRPt2hsQs2DkzAI15NwHT5C1BkVlhk84QlpKU8Pb gXrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si15062527edn.579.2020.07.07.04.37.12; Tue, 07 Jul 2020 04:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728216AbgGGLgv (ORCPT + 99 others); Tue, 7 Jul 2020 07:36:51 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38194 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgGGLgu (ORCPT ); Tue, 7 Jul 2020 07:36:50 -0400 Received: by mail-wr1-f66.google.com with SMTP id z13so44786373wrw.5; Tue, 07 Jul 2020 04:36:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g8eYN4DcaE4cWGmQIJYjXftOZqfTHMZ6RPDgEcxyfN4=; b=PSmZYdUmOKsnB+kTyNp3fcu5M5IJjcno0zdBVaWtiVcZQn8zL2CuqWCxo7LtPHPypi CRtT3+OTskT4e/1jg0V9GwNeq/GA0Zscpoy2jEafT+0YjrZ9clIzbHxLBJbaSw/TKCpU iPBYre8Fak3sfoCwjhhQhI/N4qvBTuWIOpVj4slroCaJg0x+vrG9HP4//hSs415I+sFj tuc/p23AueHA4hiPabVamlXSfY6oqui392yD6BHgVQc2SeRMKVOvyQXIKNJr6PEslmwW yiOuhNSoleJ/zdL/UFpjMI7w5Mor84GUCNGzYSjk7+TwGt81SaCpPj3WZHRPLjh2St9Q oXfQ== X-Gm-Message-State: AOAM533fnS/3GheMtzw6p0kWg697ayYcO3eefo/Im6hsdfa/nH6MmWYY JO9iAzWq6Pr25h6fl4FnJeA= X-Received: by 2002:a5d:4991:: with SMTP id r17mr25847697wrq.1.1594121808402; Tue, 07 Jul 2020 04:36:48 -0700 (PDT) Received: from kozik-lap ([194.230.155.195]) by smtp.googlemail.com with ESMTPSA id v24sm764491wrd.92.2020.07.07.04.36.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jul 2020 04:36:47 -0700 (PDT) Date: Tue, 7 Jul 2020 13:36:45 +0200 From: Krzysztof Kozlowski To: Anand Moon Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , Vinod Koul , Kukjin Kim , Marek Szyprowski Subject: Re: [PATCH v3] phy: samsung: Use readl_poll_timeout function Message-ID: <20200707113645.GA27280@kozik-lap> References: <20200707095908.372-1-linux.amoon@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200707095908.372-1-linux.amoon@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 09:59:08AM +0000, Anand Moon wrote: > Instead of a busy waiting loop while loop using udelay You doubled "loop". > use readl_poll_timeout function to check the condition > is met or timeout occurs in crport_handshake function. Still you did not mention that you convert the function to use sleeping primitive. You also did not mention whether it is actually allowed in this context and I am not sure if you investigated it. Best regards, Krzysztof > > Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800") > Signed-off-by: Anand Moon > --- > Changes v3: > --Fix the commit message. > --Drop the variable, used the value directly. > Changes v2: > --used the default timeout values. > --Added missing Fixed tags. > --- > drivers/phy/samsung/phy-exynos5-usbdrd.c | 35 +++++++----------------- > 1 file changed, 10 insertions(+), 25 deletions(-) > > diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c > index e510732afb8b..fa75fa88da33 100644 > --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c > +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -556,40 +557,24 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) > static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd, > u32 val, u32 cmd) > { > - u32 usec = 100; > unsigned int result; > + int err; > > writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); > > - do { > - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); > - if (result & PHYREG1_CR_ACK) > - break; > - > - udelay(1); > - } while (usec-- > 0); > - > - if (!usec) { > - dev_err(phy_drd->dev, > - "CRPORT handshake timeout1 (0x%08x)\n", val); > + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, > + result, (result & PHYREG1_CR_ACK), 1, 100); > + if (err) { > + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); > return -ETIME; > } > > - usec = 100; > - > writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); > > - do { > - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); > - if (!(result & PHYREG1_CR_ACK)) > - break; > - > - udelay(1); > - } while (usec-- > 0); > - > - if (!usec) { > - dev_err(phy_drd->dev, > - "CRPORT handshake timeout2 (0x%08x)\n", val); > + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, > + result, !(result & PHYREG1_CR_ACK), 1, 100); > + if (err) { > + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val); > return -ETIME; > } > > -- > 2.27.0 >