Commit graph

43 commits

Author SHA1 Message Date
Paul Menzel
d62cafcf35 ahci: Increase time-out from 10 s to 32 s
This is a cryptographically signed message in MIME format.

Date: Thu, 9 Aug 2018 07:27:35 +0200

Currently, the GRUB payload for coreboot does not detect the Western
Digital hard disk WDC WD20EARS-60M AB51 connected to the ASRock E350M1,
as that takes over ten seconds to spin up.

```
disk/ahci.c:533: port 0, err: 0
disk/ahci.c:539: port 0, err: 0
disk/ahci.c:543: port 0, err: 0
disk/ahci.c:549: port 0, offset: 120, tfd:80, CMD: 6016
disk/ahci.c:552: port 0, err: 0
disk/ahci.c:563: port 0, offset: 120, tfd:80, CMD: 6016
disk/ahci.c:566: port: 0, err: 0
disk/ahci.c:593: port 0 is busy
disk/ahci.c:621: cleaning up failed devs
```

GRUB detects the drive, when either unloading the module *ahci*, and
then loading it again, or when doing a warm reset.

As the ten second time-out is too short, increase it to 32 seconds,
used by SeaBIOS. which detects the drive successfully.

The AHCI driver in libpayload uses 30 seconds, and that time-out was
added in commit 354066e1 (libpayload: ahci: Increase timeout for
signature reading) with the description below.

> We can't read the drives signature before it's ready, i.e. spun up.
> So set the timeout to the standard 30s. Also put a notice on the
> console, so the user knows why the signature reading failed.

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-09-13 10:54:54 +02:00
Stefan Fritsch
566a03a623 ahci: Improve error handling
Check the error bits in the interrupt status register. According to the
AHCI 1.2 spec, "Interrupt sources that are disabled (‘0’) are still
reflected in the status registers.", so this should work even though
grub uses polling

This fixes the following problem on a Fujitsu E744 laptop:

Sometimes there is a very long delay (up to several minutes) when
booting from hard disk. It seems accessing the DVD drive (which has no
disk inserted) sometimes fails with some errors, which leads to each
access being stalled until the 20s timeout triggers. This seems to
happen when grub is trying to read filesystem/partition data.

The problem is that the command_issue bit that is checked in the loop is
only reset if the "HBA receives a FIS which clears the BSY, DRQ, and ERR
bits for the command", but the ERR bit is never cleared. Therefore
command_issue is never reset and grub waits for the timeout.

The relevant bit in our case is the Task File Error Status (TFES), which
is equivalent to the ERR bit 0 in tfd. But this patch also checks
the other error bits except for the "Interface non-fatal error status"
bit.

Signed-off-by: Stefan Fritsch <fritsch@genua.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-01-29 12:53:24 +01:00
Colin Watson
95440b41d3 ahci, ehci: Fix typos 2016-01-16 20:37:15 +00:00
Vladimir Serbinenko
72fc110d95 ahci: Ensure that bus mastering is set.
Fixes ahci_test failing on several platforms.
2015-07-28 01:51:14 +02:00
Paul Menzel
f4b1b48a83 disk/ahci.c: Use defines GRUB_AHCI_HBA_PORT_CMD_SPIN_UP and GRUB_AHCI_HBA_PORT_CMD_POWER_ON
Instead of hard coding `2` and `4` use the macros defined already at the
top of the file. As a consequence, wrap the now too long line.
2015-06-12 09:43:00 +03:00
Paul Menzel
ca59c24bd0 disk/ahci.c: Add port number to port debug messages
Currently, some messages cannot be mapped to the port they belong to as
the port number is missing from the output. So add `port: n` to the
debug messages.
2015-05-31 09:26:46 +03:00
Paul Menzel
fd73b3d008 Correct spelling of *scheduled*
Run the command below

	$ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g'

and revert the change in `ChangeLog-2015`.

Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com
2015-05-30 10:05:43 +03:00
Paul Menzel
5e74a3e6df disk/ahci: Use defines GRUB_ATA_STATUS_BUSY and GRUB_ATA_STATUS_DRQ
Instead of hard coding `0x88` use the macros defined in `disk/ata.h`.
2015-05-24 21:19:01 +03:00
Vladimir Serbinenko
2a8200bba8 disk/ahci: Fix device_map_range argument.
Argument is not used on x86, hence it's gone unnoticed.

