Centralise mode setting. Instead of doing it in all subdrivers, do
it in ata-all.c where it belongs. Prime controller HW by always setting PIO mode first in attach.
This commit is contained in:
parent
6a8407c80d
commit
68cf95070d
@ -73,6 +73,16 @@ static void btrim(int8_t *, int);
|
||||
static void bpack(int8_t *, int8_t *, int);
|
||||
static void ata_init(void);
|
||||
|
||||
/* global vars */
|
||||
struct intr_config_hook *ata_delayed_attach = NULL;
|
||||
devclass_t ata_devclass;
|
||||
int ata_wc = 1;
|
||||
|
||||
/* local vars */
|
||||
static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
|
||||
static int ata_dma = 1;
|
||||
static int atapi_dma = 0;
|
||||
|
||||
/* sysctl vars */
|
||||
SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters");
|
||||
TUNABLE_INT("hw.ata.ata_dma", &ata_dma);
|
||||
@ -84,16 +94,6 @@ SYSCTL_INT(_hw_ata, OID_AUTO, wc, CTLFLAG_RDTUN, &ata_wc, 0,
|
||||
TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma);
|
||||
SYSCTL_INT(_hw_ata, OID_AUTO, atapi_dma, CTLFLAG_RDTUN, &atapi_dma, 0,
|
||||
"ATAPI device DMA mode control");
|
||||
int ata_dma = 1;
|
||||
int ata_wc = 1;
|
||||
int atapi_dma = 0;
|
||||
|
||||
/* global vars */
|
||||
struct intr_config_hook *ata_delayed_attach = NULL;
|
||||
devclass_t ata_devclass;
|
||||
|
||||
/* local vars */
|
||||
static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
|
||||
|
||||
/*
|
||||
* newbus device interface related functions
|
||||
@ -675,6 +675,23 @@ ata_identify_devices(struct ata_channel *ch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* setup basic transfer mode by setting PIO mode and DMA if supported */
|
||||
if (ch->device[MASTER].attach) {
|
||||
ch->device[MASTER].setmode(&ch->device[MASTER], ATA_PIO_MAX);
|
||||
if ((((ch->devices & ATA_ATAPI_MASTER) && atapi_dma &&
|
||||
(ch->device[MASTER].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR)||
|
||||
((ch->devices & ATA_ATA_MASTER) && ata_dma)) && ch->dma)
|
||||
ch->device[MASTER].setmode(&ch->device[MASTER], ATA_DMA_MAX);
|
||||
|
||||
}
|
||||
if (ch->device[SLAVE].attach) {
|
||||
ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_PIO_MAX);
|
||||
if ((((ch->devices & ATA_ATAPI_SLAVE) && atapi_dma &&
|
||||
(ch->device[SLAVE].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR) ||
|
||||
((ch->devices & ATA_ATA_SLAVE) && ata_dma)) && ch->dma)
|
||||
ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_DMA_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -345,7 +345,7 @@ struct atapi_sense {
|
||||
/* externs */
|
||||
extern devclass_t ata_devclass;
|
||||
extern struct intr_config_hook *ata_delayed_attach;
|
||||
extern int ata_dma, ata_wc, atapi_dma;
|
||||
extern int ata_wc;
|
||||
|
||||
/* public prototypes */
|
||||
/* ata-all.c: */
|
||||
|
@ -137,12 +137,6 @@ ad_attach(struct ata_device *atadev)
|
||||
adp->max_iosize = secsperint * DEV_BSIZE;
|
||||
}
|
||||
|
||||
/* use DMA if allowed and if drive/controller supports it */
|
||||
if (ata_dma && atadev->channel->dma)
|
||||
atadev->setmode(atadev, ATA_DMA_MAX);
|
||||
else
|
||||
atadev->setmode(atadev, ATA_PIO_MAX);
|
||||
|
||||
/* setup the function ptrs */
|
||||
atadev->detach = ad_detach;
|
||||
atadev->start = ad_start;
|
||||
|
@ -227,11 +227,6 @@ setup_dev(struct atapi_xpt_softc *scp, struct ata_device *atp)
|
||||
2 * device_get_unit(atp->channel->dev) +
|
||||
(atp->unit == ATA_MASTER) ? 0 : 1);
|
||||
atp->softc = (void *)scp;
|
||||
if (atapi_dma && atp->channel->dma &&
|
||||
(atp->param->config & ATA_DRQ_MASK) != ATA_DRQ_INTR)
|
||||
atp->setmode(atp, ATA_DMA_MAX);
|
||||
else
|
||||
atp->setmode(atp, ATA_PIO_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,13 +171,6 @@ acd_attach(struct ata_device *atadev)
|
||||
else
|
||||
g_post_event(acd_geom_create, cdp, M_WAITOK, NULL);
|
||||
|
||||
/* use DMA if allowed and if drive/controller supports it */
|
||||
if (atapi_dma && atadev->channel->dma &&
|
||||
(atadev->param->config & ATA_DRQ_MASK) != ATA_DRQ_INTR)
|
||||
atadev->setmode(atadev, ATA_DMA_MAX);
|
||||
else
|
||||
atadev->setmode(atadev, ATA_PIO_MAX);
|
||||
|
||||
/* setup the function ptrs */
|
||||
atadev->detach = acd_detach;
|
||||
atadev->start = acd_start;
|
||||
|
@ -87,13 +87,6 @@ afd_attach(struct ata_device *atadev)
|
||||
return;
|
||||
}
|
||||
|
||||
/* use DMA if allowed and if drive/controller supports it */
|
||||
if (atapi_dma && atadev->channel->dma &&
|
||||
(atadev->param->config & ATA_DRQ_MASK) != ATA_DRQ_INTR)
|
||||
atadev->setmode(atadev, ATA_DMA_MAX);
|
||||
else
|
||||
atadev->setmode(atadev, ATA_PIO_MAX);
|
||||
|
||||
/* setup the function ptrs */
|
||||
atadev->detach = afd_detach;
|
||||
atadev->start = afd_start;
|
||||
|
@ -148,13 +148,6 @@ ast_attach(struct ata_device *atadev)
|
||||
dev->si_iosize_max = DFLTPHYS;
|
||||
stp->dev2 = dev;
|
||||
|
||||
/* use DMA if allowed and if drive/controller supports it */
|
||||
if (atapi_dma && atadev->channel->dma &&
|
||||
(atadev->param->config & ATA_DRQ_MASK) != ATA_DRQ_INTR)
|
||||
atadev->setmode(atadev, ATA_DMA_MAX);
|
||||
else
|
||||
atadev->setmode(atadev, ATA_PIO_MAX);
|
||||
|
||||
/* setup the function ptrs */
|
||||
atadev->detach = ast_detach;
|
||||
atadev->start = ast_start;
|
||||
|
Loading…
Reference in New Issue
Block a user