summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2000-03-13 12:04:58 +0000
committersos <sos@FreeBSD.org>2000-03-13 12:04:58 +0000
commit89d3e18adb263da48efeeeeb6c40f7e0ab34a39c (patch)
tree830423343cca949bf563ee1d4ef25d07509f60ec /sys/dev
parent88b8866bdd26b7ce811e987aa6d5cc52770dc9d9 (diff)
downloadFreeBSD-src-89d3e18adb263da48efeeeeb6c40f7e0ab34a39c.zip
FreeBSD-src-89d3e18adb263da48efeeeeb6c40f7e0ab34a39c.tar.gz
Enable disksort the right way both on ATA disks and ATAPI devices.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/ata-all.c22
-rw-r--r--sys/dev/ata/ata-disk.c15
-rw-r--r--sys/dev/ata/ata-disk.h3
-rw-r--r--sys/dev/ata/atapi-all.c40
-rw-r--r--sys/dev/ata/atapi-all.h13
-rw-r--r--sys/dev/ata/atapi-cd.c24
-rw-r--r--sys/dev/ata/atapi-fd.c13
-rw-r--r--sys/dev/ata/atapi-tape.c11
8 files changed, 75 insertions, 66 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index b8527f0..35db723 100644
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -921,15 +921,15 @@ ata_detach(device_t dev)
#if NATADISK > 0
if (scp->devices & ATA_ATA_MASTER)
- ad_detach(scp, ATA_MASTER);
+ ad_detach((struct ad_softc *)scp->dev_softc[0]);
if (scp->devices & ATA_ATA_SLAVE)
- ad_detach(scp, ATA_SLAVE);
+ ad_detach((struct ad_softc *)scp->dev_softc[1]);
#endif
#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
if (scp->devices & ATA_ATAPI_MASTER)
- atapi_detach(scp, ATA_MASTER);
+ atapi_detach((struct atapi_softc *)scp->dev_softc[0]);
if (scp->devices & ATA_ATAPI_SLAVE)
- atapi_detach(scp, ATA_SLAVE);
+ atapi_detach((struct atapi_softc *)scp->dev_softc[1]);
#endif
if (scp->dev_param[ATA_DEV(ATA_MASTER)]) {
free(scp->dev_param[ATA_DEV(ATA_MASTER)], M_ATA);
@@ -939,6 +939,8 @@ ata_detach(device_t dev)
free(scp->dev_param[ATA_DEV(ATA_SLAVE)], M_ATA);
scp->dev_param[ATA_DEV(ATA_SLAVE)] = NULL;
}
+ scp->dev_softc[ATA_DEV(ATA_MASTER)] = NULL;
+ scp->dev_softc[ATA_DEV(ATA_SLAVE)] = NULL;
scp->mode[ATA_DEV(ATA_MASTER)] = ATA_PIO;
scp->mode[ATA_DEV(ATA_SLAVE)] = ATA_PIO;
bus_teardown_intr(dev, scp->r_irq, scp->ih);
@@ -1171,6 +1173,12 @@ ata_start(struct ata_softc *scp)
#if NATADISK > 0
/* find & call the responsible driver if anything on the ATA queue */
+ if (TAILQ_EMPTY(&scp->ata_queue)) {
+ if (scp->devices & (ATA_ATA_MASTER) && scp->dev_softc[0])
+ ad_start((struct ad_softc *)scp->dev_softc[0]);
+ if (scp->devices & (ATA_ATA_SLAVE) && scp->dev_softc[1])
+ ad_start((struct ad_softc *)scp->dev_softc[1]);
+ }
if ((ad_request = TAILQ_FIRST(&scp->ata_queue))) {
TAILQ_REMOVE(&scp->ata_queue, ad_request, chain);
scp->active = ATA_ACTIVE_ATA;
@@ -1187,6 +1195,12 @@ ata_start(struct ata_softc *scp)
* if the other device is an ATA disk it already had its chance above.
* if no request can be served, timeout a call to ata_start.
*/
+ if (TAILQ_EMPTY(&scp->atapi_queue)) {
+ if (scp->devices & (ATA_ATAPI_MASTER) && scp->dev_softc[0])
+ atapi_start((struct atapi_softc *)scp->dev_softc[0]);
+ if (scp->devices & (ATA_ATAPI_SLAVE) && scp->dev_softc[1])
+ atapi_start((struct atapi_softc *)scp->dev_softc[1]);
+ }
if ((atapi_request = TAILQ_FIRST(&scp->atapi_queue))) {
struct atapi_softc *atp = atapi_request->device;
static int32_t interval = 1;
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 46915a7..802a783 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -91,7 +91,6 @@ static struct cdevsw fakewd_cdevsw = {
static struct cdevsw fakewddisk_cdevsw;
/* prototypes */
-static void ad_start(struct ad_softc *);
static void ad_timeout(struct ad_request *);
static int32_t ad_version(u_int16_t);
@@ -207,17 +206,14 @@ ad_attach(struct ata_softc *scp, int32_t device)
}
void
-ad_detach(struct ata_softc *scp, int32_t device)
+ad_detach(struct ad_softc *adp)
{
- struct ad_softc *adp = scp->dev_softc[ATA_DEV(device)];
-
disk_invalidate(&adp->disk);
disk_destroy(adp->dev1);
disk_destroy(adp->dev2);
devstat_remove_entry(&adp->stats);
ata_free_lun(&adp_lun_map, adp->lun);
free(adp, M_AD);
- scp->dev_softc[ATA_DEV(device)] = NULL;
}
static int
@@ -252,7 +248,7 @@ adstrategy(struct buf *bp)
s = splbio();
bufqdisksort(&adp->queue, bp);
- ad_start(adp);
+ ata_start(adp->controller);
splx(s);
}
@@ -320,7 +316,7 @@ addump(dev_t dev)
return 0;
}
-static void
+void
ad_start(struct ad_softc *adp)
{
struct buf *bp = bufq_first(&adp->queue);
@@ -348,10 +344,6 @@ ad_start(struct ad_softc *adp)
/* link onto controller queue */
TAILQ_INSERT_TAIL(&adp->controller->ata_queue, request, chain);
-
- /* try to start controller */
- if (adp->controller->active == ATA_IDLE)
- ata_start(adp->controller);
}
void
@@ -566,7 +558,6 @@ oops:
untimeout((timeout_t *)ad_timeout, request, request->timeout_handle);
free(request, M_AD);
- ad_start(adp);
return ATA_OP_FINISHED;
}
diff --git a/sys/dev/ata/ata-disk.h b/sys/dev/ata/ata-disk.h
index 52eaeb2..91e9fad 100644
--- a/sys/dev/ata/ata-disk.h
+++ b/sys/dev/ata/ata-disk.h
@@ -71,7 +71,8 @@ struct ad_request {
};
void ad_attach(struct ata_softc *, int32_t);
-void ad_detach(struct ata_softc *, int32_t);
+void ad_detach(struct ad_softc *);
+void ad_start(struct ad_softc *);
void ad_transfer(struct ad_request *);
int32_t ad_interrupt(struct ad_request *);
void ad_reinit(struct ad_softc *);
diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c
index 6167e78..14973eb 100644
--- a/sys/dev/ata/atapi-all.c
+++ b/sys/dev/ata/atapi-all.c
@@ -51,14 +51,6 @@ static int8_t *atapi_type(int32_t);
static int8_t *atapi_cmd2str(u_int8_t);
static int8_t *atapi_skey2str(u_int8_t);
-/* extern references */
-int32_t acdattach(struct atapi_softc *);
-int32_t afdattach(struct atapi_softc *);
-int32_t astattach(struct atapi_softc *);
-void acddetach(struct atapi_softc *);
-void afddetach(struct atapi_softc *);
-void astdetach(struct atapi_softc *);
-
/* internal vars */
MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer");
@@ -131,10 +123,8 @@ notfound:
}
void
-atapi_detach(struct ata_softc *scp, int32_t device)
+atapi_detach(struct atapi_softc *atp)
{
- struct atapi_softc *atp = scp->dev_softc[ATA_DEV(device)];
-
switch (ATP_PARAM->device_type) {
#if NATAPICD > 0
case ATAPI_TYPE_CDROM:
@@ -155,7 +145,6 @@ atapi_detach(struct ata_softc *scp, int32_t device)
return;
}
free(atp, M_ATAPI);
- scp->dev_softc[ATA_DEV(device)] = NULL;
}
int32_t
@@ -190,8 +179,7 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
/* append onto controller queue and try to start controller */
TAILQ_INSERT_TAIL(&atp->controller->atapi_queue, request, chain);
- if (atp->controller->active == ATA_IDLE)
- ata_start(atp->controller);
+ ata_start(atp->controller);
/* if callback used, then just return, gets called from interrupt context */
if (callback) {
@@ -208,6 +196,30 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
}
void
+atapi_start(struct atapi_softc *atp)
+{
+ switch (ATP_PARAM->device_type) {
+#if NATAPICD > 0
+ case ATAPI_TYPE_CDROM:
+ acd_start(atp);
+ break;
+#endif
+#if NATAPIFD > 0
+ case ATAPI_TYPE_DIRECT:
+ afd_start(atp);
+ break;
+#endif
+#if NATAPIST > 0
+ case ATAPI_TYPE_TAPE:
+ ast_start(atp);
+ break;
+#endif
+ default:
+ return;
+ }
+}
+
+void
atapi_transfer(struct atapi_request *request)
{
struct atapi_softc *atp = request->device;
diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h
index 0c97536..41084db 100644
--- a/sys/dev/ata/atapi-all.h
+++ b/sys/dev/ata/atapi-all.h
@@ -178,7 +178,8 @@ struct atapi_request {
};
void atapi_attach(struct ata_softc *, int32_t);
-void atapi_detach(struct ata_softc *, int32_t);
+void atapi_detach(struct atapi_softc *);
+void atapi_start(struct atapi_softc *);
void atapi_transfer(struct atapi_request *);
int32_t atapi_interrupt(struct atapi_request *);
int32_t atapi_queue_cmd(struct atapi_softc *, int8_t [], void *, int32_t, int32_t, int32_t, atapi_callback_t, void *, struct buf *);
@@ -187,4 +188,12 @@ int32_t atapi_test_ready(struct atapi_softc *);
int32_t atapi_wait_ready(struct atapi_softc *, int32_t);
void atapi_request_sense(struct atapi_softc *, struct atapi_reqsense *);
void atapi_dump(int8_t *, void *, int32_t);
-
+int32_t acdattach(struct atapi_softc *);
+void acddetach(struct atapi_softc *);
+void acd_start(struct atapi_softc *);
+int32_t afdattach(struct atapi_softc *);
+void afddetach(struct atapi_softc *);
+void afd_start(struct atapi_softc *);
+int32_t astattach(struct atapi_softc *);
+void astdetach(struct atapi_softc *);
+void ast_start(struct atapi_softc *);
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index 37b707b..bd43e86 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -70,14 +70,11 @@ static struct cdevsw acd_cdevsw = {
};
/* prototypes */
-int32_t acdattach(struct atapi_softc *);
-void acddetach(struct atapi_softc *);
static struct acd_softc *acd_init_lun(struct atapi_softc *, struct devstat *);
static void acd_make_dev(struct acd_softc *);
static void acd_describe(struct acd_softc *);
static void lba2msf(int32_t, u_int8_t *, u_int8_t *, u_int8_t *);
static int32_t msf2lba(u_int8_t, u_int8_t, u_int8_t);
-static void acd_start(struct acd_softc *);
static int32_t acd_done(struct atapi_request *);
static int32_t acd_read_toc(struct acd_softc *);
static void acd_construct_label(struct acd_softc *);
@@ -1087,13 +1084,14 @@ acdstrategy(struct buf *bp)
s = splbio();
bufqdisksort(&cdp->buf_queue, bp);
- acd_start(cdp);
+ ata_start(cdp->atp->controller);
splx(s);
}
-static void
-acd_start(struct acd_softc *cdp)
+void
+acd_start(struct atapi_softc *atp)
{
+ struct acd_softc *cdp = atp->driver;
struct buf *bp = bufq_first(&cdp->buf_queue);
u_int32_t lba, count;
int8_t ccb[16];
@@ -1112,16 +1110,7 @@ acd_start(struct acd_softc *cdp)
}
acd_select_slot(cdp);
-#ifdef NO_DVD_RAM_SUPPORT
- if (!(bp->b_flags & B_READ) &&
- (!(cdp->flags & F_DISK_OPEN) || !(cdp->flags & F_TRACK_OPEN))) {
- printf("acd%d: sequence error (no open)\n", cdp->lun);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
-#endif
+
bzero(ccb, sizeof(ccb));
count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size;
if (bp->b_flags & B_PHYS)
@@ -1143,7 +1132,7 @@ acd_start(struct acd_softc *cdp)
ccb[0] = ATAPI_READ_BIG;
else {
ccb[0] = ATAPI_READ_CD;
- ccb[9] = 0x10;
+ ccb[9] = 0xf8;
}
}
else
@@ -1180,7 +1169,6 @@ acd_done(struct atapi_request *request)
}
devstat_end_transaction_buf(cdp->stats, bp);
biodone(bp);
- acd_start(cdp);
return 0;
}
diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c
index 3683854..822d010 100644
--- a/sys/dev/ata/atapi-fd.c
+++ b/sys/dev/ata/atapi-fd.c
@@ -67,11 +67,8 @@ static struct cdevsw afd_cdevsw = {
static struct cdevsw afddisk_cdevsw;
/* prototypes */
-int32_t afdattach(struct atapi_softc *);
-void afddetach(struct atapi_softc *);
static int32_t afd_sense(struct afd_softc *);
static void afd_describe(struct afd_softc *);
-static void afd_start(struct afd_softc *);
static int32_t afd_partial_done(struct atapi_request *);
static int32_t afd_done(struct atapi_request *);
static int32_t afd_eject(struct afd_softc *, int32_t);
@@ -290,14 +287,15 @@ afdstrategy(struct buf *bp)
}
s = splbio();
- bufq_insert_tail(&fdp->buf_queue, bp);
- afd_start(fdp);
+ bufqdisksort(&fdp->buf_queue, bp);
+ ata_start(fdp->atp->controller);
splx(s);
}
-static void
-afd_start(struct afd_softc *fdp)
+void
+afd_start(struct atapi_softc *atp)
{
+ struct afd_softc *fdp = atp->driver;
struct buf *bp = bufq_first(&fdp->buf_queue);
u_int32_t lba, count;
int8_t ccb[16];
@@ -386,7 +384,6 @@ afd_done(struct atapi_request *request)
bp->b_resid += (bp->b_bcount - request->donecount);
devstat_end_transaction_buf(&fdp->stats, bp);
biodone(bp);
- afd_start(fdp);
return 0;
}
diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c
index e3abcf0..2f3b4d3 100644
--- a/sys/dev/ata/atapi-tape.c
+++ b/sys/dev/ata/atapi-tape.c
@@ -65,11 +65,8 @@ static struct cdevsw ast_cdevsw = {
};
/* prototypes */
-int32_t astattach(struct atapi_softc *);
-void astdetach(struct atapi_softc *);
static int32_t ast_sense(struct ast_softc *);
static void ast_describe(struct ast_softc *);
-static void ast_start(struct ast_softc *);
static int32_t ast_done(struct atapi_request *);
static int32_t ast_mode_sense(struct ast_softc *, u_int8_t, void *, int32_t);
static int32_t ast_mode_select(struct ast_softc *, void *, int32_t);
@@ -452,13 +449,14 @@ aststrategy(struct buf *bp)
s = splbio();
bufq_insert_tail(&stp->buf_queue, bp);
- ast_start(stp);
+ ata_start(stp->atp->controller);
splx(s);
}
-static void
-ast_start(struct ast_softc *stp)
+void
+ast_start(struct atapi_softc *atp)
{
+ struct ast_softc *stp = atp->driver;
struct buf *bp = bufq_first(&stp->buf_queue);
u_int32_t blkcount;
int8_t ccb[16];
@@ -511,7 +509,6 @@ ast_done(struct atapi_request *request)
}
devstat_end_transaction_buf(&stp->stats, bp);
biodone(bp);
- ast_start(stp);
return 0;
}
OpenPOWER on IntegriCloud