diff options
Diffstat (limited to 'drivers/net/mlx4/icm.c')
-rw-r--r-- | drivers/net/mlx4/icm.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 57288ca1395f..b07e4dee80aa 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
@@ -163,28 +163,30 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages, | |||
163 | ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages], | 163 | ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages], |
164 | cur_order, gfp_mask); | 164 | cur_order, gfp_mask); |
165 | 165 | ||
166 | if (!ret) { | 166 | if (ret) { |
167 | ++chunk->npages; | 167 | if (--cur_order < 0) |
168 | 168 | goto fail; | |
169 | if (coherent) | 169 | else |
170 | ++chunk->nsg; | 170 | continue; |
171 | else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { | 171 | } |
172 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | ||
173 | chunk->npages, | ||
174 | PCI_DMA_BIDIRECTIONAL); | ||
175 | 172 | ||
176 | if (chunk->nsg <= 0) | 173 | ++chunk->npages; |
177 | goto fail; | ||
178 | 174 | ||
179 | chunk = NULL; | 175 | if (coherent) |
180 | } | 176 | ++chunk->nsg; |
177 | else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { | ||
178 | chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, | ||
179 | chunk->npages, | ||
180 | PCI_DMA_BIDIRECTIONAL); | ||
181 | 181 | ||
182 | npages -= 1 << cur_order; | 182 | if (chunk->nsg <= 0) |
183 | } else { | ||
184 | --cur_order; | ||
185 | if (cur_order < 0) | ||
186 | goto fail; | 183 | goto fail; |
187 | } | 184 | } |
185 | |||
186 | if (chunk->npages == MLX4_ICM_CHUNK_LEN) | ||
187 | chunk = NULL; | ||
188 | |||
189 | npages -= 1 << cur_order; | ||
188 | } | 190 | } |
189 | 191 | ||
190 | if (!coherent && chunk) { | 192 | if (!coherent && chunk) { |