[SeaBIOS] [PATCH] Fix AHCI Disk Detection when using EDK2 CSM

Christopher Lentocha posted 1 patch 1 week, 1 day ago
src/hw/ahci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[SeaBIOS] [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Christopher Lentocha 1 week, 1 day ago

For whatever reason, when you compile SeaBIOS in Csm16 mode, and use it
under EDK2's OvmfPkg, the ATA_CMD_IDENTIFY_PACKET_DEVICE command
doesn't work properly, therefore, SeaBIOS detects the "SATA HARDDISK"
as a "SATA CDROM" device, in QEMU. Despite the Tianocore developers
seem to have removed support for Csm16 some time ago, if we decide to
remove Csm16 mode in SeaBIOS in favor of that, at least we have the
last commit of Csm16 working properly and not half-broken. In order to
fix this bug, I decided to add another command, that command being
ATA_CMD_DEVICE_RESET, right before the ATA_CMD_IDENTIFY_PACKET_DEVICE
command is called.

Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.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 4f0f640..e0864fa 100644
--- a/src/hw/ahci.c
+++ b/src/hw/ahci.c
@@ -484,7 +484,8 @@ static int ahci_port_setup(struct ahci_port_s *port)
      /* start device */
      cmd |= PORT_CMD_START;
      ahci_port_writel(ctrl, pnr, PORT_CMD, cmd);
-
+    sata_prep_simple(&port->cmd->fis, ATA_CMD_DEVICE_RESET);
+    ahci_command(port, 0, 0, buffer, sizeof(buffer));
      sata_prep_simple(&port->cmd->fis, ATA_CMD_IDENTIFY_PACKET_DEVICE);
      rc = ahci_command(port, 0, 0, buffer, sizeof(buffer));
      if (rc == 0) {
-- 
2.38.1

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Gerd Hoffmann 2 days, 6 hours ago
On Tue, Jan 21, 2025 at 11:59:14AM -0500, Christopher Lentocha wrote:
> 
> For whatever reason, when you compile SeaBIOS in Csm16 mode, and use it
> under EDK2's OvmfPkg, the ATA_CMD_IDENTIFY_PACKET_DEVICE command
> doesn't work properly, therefore, SeaBIOS detects the "SATA HARDDISK"
> as a "SATA CDROM" device, in QEMU. Despite the Tianocore developers
> seem to have removed support for Csm16 some time ago, if we decide to
> remove Csm16 mode in SeaBIOS in favor of that, at least we have the
> last commit of Csm16 working properly and not half-broken. In order to
> fix this bug, I decided to add another command, that command being
> ATA_CMD_DEVICE_RESET, right before the ATA_CMD_IDENTIFY_PACKET_DEVICE
> command is called.
> 
> Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.com>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Kevin O'Connor 1 day, 12 hours ago
On Tue, Jan 28, 2025 at 09:14:43AM +0100, Gerd Hoffmann wrote:
> On Tue, Jan 21, 2025 at 11:59:14AM -0500, Christopher Lentocha wrote:
> >
> > For whatever reason, when you compile SeaBIOS in Csm16 mode, and use it
> > under EDK2's OvmfPkg, the ATA_CMD_IDENTIFY_PACKET_DEVICE command
> > doesn't work properly, therefore, SeaBIOS detects the "SATA HARDDISK"
> > as a "SATA CDROM" device, in QEMU. Despite the Tianocore developers
> > seem to have removed support for Csm16 some time ago, if we decide to
> > remove Csm16 mode in SeaBIOS in favor of that, at least we have the
> > last commit of Csm16 working properly and not half-broken. In order to
> > fix this bug, I decided to add another command, that command being
> > ATA_CMD_DEVICE_RESET, right before the ATA_CMD_IDENTIFY_PACKET_DEVICE
> > command is called.
> >
> > Signed-off-by: Christopher Lentocha <christopherericlentocha@gmail.com>
> 
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

Sounds good.

Gerd, since you reviewed and you're more familiar with this code, feel
free to also commit.

Cheers,
-Kevin

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org
[SeaBIOS] Re: [PATCH] Fix AHCI Disk Detection when using EDK2 CSM
Posted by Gerd Hoffmann 1 day, 4 hours ago
On Wed, Jan 29, 2025 at 01:39:29AM +0000, Kevin O'Connor wrote:
 
> Sounds good.
> 
> Gerd, since you reviewed and you're more familiar with this code, feel
> free to also commit.

Committed and pushed.

take care,
  Gerd

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org