mirror of
https://github.com/opnsense/src.git
synced 2026-04-29 10:11:09 -04:00
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;
This commit is contained in:
parent
00b0483d5c
commit
0f7cfb8473
4 changed files with 18 additions and 7 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue