From 241ce89e8cb4067fc700468a4d658ae2215ec273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Thu, 9 Dec 2004 07:31:06 +0000 Subject: [PATCH] Compensate for off by one bugs in disk firmware for 48BIT addressing cutover. --- sys/dev/ata/ata-all.h | 2 ++ sys/dev/ata/ata-chipset.c | 2 +- sys/dev/ata/ata-disk.c | 2 +- sys/dev/ata/ata-lowlevel.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index 28d36c88dce6..6a9d09904dc0 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -156,6 +156,8 @@ #define ATA_OP_CONTINUES 0 #define ATA_OP_FINISHED 1 +#define ATA_MAX_28BIT_LBA 268435455 + /* ATAPI request sense structure */ struct atapi_sense { u_int8_t error_code :7; /* current or deferred errors */ diff --git a/sys/dev/ata/ata-chipset.c b/sys/dev/ata/ata-chipset.c index 6c20240b4350..09f871596f68 100644 --- a/sys/dev/ata/ata-chipset.c +++ b/sys/dev/ata/ata-chipset.c @@ -1815,7 +1815,7 @@ ata_promise_apkt(u_int8_t *bytep, struct ata_device *atadev, u_int8_t command, bytep[i++] = ATA_PDC_1B | ATA_PDC_WRITE_CTL; bytep[i++] = ATA_A_4BIT; - if ((lba > 268435455 || count > 256) && atadev->param && + if ((lba >= ATA_MAX_28BIT_LBA || count > 256) && atadev->param && (atadev->param->support.command2 & ATA_SUPPORT_ADDRESS48)) { atadev->channel->flags |= ATA_48BIT_ACTIVE; if (command == ATA_READ_DMA) diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index ccba1de78024..eebde22c4657 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -114,7 +114,7 @@ ad_attach(struct ata_device *atadev) /* use the 48bit LBA size if valid */ if ((atadev->param->support.command2 & ATA_SUPPORT_ADDRESS48) && - lbasize48 > 268435455) + lbasize48 > ATA_MAX_28BIT_LBA) adp->total_secs = lbasize48; /* setup the function ptrs */ diff --git a/sys/dev/ata/ata-lowlevel.c b/sys/dev/ata/ata-lowlevel.c index 3bc4c48f81d0..2a08bd0b42e5 100644 --- a/sys/dev/ata/ata-lowlevel.c +++ b/sys/dev/ata/ata-lowlevel.c @@ -701,7 +701,7 @@ ata_generic_command(struct ata_device *atadev, u_int8_t command, ATA_IDX_OUTB(atadev->channel, ATA_ALTSTAT, ATA_A_4BIT); /* only use 48bit addressing if needed (avoid bugs and overhead) */ - if ((lba > 268435455 || count > 256) && atadev->param && + if ((lba >= ATA_MAX_28BIT_LBA || count > 256) && atadev->param && atadev->param->support.command2 & ATA_SUPPORT_ADDRESS48) { /* translate command into 48bit version */