diff options
author | marius <marius@FreeBSD.org> | 2010-11-28 18:53:29 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2010-11-28 18:53:29 +0000 |
commit | 4f90f790243087bb072c6898279869e605f36f8e (patch) | |
tree | f7bc407f9ef679b942a5d7d309b67c79c8c57060 | |
parent | 2df0e33e2663f2a5ba84883232342557d7b06101 (diff) | |
download | FreeBSD-src-4f90f790243087bb072c6898279869e605f36f8e.zip FreeBSD-src-4f90f790243087bb072c6898279869e605f36f8e.tar.gz |
Several chipset drivers alter parameters relevant for the DMA tag creation,
i.e. alignment, max_address, max_iosize and segsize (only max_address is
thought to have an negative impact regarding this issue though), after
calling ata_dmainit() either directly or indirectly so these values have
no effect or at least no effect on the DMA tags and the defaults are used
for the latter instead. So change the drivers to set these parameters
up-front and ata_dmainit() to honor them.
Reviewd by: mav
MFC after: 1 month
-rw-r--r-- | sys/dev/ata/ata-dma.c | 33 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-ahci.c | 2 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-cyrix.c | 6 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-marvell.c | 2 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-national.c | 4 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-promise.c | 3 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-serverworks.c | 4 | ||||
-rw-r--r-- | sys/dev/ata/chipsets/ata-siliconimage.c | 7 |
8 files changed, 33 insertions, 28 deletions
diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index 478693d..872434b 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -68,17 +68,28 @@ ata_dmainit(device_t dev) struct ata_channel *ch = device_get_softc(dev); struct ata_dc_cb_args dcba; - ch->dma.alloc = ata_dmaalloc; - ch->dma.free = ata_dmafree; - ch->dma.setprd = ata_dmasetprd; - ch->dma.load = ata_dmaload; - ch->dma.unload = ata_dmaunload; - ch->dma.alignment = 2; - ch->dma.boundary = 65536; - ch->dma.segsize = 65536; - ch->dma.max_iosize = MIN((ATA_DMA_ENTRIES - 1) * PAGE_SIZE, MAXPHYS); - ch->dma.max_address = BUS_SPACE_MAXADDR_32BIT; - ch->dma.dma_slots = 1; + if (ch->dma.alloc == NULL) + ch->dma.alloc = ata_dmaalloc; + if (ch->dma.free == NULL) + ch->dma.free = ata_dmafree; + if (ch->dma.setprd == NULL) + ch->dma.setprd = ata_dmasetprd; + if (ch->dma.load == NULL) + ch->dma.load = ata_dmaload; + if (ch->dma.unload == NULL) + ch->dma.unload = ata_dmaunload; + if (ch->dma.alignment == 0) + ch->dma.alignment = 2; + if (ch->dma.boundary == 0) + ch->dma.boundary = 65536; + if (ch->dma.segsize == 0) + ch->dma.segsize = 65536; + if (ch->dma.max_iosize == 0) + ch->dma.max_iosize = MIN((ATA_DMA_ENTRIES - 1) * PAGE_SIZE, MAXPHYS); + if (ch->dma.max_address == 0) + ch->dma.max_address = BUS_SPACE_MAXADDR_32BIT; + if (ch->dma.dma_slots == 0) + ch->dma.dma_slots = 1; if (bus_dma_tag_create(bus_get_dma_tag(dev), ch->dma.alignment, 0, ch->dma.max_address, BUS_SPACE_MAXADDR, diff --git a/sys/dev/ata/chipsets/ata-ahci.c b/sys/dev/ata/chipsets/ata-ahci.c index 4a240d7..2b6f860 100644 --- a/sys/dev/ata/chipsets/ata-ahci.c +++ b/sys/dev/ata/chipsets/ata-ahci.c @@ -1005,12 +1005,12 @@ ata_ahci_dmainit(device_t dev) struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); - ata_dmainit(dev); /* note start and stop are not used here */ ch->dma.setprd = ata_ahci_dmasetprd; ch->dma.max_iosize = (ATA_AHCI_DMA_ENTRIES - 1) * PAGE_SIZE; if (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_CAP_64BIT) ch->dma.max_address = BUS_SPACE_MAXADDR; + ata_dmainit(dev); } static int diff --git a/sys/dev/ata/chipsets/ata-cyrix.c b/sys/dev/ata/chipsets/ata-cyrix.c index 5a00856..f40f6f1 100644 --- a/sys/dev/ata/chipsets/ata-cyrix.c +++ b/sys/dev/ata/chipsets/ata-cyrix.c @@ -56,7 +56,6 @@ static int ata_cyrix_chipinit(device_t dev); static int ata_cyrix_ch_attach(device_t dev); static int ata_cyrix_setmode(device_t dev, int target, int mode); - /* * Cyrix chipset support functions */ @@ -89,15 +88,12 @@ static int ata_cyrix_ch_attach(device_t dev) { struct ata_channel *ch = device_get_softc(dev); - int error; - error = ata_pci_ch_attach(dev); ch->dma.alignment = 16; ch->dma.max_iosize = 64 * DEV_BSIZE; - return (error); + return (ata_pci_ch_attach(dev)); } - static int ata_cyrix_setmode(device_t dev, int target, int mode) { diff --git a/sys/dev/ata/chipsets/ata-marvell.c b/sys/dev/ata/chipsets/ata-marvell.c index eb6414e..7fcf3c1 100644 --- a/sys/dev/ata/chipsets/ata-marvell.c +++ b/sys/dev/ata/chipsets/ata-marvell.c @@ -614,7 +614,6 @@ ata_marvell_edma_dmainit(device_t dev) struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); struct ata_channel *ch = device_get_softc(dev); - ata_dmainit(dev); /* note start and stop are not used here */ ch->dma.setprd = ata_marvell_edma_dmasetprd; @@ -625,6 +624,7 @@ ata_marvell_edma_dmainit(device_t dev) /* chip does not reliably do 64K DMA transfers */ if (ctlr->chip->cfg2 == MV_50XX || ctlr->chip->cfg2 == MV_60XX) ch->dma.max_iosize = 64 * DEV_BSIZE; + ata_dmainit(dev); } ATA_DECLARE_DRIVER(ata_marvell); diff --git a/sys/dev/ata/chipsets/ata-national.c b/sys/dev/ata/chipsets/ata-national.c index 20cafa5..0131f99 100644 --- a/sys/dev/ata/chipsets/ata-national.c +++ b/sys/dev/ata/chipsets/ata-national.c @@ -90,12 +90,10 @@ static int ata_national_ch_attach(device_t dev) { struct ata_channel *ch = device_get_softc(dev); - int error; - error = ata_pci_ch_attach(dev); ch->dma.alignment = 16; ch->dma.max_iosize = 64 * DEV_BSIZE; - return (error); + return (ata_pci_ch_attach(dev)); } static int diff --git a/sys/dev/ata/chipsets/ata-promise.c b/sys/dev/ata/chipsets/ata-promise.c index 622352b..bee7bba 100644 --- a/sys/dev/ata/chipsets/ata-promise.c +++ b/sys/dev/ata/chipsets/ata-promise.c @@ -979,13 +979,12 @@ ata_promise_mio_dmainit(device_t dev) { struct ata_channel *ch = device_get_softc(dev); - ata_dmainit(dev); /* note start and stop are not used here */ ch->dma.setprd = ata_promise_mio_setprd; ch->dma.max_iosize = 65536; + ata_dmainit(dev); } - #define MAXLASTSGSIZE (32 * sizeof(u_int32_t)) static void ata_promise_mio_setprd(void *xsc, bus_dma_segment_t *segs, int nsegs, int error) diff --git a/sys/dev/ata/chipsets/ata-serverworks.c b/sys/dev/ata/chipsets/ata-serverworks.c index 876e68a..2240d4d 100644 --- a/sys/dev/ata/chipsets/ata-serverworks.c +++ b/sys/dev/ata/chipsets/ata-serverworks.c @@ -179,8 +179,6 @@ ata_serverworks_ch_attach(device_t dev) int ch_offset; int i; - ata_pci_dmainit(dev); - ch_offset = ch->unit * 0x100; for (i = ATA_DATA; i < ATA_MAX_RES; i++) @@ -245,6 +243,8 @@ ata_serverworks_ch_attach(device_t dev) /* chip does not reliably do 64K DMA transfers */ ch->dma.max_iosize = 64 * DEV_BSIZE; + ata_pci_dmainit(dev); + return 0; } diff --git a/sys/dev/ata/chipsets/ata-siliconimage.c b/sys/dev/ata/chipsets/ata-siliconimage.c index fa7619c..f06f646 100644 --- a/sys/dev/ata/chipsets/ata-siliconimage.c +++ b/sys/dev/ata/chipsets/ata-siliconimage.c @@ -289,8 +289,6 @@ ata_sii_ch_attach(device_t dev) int unit01 = (ch->unit & 1), unit10 = (ch->unit & 2); int i; - ata_pci_dmainit(dev); - for (i = ATA_DATA; i <= ATA_COMMAND; i++) { ch->r_io[i].res = ctlr->r_res2; ch->r_io[i].offset = 0x80 + i + (unit01 << 6) + (unit10 << 8); @@ -332,6 +330,9 @@ ata_sii_ch_attach(device_t dev) ch->hw.status = ata_sii_status; if (ctlr->chip->cfg2 & SII_SETCLK) ch->flags |= ATA_CHECKS_CABLE; + + ata_pci_dmainit(dev); + return 0; } @@ -915,11 +916,11 @@ ata_siiprb_dmainit(device_t dev) { struct ata_channel *ch = device_get_softc(dev); - ata_dmainit(dev); /* note start and stop are not used here */ ch->dma.setprd = ata_siiprb_dmasetprd; ch->dma.max_address = BUS_SPACE_MAXADDR; ch->dma.max_iosize = (ATA_SIIPRB_DMA_ENTRIES - 1) * PAGE_SIZE; + ata_dmainit(dev); } ATA_DECLARE_DRIVER(ata_sii); |