drm/ast: Replace mapping code with drm_gem_vram_{kmap/kunmap}()

The AST driver establishes several memory mappings for frame buffers
and cursors. This patch converts the driver to use the equivalent
drm_gem_vram_kmap() functions. It removes the dependencies on TTM
and cleans up the code.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20190508082630.15116-12-tzimmermann@suse.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Thomas Zimmermann
2019-05-08 10:26:21 +02:00
committed by Gerd Hoffmann
parent 969562b2cd
commit 3f87330e50
3 changed files with 54 additions and 26 deletions

View File

@@ -53,6 +53,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
int src_offset, dst_offset;
int bpp = afbdev->afb.base.format->cpp[0];
int ret = -EBUSY;
u8 *dst;
bool unmap = false;
bool store_for_later = false;
int x2, y2;
@@ -101,27 +102,31 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
afbdev->x2 = afbdev->y2 = 0;
spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
if (!gbo->kmap.virtual) {
ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, &gbo->kmap);
if (ret) {
dst = drm_gem_vram_kmap(gbo, false, NULL);
if (IS_ERR(dst)) {
DRM_ERROR("failed to kmap fb updates\n");
goto out;
} else if (!dst) {
dst = drm_gem_vram_kmap(gbo, true, NULL);
if (IS_ERR(dst)) {
DRM_ERROR("failed to kmap fb updates\n");
drm_gem_vram_unreserve(gbo);
return;
goto out;
}
unmap = true;
}
for (i = y; i <= y2; i++) {
/* assume equal stride for now */
src_offset = dst_offset =
i * afbdev->afb.base.pitches[0] + (x * bpp);
memcpy_toio(gbo->kmap.virtual + src_offset,
afbdev->sysram + dst_offset,
memcpy_toio(dst + dst_offset, afbdev->sysram + src_offset,
(x2 - x + 1) * bpp);
}
if (unmap)
ttm_bo_kunmap(&gbo->kmap);
if (unmap)
drm_gem_vram_kunmap(gbo);
out:
drm_gem_vram_unreserve(gbo);
}