Enable disksort the right way both on ATA disks and ATAPI devices.
This commit is contained in:
parent
958795f321
commit
cfb21bbb7d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57985
@ -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;
|
||||
|
@ -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 @@ ad_interrupt(struct ad_request *request)
|
||||
untimeout((timeout_t *)ad_timeout, request, request->timeout_handle);
|
||||
|
||||
free(request, M_AD);
|
||||
ad_start(adp);
|
||||
return ATA_OP_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -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 *);
|
||||
|
@ -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 @@ atapi_attach(struct ata_softc *scp, int32_t device)
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -207,6 +195,30 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
|
||||
return error;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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 *);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user