From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 7AA83C433E0 for ; Tue, 7 Jul 2020 11:38:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4720B206DF for ; Tue, 7 Jul 2020 11:38:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="M7szLbrm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4720B206DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=an6k4fL7BHRVLMQVxSIuTcVL8RacW7viZOJcAt5GuRc=; b=M7szLbrmG63vkff8PVE2DKPot qRXDnpe9Znh64hpiaovMntEAdbCCxddsoDR+Dwx1F0pAXCIjNK8hDSC79eq8vhhjxVI0aIFDo8lqr lSGHMokEeYupN4UUlBlfJeSWsoFAGdJPH+iLGPkSVMmbKdLMkfxz7u4dwikyETZuGB/CtPrcSSCsh UuK0f1jMS/ecdMFFexVGdbOcBeHBYniGpUB5Cb71lecSR0AhoYDA2UCq2+efX/ncHTIa3yBSvHLoN LIaunZ/DRBwmf19TadoMcYJWiygpbz3e8kNXa/jdrVrE9vhOy+ds8hjHiAmt4T2tNCTkRciJ23Upv 7pw+TG2uQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jslu9-0006n8-15; Tue, 07 Jul 2020 11:36:53 +0000 Received: from mail-wr1-f67.google.com ([209.85.221.67]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jslu6-0006lX-0N for linux-arm-kernel@lists.infradead.org; Tue, 07 Jul 2020 11:36:50 +0000 Received: by mail-wr1-f67.google.com with SMTP id r12so44713682wrj.13 for ; 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=Ok8HupiUQScPR5y0gIAcTI9wJ+YazL6wxiQ7KaGh0TWlLpVuM9SCFV7Fxp1Yv7R+CR SjeeMg2zow37+ZW1OqYIkSscsmnpdmvpAWR6qdNvaAesG8+VgS/ObUUR+1QOlzqJi9D/ RSWgl4FOsNM2L8/5Ft84UZNzNGlFYBBQDUSvED7XbLTazp0bfyHFD6OOG7iLYKMkDJ48 UwFVOXCIfyXxcE5HZ14XVrJVAbueQxxqyQj0RQLCTeQxEguZzX2dv+jRnQuGM4CyP2CX lAb7A5wzydLsZX10Y34wApZ/8VWr6lYXsfRKKKtXLvupw2RQjLV58b0SFdmLiqik4l1P sl3w== X-Gm-Message-State: AOAM531CS1itzHT44WVBnSL5uxZXbhZqzCj0Garz7T6c8740iwxNI90u GioH5rsZdzA5URgqFx3OA0///uPc X-Google-Smtp-Source: ABdhPJwKCEvXtM2zZL2ji1JGazyFrHq5dOKCyuwKbPn7zy2n+xmnz/++1EwOm1VFpfZBrfngSrd0cw== 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 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-Disposition: inline In-Reply-To: <20200707095908.372-1-linux.amoon@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200707_073650_080900_3D5ACC12 X-CRM114-Status: GOOD ( 21.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , Vinod Koul , Kukjin Kim , linux-arm-kernel@lists.infradead.org, Marek Szyprowski Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel