Merge branch 'linus' into x86/i8259
[sfrench/cifs-2.6.git] / drivers / infiniband / hw / mthca / mthca_memfree.c
index 252db0822f6cbc2e8d1f092b6c9965aa102142ef..d5862e5d99a09ce89509976b9bdc5049e49e5b26 100644 (file)
@@ -109,7 +109,11 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m
 {
        struct page *page;
 
-       page = alloc_pages(gfp_mask, order);
+       /*
+        * Use __GFP_ZERO because buggy firmware assumes ICM pages are
+        * cleared, and subtle failures are seen if they aren't.
+        */
+       page = alloc_pages(gfp_mask | __GFP_ZERO, order);
        if (!page)
                return -ENOMEM;
 
@@ -359,12 +363,14 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
                                              int use_lowmem, int use_coherent)
 {
        struct mthca_icm_table *table;
+       int obj_per_chunk;
        int num_icm;
        unsigned chunk_size;
        int i;
        u8 status;
 
-       num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE;
+       obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size;
+       num_icm = DIV_ROUND_UP(nobj, obj_per_chunk);
 
        table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL);
        if (!table)
@@ -412,7 +418,7 @@ err:
                if (table->icm[i]) {
                        mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE,
                                        MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE,
-                                       &status);
+                                       &status);
                        mthca_free_icm(dev, table->icm[i], table->coherent);
                }