[PATCH 02 of 33] IB/ipath - fix user memory region creation when IOMMU present

2007-03-15 Thread Bryan O'Sullivan
# HG changeset patch
# User Bryan O'Sullivan <[EMAIL PROTECTED]>
# Date 1173994464 25200
# Node ID 3337d450afeebc553a09fe5c18ed0b2444547c24
# Parent  b1d05f3486f8bba1dd3c5cbca39f06a5e1b3d6fb
IB/ipath - fix user memory region creation when IOMMU present

The loop which initializes the user memory region from an array
of pages was using the wrong limit for the array.  This worked
OK when dma_map_sg() returned the same number as the number of pages.
This patch fixes the problem.

Signed-off-by: Ralph Campbell <[EMAIL PROTECTED]>
Signed-off-by: Bryan O'Sullivan <[EMAIL PROTECTED]>

diff -r b1d05f3486f8 -r 3337d450afee drivers/infiniband/hw/ipath/ipath_mr.c
--- a/drivers/infiniband/hw/ipath/ipath_mr.cThu Mar 15 14:34:24 2007 -0700
+++ b/drivers/infiniband/hw/ipath/ipath_mr.cThu Mar 15 14:34:24 2007 -0700
@@ -210,9 +210,15 @@ struct ib_mr *ipath_reg_user_mr(struct i
m = 0;
n = 0;
list_for_each_entry(chunk, >chunk_list, list) {
-   for (i = 0; i < chunk->nmap; i++) {
-   mr->mr.map[m]->segs[n].vaddr =
-   page_address(chunk->page_list[i].page);
+   for (i = 0; i < chunk->nents; i++) {
+   void *vaddr;
+
+   vaddr = page_address(chunk->page_list[i].page);
+   if (!vaddr) {
+   ret = ERR_PTR(-EINVAL);
+   goto bail;
+   }
+   mr->mr.map[m]->segs[n].vaddr = vaddr;
mr->mr.map[m]->segs[n].length = region->page_size;
n++;
if (n == IPATH_SEGSZ) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02 of 33] IB/ipath - fix user memory region creation when IOMMU present

2007-03-15 Thread Bryan O'Sullivan
# HG changeset patch
# User Bryan O'Sullivan [EMAIL PROTECTED]
# Date 1173994464 25200
# Node ID 3337d450afeebc553a09fe5c18ed0b2444547c24
# Parent  b1d05f3486f8bba1dd3c5cbca39f06a5e1b3d6fb
IB/ipath - fix user memory region creation when IOMMU present

The loop which initializes the user memory region from an array
of pages was using the wrong limit for the array.  This worked
OK when dma_map_sg() returned the same number as the number of pages.
This patch fixes the problem.

Signed-off-by: Ralph Campbell [EMAIL PROTECTED]
Signed-off-by: Bryan O'Sullivan [EMAIL PROTECTED]

diff -r b1d05f3486f8 -r 3337d450afee drivers/infiniband/hw/ipath/ipath_mr.c
--- a/drivers/infiniband/hw/ipath/ipath_mr.cThu Mar 15 14:34:24 2007 -0700
+++ b/drivers/infiniband/hw/ipath/ipath_mr.cThu Mar 15 14:34:24 2007 -0700
@@ -210,9 +210,15 @@ struct ib_mr *ipath_reg_user_mr(struct i
m = 0;
n = 0;
list_for_each_entry(chunk, region-chunk_list, list) {
-   for (i = 0; i  chunk-nmap; i++) {
-   mr-mr.map[m]-segs[n].vaddr =
-   page_address(chunk-page_list[i].page);
+   for (i = 0; i  chunk-nents; i++) {
+   void *vaddr;
+
+   vaddr = page_address(chunk-page_list[i].page);
+   if (!vaddr) {
+   ret = ERR_PTR(-EINVAL);
+   goto bail;
+   }
+   mr-mr.map[m]-segs[n].vaddr = vaddr;
mr-mr.map[m]-segs[n].length = region-page_size;
n++;
if (n == IPATH_SEGSZ) {
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/