@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
317317 if (ttm_tt_is_populated (ttm ))
318318 return 0 ;
319319
320- atomic_long_add (ttm -> num_pages , & ttm_pages_allocated );
321- if (bdev -> pool .use_dma32 )
322- atomic_long_add (ttm -> num_pages , & ttm_dma32_pages_allocated );
320+ if (!(ttm -> page_flags & TTM_PAGE_FLAG_SG )) {
321+ atomic_long_add (ttm -> num_pages , & ttm_pages_allocated );
322+ if (bdev -> pool .use_dma32 )
323+ atomic_long_add (ttm -> num_pages ,
324+ & ttm_dma32_pages_allocated );
325+ }
323326
324327 while (atomic_long_read (& ttm_pages_allocated ) > ttm_pages_limit ||
325328 atomic_long_read (& ttm_dma32_pages_allocated ) >
@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
350353 return 0 ;
351354
352355error :
353- atomic_long_sub (ttm -> num_pages , & ttm_pages_allocated );
354- if (bdev -> pool .use_dma32 )
355- atomic_long_sub (ttm -> num_pages , & ttm_dma32_pages_allocated );
356+ if (!(ttm -> page_flags & TTM_PAGE_FLAG_SG )) {
357+ atomic_long_sub (ttm -> num_pages , & ttm_pages_allocated );
358+ if (bdev -> pool .use_dma32 )
359+ atomic_long_sub (ttm -> num_pages ,
360+ & ttm_dma32_pages_allocated );
361+ }
356362 return ret ;
357363}
358364EXPORT_SYMBOL (ttm_tt_populate );
@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)
382388 else
383389 ttm_pool_free (& bdev -> pool , ttm );
384390
385- atomic_long_sub (ttm -> num_pages , & ttm_pages_allocated );
386- if (bdev -> pool .use_dma32 )
387- atomic_long_sub (ttm -> num_pages , & ttm_dma32_pages_allocated );
391+ if (!(ttm -> page_flags & TTM_PAGE_FLAG_SG )) {
392+ atomic_long_sub (ttm -> num_pages , & ttm_pages_allocated );
393+ if (bdev -> pool .use_dma32 )
394+ atomic_long_sub (ttm -> num_pages ,
395+ & ttm_dma32_pages_allocated );
396+ }
388397
389398 ttm -> page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED ;
390399}
0 commit comments