Found by: Coverity scan.
2015-01-24 21:37:28 +01:00
Vladimir Serbinenko
d0949e3747 * grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI
exclusively.
2014-02-20 10:11:43 +01:00
Vladimir Serbinenko
9abbaae7cd * grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to
7 seconds to recover if last poweroff was bad.
2014-01-29 23:50:49 +01:00
Vladimir Serbinenko
d6b94c5eb2 * grub-core/disk/ahci.c: Properly handle transactions with no
transferred data.
2014-01-29 23:49:51 +01:00
Vladimir Serbinenko
07ea8daa86 * grub-core/disk/ahci.c: Add safety cleanups. 2014-01-29 23:46:17 +01:00
Vladimir Serbinenko
3142b2feac * grub-core/disk/ahci.c: Allocate and clean space for all possible 32
slots to avoid pointing to uninited area.
2014-01-29 23:45:18 +01:00
Vladimir Serbinenko
4686e163f2 * grub-core/disk/ahci.c: Do not enable I/O decoding and keep
enabling busmaster for the end.
2014-01-29 23:43:25 +01:00
Vladimir Serbinenko
a1dcc2cb98 * grub-core/disk/ahci.c (grub_ahci_pciinit): Detect ATAPI devices.
* grub-core/disk/ata.c (grub_ata_identify): Use atapi_identify if
	device is known to be ATAPI.
2013-11-03 13:52:36 +01:00
Vladimir 'phcoder' Serbinenko
54ea2f4401 * grub-core/disk/ahci.c: Add needed explicit cast.
* grub-core/lib/backtrace.c: Likewise.
	* grub-core/net/ip.c: Likewise.
	* grub-core/net/tcp.c: Likewise.
	* grub-core/net/udp.c: Likewise.
2013-08-21 21:02:14 +02:00
Vladimir 'phcoder' Serbinenko
96f33fed86 Make PCI init in i386-qemu port more robust. 2013-04-29 15:09:39 +02:00
Vladimir 'phcoder' Serbinenko
e2f27a8c53 Enforce disabling of firmware disk drivers when native drivers kick in. 2013-04-29 12:16:46 +02:00
Vladimir 'phcoder' Serbinenko
9fb0fd4f35 * grub-core/disk/ahci.c: Fix compilation for amd64 (format warnings). 2013-04-28 15:17:43 +02:00
Vladimir 'phcoder' Serbinenko
c796a107b6 * grub-core/disk/ahci.c (grub_ahci_pciinit): Fix handling of empty
ports.
2013-04-27 21:49:14 +02:00
Vladimir 'phcoder' Serbinenko
dc2a6c8b0e Improve AHCI detection and command issuing. 2013-04-27 17:18:02 +02:00
Vladimir 'phcoder' Serbinenko
8990963a7f * grub-core/disk/ahci.c: Give more time for AHCI request. 2013-03-25 10:32:56 +01:00
Colin Watson
25239370fd Remove nested functions from device iterators.
* include/grub/arc/arc.h (grub_arc_iterate_devs_hook_t): New type.
(grub_arc_iterate_devs): Add hook_data argument.
* include/grub/ata.h (grub_ata_dev_iterate_hook_t): New type.
(struct grub_ata_dev.iterate): Add hook_data argument.
* include/grub/device.h (grub_device_iterate_hook_t): New type.
(grub_device_iterate): Add hook_data argument.
* include/grub/disk.h (grub_disk_dev_iterate_hook_t): New type.
(struct grub_disk_dev.iterate): Add hook_data argument.
(grub_disk_dev_iterate): Likewise.
* include/grub/gpt_partition.h (grub_gpt_partition_map_iterate):
Likewise.
* include/grub/msdos_partition.h (grub_partition_msdos_iterate):
Likewise.
* include/grub/partition.h (grub_partition_iterate_hook_t): New
type.
(struct grub_partition_map.iterate): Add hook_data argument.
(grub_partition_iterate): Likewise.
* include/grub/scsi.h (grub_scsi_dev_iterate_hook_t): New type.
(struct grub_scsi_dev.iterate): Add hook_data argument.

