From patchwork Mon Jul 13 07:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 11658953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1609D138C for ; Mon, 13 Jul 2020 07:44:26 +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 E348620674 for ; Mon, 13 Jul 2020 07:44:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wD1Gc9w2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZhlT799S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E348620674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YSvebE+5jZPKPka5DKfzwKAh/ozsD7bdRir8oNfN+10=; b=wD1Gc9w2qPzZ1mhbDE7GYH5ssY dWgYkHsjEJBlKMrLQ4VsiWwL3nyg4e2PYoW/65JIoJIPK7Ow6PCMZLaV0cbT5lu1a6QdKZqVGHH1W wVec5LH4fE7R6mkOFIJWTU9Ifnjn2SVpeMTS1GrHcf/z2OllUat8JnjdvjSQKqT6PtNsMhLeioEag apfSHrA7ZsHNc5mAR0SEHKiZcgt57fEwsqZwBNl969lb4B5mgkSAx0Il719CKhBZKKbAxUh66qaxx eDoQYQKhhUyldybXNbGCgwN2Lye2dQ35PkzMAN8X3z7G8B4hqQqHp/9W5tdiFd6cxVdk4M+Zn608o FWQTSlSQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jut75-0007as-4P; Mon, 13 Jul 2020 07:42:59 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jut72-0007Zh-DG for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2020 07:42:57 +0000 Received: by mail-pl1-x642.google.com with SMTP id w17so5147204ply.11 for ; Mon, 13 Jul 2020 00:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kv7SaniNrlUPbvo7cWwc80WSNfLRXfgs1fiLYtKopIU=; b=ZhlT799SGBQhoHqAHdZ4lZj1j/AYdgOOYfKXe+d0zRdJWGte52q6+ZlkptRwdhl5v4 QV/4eytBNvOoIsIoKXWzcx86NjNK6/6pwau43reCmmEc8nR9FbS/FUPUgB1xvF7Zys2B 3nxgz2QzSdL0QR4FYvC/zdx3DWypbf6R/xf02t6VJn9f7Mej+t1xPMUDayyZLFwXJQLs yGFjT8yL9ybELIToHwaEOZK9Na+q37Qt5MWWdutGF7lFA6oqtPBW9UknREOKpdbT0o2m uLm5Eae8jQWqrSRbJV/aK7ExOX6L7L4QyP1+iAmM7mBe2TPqtWFbGmQ/WZ+LWqjsfR7J BfRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kv7SaniNrlUPbvo7cWwc80WSNfLRXfgs1fiLYtKopIU=; b=mKcGLXKiyLwaQagzHQqtI+cSSdH2rpOvdBDIeAVZQra4beABNHAcUrKYPvMKqCeprX LaQ3WQYzDcF/pT92dEgFORgKs0UpIQR9jw/iaZyKRpYegftzQ9qi2m7EPc0Q2W77+5/e eugB8Y1P8v7oC/m4AbLsTqKnnrNLP5aLSc1ysXnTORuQaxw9dZrVyXYmZkw7xBj0vS39 SiQ0jtIv3Gb9TXbmdX1XOu+4vu4RpKNanxAevhFhTdEaNYYC807zPxHMdkYr8ipGbPgw eLc9NUp5fDtMP42tdn99/XtyN67oBWGPzOk4hcPucCzINOtc43vV1lSktmZidVkAP8Fz jbHQ== X-Gm-Message-State: AOAM533a/bQDjRxRN7vWoyzcySNAOTyInscOliuIisH098JUUIyxKH0t DgXiTDvK43snDF+xUCAVUumeJiqG X-Google-Smtp-Source: ABdhPJxHcu1Ud7WDBTb4qIFDB5l2yIOfKVi3zND/ElHwtLcc7bQ/TVlT+STA2ZBAjz08dje95SGmYA== X-Received: by 2002:a17:90a:bf89:: with SMTP id d9mr19127661pjs.89.1594626172692; Mon, 13 Jul 2020 00:42:52 -0700 (PDT) Received: from localhost.localdomain ([103.51.74.198]) by smtp.gmail.com with ESMTPSA id e12sm13521180pfd.69.2020.07.13.00.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 00:42:52 -0700 (PDT) From: Anand Moon To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] phy: samsung: Use readl_poll_timeout function Date: Mon, 13 Jul 2020 07:42:43 +0000 Message-Id: <20200713074243.530-1-linux.amoon@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200713_034256_459421_AC9D9B42 X-CRM114-Status: GOOD ( 17.23 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 1.5 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [103.51.74.198 listed in dnsbl.sorbs.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [linux.amoon[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: Marek Szyprowski , Vinod Koul , Kukjin Kim , Krzysztof Kozlowski , Kishon Vijay Abraham I Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Instead of a busy waiting while loop using udelay use readl_poll_timeout function to check the condition is met or timeout occurs in crport_handshake function. readl_poll_timeout is called in non atomic context so it safe to sleep until the condition is met. Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800") Signed-off-by: Anand Moon --- Changes v4: Rebased on to of patch [0] https://patchwork.kernel.org/patch/11651673/ --Fix the commit message. --Fix the error timeout condition for -ETIMEDOUT --- 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 | 39 ++++++++---------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c index 7f6279fb4f8f..ad81aa65cdff 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,41 +557,25 @@ 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); - return -ETIME; + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, (result & PHYREG1_CR_ACK), 1, 100); + if (err == -ETIMEDOUT) { + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); + return err; } - 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); - return -ETIME; + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, !(result & PHYREG1_CR_ACK), 1, 100); + if (err == -ETIMEDOUT) { + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val); + return err; } return 0;