summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 20:47:53 +0300
committerTom Rini <trini@konsulko.com>2023-01-24 02:11:40 +0300
commit2b3ebf2013d808fc02df0fecf7eb22a6dfaffeb5 (patch)
tree5dde48f554a5b379c1623be9d54c5ba9fabda768 /drivers
parenta60f7a3e35bc6da231046a8931072027575c6939 (diff)
downloadu-boot-2b3ebf2013d808fc02df0fecf7eb22a6dfaffeb5.tar.xz
ata: Don't try to use non-existent ports
The controller indicates the number of ports but also has a port map which specifies which ports are actually valid. Make use of this to avoid trying to send commands to an invalid port. This avoids a crash on some controllers. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index de6131f1d9..272c48b8e5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -675,6 +675,12 @@ static int ata_scsiop_inquiry(struct ahci_uc_priv *uc_priv,
/* Read id from sata */
port = pccb->target;
+ /* If this port number is not valid, give up */
+ if (!(uc_priv->port_map & (1 << port))) {
+ debug("Port %x not valid in map %x\n", port, uc_priv->port_map);
+ return -ENODEV;
+ }
+
if (ahci_device_data_io(uc_priv, port, (u8 *)&fis, sizeof(fis),
(u8 *)tmpid, ATA_ID_WORDS * 2, 0)) {
debug("scsi_ahci: SCSI inquiry command failure.\n");