浏览代码

powerpc/swiotlb: Fix off by one in determining boundary of which ops to use

When we compare the devices DMA mask to the amount of memory we need to
make sure we treat the DMA mask as an address boundary.  For example if
the DMA_MASK(32) and we have 4G of memory we'd incorrectly set the dma
ops to swiotlb.  We need to add one to the dma mask when we convert it.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Kumar Gala 15 年之前
父节点
当前提交
b8b14c6676
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      arch/powerpc/kernel/dma-swiotlb.c

+ 3 - 2
arch/powerpc/kernel/dma-swiotlb.c

@@ -1,7 +1,8 @@
 /*
 /*
  * Contains routines needed to support swiotlb for ppc.
  * Contains routines needed to support swiotlb for ppc.
  *
  *
- * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor
+ * Copyright (C) 2009-2010 Freescale Semiconductor, Inc.
+ * Author: Becky Bruce
  *
  *
  * This program is free software; you can redistribute  it and/or modify it
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
  * under  the terms of  the GNU General  Public License as published by the
@@ -70,7 +71,7 @@ static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
 	sd->max_direct_dma_addr = 0;
 	sd->max_direct_dma_addr = 0;
 
 
 	/* May need to bounce if the device can't address all of DRAM */
 	/* May need to bounce if the device can't address all of DRAM */
-	if (dma_get_mask(dev) < lmb_end_of_DRAM())
+	if ((dma_get_mask(dev) + 1) < lmb_end_of_DRAM())
 		set_dma_ops(dev, &swiotlb_dma_ops);
 		set_dma_ops(dev, &swiotlb_dma_ops);
 
 
 	return NOTIFY_DONE;
 	return NOTIFY_DONE;