[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SATA disk on cntroller in AHCI mode not found: Hang at `AHCI status
From: |
Paul Menzel |
Subject: |
Re: SATA disk on cntroller in AHCI mode not found: Hang at `AHCI status <1 0 150>` |
Date: |
Fri, 19 Apr 2013 16:40:16 +0200 |
Dear GRUB folks,
Am Donnerstag, den 18.04.2013, 13:11 +0200 schrieb Paul Menzel:
> here is an update on the issue I only reported to #grub on
> <irc.freenode.net>.
>
>
> Am Freitag, den 05.04.2013, 12:54 +0200 schrieb Paul Menzel:
>
> > as reported to the coreboot mailing list already [1][2], using GRUB
> > (4778) as a payload [3] on the AMD SB800 based ASRock E350M1 [4], the
> > SATA disk attached to the SATA controller is not found when the
> > controller is in AHCI mode. Using IDE mode works.
>
> […]
>
> > I’ll gladly test patches and provide more information.
>
> Vladmir gave me the following patch to test [5].
[…]
> The change to `ahci.c` did make a change and it progressed further.
>
> grub> insmod pata
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0xff
> error: no device connected.
> disk/pata.c:295: sectors=0xff
> error: no device connected.
> grub> insmod ahci
> disk/ahci.c:308: Requesting AHCI ownership
> disk/ahci.c:311: Waiting for BIOS to give up ownership
> disk/ahci.c:322: AHCI ownership obtained
> disk/ahci.c:328: AHCI is in compat mode. Switching
> disk/ahci.c:374: 6 AHCI ports
> disk/ahci.c:384: status 0:123
> disk/ahci.c:186: found device ahci0 (port 0)
> disk/ahci.c:229: det = 3
> disk/ahci.c:240: link up
> disk/ahci.c:246: After PORT_CMD_ST
> disk/ahci.c:255: before return 0
> disk/ahci.c:384: status 1:0
> disk/ahci.c:384: status 2:0
> disk/ahci.c:384: status 3:0
> disk/ahci.c:384: status 4:0
> disk/ahci.c:384: status 5:0
> grub> ls
> disk/ahci.c:710: opening AHCI dev `ahci0'
> disk/ahci.c:535: AHCI tfd = 150
> disk/ahci.c:561: grub_ahci_read (size=512, cmdsize = 0)
> disk/ahci.c:574: AHCI tfd = 150
> disk/ahci.c:604: cfis: 27 80 ec 00 00 00 00 e0
> disk/ahci.c:609: cfis: 00 00 00 00 00 00 00 00
> disk/ahci.c:622: PRDT = c7eed800, 0, 800001ff (128)
> disk/ahci.c:627: AHCI command schedulded
> disk/ahci.c:629: AHCI tfd = 150
> disk/ahci.c:633: AHCI tfd = 150
> disk/ahci.c:635: AHCI sig = 101
> disk/ahci.c:637: AHCI tfd = 150
> disk/ahci.c:646: AHCI status <1 0 150>
> disk/ahci.c:658: AHCI command completed <1 0 150 0 0, 0 0>
> disk/ahci.c:668: last PIO FIS 00000000 00000000 00000000 00000000
> 00000000
> 00000000 00000000 00000000
> disk/ahci.c:678: last REG FIS 00000000 00000000 00000000 00000000
> 00000000
> 00000000 00000000 00000000
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0xff
> disk/pata.c:295: sectors=0xff
> disk/ahci.c:710: opening AHCI dev `ahci0'
> disk/ahci.c:535: AHCI tfd = 150
> disk/ahci.c:561: grub_ahci_read (size=512, cmdsize = 0)
> disk/ahci.c:574: AHCI tfd = 150
> disk/ahci.c:604: cfis: 27 80 ec 00 00 00 00 e0
> disk/ahci.c:609: cfis: 00 00 00 00 00 00 00 00
> disk/ahci.c:622: PRDT = c7eed800, 0, 800001ff (128)
> disk/ahci.c:627: AHCI command schedulded
> disk/ahci.c:629: AHCI tfd = 150
> disk/ahci.c:633: AHCI tfd = 150
> disk/ahci.c:635: AHCI sig = 101
> disk/ahci.c:637: AHCI tfd = 150
> disk/ahci.c:646: AHCI status <1 0 150>
> disk/ahci.c:658: AHCI command completed <1 0 150 0 0, 0 0>
> disk/ahci.c:668: last PIO FIS 00000000 00000000 00000000 00000000
> 00000000
> 00000000 00000000 00000000
> disk/ahci.c:678: last REG FIS 00000000 00000000 00000000 00000000
> 00000000
> 00000000 00000000 00000000
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0x5a
> disk/pata.c:295: sectors=0xff
> disk/pata.c:295: sectors=0xff
> (memdisk)
>
> So it gets further but still does not find the disk.
>
> Vladimir also said, he can reproduce this issue, when putting his AMD
> board’s SATA controller in IDE mode in the BIOS and then trying to
> change it in GRUB to AHCI mode.
Vladimir gave me another patch to try changing the reset code [6].
=== modified file 'grub-core/disk/ahci.c'
--- grub-core/disk/ahci.c 2010-12-25 11:11:54 +0000
+++ grub-core/disk/ahci.c 2010-12-25 15:30:53 +0000
@@ -131,7 +131,8 @@
static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
- struct grub_disk_ata_pass_through_parms
*parms);
+ struct grub_disk_ata_pass_through_parms
*parms,
+ int reset);
enum
@@ -374,9 +375,30 @@
9 /* LBA48 mid */,
10 /* LBA48 high */ };
+static grub_err_t
+grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
+{
+ dev->hba->ports[dev->port].sata_error =
dev->hba->ports[dev->port].sata_error;
+
+ if (force || (dev->hba->ports[dev->port].command_issue & 1)
+ || (dev->hba->ports[dev->port].task_file_data & 0x80))
+ {
+ struct grub_disk_ata_pass_through_parms parms2;
+ dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ while ((dev->hba->ports[dev->port].command &
GRUB_AHCI_HBA_PORT_CMD_CR));
+ dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
+ while (!(dev->hba->ports[dev->port].command &
GRUB_AHCI_HBA_PORT_CMD_CR));
+ dev->hba->ports[dev->port].sata_error =
dev->hba->ports[dev->port].sata_error;
+ grub_memset (&parms2, 0, sizeof (parms2));
+ parms2.taskfile.cmd = 8;
+ return grub_ahci_readwrite_real (dev, &parms2, 1);
+ }
+ return GRUB_ERR_NONE;
+}
+
static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
- struct grub_disk_ata_pass_through_parms
*parms)
+ struct grub_disk_ata_pass_through_parms
*parms, int reset)
{
struct grub_pci_dma_chunk *bufc;
grub_uint64_t endtime;
@@ -386,15 +408,8 @@
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
- if ((dev->hba->ports[dev->port].task_file_data & 0x80))
- {
- dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
- while ((dev->hba->ports[dev->port].command &
GRUB_AHCI_HBA_PORT_CMD_CR));
- dev->hba->ports[dev->port].command |= GRUB_AHCI_HBA_PORT_CMD_ST;
- while (!(dev->hba->ports[dev->port].command &
GRUB_AHCI_HBA_PORT_CMD_CR));
- }
-
- dev->hba->ports[dev->port].sata_error =
dev->hba->ports[dev->port].sata_error;
+ if (!reset)
+ grub_ahci_reset_port (dev, 0);
grub_dprintf("ahci", "grub_ahci_read (size=%llu, cmdsize = %llu)\n",
(unsigned long long) parms->size,
@@ -475,7 +490,7 @@
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
- endtime = grub_get_time_ms () + 1000;
+ endtime = grub_get_time_ms () + 10000;
while ((dev->hba->ports[dev->port].command_issue & 1))
if (grub_get_time_ms () > endtime)
{
@@ -483,7 +498,8 @@
dev->hba->ports[dev->port].command_issue,
dev->hba->ports[dev->port].intstatus,
dev->hba->ports[dev->port].task_file_data);
- err = grub_error (GRUB_ERR_IO, "AHCI transfer timeouted");
+ grub_ahci_reset_port (dev, 1);
+ err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out");
break;
}
@@ -527,7 +543,7 @@
grub_ahci_readwrite (grub_ata_t disk,
struct grub_disk_ata_pass_through_parms *parms)
{
- return grub_ahci_readwrite_real (disk->data, parms);
+ return grub_ahci_readwrite_real (disk->data, parms, 0);
}
static grub_err_t
It does not apply cleanly to my version and misses probably something as
`grub_ahci_readwrite` was also changed but not `ata.h`. I am attaching
my adapted version of `ahci.c` I tested. Here is the result.
Unfortunately it hangs now.
grub> insmod ahci
disk/ahci.c:308: Requesting AHCI ownership
disk/ahci.c:311: Waiting for BIOS to give up ownership
disk/ahci.c:322: AHCI ownership obtained
disk/ahci.c:328: AHCI is in compat mode. Switching
disk/ahci.c:374: 6 AHCI ports
disk/ahci.c:384: status 0:123
disk/ahci.c:186: found device ahci0 (port 0)
disk/ahci.c:229: det = 3
disk/ahci.c:240: link up
disk/ahci.c:246: After PORT_CMD_ST
disk/ahci.c:255: before return 0
disk/ahci.c:384: status 1:0
disk/ahci.c:384: status 2:0
disk/ahci.c:384: status 3:0
disk/ahci.c:384: status 4:0
disk/ahci.c:384: status 5:0
grub> ls
disk/ahci.c:713: opening AHCI dev `ahci0'
disk/ahci.c:555: AHCI tfd = 150
disk/ahci.c:562: grub_ahci_read (size=512, cmdsize = 0)
disk/ahci.c:575: AHCI tfd = 150
disk/ahci.c:605: cfis: 27 80 ec 00 00 00 00 e0
disk/ahci.c:610: cfis: 00 00 00 00 00 00 00 00
disk/ahci.c:623: PRDT = c7eedc00, 0, 800001ff (128)
disk/ahci.c:628: AHCI command schedulded
disk/ahci.c:630: AHCI tfd = 150
disk/ahci.c:634: AHCI tfd = 150
disk/ahci.c:636: AHCI sig = 101
disk/ahci.c:638: AHCI tfd = 150
disk/ahci.c:647: AHCI status <1 0 150>
I have to reset the machine to break the hang.
Hopefully I did not mess up applying the patch. If yes, it would be nice
to test some branch with the latest AHCI test code.
Thanks,
Paul
> > [1] http://www.coreboot.org/pipermail/coreboot/2013-March/075583.html
> > [2] http://www.coreboot.org/pipermail/coreboot/2013-April/075592.html
> > [3] http://www.coreboot.org/GRUB2
> > [4] http://www.coreboot.org/ASRock_E350M1
> [5] http://paste.debian.net/249135/
[6] http://paste.debian.net/249577/
ahci.c
Description: Text Data
signature.asc
Description: This is a digitally signed message part