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,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 BEAD0C433DF for ; Sun, 5 Jul 2020 18:04:18 +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 8F4172073E for ; Sun, 5 Jul 2020 18:04:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sy4ztmVZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F4172073E 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=Ofhl9tUjvzdUPRI29WlUrFZYJ8RuGraj1684JZM+wBU=; b=sy4ztmVZdCbqzpWFBIS8g2ect zXjsk6vwolHx5pGogjUzL4f1V0nb7lFXkSkfqFYZMNe9dufggHy6K3Eo3N3iYYQ0Wf1dT8Kq1TEzi v1rzLLTxdAvKaAyZWexuijl9Xek8RJEbrcR00g3jIJthEk94NKEq2JO5OG1ckyl9q0tsQgFCBQV7x NlRrz4OA0HRfDTNhdkPQ5NaOlUHrAcQqdIqzNCbjLWNxK99TMH6X1F+dISaLNKAnSmq+1ch7WNBoS 7diqGw757so3dOPJKodMpkP6TT0Dpa3D5VRlzpAd0eo6pGwvpZ+YQY4DqMmpCV566nPTbiWVydz7N sGln9TYpA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1js8ye-0001n1-Sc; Sun, 05 Jul 2020 18:02:56 +0000 Received: from mail-wm1-f68.google.com ([209.85.128.68]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1js8yc-0001mY-GM for linux-arm-kernel@lists.infradead.org; Sun, 05 Jul 2020 18:02:55 +0000 Received: by mail-wm1-f68.google.com with SMTP id a6so25578220wmm.0 for ; Sun, 05 Jul 2020 11:02:53 -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=uPHomDteoTeqD1Zdsfu51U2CvSKbygx5cXktKVzxSNQ=; b=oxd7sBQvg1np8RyBI0RQYzCIZzasi3RLx75pY/c9YrMPhCmtOHEBuIwIOr77VD78ZQ DVkDd+r8coKeMy9+GNKjxX96JjbWtGsNTKLUv+2z2+3jvEaFI+QzxEh0wcyLJi2km8dU KT/gFcMTpYmK+gpZzeJkD/TTOYYL3I5RlG/J+fOZl4tffLs/Tf0t3p6JCwLdtc541ALL L/vt3WJyVum4cMkg4pDGAlhrxYWQGplOKa486b9ccATQ1kQUUCnjDmXPC8TIALEtJZ/K pLRKOxjdspqdT5mYuAYvjbFvPXnwEsK0yxsIgVp6XKQ8EvrFsExKZhGNcBf82kRHH1bS ZxdA== X-Gm-Message-State: AOAM532ysdoL54eK9xfbg/SueYCAs56z+rKju4jrYgB2athnjhBgyUPl lJPspN4u2IaujmVUM+E0Hks= X-Google-Smtp-Source: ABdhPJwnfTrvsdcHqKUfAzn5bksiQ7r5jv+emzW58WvipXFMrOlRo1gOQT1r+OV6UuZiEEBDtCYzwQ== X-Received: by 2002:a7b:ce97:: with SMTP id q23mr46389395wmj.89.1593972171899; Sun, 05 Jul 2020 11:02:51 -0700 (PDT) Received: from kozik-lap ([194.230.155.195]) by smtp.googlemail.com with ESMTPSA id d28sm22653770wrc.50.2020.07.05.11.02.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Jul 2020 11:02:51 -0700 (PDT) Date: Sun, 5 Jul 2020 20:02:48 +0200 From: Krzysztof Kozlowski To: Anand Moon Subject: Re: [PATCH v2] phy: samsung: Use readl_poll_timeout function Message-ID: <20200705180248.GA2765@kozik-lap> References: <20200705060435.504-1-linux.amoon@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200705060435.504-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-20200705_140254_557299_3E250174 X-CRM114-Status: GOOD ( 20.69 ) 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 Sun, Jul 05, 2020 at 06:04:35AM +0000, Anand Moon wrote: > User readl_poll_timeout function instead of open > coded handling in crport_handshake function. Your change does not replace only the "open coded handling" with readl_poll_timeout(). Your change does more - switches busy waiting with udelay to a sleeping mode. I am not sure if it is correct but definitly it should be mentioned. Otherwise how can we be sure that you checked if this is allowed in this section? Did you test everything with DEBUG_ATOMIC_SLEEP? > > Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800") > Signed-off-by: Anand Moon > --- > Changes v2: > --used the default timeout values. > --Added missing Fixed tags. > --- > drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +++++++++--------------- > 1 file changed, 13 insertions(+), 24 deletions(-) > > diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c > index e510732afb8b..c97f5fb6a9a0 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,28 @@ 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; > + u32 timeout_us = 100, sleep_us = 1; No need for the variables actually and their type does not match. Just use the values directly. > 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), sleep_us, timeout_us); > + if (err) { > + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); > return -ETIME; > } > > - usec = 100; > + timeout_us = 100; > + sleep_us = 1; Why defining then again? Best regards, Krzysztof > > 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), sleep_us, timeout_us); > + 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