Update all callers.
2013-01-20 15:52:15 +00:00
Colin Watson
ca3a74469a Remove nested functions from PCI iterators.
* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument,
passed to hook.  Update all callers to pass appropriate hook data.
* grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise.
* include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument.
Remove NESTED_FUNC_ATTR from here and from all users.
(grub_pci_iterate): Update prototype.
* grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static
instead of nested.  Rename to ...
(grub_cs5536_find_iter): ... this.
* grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise.
* grub-core/kern/mips/loongson/init.c (init_pci: set_card):
Likewise.
* grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card):
Likewise.
* grub-core/video/bochs.c (grub_video_bochs_setup: find_card):
Likewise.
* grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card):
Likewise.
* grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise.
* grub-core/video/radeon_fuloong2e.c
(grub_video_radeon_fuloong2e_setup: find_card): Likewise.
* grub-core/video/sis315pro.c (grub_video_sis315pro_setup:
find_card): Likewise.
* grub-core/video/sm712.c (grub_video_sm712_setup: find_card):
Likewise.
2013-01-13 01:10:41 +00:00
Vladimir 'phcoder' Serbinenko
9c4b5c13e6 Improve gettext support. Stylistic fixes and error handling fixes while
on it.
2012-02-08 19:26:01 +01:00
Vladimir 'phcoder' Serbinenko
2b5336a24a * include/grub/ata.h (grub_ata): Add a new element maxbuffer.
* grub-core/disk/ata.c (grub_ata_readwrite): Limit to ata->maxbuffer.
	* grub-core/disk/pata.c (grub_pata_open): Set ata->maxbuffer.
	* grub-core/disk/ahci.c (grub_ahci_open): Likewise.
2012-01-29 19:00:30 +01:00
Vladimir 'phcoder' Serbinenko
87edb8940a Replace single-linked with double-linked lists. It results in more
compact and more efficient code.

	* grub-core/kern/list.c (grub_list_push): Moved from here ...
	* include/grub/list.h (grub_list_push): ... to here. Set prev.
	(grub_list_remove): Moved from here ...
	* include/grub/list.h (grub_list_remove): ... here. Use and set prev.
	(grub_prio_list_insert): Set prev.
	* include/grub/list.h (grub_list): Add prev. All users updated.
2012-01-24 13:31:12 +01:00
Vladimir 'phcoder' Serbinenko
74dbd24466 * include/grub/loader.h (grub_loader_register_preboot_hook):
Use struct preboot * and not void * for handle. All users updated.
	(grub_loader_unregister_preboot_hook): Likewise.
2011-12-13 00:28:14 +01:00
Vladimir 'phcoder' Serbinenko
48d6e45653 * grub-core/disk/ahci.c (grub_ahci_pciinit): Fix compat condition. 2011-12-12 22:20:14 +01:00
Vladimir 'phcoder' Serbinenko
00542307eb merge mainline into lazy 2011-07-07 12:21:53 +02:00
Vladimir 'phcoder' Serbinenko
41bec7fec9 * grub-core/disk/ahci.c (grub_ahci_readwrite_real): Use proper
definitions for dprintf.
	* grub-core/disk/pata.c (grub_pata_readwrite): Likewise.
2011-06-27 08:43:13 +02:00
Vladimir 'phcoder' Serbinenko
005dd67cb6 * grub-core/disk/ahci.c: Add missing license statements.
* grub-core/fs/romfs.c: Likewise.
	* grub-core/lib/ia64/setjmp.S: Likewise.
	* grub-core/loader/i386/pc/freedos.c: Likewise.
	* grub-core/loader/ia64/efi/linux.c: Likewise.
	* grub-core/video/colors.c: Likewise.
	* include/grub/dl.h (GRUB_MOD_DEP): New macro.
2011-06-24 00:29:21 +02:00
Vladimir 'phcoder' Serbinenko
0670a9751b merge mainline into ahci 2011-05-16 17:17:04 +02:00
Vladimir 'phcoder' Serbinenko
7a1d4deec9 Fix finalisation/restore 2011-01-03 15:59:20 +01:00
Vladimir 'phcoder' Serbinenko
9797178671 Accept ports in state 1 2010-12-25 18:02:43 +01:00
Vladimir 'phcoder' Serbinenko
d1e517eb20 extend --disk-module to AHCI and USB 2010-12-25 12:11:54 +01:00
Vladimir 'phcoder' Serbinenko
d9675dbee3 Move 0xE0 to callers rather than to have it in drivers 2010-12-25 03:47:51 +01:00
Vladimir 'phcoder' Serbinenko
188ac234bd use DMA for AHCI commands 2010-12-25 03:12:49 +01:00
Vladimir 'phcoder' Serbinenko
060d0c7ac2 working AHCI (at last) 2010-12-25 03:06:07 +01:00
Vladimir 'phcoder' Serbinenko
51f7e1acb7 DMA ATA commands support 2010-12-25 02:53:20 +01:00
Vladimir 'phcoder' Serbinenko
908a8fc37a Fix several AHCI problems 2010-12-24 19:48:55 +01:00
Vladimir 'phcoder' Serbinenko
de2690be7c merge mainline into ahci 2010-12-24 16:16:01 +01:00