Give ATA device a bit more time on first try in order to allow disks

to spin up.

	* grub-core/disk/ata.c (grub_atapi_identify): Use GRUB_ATA_TOUT_DEV_INIT
	if dev->present is 1. Reset dev->present on failure.
	(grub_ata_device_initialize): Set dev->present to 1.
	* include/grub/ata.h (GRUB_ATA_TOUT_DEV_INIT): New value.
	(grub_ata_device): New member 'present'.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-13 21:41:18 +02:00
parent bda0e21993
commit 36084912c0
3 changed files with 40 additions and 11 deletions

View file

@ -1,3 +1,14 @@
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
Give ATA device a bit more time on first try in order to allow disks
to spin up.
* grub-core/disk/ata.c (grub_atapi_identify): Use GRUB_ATA_TOUT_DEV_INIT
if dev->present is 1. Reset dev->present on failure.
(grub_ata_device_initialize): Set dev->present to 1.
* include/grub/ata.h (GRUB_ATA_TOUT_DEV_INIT): New value.
(grub_ata_device): New member 'present'.
2011-05-13 Vladimir Serbinenko <phcoder@gmail.com> 2011-05-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimage.c (generate_image): Update hash. * util/grub-mkimage.c (generate_image): Update hash.

View file

@ -160,18 +160,23 @@ grub_atapi_identify (struct grub_ata_device *dev)
grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4); grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
grub_ata_wait (); grub_ata_wait ();
if (grub_ata_check_ready (dev)) if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
&& grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT
: GRUB_ATA_TOUT_STD))
{ {
grub_free (info); grub_free (info);
dev->present = 0;
return grub_errno; return grub_errno;
} }
grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE); grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE);
grub_ata_wait (); grub_ata_wait ();
if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD)) if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT
: GRUB_ATA_TOUT_STD))
{ {
grub_free (info); grub_free (info);
dev->present = 0;
return grub_errno; return grub_errno;
} }
grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE); grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
@ -258,8 +263,11 @@ grub_ata_identify (struct grub_ata_device *dev)
grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4); grub_ata_regset (dev, GRUB_ATA_REG_DISK, 0xE0 | dev->device << 4);
grub_ata_wait (); grub_ata_wait ();
if (grub_ata_check_ready (dev)) if ((grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
&& grub_ata_wait_not_busy (dev, dev->present ? GRUB_ATA_TOUT_DEV_INIT
: GRUB_ATA_TOUT_STD))
{ {
dev->present = 0;
grub_free (info); grub_free (info);
return grub_errno; return grub_errno;
} }
@ -267,7 +275,8 @@ grub_ata_identify (struct grub_ata_device *dev)
grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_DEVICE); grub_ata_regset (dev, GRUB_ATA_REG_CMD, GRUB_ATA_CMD_IDENTIFY_DEVICE);
grub_ata_wait (); grub_ata_wait ();
if (grub_ata_wait_drq (dev, 0, GRUB_ATA_TOUT_STD)) if (grub_ata_wait_drq (dev, 0, dev->present ? GRUB_ATA_TOUT_DEV_INIT
: GRUB_ATA_TOUT_STD))
{ {
grub_free (info); grub_free (info);
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
@ -280,14 +289,19 @@ grub_ata_identify (struct grub_ata_device *dev)
return grub_atapi_identify (dev); return grub_atapi_identify (dev);
else if (sts == 0x00) else if (sts == 0x00)
{
dev->present = 0;
/* No device, return error but don't print message. */ /* No device, return error but don't print message. */
return GRUB_ERR_UNKNOWN_DEVICE; return GRUB_ERR_UNKNOWN_DEVICE;
}
else else
{
dev->present = 0;
/* Other Error. */ /* Other Error. */
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"device cannot be identified"); "device cannot be identified");
} }
}
grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE); grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
@ -381,6 +395,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
dev->device = device; dev->device = device;
dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE; dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE;
dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE; dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE;
dev->present = 1;
dev->next = NULL; dev->next = NULL;
/* Register the device. */ /* Register the device. */

View file

@ -94,7 +94,8 @@ enum grub_ata_commands
enum grub_ata_timeout_milliseconds enum grub_ata_timeout_milliseconds
{ {
GRUB_ATA_TOUT_STD = 1000, /* 1s standard timeout. */ GRUB_ATA_TOUT_STD = 1000, /* 1s standard timeout. */
GRUB_ATA_TOUT_DATA = 10000 /* 10s DATA I/O timeout. */ GRUB_ATA_TOUT_DATA = 10000, /* 10s DATA I/O timeout. */
GRUB_ATA_TOUT_DEV_INIT = 10000, /* Give the device 10s on first try to spinon. */
}; };
struct grub_ata_device struct grub_ata_device
@ -128,6 +129,8 @@ struct grub_ata_device
/* Set to 0 for ATA, set to 1 for ATAPI. */ /* Set to 0 for ATA, set to 1 for ATAPI. */
int atapi; int atapi;
int present;
struct grub_ata_device *next; struct grub_ata_device *next;
}; };