From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CBA7C4338F for ; Sun, 1 Aug 2021 03:30:35 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5340560238 for ; Sun, 1 Aug 2021 03:30:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5340560238 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 293CF8324A; Sun, 1 Aug 2021 05:30:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TRjPvU0/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0F7B83268; Sun, 1 Aug 2021 05:30:29 +0200 (CEST) Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5B27E82C24 for ; Sun, 1 Aug 2021 05:30:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mibodhi@gmail.com Received: by mail-qv1-xf2e.google.com with SMTP id x12so7312403qvo.12 for ; Sat, 31 Jul 2021 20:30:26 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=mnfxDmXz+u8RQEAsRX8ijLWn76Pv+j0dLhbWNRz4Mgw=; b=TRjPvU0/1XpDSU06ZbDelx9QFa8BtxreQTSBTHfH/NHns22qhIsTRiLd8JMEggAv4O 80RN8tbFOzms93EZC/OB3GXfquOnbGxGiN7OydAZJGjx400OYX2/kkPFlLSx2gbLSH6j nM0gVS6seRiZzAWJEv3InB2n9quet+4yCFtZS8/sSKewR4ZYCk0UQ8o0rk9jS5A9jTyR Xzja9OdezisaQBdd1FNBNTmMzMeAFTuzh7JTJYRxeTOhbvxlLiKVxpvl8cpfpxtuxeD1 iu5A/oNVNBQOYjNk30GUtFniLyoHT9//q1PnN0b5fjZ0R4pyFedMRQE86NRgihfhBoVa TR2g== 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:mime-version:content-transfer-encoding; bh=mnfxDmXz+u8RQEAsRX8ijLWn76Pv+j0dLhbWNRz4Mgw=; b=BmGPxuNgeZ7MraJwZlkkxNP3lwPWDPXfhr0G/xCnS9WBuQgCCZhxxAjOKUU4bKJlzj LaCpqxQQmujhe02IJEVaFUUG0l/svyQb6vvu9oY9dlccXLBZjQpsQhHnY44+lbJqrf40 YkAyucA+VrDgOQySlEHg3nKtb1cryN27JLCfwVK0mt9gbeg7nt3O18S9WOJZPuL6oEig Ooc2XBpS/PV2cznCyv1X/6qZKyNHeBvcERY16JiPd1oiZWUD94FEqA7oUweLGJQSMSlx nxtfuZlPirIDqlkgmL18e4h63qGhTp2pCSTsRaj1hxhlGLkWKnlyR4IXu1ZszdDohX7X EvTg== X-Gm-Message-State: AOAM5319LyfvZ5WZyGZKYaGAXCBUaDvMb+yi3tpU0OyKdTzE+Zs2oK65 xu5O9CKhI3jx1BWJOrSeVeE= X-Google-Smtp-Source: ABdhPJwv9poQkzZgggjQm+5wNqMmjtnqbC+tf2rQTHSQ89gHszfrafs3t7lewewL4Aalx1aWQrGELg== X-Received: by 2002:a0c:ee2a:: with SMTP id l10mr10166064qvs.22.1627788625115; Sat, 31 Jul 2021 20:30:25 -0700 (PDT) Received: from localhost.localdomain ([66.218.48.244]) by smtp.gmail.com with ESMTPSA id d25sm2773716qtw.59.2021.07.31.20.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 20:30:24 -0700 (PDT) From: Tony Dinh To: Stefan Roese , U-Boot Mailing List Cc: Tom Rini , Simon Glass , Tony Dinh Subject: [PATCH v2] arm: mvebu: sata_mv failed to identify HDDs during cold start Date: Sat, 31 Jul 2021 20:29:35 -0700 Message-Id: <20210801032935.5533-1-mibodhi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <26c76127-7415-d3dd-f20d-ac05cd04a6b0@denx.de> References: <26c76127-7415-d3dd-f20d-ac05cd04a6b0@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean During cold start, with some HDDs, mv_sata_identify() does not populate the ID words on the 1st ATA ID command. In fact, the first ATA ID command will only power up the drive, and then the ATA ID command processing is lost in the process. Tests with: - Seagate ST9250320AS 250GB HDD and Seagate ST4000DM004-2CV104 4TB HDD. - Zyxel NSA310S (Kirkwood 88F6702), Marvell Dreamplug (Kirkwood 88F6281), Seagate GoFlex Home (Kirkwood 88F6281), Pogoplug V4 (Kirkwood 88F6192). Observation: - The Seagate ST9250320AS 250GB took about 3 seconds to spin up. - The Seagate ST4000DM004-2CV104 4TB took about 8 seconds to spin up. - mv_sata_identify() did not populate the ID words after the call to mv_ata_exec_ata_cmd_nondma(). - Attempt to insert a long delay of 30 seconds, ie. mdelay(30_000), after the call to ata_wait_register() inside mv_ata_exec_ata_cmd_nondma() did not help with the 4TB drive. The ID words were still empty after that 30s delay. Patch Description: - Added a second ATA ID command in mv_sata_identify(), which will be executed if the 1st ATA ID command did not return with valid ID words. - Use the HDD drive capacity in the ID words as a successful indicator of ATA ID command. - In the scenario where a box is rebooted, the 1st ATA ID command is always successful, so there is no extra time wasted. - In the scenario where a box is cold started, the 1st ATA command is the power up command. The 2nd ATA ID command alleviates the uncertainty of how long we have to wait for the ID words to be populated by the SATA controller. Reviewed-by: Stefan Roese Signed-off-by: Tony Dinh --- Changes in v2: Return value -ENODEV if mv_identify() failed to identify the drive drivers/ata/sata_mv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 1012cb5374..dadb2c7c2e 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -809,6 +809,7 @@ static int mv_ata_exec_ata_cmd_nondma(struct udevice *dev, int port, static int mv_sata_identify(struct udevice *dev, int port, u16 *id) { struct sata_fis_h2d h2d; + int len; memset(&h2d, 0, sizeof(struct sata_fis_h2d)); @@ -818,8 +819,32 @@ static int mv_sata_identify(struct udevice *dev, int port, u16 *id) /* Give device time to get operational */ mdelay(10); - return mv_ata_exec_ata_cmd_nondma(dev, port, &h2d, (u8 *)id, - ATA_ID_WORDS * 2, READ_CMD); + /* During cold start, with some HDDs, the first ATA ID command does + * not populate the ID words. In fact, the first ATA ID + * command will only power up the drive, and then the ATA ID command + * processing is lost in the process. + */ + len = mv_ata_exec_ata_cmd_nondma(dev, port, &h2d, (u8 *)id, + ATA_ID_WORDS * 2, READ_CMD); + + /* If drive capacity has been filled in, then it was successfully + * identified (the drive has been powered up before, i.e. + * this function is invoked during a reboot) + */ + if (ata_id_n_sectors(id) != 0) + return len; + + /* Issue the 2nd ATA ID command to make sure the ID words are + * populated properly. + */ + mdelay(10); + len = mv_ata_exec_ata_cmd_nondma(dev, port, &h2d, (u8 *)id, + ATA_ID_WORDS * 2, READ_CMD); + if (ata_id_n_sectors(id) != 0) + return len; + + printf("Err: Failed to identify SATA device %d\n", port); + return -ENODEV; } static void mv_sata_xfer_mode(struct udevice *dev, int port, u16 *id) -- 2.20.1