From patchwork Fri Jan 13 12:37:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 9515523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6718A601DA for ; Fri, 13 Jan 2017 12:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ADF928606 for ; Fri, 13 Jan 2017 12:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E19D2862E; Fri, 13 Jan 2017 12:40:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE54928606 for ; Fri, 13 Jan 2017 12:40:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cS19e-0006d5-3D; Fri, 13 Jan 2017 12:40:26 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cS18e-0003rC-U6 for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2017 12:39:27 +0000 Received: by mail-wm0-x236.google.com with SMTP id f73so11727847wmf.1 for ; Fri, 13 Jan 2017 04:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yK0JjZwLNCvqkSGBWbxHcL+MBHqj807HxAJDBQsh2pk=; b=c6ttGz6rujGxiWH5qS6NHwu6WRiZ8Jow/Q3wRtHwyVECTzhLSTtK2E08Phnyr6fkB6 XqIXBMV38DpOjyL37wDfCyWajlTu3Ho0c9etP2AeBSOzIXj/i7Mat0KoVYxVdBs0ks6B zXRTiVQVf4TsBvoG6TH9WM/l9uth8DzYYkUbIBYs1G2TBOonIqAr4xQ0GLZKB9k6tikD XpJD016rELRxSIukLWisGm74Myl5otLDPtB+IjkiMV2ZAWLDU/eezehN1eM8/P5U4R6U MO4qqPNh6b4q9rPXNvo37zQwDXaA9pLcJqDrMurW6Moo8wrHSnx+z0waW/uiFaKzPs0s Wnnw== 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:in-reply-to :references; bh=yK0JjZwLNCvqkSGBWbxHcL+MBHqj807HxAJDBQsh2pk=; b=g8tDn8BTnx3DZLCyiAvmXeGuFIvAYmwv4w/KWfyR/8kCon8b7YT1oiKX+lwSdNk88U tIAIiLTNgBeghraIbU4zGO9/oOBccH8V60lDFCZif1YxlR3uTBlyPQCi6/hNSZEZMoXc LRWkrNhdqjUgKeTrAldDrk6PQ5YFjINlPd0vAduNt2pONS0DFhUkdRkxRphM8LkH7y1K 7MMlaUgIQuaz81nEyTNqTDQMpdgjWFt0AMPXgaXL9rftkPAeBclMVZIKJ2H2fc4B29w7 a0Uc6gEndVuFo0DGe2IcWZNqDAzZwJawLxakstNuEOqY1hIJQ14dvoMQ2KyHFpEwNopA 1vbA== X-Gm-Message-State: AIkVDXIZurySEjGP++zFjiB0mmz/Jf0s9pv2h4vp697ShAtrB9LBDC5+a2HlSc8Nl6pp2FLL X-Received: by 10.223.163.26 with SMTP id c26mr11598106wrb.38.1484311142840; Fri, 13 Jan 2017 04:39:02 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y127sm4022680wmg.12.2017.01.13.04.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 04:39:02 -0800 (PST) From: Bartosz Golaszewski To: Kevin Hilman , Sekhar Nori , Patrick Titiano , Michael Turquette , Tejun Heo , Rob Herring , Mark Rutland , Russell King , David Lechner Subject: [PATCH 04/10] sata: hardreset: retry if phys link is down Date: Fri, 13 Jan 2017 13:37:58 +0100 Message-Id: <1484311084-31547-5-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484311084-31547-1-git-send-email-bgolaszewski@baylibre.com> References: <1484311084-31547-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170113_043925_357539_EA8790D8 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ide@vger.kernel.org, Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The sata core driver already retries to resume the link because some controllers ignore writes to the SControl register. We have a use case with the da850 SATA controller where at PLL0 frequency of 456MHz (needed to properly service the LCD controller) the chip becomes unstable and the hardreset operation is ignored the first time 50% of times. Retrying just the resume operation doesn't work - we need to issue the phy/wake reset again to make it work. If ata_phys_link_offline() returns true in sata_link_hardreset(), retry a couple times before really giving up. Signed-off-by: Bartosz Golaszewski --- drivers/ata/libata-core.c | 16 ++++++++++++---- include/linux/libata.h | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 9cd0a2d..3b848a3 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3985,8 +3985,8 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, unsigned long deadline, bool *online, int (*check_ready)(struct ata_link *)) { + int rc, retry = ATA_LINK_RESET_TRIES; u32 scontrol; - int rc; DPRINTK("ENTER\n"); @@ -4009,7 +4009,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, sata_set_spd(link); } - +retry: /* issue phy wake/reset */ if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol))) goto out; @@ -4028,9 +4028,17 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, rc = sata_link_resume(link, timing, deadline); if (rc) goto out; - /* if link is offline nothing more to do */ - if (ata_phys_link_offline(link)) + + if (ata_phys_link_offline(link)) { + if (retry--) { + ata_link_warn(link, + "link still offline after hardreset - retrying\n"); + goto retry; + } + + /* if link is still offline nothing more to do */ goto out; + } /* Link is online. From this point, -ENODEV too is an error. */ if (online) diff --git a/include/linux/libata.h b/include/linux/libata.h index c170be5..2c840c0 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -392,8 +392,10 @@ enum { /* max tries if error condition is still set after ->error_handler */ ATA_EH_MAX_TRIES = 5, - /* sometimes resuming a link requires several retries */ + /* sometimes resuming a link requires several retries... */ ATA_LINK_RESUME_TRIES = 5, + /* ... and sometimes we need to retry the whole reset procedure */ + ATA_LINK_RESET_TRIES = 5, /* how hard are we gonna try to probe/recover devices */ ATA_PROBE_MAX_TRIES = 3,