From 87e55baaad182262e84463960ef9b1427c7dd900 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 24 Nov 2024 22:45:05 -0500 Subject: [PATCH] ata: Use a better default for SET_MULTIPLE_MODE * If the device returns a valid upper limit (word 47) use that. * If the current limit (word 59) is valid, use that. * Fall back to 1 as a default, not 16! Note this is only used for PIO transfers! Change-Id: I269b751466242bbcce91ee991d9ade449cc84b6b --- firmware/drivers/ata.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 04b6b15b08..2baa444762 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -112,7 +112,7 @@ static long power_off_tick = 0; static sector_t total_sectors; static uint32_t log_sector_size; -static int multisectors; /* number of supported multisectors */ +static uint8_t multisectors; /* number of supported multisectors */ static unsigned short identify_info[ATA_IDENTIFY_WORDS] STORAGE_ALIGN_ATTR; @@ -1097,10 +1097,12 @@ int STORAGE_INIT_ATTR ata_init(void) } multisectors = identify_info[47] & 0xff; - if (multisectors == 0) /* Invalid multisector info, try with 16 */ - multisectors = 16; + if (!multisectors && (identify_info[59] & 0x100) == 0x100) + multisectors = identify_info[59] & 0xff; + if (!multisectors) + multisectors = 1; /* One transfer per REQ */ - DEBUGF("ata: %d sectors per ata request\n", multisectors); + DEBUGF("ata: max %d sectors per DRQ\n", multisectors); total_sectors = (identify_info[61] << 16) | identify_info[60]; @@ -1142,6 +1144,7 @@ int STORAGE_INIT_ATTR ata_init(void) ata_state = ATA_ON; keep_ata_active(); } + rc = set_multiple_mode(multisectors); if (rc) rc = -100 + rc;