Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4189207ybt; Sun, 5 Jul 2020 20:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPIVIbX5DHSwBIYkA2JKPj1PoJ6wGj+FZ5fHqhFz/RdFQR/cskyOLuKbAnpQzTGRVAEOol X-Received: by 2002:a50:f08c:: with SMTP id v12mr52688741edl.119.1594007316407; Sun, 05 Jul 2020 20:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594007316; cv=none; d=google.com; s=arc-20160816; b=tI0ozkDfFqnqfwL0rqr4eYY/S4rm+oXgHGSU75qKpWSdHu0NJcyOEHh3aYKQ74B+SR gk0SrIwvuqjnvRgM+MEHbHAW4Z3WB3L2F3gHodbXIvm2vjIUro+dUfKyECA3Yqm39D0t 2YsJRlpozRIo1cA19qdJyrJfdlu1gDx5aBIj1bOfuK4R0HhctXTNst3g3VPXc6mEcIcB YhM3jY5ffuhJKT5plYbei0zlUgTdemMvE9O6xFmVBVbaCdMVO9ucwuZF4F+UqUckdbox AVMI3VfHi6kJWlOM5FHrca+cbIQ6o7YlfY+B+O93L2oCb4WPjaA2wX2/64pkiwV16JvG OBxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IbFKvwUAZYidEEuDI3n6ueyYMeGnBHxKERKc5eSxw+c=; b=FTfalXZNjl/EB8rCxw1W52z7tFxnR8lgs+owvB8kQErI5XnKxDDn0fwjFRL3bb7vfT 98RZemSidGTMarG++PvlPudhADm2ZvP5vMLvELR0YvKa6fdPdipspSAObLLpy8cUvrPs spodb0LdSV06fVFnsDlCSxfxk9K3ANUzqajrxRNPa4rJUxr/JVEXa1rI30nahL1tjJV5 AOhOESuemVxkEL0ftPP24S81fHO7Y+T4pUjTpQ5nLgYBPDDM1SIPxN5lGKDNDrt3EKAE VTljTERwyHi0jeeAP97H2wFQDNHDxirtGidWcfyDhY7zceRyDRei52DFEI+d1EdBz730 edWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PXd2NakA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si11835813ejc.328.2020.07.05.20.48.13; Sun, 05 Jul 2020 20:48:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PXd2NakA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728747AbgGFDrV (ORCPT + 99 others); Sun, 5 Jul 2020 23:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728668AbgGFDrU (ORCPT ); Sun, 5 Jul 2020 23:47:20 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3230C061794; Sun, 5 Jul 2020 20:47:20 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id q8so37889774iow.7; Sun, 05 Jul 2020 20:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IbFKvwUAZYidEEuDI3n6ueyYMeGnBHxKERKc5eSxw+c=; b=PXd2NakAyUx5SjY38+/3VFE5sAGCgZ9aBGUq/ScZpncOh9+s2PP5Sl4F/sigLmGNoB 3DWbg8XVnymQXfm9NzZugObhNcTtdwNaAOuwmS67c5icYy3Lk0crSRK/BkdO8p4eRi6W vv8PXOnuz69lz1LloiXbV3eTXD3NL8Zh8O4PobTFibsF/eMoAN35uyDgf8xLOwbqw+xB Xm1YL7eRVOula8mR8Tes43+TDH50NGELPtDolE+1AR7uttajcyof8rz4Dbt3Gc/v0kkM 10yHonaMVG+eAuCJkGUZYxtJsqfRys2m/m5BwlpSm78x/5Gb9NQYALJUH4tzveU8+1lg KOug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IbFKvwUAZYidEEuDI3n6ueyYMeGnBHxKERKc5eSxw+c=; b=uKXYGrf5fWKhzscpnee2LUGADBEBhxrdwVbli58B4DUzdnnpQgR39jX9Clkj3pZY7U zBvYjmCKwjydDyxbJZl2kQvblub/ABQjgmlTu5Uk9HRkPFuk3NfDLOI/u2fEDXfJOZr+ fcNa2NYRzfd5B/S8LsRoTta0EdoaAAYW5+kcEiqqIMGUNJc2+sJj30sTFP7e8bv/6u5Z etjLEY4lplB4WRSZ2eXiupUd0JdMliofNKn6aa9iv5xvfpM3FvRXIYf/rtHF5pc18/1c EjhTneJUoG4Csumza4eKIlcAIp3YIN+BZ0iuQjg8XPqNdntKprBoJPMsz4N6eiCbbGce cehg== X-Gm-Message-State: AOAM5312u2lcj7EiVZiOLUzANgVs3hIlCBE4nP9TY5iBIF30nL0l8nJk SrlsdxRSH4ditht2PyPOIZqjBMGIQFfyzKvKiHg= X-Received: by 2002:a5e:cb42:: with SMTP id h2mr23198425iok.43.1594007239994; Sun, 05 Jul 2020 20:47:19 -0700 (PDT) MIME-Version: 1.0 References: <20200705060435.504-1-linux.amoon@gmail.com> <20200705180248.GA2765@kozik-lap> In-Reply-To: <20200705180248.GA2765@kozik-lap> From: Anand Moon Date: Mon, 6 Jul 2020 09:17:09 +0530 Message-ID: Subject: Re: [PATCH v2] phy: samsung: Use readl_poll_timeout function To: Krzysztof Kozlowski Cc: linux-arm-kernel , linux-samsung-soc@vger.kernel.org, Linux Kernel , Kishon Vijay Abraham I , Vinod Koul , Kukjin Kim , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Krzysztof, Thanks for your review comments. On Sun, 5 Jul 2020 at 23:32, Krzysztof Kozlowski wrote: > > 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? Yes this DEBUG_ATOMIC_SLEEP is enabled in exynos_defconfig. > Ok how about the below commit message. Instead of a busy waiting loop while loop using udelay use readl_poll_timeout function to check the condition is met or timeout occurs in crport_handshake function. > > > > 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. Ok thanks > > > 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? I had removed this in this but last minute I added this code again. > > Best regards, > Krzysztof > Best Regards -Anand