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.8 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 C4429C4338F for ; Sun, 25 Jul 2021 21:59:21 +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 DB24D60F11 for ; Sun, 25 Jul 2021 21:59:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB24D60F11 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 46B0583201; Sun, 25 Jul 2021 23:59:18 +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="qJ4Hnvev"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BAEC83224; Sun, 25 Jul 2021 23:59:16 +0200 (CEST) Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (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 889CD82C2D for ; Sun, 25 Jul 2021 23:59:12 +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-xf29.google.com with SMTP id s14so4180718qvm.4 for ; Sun, 25 Jul 2021 14:59:12 -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=wUysa0a3NDYMoE9O2ZwhfcYzrMgb5ZcWAxrkDMGamF0=; b=qJ4HnvevKyNOM9CG0VfqnCuYKU7BUPXtIlqQ5mx/BA+fBtAg98HkXsOAOSR3dqzosg 8aMafUUK7deBpObhRE270vT+EFisdHxwJewCHEly0dAfvYEmciMIQ4BfgG9QN6jlUekN xfxksfczF8lAEmI9DD1yaklPXzVuXeuZJi5vJ0ZKcAoa5rBhBuG2qCLMNMbr4WrHikqw R113KJVfydjexjajc16vVrEzyQWNDgUhnEfncl41jRrCce6urqcbHsTzNlTiyLqdXfRz /3g8iCUgZU6yml/wZldF7Dbi9+6FZS3ld8FZkF56dvbDtaQXe+Od9ZOuR2kPQBvELu0m NqKg== 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=wUysa0a3NDYMoE9O2ZwhfcYzrMgb5ZcWAxrkDMGamF0=; b=LFvnkXC1AvSTJQFpYrnL7Z2B6c/p1RqhIYKFmoXzFhtX0Lzq2Qs+ZQPka21LEvpTij 4IPcISrXX6Y1R9/p1uNerwbSLopyacyXErebvreUEvs2m8XuMiwfAXE8fa750YqR0HLH QDViRG5FCt1RF5UDJ7eFSpJowl9OaAR/tRpjl1AhobftKX1iBRkv1CWlGzMA+Wm41gvM Wov6g2DCH7Py/AMdZvJL9Ic2srtCaPgtRG8qa99AwSNN4JHVpP3HxwU5cD66LPAeTe71 7rXn0ZWYw7Wu+/IjV4i6+OnUl/MTw/4B48JK3kazCnXvn1DbPaNNzUpBqCcTYTUX/PEu CBPA== X-Gm-Message-State: AOAM533mW6kf9ctULxn9oUdPqgwHa5FswaN/o+bhC+XcaD2pxCUVMwsP Nrd5s5V8GeifGQk7XdhylpE= X-Google-Smtp-Source: ABdhPJw4/5fOYQ4gYAhKzqNjsTT4kZINpMr5G3WaTvuEZkIRbzApYBKwgJQwlcE5Zq8neaa+ZdWFeA== X-Received: by 2002:a05:6214:1362:: with SMTP id c2mr10673524qvw.9.1627250351107; Sun, 25 Jul 2021 14:59:11 -0700 (PDT) Received: from localhost.localdomain ([66.218.48.116]) by smtp.gmail.com with ESMTPSA id h2sm18777283qkf.106.2021.07.25.14.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 14:59:10 -0700 (PDT) From: Tony Dinh To: sr@denx.de, U-Boot Mailing List Cc: Simon Glass , Tom Rini , Tony Dinh Subject: [PATCH] arm: mvebu: sata_mv failed to identify HDDs during cold start Date: Sun, 25 Jul 2021 14:57:50 -0700 Message-Id: <20210725215751.26295-1-mibodhi@gmail.com> X-Mailer: git-send-email 2.20.1 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. Signed-off-by: Tony Dinh --- 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..7d1515d5f8 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 -1; } static void mv_sata_xfer_mode(struct udevice *dev, int port, u16 *id) -- 2.20.1