From a1d998a806ec29825059ba1887466280bff4cd9d Mon Sep 17 00:00:00 2001 From: sos Date: Sat, 27 Jul 2002 12:22:39 +0000 Subject: Properly change the block_size on different CD media, and use that to calculate the max amount of data in one IO request. Correct the max size on atapi floppies/tapes as well. --- sys/dev/ata/atapi-cd.c | 15 ++++++++++++--- sys/dev/ata/atapi-fd.c | 2 +- sys/dev/ata/atapi-tape.c | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index d0e8c39..be5bd17 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -74,6 +74,7 @@ static struct cdevsw acd_cdevsw = { /* prototypes */ static struct acd_softc *acd_init_lun(struct ata_device *); static void acd_make_dev(struct acd_softc *); +static void acd_set_ioparm(struct acd_softc *); static void acd_describe(struct acd_softc *); static void lba2msf(u_int32_t, u_int8_t *, u_int8_t *, u_int8_t *); static u_int32_t msf2lba(u_int8_t, u_int8_t, u_int8_t); @@ -282,11 +283,17 @@ acd_make_dev(struct acd_softc *cdp) make_dev_alias(dev, "acd%da", cdp->lun); make_dev_alias(dev, "acd%dc", cdp->lun); dev->si_drv1 = cdp; - dev->si_iosize_max = 126 * DEV_BSIZE; - dev->si_bsize_phys = 2048; /* XXX SOS */ cdp->dev = dev; cdp->device->flags |= ATA_D_MEDIA_CHANGED; cdp->clone_evh = EVENTHANDLER_REGISTER(dev_clone, acd_clone, cdp, 1000); + acd_set_ioparm(cdp); +} + +static void +acd_set_ioparm(struct acd_softc *cdp) +{ + cdp->dev->si_iosize_max = (65534 / cdp->block_size) * cdp->block_size; + cdp->dev->si_bsize_phys = cdp->block_size; } static void @@ -1011,6 +1018,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) case CDRIOCSETBLOCKSIZE: cdp->block_size = *(int *)addr; + acd_set_ioparm(cdp); break; case CDRIOCGETPROGRESS: @@ -1255,6 +1263,7 @@ acd_read_toc(struct acd_softc *cdp) cdp->toc.hdr.len = ntohs(cdp->toc.hdr.len); cdp->block_size = (cdp->toc.tab[0].control & 4) ? 2048 : 2352; + acd_set_ioparm(cdp); bzero(ccb, sizeof(ccb)); ccb[0] = ATAPI_READ_CAPACITY; if (atapi_queue_cmd(cdp->device, ccb, (caddr_t)sizes, sizeof(sizes), @@ -1515,7 +1524,7 @@ acd_init_track(struct acd_softc *cdp, struct cdr_track *track) param.session_format = CDR_SESS_CDROM_XA; break; } - + acd_set_ioparm(cdp); return acd_mode_select(cdp, (caddr_t)¶m, param.page_length + 10); } diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index e0a4c24..4360847 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -112,7 +112,7 @@ afdattach(struct ata_device *atadev) !strncmp(atadev->param->model, "IOMEGA Clik!", 12)) fdp->dev->si_iosize_max = 64 * DEV_BSIZE; else - fdp->dev->si_iosize_max = 126 * DEV_BSIZE; + fdp->dev->si_iosize_max = 127 * DEV_BSIZE; afd_describe(fdp); atadev->flags |= ATA_D_MEDIA_CHANGED; diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index b8b6455..6801035 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -132,12 +132,12 @@ astattach(struct ata_device *atadev) dev = make_dev(&ast_cdevsw, dkmakeminor(stp->lun, 0, 0), UID_ROOT, GID_OPERATOR, 0640, "ast%d", stp->lun); dev->si_drv1 = stp; - dev->si_iosize_max = 126 * DEV_BSIZE; + dev->si_iosize_max = 127 * DEV_BSIZE; stp->dev1 = dev; dev = make_dev(&ast_cdevsw, dkmakeminor(stp->lun, 0, 1), UID_ROOT, GID_OPERATOR, 0640, "nast%d", stp->lun); dev->si_drv1 = stp; - dev->si_iosize_max = 126 * DEV_BSIZE; + dev->si_iosize_max = 127 * DEV_BSIZE; stp->dev2 = dev; stp->device->flags |= ATA_D_MEDIA_CHANGED; ast_describe(stp); -- cgit v1.1