When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
fail log: 02.386: |bffa6000| AHCI/1: link up 02.387: |bffa6000| AHCI/1: send cmd ... 02.387: |bffa7000| phys_free bffa9c00 (detail=0xbffaa320) 02.396: |bffa7000| phys_free bffaa200 (detail=0xbffaa1d0) 02.396: |bffa7000| phys_free bffaa000 (detail=0xbffaa1a0) 02.396: |bffa7000| phys_free bffaa380 (detail=0xbffaa350) 02.400: \bffa7000/ End thread 02.401: phys_free bffa7000 (detail=0xbffaa170) 34.391: |bffa6000| WARNING - Timeout at ahci_command:153! 34.392: |bffa6000| AHCI/1: send cmd ... 66.397: |bffa6000| WARNING - Timeout at ahci_command:153!
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com --- src/hw/ahci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index d45b430..bab5c35 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -104,7 +104,7 @@ static void ahci_port_writel(struct ahci_ctrl_s *ctrl, u32 pnr, u32 reg, u32 val static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi, void *buffer, u32 bsize) { - u32 val, status, success, flags, intbits, error; + u32 val, status, success, flags, intbits, error, tf; struct ahci_ctrl_s *ctrl = port_gf->ctrl; struct ahci_cmd_s *cmd = port_gf->cmd; struct ahci_fis_s *fis = port_gf->fis; @@ -148,6 +148,14 @@ static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi, error = GET_LOWFLAT(fis->rfis[3]); break; } + + if(intbits & PORT_IRQ_TF_ERR){ + tf = ahci_port_readl(ctrl,pnr,PORT_TFDATA); + status = tf & 0xff; + error = tf & 0xff00; + break; + } + } if (timer_check(end)) { warn_timeout(); -- 2.17.1
if there 's any question about the above issue,feel free to contact me. Best Regards ‘
On Tue, Aug 04, 2020 at 11:17:05AM -0000, RunaGuo-oc@zhaoxin.com wrote:
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
Thanks. Gerd wrote the AHCI support. (As well as the XHCI support referenced in your other report.) Hopefully he'll be able to comment.
-Kevin
thanks,see the attachment for detailed log. if there 's any question,feel free to contact me. Best Regards ‘ Runa
________________________________ 发件人: Kevin O'Connor kevin@koconnor.net 发送时间: 2020年8月10日 23:46 收件人: RunaGuo-oc; Gerd Hoffmann 抄送: seabios@seabios.org 主题: Re: [SeaBIOS] [PATCH] AHCI: The attached ATA device cannot be detected when binding AHCI controller to Virtual Machine
On Tue, Aug 04, 2020 at 11:17:05AM -0000, RunaGuo-oc@zhaoxin.com wrote:
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
Thanks. Gerd wrote the AHCI support. (As well as the XHCI support referenced in your other report.) Hopefully he'll be able to comment.
-Kevin
Hi,
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
Patch looks reasonable. I'm wondering how to reproduce the bug? When booting guests in qemu using the q35 machine (with built-in ahci controller) seabios detects everything just fine in my testing.
thanks, Gerd
Gerd Hoffmann wrote:
Hi,
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time. May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
Patch looks reasonable. I'm wondering how to reproduce the bug? When booting guests in qemu using the q35 machine (with built-in ahci controller) seabios detects everything just fine in my testing.
thanks, Gerd
Thank you for your reply. My opinion, From SATA Protocol Analyzer, when ATA device received an ATAPI cmd, AHCI controller will received an D2H Register FIS with ERR bit set to 1. Form AHCI spec,I have not yet found any evidences for HW to set the PxIS(bit0/1)in this case while seabios only polling these bits. Zhaoxin AHCI controller can be used to reproduce this issue, I think its design conforms to the AHCI spec specification.
On Tue, Aug 04, 2020 at 11:17:05AM -0000, RunaGuo-oc@zhaoxin.com wrote:
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
fail log: 02.386: |bffa6000| AHCI/1: link up 02.387: |bffa6000| AHCI/1: send cmd ... 02.387: |bffa7000| phys_free bffa9c00 (detail=0xbffaa320) 02.396: |bffa7000| phys_free bffaa200 (detail=0xbffaa1d0) 02.396: |bffa7000| phys_free bffaa000 (detail=0xbffaa1a0) 02.396: |bffa7000| phys_free bffaa380 (detail=0xbffaa350) 02.400: \bffa7000/ End thread 02.401: phys_free bffa7000 (detail=0xbffaa170) 34.391: |bffa6000| WARNING - Timeout at ahci_command:153! 34.392: |bffa6000| AHCI/1: send cmd ... 66.397: |bffa6000| WARNING - Timeout at ahci_command:153!
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com
Patch doesn't apply to git master. Can you rebase and resend? And while being at it wrap the commit message to hot have lines longer than 80 chars?
thanks, Gerd
I am so sorry to reply late.
Here is the newly rebase patch, pls help check, thanks.
1: For ATA device, the first ATA_CMD_IDENTIFY_PACKET_DEVICE command will be failed with PORT_IRQ_TF set to 1 from ahci spec; 2: For seabios, this fail will be considered as timeout for it only polling PORT_IRQ_D2H_REG/PIO_FIS; 3: From ahci spec, I have not yet found any evidences which can be use to combine the above fail with these above error;
May be, we can also add PORT_IRQ_TF_ERR bit check while polling command completion?
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com --- src/hw/ahci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index d45b430..998b5fe 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -143,7 +143,8 @@ static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi, error = GET_LOWFLAT(fis->psfis[3]); break; } - if (intbits & 0x01) { + + if (intbits & (0x01| PORT_IRQ_TF_ERR)) { status = GET_LOWFLAT(fis->rfis[2]); error = GET_LOWFLAT(fis->rfis[3]); break; -- 2.17.1
________________________________ 发件人: Gerd Hoffmann kraxel@redhat.com 发送时间: 2020年9月30日 18:58:20 收件人: RunaGuo-oc 抄送: seabios@seabios.org 主题: Re: [SeaBIOS] [PATCH] AHCI: The attached ATA device cannot be detected when binding AHCI controller to Virtual Machine
On Tue, Aug 04, 2020 at 11:17:05AM -0000, RunaGuo-oc@zhaoxin.com wrote:
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
fail log: 02.386: |bffa6000| AHCI/1: link up 02.387: |bffa6000| AHCI/1: send cmd ... 02.387: |bffa7000| phys_free bffa9c00 (detail=0xbffaa320) 02.396: |bffa7000| phys_free bffaa200 (detail=0xbffaa1d0) 02.396: |bffa7000| phys_free bffaa000 (detail=0xbffaa1a0) 02.396: |bffa7000| phys_free bffaa380 (detail=0xbffaa350) 02.400: \bffa7000/ End thread 02.401: phys_free bffa7000 (detail=0xbffaa170) 34.391: |bffa6000| WARNING - Timeout at ahci_command:153! 34.392: |bffa6000| AHCI/1: send cmd ... 66.397: |bffa6000| WARNING - Timeout at ahci_command:153!
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com
Patch doesn't apply to git master. Can you rebase and resend? And while being at it wrap the commit message to hot have lines longer than 80 chars?
thanks, Gerd
Dear Run Guo,
Am 28.03.21 um 13:23 schrieb RunaGuo-oc:
I am so sorry to reply late.
Thank you for following up. Can you please configure your email client to use UTF-8 character set instead of gb2312? The subject line looks quite mangled. Also, please just send plain text messages, and no HTML part [1].
Here is the newly rebase patch, pls help check, thanks.
Can you please use git send-email to send the patches [2]?
$ git commit --amend -s $ git format-patch --reroll-count=3 -1 $ git send-email 0001*
1: For ATA device, the first ATA_CMD_IDENTIFY_PACKET_DEVICE command will be failed with PORT_IRQ_TF set to 1 from ahci spec;
AHCI
2: For seabios, this fail will be considered as timeout for it only polling PORT_IRQ_D2H_REG/PIO_FIS;
SeaBIOS
3: From ahci spec, I have not yet found any evidences which can be use to combine the
AHCI
above fail with these above error;
Please add how you tested this.
May be, we can also add PORT_IRQ_TF_ERR bit check while polling command completion?
Thank you again for your contribution.
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com
Please configure the author name with:
$ git config --global user.name Runa Guo-oc
src/hw/ahci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index d45b430..998b5fe 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -143,7 +143,8 @@ static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi, error = GET_LOWFLAT(fis->psfis[3]); break; }
if (intbits & 0x01) {
if (intbits & (0x01| PORT_IRQ_TF_ERR)) { status = GET_LOWFLAT(fis->rfis[2]); error = GET_LOWFLAT(fis->rfis[3]); break;
-- 2.17.1
Kind regards,
Paul
[1]: https://useplaintext.email/ [2]: https://git-scm.com/docs/git-send-email#_examples
Hi Paul,
Thank you for your recent detailed email reply. I'm not good at sending patches. I have already sent another patch which met your request by git send-email format before i found your email address, i hope you can also receive it, i.m so sorry. for your question about how i test this: 1:boot OS from storages other than AHCI with IOV enabled,eg,XHCI; 2:attach an SSD(not ODD) to SATA-AHCI port in zhaoxin platform; 3:build seabios in debug mode and run the qemu script in attachment document; 4: we can failed log in previous mail.
thanks, Runa ________________________________ 发件人: RunaGuo-oc 发送时间: 2021年3月28日 19:23 收件人: Gerd Hoffmann 抄送: seabios@seabios.org 主题: 答复: [SeaBIOS] [PATCH] AHCI: The attached ATA device cannot be detected when binding AHCI controller to Virtual Machine
I am so sorry to reply late.
Here is the newly rebase patch, pls help check, thanks.
1: For ATA device, the first ATA_CMD_IDENTIFY_PACKET_DEVICE command will be failed with PORT_IRQ_TF set to 1 from ahci spec; 2: For seabios, this fail will be considered as timeout for it only polling PORT_IRQ_D2H_REG/PIO_FIS; 3: From ahci spec, I have not yet found any evidences which can be use to combine the above fail with these above error;
May be, we can also add PORT_IRQ_TF_ERR bit check while polling command completion?
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com --- src/hw/ahci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/hw/ahci.c b/src/hw/ahci.c index d45b430..998b5fe 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -143,7 +143,8 @@ static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi, error = GET_LOWFLAT(fis->psfis[3]); break; } - if (intbits & 0x01) { + + if (intbits & (0x01| PORT_IRQ_TF_ERR)) { status = GET_LOWFLAT(fis->rfis[2]); error = GET_LOWFLAT(fis->rfis[3]); break; -- 2.17.1
________________________________ 发件人: Gerd Hoffmann kraxel@redhat.com 发送时间: 2020年9月30日 18:58:20 收件人: RunaGuo-oc 抄送: seabios@seabios.org 主题: Re: [SeaBIOS] [PATCH] AHCI: The attached ATA device cannot be detected when binding AHCI controller to Virtual Machine
On Tue, Aug 04, 2020 at 11:17:05AM -0000, RunaGuo-oc@zhaoxin.com wrote:
When binding AHCI controller to virtual machine, the attached ATA device cannot be recognized for the following reason: The first Identify PACKET CMD will be failed without dobut which will lead PORT_IRQ_TF_ERR be set in PxIS due to ERR bit set to 1 in D2H Register FIS(PxTFD.STS.ERR=1). In this case, the first CMD will be timeout for seabios only polling PORT_IRQ_D2H_REG_FIS & PORT_IRQ_PIOS_FIS before triggering error handling which leads AHCI controller is an error state, then the second IDENTIFY CMD cannot be issued by AHCI controller, no ATA device will be detected.
In AHCI spec HBA Port State Machine section(5.3.8.1 and 5.3.16.5), we can see this sequence: RegFIS:Entry --> ERR:FatalTaskfile (PxTFD.STS.ERR=1) --> ERR:WaitForClear, no entry for PORT_IRQ_D2H_REG_FIS/PORT_IRQ_PIOS_FIS to be set at this time.
May be we can also add PORT_IRQ_TF_ERR bit check when polling command completion status?
fail log: 02.386: |bffa6000| AHCI/1: link up 02.387: |bffa6000| AHCI/1: send cmd ... 02.387: |bffa7000| phys_free bffa9c00 (detail=0xbffaa320) 02.396: |bffa7000| phys_free bffaa200 (detail=0xbffaa1d0) 02.396: |bffa7000| phys_free bffaa000 (detail=0xbffaa1a0) 02.396: |bffa7000| phys_free bffaa380 (detail=0xbffaa350) 02.400: \bffa7000/ End thread 02.401: phys_free bffa7000 (detail=0xbffaa170) 34.391: |bffa6000| WARNING - Timeout at ahci_command:153! 34.392: |bffa6000| AHCI/1: send cmd ... 66.397: |bffa6000| WARNING - Timeout at ahci_command:153!
Signed-off-by: zhaoxin\runaguooc RunaGuo-oc@zhaoxin.com
Patch doesn't apply to git master. Can you rebase and resend? And while being at it wrap the commit message to hot have lines longer than 80 chars?
thanks, Gerd