Move the definition of NIDEDMA_TABLES from pciidereg.h to be closer to

its only user in pciide_common.c.  Also redefine NIDEDMA_TABLES to match
the max DMA transfer size specified in the call to bus_dmamap_create()
(IDEDMA_BYTE_COUNT_MAX instead of MAXPHYS).
The macro is also redefined to handle devices that have a PAGE_SIZE greater
than sc_dma_maxsegsz (buggy revision of satalink 3112 on ibm4xx).
This commit is contained in:
briggs 2005-02-15 03:18:22 +00:00
parent b4d3212ec4
commit f5218aad0f
2 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciide_common.c,v 1.23 2005/02/04 02:10:45 perry Exp $ */
/* $NetBSD: pciide_common.c,v 1.24 2005/02/15 03:18:22 briggs Exp $ */
/*
@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.23 2005/02/04 02:10:45 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.24 2005/02/15 03:18:22 briggs Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -522,6 +522,9 @@ pciide_channel_dma_setup(cp)
}
}
#define NIDEDMA_TABLES(sc) \
(IDEDMA_BYTE_COUNT_MAX/(min((sc)->sc_dma_maxsegsz, PAGE_SIZE)) + 1)
int
pciide_dma_table_setup(sc, channel, drive)
struct pciide_softc *sc;
@ -530,7 +533,7 @@ pciide_dma_table_setup(sc, channel, drive)
bus_dma_segment_t seg;
int error, rseg;
const bus_size_t dma_table_size =
sizeof(struct idedma_table) * NIDEDMA_TABLES;
sizeof(struct idedma_table) * NIDEDMA_TABLES(sc);
struct pciide_dma_maps *dma_maps =
&sc->pciide_channels[channel].dma_maps[drive];
@ -578,7 +581,7 @@ pciide_dma_table_setup(sc, channel, drive)
DEBUG_PROBE);
/* Create a xfer DMA map for this drive */
if ((error = bus_dmamap_create(sc->sc_dmat, IDEDMA_BYTE_COUNT_MAX,
NIDEDMA_TABLES, sc->sc_dma_maxsegsz, sc->sc_dma_boundary,
NIDEDMA_TABLES(sc), sc->sc_dma_maxsegsz, sc->sc_dma_boundary,
BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
&dma_maps->dmamap_xfer)) != 0) {
aprint_error(dmaerrfmt, sc->sc_wdcdev.sc_atac.atac_dev.dv_xname,

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciidereg.h,v 1.7 2003/11/27 23:02:40 fvdl Exp $ */
/* $NetBSD: pciidereg.h,v 1.8 2005/02/15 03:18:22 briggs Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
@ -112,6 +112,3 @@ struct idedma_table {
#define IDEDMA_BYTE_COUNT_MAX 0x00010000 /* Max I/O per table */
#define IDEDMA_BYTE_COUNT_ALIGN 0x00010000
/* Number of idedma table needed */
#define NIDEDMA_TABLES (MAXPHYS/PAGE_SIZE + 1)