We need to use post-decrement to get the dma_map_page undone also for i==0, and to avoid some very unpleasant behaviour if dma_map_page failed already at i==0.
Unified · Split
| @@ -1520,7 +1520,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) · 1519 unmodified lines | ||
| 1520 | 1520 | DMA_BIDIRECTIONAL); |
| 1521 | 1521 | |
| 1522 | 1522 | if (dma_mapping_error(pdev, addr)) { |
| 1523 | − while (--i) { | |
| 1523 | + while (i--) { | |
| 1524 | 1524 | dma_unmap_page(pdev, ttm_dma->dma_address[i], |
| 1525 | 1525 | PAGE_SIZE, DMA_BIDIRECTIONAL); |
| 1526 | 1526 | ttm_dma->dma_address[i] = 0; |