Commit c3da14474063e71686039d961d14785a9c2971ae

Authored by Stephen Hemminger
Committed by Jeff Garzik
1 parent cfc3ed796e

[PATCH] skge: check the allocation of ring buffer

The SysKonnect Genesis and Yukon chip sets have restrictions on the possible
control block area.  The memory needs to not cross 4 Gig boundary, and it needs
to be 8 byte aligned.  This patch checks and fails to bring the device up
if region is unacceptable.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

Showing 1 changed file with 9 additions and 1 deletions Side-by-side Diff

... ... @@ -727,7 +727,7 @@
727 727 * Allocate ring elements and chain them together
728 728 * One-to-one association of board descriptors with ring elements
729 729 */
730   -static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u64 base)
  730 +static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
731 731 {
732 732 struct skge_tx_desc *d;
733 733 struct skge_element *e;
... ... @@ -2167,6 +2167,14 @@
2167 2167 skge->mem = pci_alloc_consistent(hw->pdev, skge->mem_size, &skge->dma);
2168 2168 if (!skge->mem)
2169 2169 return -ENOMEM;
  2170 +
  2171 + BUG_ON(skge->dma & 7);
  2172 +
  2173 + if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) {
  2174 + printk(KERN_ERR PFX "pci_alloc_consistent region crosses 4G boundary\n");
  2175 + err = -EINVAL;
  2176 + goto free_pci_mem;
  2177 + }
2170 2178  
2171 2179 memset(skge->mem, 0, skge->mem_size);
2172 2180