summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2005-12-05 22:31:55 +0000
committersos <sos@FreeBSD.org>2005-12-05 22:31:55 +0000
commita35284f0f57f93a7260383e3f0f0eb546e54b4c2 (patch)
tree77ac7c1ac5479936f312bc0d8ba073c2123178d4 /sys
parentaa9c5f3cddee28919e68f86222476ba0e47fb54e (diff)
downloadFreeBSD-src-a35284f0f57f93a7260383e3f0f0eb546e54b4c2.zip
FreeBSD-src-a35284f0f57f93a7260383e3f0f0eb546e54b4c2.tar.gz
Dont use the BUS_DMA_ALLOCNOW flag. Instead use BUS_DMA_NOWAIT and return
ENOMEM to the upper layers if we run out of memory. This solves part of the trouble with running on >4GB memory systems.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ata/ata-dma.c18
-rw-r--r--sys/dev/ata/ata-lowlevel.c16
2 files changed, 19 insertions, 15 deletions
diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c
index 2526fcc..2d3d6b2 100644
--- a/sys/dev/ata/ata-dma.c
+++ b/sys/dev/ata/ata-dma.c
@@ -115,7 +115,7 @@ ata_dmaalloc(device_t dev)
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
NULL, NULL, ch->dma->max_iosize,
ATA_DMA_ENTRIES, ch->dma->segsize,
- BUS_DMA_ALLOCNOW, NULL, NULL, &ch->dma->data_tag))
+ 0, NULL, NULL, &ch->dma->data_tag))
goto error;
if (bus_dmamem_alloc(ch->dma->sg_tag, (void **)&ch->dma->sg, 0,
@@ -223,31 +223,33 @@ ata_dmaload(device_t dev, caddr_t data, int32_t count, int dir,
{
struct ata_channel *ch = device_get_softc(dev);
struct ata_dmasetprd_args cba;
+ int error;
if (ch->dma->flags & ATA_DMA_LOADED) {
device_printf(dev, "FAILURE - already active DMA on this device\n");
- return -1;
+ return EIO;
}
if (!count) {
device_printf(dev, "FAILURE - zero length DMA transfer attempted\n");
- return -1;
+ return EIO;
}
if (((uintptr_t)data & (ch->dma->alignment - 1)) ||
(count & (ch->dma->alignment - 1))) {
device_printf(dev, "FAILURE - non aligned DMA transfer attempted\n");
- return -1;
+ return EIO;
}
if (count > ch->dma->max_iosize) {
device_printf(dev, "FAILURE - oversized DMA transfer attempt %d > %d\n",
count, ch->dma->max_iosize);
- return -1;
+ return EIO;
}
cba.dmatab = addr;
- if (bus_dmamap_load(ch->dma->data_tag, ch->dma->data_map, data, count,
- ch->dma->setprd, &cba, 0) || cba.error)
- return -1;
+ if ((error = bus_dmamap_load(ch->dma->data_tag, ch->dma->data_map,
+ data, count, ch->dma->setprd, &cba,
+ BUS_DMA_NOWAIT)) || (error = cba.error))
+ return error;
*entries = cba.nsegs;
diff --git a/sys/dev/ata/ata-lowlevel.c b/sys/dev/ata/ata-lowlevel.c
index 8ece605..2e79ae0 100644
--- a/sys/dev/ata/ata-lowlevel.c
+++ b/sys/dev/ata/ata-lowlevel.c
@@ -73,7 +73,7 @@ ata_begin_transaction(struct ata_request *request)
{
struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
struct ata_device *atadev = device_get_softc(request->dev);
- int dummy;
+ int dummy, error;
ATA_DEBUG_RQ(request, "begin transaction");
@@ -130,10 +130,11 @@ ata_begin_transaction(struct ata_request *request)
/* ATA DMA data transfer commands */
case ATA_R_DMA:
/* check sanity, setup SG list and DMA engine */
- if (ch->dma->load(ch->dev, request->data, request->bytecount,
- request->flags & ATA_R_READ, ch->dma->sg, &dummy)) {
+ if ((error = ch->dma->load(ch->dev, request->data, request->bytecount,
+ request->flags & ATA_R_READ, ch->dma->sg,
+ &dummy))) {
device_printf(request->dev, "setting up DMA failed\n");
- request->result = EIO;
+ request->result = error;
goto begin_finished;
}
@@ -184,10 +185,11 @@ ata_begin_transaction(struct ata_request *request)
}
/* check sanity, setup SG list and DMA engine */
- if (ch->dma->load(ch->dev, request->data, request->bytecount,
- request->flags & ATA_R_READ, ch->dma->sg, &dummy)) {
+ if ((error = ch->dma->load(ch->dev, request->data, request->bytecount,
+ request->flags & ATA_R_READ, ch->dma->sg,
+ &dummy))) {
device_printf(request->dev, "setting up DMA failed\n");
- request->result = EIO;
+ request->result = error;
goto begin_finished;
}
OpenPOWER on IntegriCloud