Skip to content

Commit

Permalink
swiotlb: add comment where we handle the overflow of a dma mask on 32…
Browse files Browse the repository at this point in the history
… bit

Impact: cleanup

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ian Campbell authored and Ingo Molnar committed Dec 17, 2008
1 parent 0016fde commit a5ddde4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
start_dma_addr = virt_to_bus(io_tlb_start) & mask;

offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;

/*
* Carefully handle integer overflow which can occur when mask == ~0UL.
*/
max_slots = mask + 1
? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT
: 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);
Expand Down

0 comments on commit a5ddde4

Please sign in to comment.