From 1a4add9e873fb312c21c57ac3208cd758f16033c Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Tue, 25 Jul 2017 12:18:49 +0200 Subject: libpayload/storage: Replace 1s AHCI reset delay with a timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AHCI spec explicitly states that we may poll. TEST=Ran FILO on kontron/bsl6 and observed that the controller always becomes ready during the first delay. Change-Id: If34694abff14d719d10d89bc6771dbfa12065071 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/20764 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Kyösti Mälkki --- payloads/libpayload/drivers/storage/ahci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'payloads/libpayload') diff --git a/payloads/libpayload/drivers/storage/ahci.c b/payloads/libpayload/drivers/storage/ahci.c index 3a0b99df42..f3882830d2 100644 --- a/payloads/libpayload/drivers/storage/ahci.c +++ b/payloads/libpayload/drivers/storage/ahci.c @@ -258,7 +258,9 @@ static void ahci_init_pci(pcidev_t dev) /* Reset host controller. */ ctrl->global_ctrl |= HBA_CTRL_RESET; /* Reset has to be finished after 1s. */ - delay(1); + int timeout = 10 * 1000; /* Time out after 10,000 * 100us == 1s. */ + while (ctrl->global_ctrl & HBA_CTRL_RESET && timeout--) + udelay(100); if (ctrl->global_ctrl & HBA_CTRL_RESET) { printf("ahci: ERROR: " "Controller reset didn't finish within 1s.\n"); -- cgit v1.2.3