diff options
-rw-r--r-- | sys/dev/ata/ata-all.c | 37 | ||||
-rw-r--r-- | sys/dev/ata/ata-all.h | 2 | ||||
-rw-r--r-- | sys/dev/ata/ata-disk.c | 6 | ||||
-rw-r--r-- | sys/dev/ata/atapi-cam.c | 5 | ||||
-rw-r--r-- | sys/dev/ata/atapi-cd.c | 7 | ||||
-rw-r--r-- | sys/dev/ata/atapi-fd.c | 7 | ||||
-rw-r--r-- | sys/dev/ata/atapi-tape.c | 7 |
7 files changed, 28 insertions, 43 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index a04f806..c5f1b44 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -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 diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index f272684..daf2b3d 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -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: */ diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 08e7f34..353ee6b 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.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; diff --git a/sys/dev/ata/atapi-cam.c b/sys/dev/ata/atapi-cam.c index a95825d..2a4b3d9 100644 --- a/sys/dev/ata/atapi-cam.c +++ b/sys/dev/ata/atapi-cam.c @@ -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); } } diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 1e62a1f..38369b9 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -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; diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index 4304a3a..91f2110 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -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; diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 7fce3b7..f442258 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -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; |