diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-09-08 12:01:14 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-09-08 17:30:24 -0700 |
commit | bb3207863014c7310593146f11fbc6573eab43c8 (patch) | |
tree | d54da64e459d28969cdd9250cadaaa581cbae43d /drivers/dma/ioat/dma.c | |
parent | 4fb9b9e8d55880523db550043dfb204696dd0422 (diff) | |
download | kernel_goldelico_gta04-bb3207863014c7310593146f11fbc6573eab43c8.zip kernel_goldelico_gta04-bb3207863014c7310593146f11fbc6573eab43c8.tar.gz kernel_goldelico_gta04-bb3207863014c7310593146f11fbc6573eab43c8.tar.bz2 |
ioat: ignore reserved bits for chancnt and xfercap
Don't trust that the reserved bits are always zero, also sanity check
the returned value.
Signed-off-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/ioat/dma.c')
-rw-r--r-- | drivers/dma/ioat/dma.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index 08417ad..5173ba9 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c @@ -132,7 +132,14 @@ static int ioat1_enumerate_channels(struct ioatdma_device *device) INIT_LIST_HEAD(&dma->channels); dma->chancnt = readb(device->reg_base + IOAT_CHANCNT_OFFSET); + dma->chancnt &= 0x1f; /* bits [4:0] valid */ + if (dma->chancnt > ARRAY_SIZE(device->idx)) { + dev_warn(dev, "(%d) exceeds max supported channels (%zu)\n", + dma->chancnt, ARRAY_SIZE(device->idx)); + dma->chancnt = ARRAY_SIZE(device->idx); + } xfercap_scale = readb(device->reg_base + IOAT_XFERCAP_OFFSET); + xfercap_scale &= 0x1f; /* bits [4:0] valid */ xfercap = (xfercap_scale == 0 ? -1 : (1UL << xfercap_scale)); dev_dbg(dev, "%s: xfercap = %d\n", __func__, xfercap); |