Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3933442ybt; Sun, 5 Jul 2020 11:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSYO7cCh10HQ0WkdqzBsnxL8TtD2pN2fzSqNzp9NZS1qdABMtyF+4FFxvYl/Le6lCk1AII X-Received: by 2002:a05:6402:1b0e:: with SMTP id by14mr49929999edb.266.1593972220541; Sun, 05 Jul 2020 11:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593972220; cv=none; d=google.com; s=arc-20160816; b=oXhknIGuihRMq0PYj4L00ObQ6EkZoL5aGTwvqTmtOVqHaH0aRttnjrblSnthqBlLZL GYidtGyBptjoPq6ZZdfyZCJyHAl0e6lUiWdnkpI7AKYYmiKYlo+jgCiKYCvH4y17rq+z GgpEJpLNKX56Pl2z7pGMno4dOjQtkAvMHPhQbc61jutEX/ZZ3ZeQHJUT5HHKJvmEKcth 3kYKdVm6JbuAm3ET364rmkdSwkrycCBEEDadr+JgOk4oaCPfHoIxMx/ak4DMbxKmMxjX v14HFsXGtyr/7prRUJNpd+tzv+eO3aD6gUSLu/xl4f5rSb9Qw5xfFqGQ6jRJiWyLNKt5 CtVg== 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=uPHomDteoTeqD1Zdsfu51U2CvSKbygx5cXktKVzxSNQ=; b=JVMW2gx/+XMhZ0LESrAVgSnYih4ryvVoz2kBoXbaA4O+4/7GDOSpY+VVk0BSU5+HhI 6hu+wGFpKUXPCHH5wGhBw79rwUhe8YGnDhYtQVwPeWTTx52y2syTEa8i3NKfHpAfvrtY F9rpqzy0y8dFqoOmCPXQ4n/tsMfnIRP8c/qNYCiNMYKOqDqA6fbNirR8j8vjsuiOFRFe H3Rnbprf2431mwLYKTBxSZeh4399fdfRL8bLvBOGPsD2N4taoIVFF3xiO7cU50RzIlCo ihSipbWoUi4CPQQAfwNgfIdIRybgoKDKcEL4TQcxLHOW3hoOUXPSNf0dj8hQIYIQoz56 5swA== 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 g24si11139834eje.347.2020.07.05.11.03.17; Sun, 05 Jul 2020 11:03:40 -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 S1727878AbgGESCy (ORCPT + 99 others); Sun, 5 Jul 2020 14:02:54 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54388 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgGESCx (ORCPT ); Sun, 5 Jul 2020 14:02:53 -0400 Received: by mail-wm1-f65.google.com with SMTP id o8so36776406wmh.4; Sun, 05 Jul 2020 11:02:52 -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=SJZ6nrkPHfbGh5k/coEtKtpKoXOle9+mPZD3hbqxce2nspFHJyx5i6aV1dV7FO6PbR MQiik9H+EoK3U6mpGRzoTC8Onoip4YRRghUBAiA01udpB4H5Bpe7KZGPPFey13XHRrzd i7ACU70MUvBfNeh1LlCjNbXqTm7mnvQgcO8ECUPzWw9qD6uYDQ8HfPhAEUvY8TomOcRO +a81Lnu5V51bnYUKT9xRKsg4Zy9o89V1GdTAWM1EDoZPTTkjRoj+EVQWJ50ouSBUYjmv xTjjr2QBp2HOP2/MOi4woqm/lQWvXeZnkULaXLly+XrKvqydZz2SjqfeFR900HSGMc6I q0hA== X-Gm-Message-State: AOAM531Lf5lFSUclI1eDuanX63mUHMDBogRSvVkdQWmBnzw5xzDPqV/1 n8MdowUzLq4VgokSOgnzUSE= 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 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 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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200705060435.504-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 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 >