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: 91387 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp169904qgi; Fri, 13 Jan 2017 04:40:27 -0800 (PST) X-Received: by 10.98.56.196 with SMTP id f187mr22795462pfa.131.1484311227863; Fri, 13 Jan 2017 04:40:27 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id 23si11513361pfy.74.2017.01.13.04.40.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 04:40:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 198.137.202.9 as permitted sender) client-ip=198.137.202.9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 198.137.202.9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1cS19d-0006d5-Qa; Fri, 13 Jan 2017 12:40:25 +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-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:236 listed in] [list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.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+patch=linaro.org@lists.infradead.org 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(-) -- 2.9.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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,