From f5218aad0fff9f99ec62d9076c60042bd3b417ab Mon Sep 17 00:00:00 2001 From: briggs Date: Tue, 15 Feb 2005 03:18:22 +0000 Subject: [PATCH] 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). --- sys/dev/pci/pciide_common.c | 11 +++++++---- sys/dev/pci/pciidereg.h | 5 +---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/dev/pci/pciide_common.c b/sys/dev/pci/pciide_common.c index df3417736fc3..ae682edb6ff6 100644 --- a/sys/dev/pci/pciide_common.c +++ b/sys/dev/pci/pciide_common.c @@ -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 -__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 #include @@ -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, diff --git a/sys/dev/pci/pciidereg.h b/sys/dev/pci/pciidereg.h index 3591049d023d..d4f09549b469 100644 --- a/sys/dev/pci/pciidereg.h +++ b/sys/dev/pci/pciidereg.h @@ -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)