diff options
author | sos <sos@FreeBSD.org> | 2000-03-05 16:52:26 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2000-03-05 16:52:26 +0000 |
commit | 2610d76c24fda4e4028b633dc4df3471e82e5d65 (patch) | |
tree | e98d9c247873e4565dda59e44e728854c8f78759 /sys | |
parent | 3e2fdbb2dd8aef2ecdcb4a5026733773122121aa (diff) | |
download | FreeBSD-src-2610d76c24fda4e4028b633dc4df3471e82e5d65.zip FreeBSD-src-2610d76c24fda4e4028b633dc4df3471e82e5d65.tar.gz |
Fix the CD driver so that the last blocks can be read even if
a blocksize != 2k is used.
Update the timeout code to try fallback to PIO if problems
arise in DMA mode.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ata/ata-all.h | 4 | ||||
-rw-r--r-- | sys/dev/ata/ata-disk.c | 46 | ||||
-rw-r--r-- | sys/dev/ata/ata-disk.h | 8 | ||||
-rw-r--r-- | sys/dev/ata/ata-dma.c | 6 | ||||
-rw-r--r-- | sys/dev/ata/atapi-all.c | 52 | ||||
-rw-r--r-- | sys/dev/ata/atapi-all.h | 9 | ||||
-rw-r--r-- | sys/dev/ata/atapi-cd.c | 35 | ||||
-rw-r--r-- | sys/dev/ata/atapi-fd.c | 8 | ||||
-rw-r--r-- | sys/dev/ata/atapi-tape.c | 10 |
9 files changed, 103 insertions, 75 deletions
diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index fcac26e..62a10b5 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -63,8 +63,8 @@ #define ATA_C_WRITE 0x30 /* write command */ #define ATA_C_PACKET_CMD 0xa0 /* packet command */ #define ATA_C_ATAPI_IDENTIFY 0xa1 /* get ATAPI params*/ -#define ATA_C_READ_MULTI 0xc4 /* read multi command */ -#define ATA_C_WRITE_MULTI 0xc5 /* write multi command */ +#define ATA_C_READ_MUL 0xc4 /* read multi command */ +#define ATA_C_WRITE_MUL 0xc5 /* write multi command */ #define ATA_C_SET_MULTI 0xc6 /* set multi size command */ #define ATA_C_READ_DMA 0xc8 /* read w/DMA command */ #define ATA_C_WRITE_DMA 0xca /* write w/DMA command */ diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 301fe6b..46915a7 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -292,7 +292,7 @@ addump(dev_t dev) while (request.bytecount > 0) { ad_transfer(&request); - if (request.flags & AR_F_ERROR) + if (request.flags & ADR_F_ERROR) return EIO; request.donecount += request.currentsize; request.bytecount -= request.currentsize; @@ -341,7 +341,7 @@ ad_start(struct ad_softc *adp) request->blockaddr = bp->b_pblkno; request->bytecount = bp->b_bcount; request->data = bp->b_data; - request->flags = (bp->b_flags & B_READ) ? AR_F_READ : 0; + request->flags = (bp->b_flags & B_READ) ? ADR_F_READ : 0; /* remove from drive queue */ bufq_remove(&adp->queue, bp); @@ -402,23 +402,23 @@ ad_transfer(struct ad_request *request) devstat_start_transaction(&adp->stats); /* does this drive & transfer work with DMA ? */ - request->flags &= ~AR_F_DMA_USED; + request->flags &= ~ADR_F_DMA_USED; if ((adp->controller->mode[ATA_DEV(adp->unit)] >= ATA_DMA) && !ata_dmasetup(adp->controller, adp->unit, (void *)request->data, request->bytecount, - (request->flags & AR_F_READ))) { - request->flags |= AR_F_DMA_USED; - cmd = request->flags & AR_F_READ ? ATA_C_READ_DMA : ATA_C_WRITE_DMA; + (request->flags & ADR_F_READ))) { + request->flags |= ADR_F_DMA_USED; + cmd = request->flags&ADR_F_READ ? ATA_C_READ_DMA : ATA_C_WRITE_DMA; request->currentsize = request->bytecount; } /* does this drive support multi sector transfers ? */ else if (request->currentsize > DEV_BSIZE) - cmd = request->flags & AR_F_READ?ATA_C_READ_MULTI:ATA_C_WRITE_MULTI; + cmd = request->flags&ADR_F_READ ? ATA_C_READ_MUL : ATA_C_WRITE_MUL; /* just plain old single sector transfer */ else - cmd = request->flags & AR_F_READ ? ATA_C_READ : ATA_C_WRITE; + cmd = request->flags&ADR_F_READ ? ATA_C_READ : ATA_C_WRITE; if (ata_command(adp->controller, adp->unit, cmd, cylinder, head, sector, count, 0, ATA_IMMEDIATE)) { @@ -427,7 +427,7 @@ ad_transfer(struct ad_request *request) } /* if this is a DMA transfer, start it, return and wait for interrupt */ - if (request->flags & AR_F_DMA_USED) { + if (request->flags & ADR_F_DMA_USED) { ata_dmastart(adp->controller); return; } @@ -437,7 +437,7 @@ ad_transfer(struct ad_request *request) request->currentsize = min(request->bytecount, adp->transfersize); /* if this is a PIO read operation, return and wait for interrupt */ - if (request->flags & AR_F_READ) + if (request->flags & ADR_F_READ) return; /* ready to write PIO data ? */ @@ -463,7 +463,7 @@ ad_interrupt(struct ad_request *request) int32_t dma_stat = 0; /* finish DMA transfer */ - if (request->flags & AR_F_DMA_USED) + if (request->flags & ADR_F_DMA_USED) dma_stat = ata_dmadone(adp->controller); /* get drive status */ @@ -476,15 +476,15 @@ ad_interrupt(struct ad_request *request) /* did any real errors happen ? */ if ((adp->controller->status & ATA_S_ERROR) || - ((request->flags & AR_F_DMA_USED) && (dma_stat & ATA_BMSTAT_ERROR))) { + ((request->flags & ADR_F_DMA_USED) && (dma_stat & ATA_BMSTAT_ERROR))) { oops: printf("ad%d: %s %s ERROR blk# %d", adp->lun, (adp->controller->error & ATA_E_ICRC) ? "UDMA ICRC" : "HARD", - (request->flags & AR_F_READ) ? "READ" : "WRITE", + (request->flags & ADR_F_READ) ? "READ" : "WRITE", request->blockaddr + (request->donecount / DEV_BSIZE)); /* if this is a UDMA CRC error, reinject request */ - if (request->flags & AR_F_DMA_USED && + if (request->flags & ADR_F_DMA_USED && adp->controller->error & ATA_E_ICRC) { untimeout((timeout_t *)ad_timeout, request,request->timeout_handle); @@ -500,26 +500,26 @@ oops: } /* if using DMA, try once again in PIO mode */ - if (request->flags & AR_F_DMA_USED) { + if (request->flags & ADR_F_DMA_USED) { untimeout((timeout_t *)ad_timeout, request,request->timeout_handle); ata_dmainit(adp->controller, adp->unit, ata_pmode(AD_PARAM), -1,-1); - request->flags |= AR_F_FORCE_PIO; + request->flags |= ADR_F_FORCE_PIO; TAILQ_INSERT_HEAD(&adp->controller->ata_queue, request, chain); return ATA_OP_FINISHED; } - request->flags |= AR_F_ERROR; + request->flags |= ADR_F_ERROR; printf(" status=%02x error=%02x\n", adp->controller->status, adp->controller->error); } /* if we arrived here with forced PIO mode, DMA doesn't work right */ - if (request->flags & AR_F_FORCE_PIO) + if (request->flags & ADR_F_FORCE_PIO) printf("ad%d: DMA problem fallback to PIO mode\n", adp->lun); /* if this was a PIO read operation, get the data */ - if (!(request->flags & AR_F_DMA_USED) && - ((request->flags & (AR_F_READ | AR_F_ERROR)) == AR_F_READ)) { + if (!(request->flags & ADR_F_DMA_USED) && + ((request->flags & (ADR_F_READ | ADR_F_ERROR)) == ADR_F_READ)) { /* ready to receive data? */ if ((adp->controller->status & (ATA_S_READY | ATA_S_DSC | ATA_S_DRQ)) @@ -545,7 +545,7 @@ oops: } /* finish up transfer */ - if (request->flags & AR_F_ERROR) { + if (request->flags & ADR_F_ERROR) { request->bp->b_error = EIO; request->bp->b_flags |= B_ERROR; } @@ -591,9 +591,9 @@ ad_timeout(struct ad_request *request) adp->controller->running = NULL; printf("ad%d: %s command timeout - resetting\n", - adp->lun, (request->flags & AR_F_READ) ? "READ" : "WRITE"); + adp->lun, (request->flags & ADR_F_READ) ? "READ" : "WRITE"); - if (request->flags & AR_F_DMA_USED) { + if (request->flags & ADR_F_DMA_USED) { ata_dmadone(adp->controller); if (request->retries == AD_MAX_RETRIES) { ata_dmainit(adp->controller, adp->unit, ata_pmode(AD_PARAM), -1,-1); diff --git a/sys/dev/ata/ata-disk.h b/sys/dev/ata/ata-disk.h index 47f9f78..52eaeb2 100644 --- a/sys/dev/ata/ata-disk.h +++ b/sys/dev/ata/ata-disk.h @@ -59,10 +59,10 @@ struct ad_request { struct callout_handle timeout_handle; /* handle for untimeout */ int32_t retries; /* retry count */ int32_t flags; -#define AR_F_READ 0x0001 -#define AR_F_ERROR 0x0002 -#define AR_F_DMA_USED 0x0004 -#define AR_F_FORCE_PIO 0x0008 +#define ADR_F_READ 0x0001 +#define ADR_F_ERROR 0x0002 +#define ADR_F_DMA_USED 0x0004 +#define ADR_F_FORCE_PIO 0x0008 int8_t *data; /* pointer to data buf */ struct buf *bp; /* associated buf ptr */ diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index 11a9458..0f430a5 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -275,6 +275,8 @@ ata_dmainit(struct ata_softc *scp, int32_t device, return; } } + pci_write_config(parent, 0x53, + (pci_read_config(parent, 0x53, 1) & ~0x01) | 0x02, 1); /* we could set PIO mode timings, but we assume the BIOS did that */ break; @@ -582,9 +584,11 @@ via_generic: (error) ? "failed" : "success", apiomode < 0 ? 0 : apiomode); if (!error) scp->mode[ATA_DEV(device)] = ata_pio2mode(apiomode); - else + else { if (bootverbose) ata_printf(scp, device, "using PIO mode set by BIOS\n"); + scp->mode[ATA_DEV(device)] = ATA_PIO; + } } int32_t diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index ca9cbba..6167e78 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -63,7 +63,7 @@ void astdetach(struct atapi_softc *); MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer"); /* defines */ -#define ATAPI_MAX_RETRIES 5 +#define ATAPI_MAX_RETRIES 3 #define ATP_PARAM ATA_PARAM(atp->controller, atp->unit) void @@ -97,7 +97,7 @@ atapi_attach(struct ata_softc *scp, int32_t device) #endif /* set PIO mode */ ata_dmainit(atp->controller, atp->unit, - (ata_pmode(ATP_PARAM)<0) ? 0 : ata_pmode(ATP_PARAM), -1,-1); + ata_pmode(ATP_PARAM)<0 ? 0 : ata_pmode(ATP_PARAM), -1, -1); switch (ATP_PARAM->device_type) { #if NATAPICD > 0 @@ -233,6 +233,7 @@ atapi_transfer(struct atapi_request *request) atp->flags &= ~ATAPI_F_DSC_USED; /* if DMA enabled setup DMA hardware */ + request->flags &= ~ATPR_F_DMA_USED; if ((atp->controller->mode[ATA_DEV(atp->unit)] >= ATA_DMA) && (request->ccb[0] == ATAPI_READ || request->ccb[0] == ATAPI_READ_BIG || @@ -241,18 +242,18 @@ atapi_transfer(struct atapi_request *request) !(atp->controller->flags & ATA_ATAPI_DMA_RO))) && !ata_dmasetup(atp->controller, atp->unit, (void *)request->data, request->bytecount, - request->flags & A_READ)) { - atp->flags |= ATAPI_F_DMA_USED; + request->flags & ATPR_F_READ)) { + request->flags |= ATPR_F_DMA_USED; } /* start ATAPI operation */ if (ata_command(atp->controller, atp->unit, ATA_C_PACKET_CMD, request->bytecount, 0, 0, 0, - (atp->flags & ATAPI_F_DMA_USED) ? ATA_F_DMA : 0, + (request->flags & ATPR_F_DMA_USED) ? ATA_F_DMA : 0, ATA_IMMEDIATE)) printf("%s: failure to send ATAPI packet command\n", atp->devname); - if (atp->flags & ATAPI_F_DMA_USED) + if (request->flags & ATPR_F_DMA_USED) ata_dmastart(atp->controller); /* command interrupt device ? just return */ @@ -307,15 +308,15 @@ atapi_interrupt(struct atapi_request *request) return ATA_OP_CONTINUES; } - if (atp->flags & ATAPI_F_DMA_USED) { + if (request->flags & ATPR_F_DMA_USED) { dma_stat = ata_dmadone(atp->controller); - atp->flags &= ~ATAPI_F_DMA_USED; if ((atp->controller->status & (ATA_S_ERROR | ATA_S_DWF)) || dma_stat & ATA_BMSTAT_ERROR) { request->result = inb(atp->controller->ioaddr + ATA_ERROR); } else { request->result = 0; + request->donecount = request->bytecount; request->bytecount = 0; } } @@ -325,7 +326,7 @@ atapi_interrupt(struct atapi_request *request) switch (reason) { case ATAPI_P_WRITE: - if (request->flags & A_READ) { + if (request->flags & ATPR_F_READ) { request->result = inb(atp->controller->ioaddr + ATA_ERROR); printf("%s: %s trying to write on read buffer\n", atp->devname, atapi_cmd2str(atp->cmd)); @@ -335,7 +336,7 @@ atapi_interrupt(struct atapi_request *request) return ATA_OP_CONTINUES; case ATAPI_P_READ: - if (!(request->flags & A_READ)) { + if (!(request->flags & ATPR_F_READ)) { request->result = inb(atp->controller->ioaddr + ATA_ERROR); printf("%s: %s trying to read on write buffer\n", atp->devname, atapi_cmd2str(atp->cmd)); @@ -346,7 +347,7 @@ atapi_interrupt(struct atapi_request *request) case ATAPI_P_DONEDRQ: printf("%s: %s DONEDRQ\n", atp->devname, atapi_cmd2str(atp->cmd)); - if (request->flags & A_READ) + if (request->flags & ATPR_F_READ) atapi_read(request, length); else atapi_write(request, length); @@ -376,7 +377,7 @@ op_finished: request->ccb[0] = ATAPI_REQUEST_SENSE; request->ccb[4] = sizeof(struct atapi_reqsense); request->bytecount = sizeof(struct atapi_reqsense); - request->flags = A_READ; + request->flags = ATPR_F_READ; TAILQ_INSERT_HEAD(&atp->controller->atapi_queue, request, chain); } else { @@ -432,12 +433,16 @@ void atapi_reinit(struct atapi_softc *atp) { /* reinit device parameters */ - ata_dmainit(atp->controller, atp->unit, - (ata_pmode(ATP_PARAM) < 0) ? - (ATP_PARAM->dmaflag ? 4 : 0) : ata_pmode(ATP_PARAM), - (ata_wmode(ATP_PARAM) < 0) ? - (ATP_PARAM->dmaflag ? 2 : 0) : ata_wmode(ATP_PARAM), - ata_umode(ATP_PARAM)); + if (atp->controller->mode[ATA_DEV(atp->unit)] >= ATA_DMA) + ata_dmainit(atp->controller, atp->unit, + (ata_pmode(ATP_PARAM) < 0) ? + (ATP_PARAM->dmaflag ? 4 : 0) : ata_pmode(ATP_PARAM), + (ata_wmode(ATP_PARAM) < 0) ? + (ATP_PARAM->dmaflag ? 2 : 0) : ata_wmode(ATP_PARAM), + ata_umode(ATP_PARAM)); + else + ata_dmainit(atp->controller, atp->unit, + ata_pmode(ATP_PARAM)<0 ? 0 : ata_pmode(ATP_PARAM), -1, -1); } int32_t @@ -500,6 +505,7 @@ atapi_read(struct atapi_request *request, int32_t length) } *buffer += size; request->bytecount -= size; + request->donecount += size; } static void @@ -528,6 +534,7 @@ atapi_write(struct atapi_request *request, int32_t length) } *buffer += size; request->bytecount -= size; + request->donecount += size; } static void @@ -540,8 +547,15 @@ atapi_timeout(struct atapi_request *request) printf("%s: %s command timeout - resetting\n", atp->devname, atapi_cmd2str(request->ccb[0])); - if (request->flags & ATAPI_F_DMA_USED) + if (request->flags & ATPR_F_DMA_USED) { ata_dmadone(atp->controller); + if (request->retries == ATAPI_MAX_RETRIES) { + ata_dmainit(atp->controller, atp->unit, + (ata_pmode(ATP_PARAM)<0)?0:ata_pmode(ATP_PARAM),-1,-1); + printf("%s: trying fallback to PIO mode\n", atp->devname); + request->retries = 0; + } + } /* if retries still permit, reinject this request */ if (request->retries++ < ATAPI_MAX_RETRIES) diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h index 998bbc4..0c97536 100644 --- a/sys/dev/ata/atapi-all.h +++ b/sys/dev/ata/atapi-all.h @@ -148,9 +148,8 @@ struct atapi_softc { int8_t *devname; /* this devices name */ int8_t cmd; /* last cmd executed */ u_int32_t flags; /* drive flags */ -#define ATAPI_F_DMA_USED 0x0001 -#define ATAPI_F_DSC_USED 0x0002 -#define ATAPI_F_MEDIA_CHANGED 0x0004 +#define ATAPI_F_DSC_USED 0x0001 +#define ATAPI_F_MEDIA_CHANGED 0x0002 }; @@ -161,6 +160,7 @@ struct atapi_request { u_int8_t ccb[16]; /* command control block */ int32_t ccbsize; /* size of ccb (12 | 16) */ u_int32_t bytecount; /* bytes to transfer */ + u_int32_t donecount; /* bytes transferred */ int32_t timeout; /* timeout for this cmd */ struct callout_handle timeout_handle; /* handle for untimeout */ int32_t retries; /* retry count */ @@ -168,7 +168,8 @@ struct atapi_request { int32_t error; /* result translated to errno */ struct atapi_reqsense sense; /* sense data if error */ int32_t flags; -#define A_READ 0x0001 +#define ATPR_F_READ 0x0001 +#define ATPR_F_DMA_USED 0x0002 int8_t *data; /* pointer to data buf */ struct buf *bp; /* associated buf ptr */ diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 703fbc2..027f510 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -151,7 +151,7 @@ acdattach(struct atapi_softc *atp) } bzero(chp, sizeof(struct changer)); error = atapi_queue_cmd(cdp->atp, ccb, chp, sizeof(struct changer), - A_READ, 60, NULL, NULL, NULL); + ATPR_F_READ, 60, NULL, NULL, NULL); if (!error) { struct acd_softc *tmpcdp = cdp; @@ -694,7 +694,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p) } if ((error = atapi_queue_cmd(cdp->atp, ccb, &cdp->subchan, - sizeof(cdp->subchan), A_READ, 10, + sizeof(cdp->subchan), ATPR_F_READ, 10, NULL, NULL, NULL))) { break; } @@ -842,7 +842,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p) ccb[8] = blocks; ccb[9] = 0xf0; if ((error = atapi_queue_cmd(cdp->atp, ccb, buffer, size, - A_READ, 30, NULL, NULL, NULL))) + ATPR_F_READ, 30, NULL, NULL,NULL))) break; if ((error = copyout(buffer, ubuf, size))) @@ -1122,6 +1122,15 @@ acd_start(struct acd_softc *cdp) lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); if (bp->b_flags & B_READ) { + /* if transfer goes beyond EOM adjust it to be within limits */ + if (lba + count > cdp->info.volsize) { + /* if we are entirely beyond EOM return EOF */ + if ((count = cdp->info.volsize - lba) <= 0) { + bp->b_resid = bp->b_bcount; + biodone(bp); + return; + } + } if (cdp->block_size == 2048) ccb[0] = ATAPI_READ_BIG; else { @@ -1142,8 +1151,8 @@ acd_start(struct acd_softc *cdp) devstat_start_transaction(cdp->stats); - atapi_queue_cmd(cdp->atp, ccb, bp->b_data, bp->b_bcount, - (bp->b_flags&B_READ)?A_READ : 0, 30, acd_done, cdp, bp); + atapi_queue_cmd(cdp->atp, ccb, bp->b_data, count * cdp->block_size, + bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, cdp,bp); } static int32_t @@ -1157,7 +1166,7 @@ acd_done(struct atapi_request *request) bp->b_flags |= B_ERROR; } else { - bp->b_resid = request->bytecount; + bp->b_resid = bp->b_bcount - request->donecount; if (!(bp->b_flags & B_READ)) cdp->flags |= F_WRITTEN; } @@ -1189,7 +1198,7 @@ acd_read_toc(struct acd_softc *cdp) ccb[0] = ATAPI_READ_TOC; ccb[7] = len>>8; ccb[8] = len; - if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, A_READ, 30, + if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, ATPR_F_READ, 30, NULL, NULL, NULL)) { bzero(&cdp->toc, sizeof(cdp->toc)); return 0; @@ -1205,7 +1214,7 @@ acd_read_toc(struct acd_softc *cdp) ccb[0] = ATAPI_READ_TOC; ccb[7] = len>>8; ccb[8] = len; - if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, A_READ, 30, + if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, ATPR_F_READ, 30, NULL, NULL, NULL)) { bzero(&cdp->toc, sizeof(cdp->toc)); return 0; @@ -1216,7 +1225,7 @@ acd_read_toc(struct acd_softc *cdp) bzero(ccb, sizeof(ccb)); ccb[0] = ATAPI_READ_CAPACITY; if (atapi_queue_cmd(cdp->atp, ccb, &cdp->info, sizeof(cdp->info), - A_READ, 30, NULL, NULL, NULL)) + ATPR_F_READ, 30, NULL, NULL, NULL)) bzero(&cdp->info, sizeof(cdp->info)); cdp->info.volsize = ntohl(cdp->info.volsize); @@ -1439,7 +1448,7 @@ acd_read_track_info(struct acd_softc *cdp, int32_t error; if ((error = atapi_queue_cmd(cdp->atp, ccb, info, sizeof(*info), - A_READ, 30, NULL, NULL, NULL))) + ATPR_F_READ, 30, NULL, NULL, NULL))) return error; info->track_start_addr = ntohl(info->track_start_addr); info->next_writeable_addr = ntohl(info->next_writeable_addr); @@ -1497,7 +1506,7 @@ acd_report_key(struct acd_softc *cdp, struct dvd_authinfo *ai) bzero(&d, sizeof(d)); d.length = htons(length - 2); error = atapi_queue_cmd(cdp->atp, ccb, &d, length, - (ai->format == DVD_INVALIDATE_AGID) ? 0 : A_READ, + ai->format == DVD_INVALIDATE_AGID ? 0 : ATPR_F_READ, 10, NULL, NULL, NULL); if (error) return error; @@ -1639,7 +1648,7 @@ acd_read_structure(struct acd_softc *cdp, struct dvd_struct *s) ccb[9] = length & 0xff; ccb[10] = s->agid << 6; d.length = htons(length - 2); - error = atapi_queue_cmd(cdp->atp, ccb, &d, length, A_READ, 30, + error = atapi_queue_cmd(cdp->atp, ccb, &d, length, ATPR_F_READ, 30, NULL, NULL, NULL); if (error) return error; @@ -1764,7 +1773,7 @@ acd_mode_sense(struct acd_softc *cdp, u_int8_t page, pagesize>>8, pagesize, 0, 0, 0, 0, 0, 0, 0 }; int32_t error; - error = atapi_queue_cmd(cdp->atp, ccb, pagebuf, pagesize, A_READ, 10, + error = atapi_queue_cmd(cdp->atp, ccb, pagebuf, pagesize, ATPR_F_READ, 10, NULL, NULL, NULL); #ifdef ACD_DEBUG atapi_dump("acd: mode sense ", pagebuf, pagesize); diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index 3423f5b..ea15241 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -149,7 +149,7 @@ afd_sense(struct afd_softc *fdp) /* get drive capabilities, some drives needs this repeated */ for (count = 0 ; count < 5 ; count++) { if (!(error = atapi_queue_cmd(fdp->atp, ccb, buffer, sizeof(buffer), - A_READ, 30, NULL, NULL, NULL))) + ATPR_F_READ, 30, NULL, NULL, NULL))) break; } if (error) @@ -340,7 +340,7 @@ afd_start(struct afd_softc *fdp) atapi_queue_cmd(fdp->atp, ccb, data_ptr, fdp->transfersize * fdp->cap.sector_size, - (bp->b_flags & B_READ) ? A_READ : 0, 30, + (bp->b_flags & B_READ) ? ATPR_F_READ : 0, 30, afd_partial_done, fdp, bp); count -= fdp->transfersize; @@ -356,7 +356,7 @@ afd_start(struct afd_softc *fdp) ccb[8] = count; atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size, - (bp->b_flags & B_READ) ? A_READ : 0, 30, afd_done, fdp, bp); + bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, afd_done, fdp,bp); } static int32_t @@ -383,7 +383,7 @@ afd_done(struct atapi_request *request) bp->b_flags |= B_ERROR; } else - bp->b_resid += request->bytecount; + bp->b_resid += (bp->b_bcount - request->donecount); devstat_end_transaction_buf(&fdp->stats, bp); biodone(bp); afd_start(fdp); diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 9d41648..29c159f 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -489,8 +489,8 @@ ast_start(struct ast_softc *stp) devstat_start_transaction(&stp->stats); - atapi_queue_cmd(stp->atp, ccb, bp->b_data, bp->b_bcount, - (bp->b_flags & B_READ) ? A_READ : 0, 60, ast_done, stp, bp); + atapi_queue_cmd(stp->atp, ccb, bp->b_data, blkcount * stp->blksize, + bp->b_flags&B_READ ? ATPR_F_READ : 0, 60, ast_done, stp,bp); } static int32_t @@ -506,7 +506,7 @@ ast_done(struct atapi_request *request) else { if (!(bp->b_flags & B_READ)) stp->flags |= F_DATA_WRITTEN; - bp->b_resid = request->bytecount; + bp->b_resid = bp->b_bcount - request->donecount; ast_total += (bp->b_bcount - bp->b_resid); } devstat_end_transaction_buf(&stp->stats, bp); @@ -523,7 +523,7 @@ ast_mode_sense(struct ast_softc *stp, u_int8_t page, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int32_t error; - error = atapi_queue_cmd(stp->atp, ccb, pagebuf, pagesize, A_READ, 10, + error = atapi_queue_cmd(stp->atp, ccb, pagebuf, pagesize, ATPR_F_READ, 10, NULL, NULL, NULL); #ifdef AST_DEBUG atapi_dump("ast: mode sense ", pagebuf, pagesize); @@ -577,7 +577,7 @@ ast_read_position(struct ast_softc *stp, int32_t hard, int32_t error; error = atapi_queue_cmd(stp->atp, ccb, position, - sizeof(struct ast_readposition), A_READ, 10, + sizeof(struct ast_readposition), ATPR_F_READ, 10, NULL, NULL, NULL); position->tape = ntohl(position->tape); position->host = ntohl(position->host); |