mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-19 13:44:03 +00:00
nouveau: use ttm populate mapping functions. (v2)
Instead of rolling driver copies of them. v2: cleanup return handling (Ben) Reviewed-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-4-airlied@gmail.com
This commit is contained in:
parent
a2d6ddc417
commit
bd549d35b4
1 changed files with 2 additions and 36 deletions
|
@ -1526,8 +1526,6 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
|
||||||
struct ttm_dma_tt *ttm_dma = (void *)ttm;
|
struct ttm_dma_tt *ttm_dma = (void *)ttm;
|
||||||
struct nouveau_drm *drm;
|
struct nouveau_drm *drm;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
unsigned i;
|
|
||||||
int r;
|
|
||||||
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
|
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
|
||||||
|
|
||||||
if (ttm->state != tt_unpopulated)
|
if (ttm->state != tt_unpopulated)
|
||||||
|
@ -1555,31 +1553,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
|
||||||
return ttm_dma_populate((void *)ttm, dev, ctx);
|
return ttm_dma_populate((void *)ttm, dev, ctx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return ttm_populate_and_map_pages(dev, ttm_dma, ctx);
|
||||||
r = ttm_pool_populate(ttm, ctx);
|
|
||||||
if (r) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ttm->num_pages; i++) {
|
|
||||||
dma_addr_t addr;
|
|
||||||
|
|
||||||
addr = dma_map_page(dev, ttm->pages[i], 0, PAGE_SIZE,
|
|
||||||
DMA_BIDIRECTIONAL);
|
|
||||||
|
|
||||||
if (dma_mapping_error(dev, addr)) {
|
|
||||||
while (i--) {
|
|
||||||
dma_unmap_page(dev, ttm_dma->dma_address[i],
|
|
||||||
PAGE_SIZE, DMA_BIDIRECTIONAL);
|
|
||||||
ttm_dma->dma_address[i] = 0;
|
|
||||||
}
|
|
||||||
ttm_pool_unpopulate(ttm);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ttm_dma->dma_address[i] = addr;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1588,7 +1562,6 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
|
||||||
struct ttm_dma_tt *ttm_dma = (void *)ttm;
|
struct ttm_dma_tt *ttm_dma = (void *)ttm;
|
||||||
struct nouveau_drm *drm;
|
struct nouveau_drm *drm;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
unsigned i;
|
|
||||||
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
|
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
|
||||||
|
|
||||||
if (slave)
|
if (slave)
|
||||||
|
@ -1611,14 +1584,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < ttm->num_pages; i++) {
|
ttm_unmap_and_unpopulate_pages(dev, ttm_dma);
|
||||||
if (ttm_dma->dma_address[i]) {
|
|
||||||
dma_unmap_page(dev, ttm_dma->dma_address[i], PAGE_SIZE,
|
|
||||||
DMA_BIDIRECTIONAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ttm_pool_unpopulate(ttm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue