lkml.org 
[lkml]   [2020]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] phy: samsung: Use readl_poll_timeout function
Hi Krzysztof,

Thanks for your review comments.

On Sun, 5 Jul 2020 at 23:32, Krzysztof Kozlowski <krzk@kernel.org> 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 <linux.amoon@gmail.com>
> > ---
> > 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 <linux/of.h>
> > #include <linux/of_address.h>
> > #include <linux/of_device.h>
> > +#include <linux/iopoll.h>
> > #include <linux/phy/phy.h>
> > #include <linux/platform_device.h>
> > #include <linux/mutex.h>
> > @@ -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

\
 
 \ /
  Last update: 2020-07-06 05:48    [W:0.044 / U:3.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site