From patchwork Wed Jan 18 13:19: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: 9523769 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 8474D6020A for ; Wed, 18 Jan 2017 13:25:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7430D20246 for ; Wed, 18 Jan 2017 13:25:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67CD1285EC; Wed, 18 Jan 2017 13:25:17 +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=unavailable 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 199B320246 for ; Wed, 18 Jan 2017 13:25:17 +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 1cTqEi-0004jW-My; Wed, 18 Jan 2017 13:25:12 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTqAZ-00078N-Nb for linux-arm-kernel@bombadil.infradead.org; Wed, 18 Jan 2017 13:20:55 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTqAX-0005a2-Lo for linux-arm-kernel@lists.infradead.org; Wed, 18 Jan 2017 13:20:54 +0000 Received: by mail-wm0-x236.google.com with SMTP id r126so244767617wmr.0 for ; Wed, 18 Jan 2017 05:20:32 -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=gjYAUx7cCSy+KrACbqFxG1BPaNYntYNoHa+KVUCPqgQ=; b=OQRrxnDyQnpdGHpEwa6I/wY/P2xoMPLX+8Z9Y8uea+ySpzakBkHRTcLIKOokWJUtzW 9uUYHPsEnmFNMDqwNorcHejD+ypqrd6cNYRQVx6UE9ESXipAnwPD5P/unBKohZXpHNVH 27SxCJBX+9AzI3a3Z0nTx6gUh8FTbzx9fnv57Feo6UzuRKnQzKt/fBJ0OF0sbiYy+e0B tYU0IQCQ5Qtj91bwb1tWc2eROmGVCM1vYokjUwGZaQhNMUISlSnsAuhSBI42PZOGzcda NoeVWOGMsdPDnTu37D9XVrrFG1QYc9hWyXrnO2CiGM9/51ZDnrpzEfgm5+QeLeQfzMqA i98Q== 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=gjYAUx7cCSy+KrACbqFxG1BPaNYntYNoHa+KVUCPqgQ=; b=EQ4rrmHPlobGLJZmwC7kDyik0Dx9V6prIBJGyi4/q/UzG9zibFAEQlwrMVB+Bqohr/ 2a6jdbCbFE7yPiTZ4++Zp7ReYD9J/leQZCXHBcJKTU2+wO09H2HaSZp+tU59ow14Xrti QDP2gjr0SitLrsvkkw7pZpipTntpSOWDbyR8OIJBGimxh5tkJ2NdAcX8017mWiI56k7z nMWzshSchAga429P7ApsKQi4Rhh5Rqqo2ixc1cn6Hi1oHn830GMlYDmTBlbTlZkYMjS0 bI895JPtJcXSO5kkEIanAo9555h50OvnCZPrmIgqpNBgrFnHqqx+xFkGN5k/VttxdhZ1 iqIg== X-Gm-Message-State: AIkVDXIlL864DybUc1e94DeN+KfZtlfj01uXW3PLocWilL1/6Yxz7nPiKLe4RoIXoKoU4vnu X-Received: by 10.28.191.139 with SMTP id o11mr22358455wmi.97.1484745630639; Wed, 18 Jan 2017 05:20:30 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id w79sm4899569wmw.0.2017.01.18.05.20.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Jan 2017 05:20:29 -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 v3 10/13] sata: ahci-da850: add a workaround for controller instability Date: Wed, 18 Jan 2017 14:19:58 +0100 Message-Id: <1484745601-4769-11-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> References: <1484745601-4769-1-git-send-email-bgolaszewski@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170118_082053_858231_A26D2E96 X-CRM114-Status: GOOD ( 17.68 ) 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 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. The sata core driver already retries to resume the link because some controllers ignore writes to the SControl register, but just retrying the resume operation doesn't work - we need to issue he phy/wake reset again to make it work. Reimplement ahci_hardreset() in the driver and poke the controller a couple times before really giving up. Signed-off-by: Bartosz Golaszewski --- drivers/ata/ahci_da850.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index 11dd87e..0b2b1a4 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c @@ -16,7 +16,8 @@ #include #include "ahci.h" -#define DRV_NAME "ahci_da850" +#define DRV_NAME "ahci_da850" +#define HARDRESET_RETRIES 5 /* SATA PHY Control Register offset from AHCI base */ #define SATA_P0PHYCR_REG 0x178 @@ -76,6 +77,29 @@ static int ahci_da850_softreset(struct ata_link *link, return ret; } +static int ahci_da850_hardreset(struct ata_link *link, + unsigned int *class, unsigned long deadline) +{ + int ret, retry = HARDRESET_RETRIES; + bool online; + + /* + * In order to correctly service the LCD controller of the da850 SoC, + * we increased the PLL0 frequency to 456MHz from the default 300MHz. + * + * This made the SATA controller unstable and the hardreset operation + * does not always succeed the first time. Before really giving up to + * bring up the link, retry the reset a couple times. + */ + do { + ret = ahci_do_hardreset(link, class, deadline, &online); + if (online) + return ret; + } while (retry--); + + return ret; +} + static struct ata_port_operations ahci_da850_port_ops = { .inherits = &ahci_platform_ops, .softreset = ahci_da850_softreset, @@ -83,6 +107,8 @@ static struct ata_port_operations ahci_da850_port_ops = { * No need to override .pmp_softreset - it's only used for actual * PMP-enabled ports. */ + .hardreset = ahci_da850_hardreset, + .pmp_hardreset = ahci_da850_hardreset, }; static const struct ata_port_info ahci_da850_port_info = {