diff options
author | sos <sos@FreeBSD.org> | 2004-09-03 12:10:44 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2004-09-03 12:10:44 +0000 |
commit | f4de4acfe415c8a12382bfc9c19e0db082649332 (patch) | |
tree | 5dc2d8e6fdb203486ef01bec1005d2fffb03cb81 /sys/dev/ata | |
parent | 42bfd75cfee107adb9e3fd0b3899fa4d0e7f0762 (diff) | |
download | FreeBSD-src-f4de4acfe415c8a12382bfc9c19e0db082649332.zip FreeBSD-src-f4de4acfe415c8a12382bfc9c19e0db082649332.tar.gz |
Introduce ata_udelay() that uses tsleep instead of DELAY if possible.
In places where we have long delays that doesn't depend on too accurate
timing, use ata_udelay() instead of DELAY() so we dont uselessly spin
the CPU if not nessesary;
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata-all.c | 9 | ||||
-rw-r--r-- | sys/dev/ata/ata-all.h | 1 | ||||
-rw-r--r-- | sys/dev/ata/ata-chipset.c | 8 | ||||
-rw-r--r-- | sys/dev/ata/ata-lowlevel.c | 7 |
4 files changed, 18 insertions, 7 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index fba9edc..89f20c6 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -734,6 +734,15 @@ ata_boot_attach(void) /* * misc support functions */ +void +ata_udelay(int interval) +{ + if (interval < (1000000/hz) || ata_delayed_attach) + DELAY(interval); + else + tsleep(&interval, PRIBIO, "ataslp", interval/(1000000/hz)); +} + static void bswap(int8_t *buf, int len) { diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index 6d85989..7de6d7f 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -390,6 +390,7 @@ int ata_attach(device_t dev); int ata_detach(device_t dev); int ata_suspend(device_t dev); int ata_resume(device_t dev); +void ata_udelay(int interval); int ata_printf(struct ata_channel *ch, int device, const char *fmt, ...) __printflike(3, 4); int ata_prtdev(struct ata_device *atadev, const char *fmt, ...) __printflike(2, 3); void ata_set_name(struct ata_device *atadev, char *name, int lun); diff --git a/sys/dev/ata/ata-chipset.c b/sys/dev/ata/ata-chipset.c index 15f4e35..9abd1d6 100644 --- a/sys/dev/ata/ata-chipset.c +++ b/sys/dev/ata/ata-chipset.c @@ -926,9 +926,9 @@ ata_intel_reset(struct ata_channel *ch) pci_write_config(parent, 0x92, pci_read_config(parent, 0x92, 2) | mask, 2); while (timeout--) { - DELAY(10000); + ata_udelay(10000); if ((pci_read_config(parent, 0x92, 2) & (mask << 4)) == (mask << 4)) { - DELAY(10000); + ata_udelay(10000); return; } } @@ -1107,7 +1107,7 @@ ata_nvidia_ident(device_t dev) static struct ata_chip_id ids[] = {{ ATA_NFORCE1, 0, AMDNVIDIA, NVIDIA, ATA_UDMA5, "nVidia nForce" }, { ATA_NFORCE2, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce2" }, - { ATA_NFORCE2_MCP, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia MCP" }, + { ATA_NFORCE2_MCP, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce2 MCP" }, { ATA_NFORCE3, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3" }, { ATA_NFORCE3_PRO, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3 Pro" }, { ATA_NFORCE3_MCP, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3 MCP" }, @@ -2171,7 +2171,7 @@ ata_sii_reset(struct ata_channel *ch) ATA_IDX_OUTL(ch, ATA_BMDEVSPEC_1, 0x00000001); DELAY(25000); ATA_IDX_OUTL(ch, ATA_BMDEVSPEC_1, 0x00000000); - tsleep(ch, PRIBIO, "siirst", hz); + ata_udelay(1000000); } static void diff --git a/sys/dev/ata/ata-lowlevel.c b/sys/dev/ata/ata-lowlevel.c index 65e2c24..3fef4a6 100644 --- a/sys/dev/ata/ata-lowlevel.c +++ b/sys/dev/ata/ata-lowlevel.c @@ -48,6 +48,7 @@ static int ata_generic_transaction(struct ata_request *); static void ata_generic_interrupt(void *); static void ata_generic_reset(struct ata_channel *); static int ata_wait(struct ata_device *, u_int8_t); +/*static int ata_command(struct ata_device *, u_int8_t, u_int64_t, u_int16_t, u_int16_t);*/ static void ata_pio_read(struct ata_request *, int); static void ata_pio_write(struct ata_request *, int); @@ -585,9 +586,9 @@ ata_generic_reset(struct ata_channel *ch) ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); DELAY(10); ATA_IDX_OUTB(ch, ATA_ALTSTAT, ATA_A_IDS | ATA_A_RESET); - DELAY(10000); + ata_udelay(10000); ATA_IDX_OUTB(ch, ATA_ALTSTAT, ATA_A_IDS); - DELAY(100000); + ata_udelay(100000); ATA_IDX_INB(ch, ATA_ERROR); /* wait for BUSY to go inactive */ @@ -656,7 +657,7 @@ ata_generic_reset(struct ata_channel *ch) if (stat1 == 0xff && timeout > 5) mask &= ~0x02; } - DELAY(100000); + ata_udelay(100000); } if (bootverbose) |