From patchwork Wed Sep 18 14:22:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 11150449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95B171745 for ; Wed, 18 Sep 2019 14:23:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E66F2196E for ; Wed, 18 Sep 2019 14:23:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E66F2196E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68A836F3B4; Wed, 18 Sep 2019 14:23:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 47BEA6F3B4 for ; Wed, 18 Sep 2019 14:23:14 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 05B47B67C; Wed, 18 Sep 2019 14:23:11 +0000 (UTC) From: Thomas Zimmermann To: airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, sam@ravnborg.org, yc_chen@aspeedtech.com, corbet@lwn.net Subject: [PATCH 00/11] drm/vram: Add VRAM buffers for HW cursors Date: Wed, 18 Sep 2019 16:22:56 +0200 Message-Id: <20190918142307.27127-1-tzimmermann@suse.de> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patchset adds dedicated VRAM buffers and cleans up the memory management of HW cursors in ast and mgag200. The ast and mgag200 drivers support HW cursors of uncommon pixel formats. Both drivers manage cursor memory in dedicated GEM VRAM buffer objects with a double buffering scheme; either by alternating between two GEM BOs, or by alternating between offsets within the same GEM BO. The code is convoluted and can lead to memory fragmentation if the BO is stored the middle of VRAM. This is especially a problem on devices with only a small amount of video memory. This patchset introduces VRAM buffers, a simple data structure that manages dedicated areas of VRAM. The VRAM buffer supports double- buffering (or more) to allow for flicker-free updates. A typical use case is in managing small, static buffers, such as cursors or sprites. The patchset then cleans up cursor memory management in ast and mgag200. To avoid the fragmentation issue, at the high end of each device's VRAM, a few KiB are reserved for the HW cursor. This memory is maintained by a double-buffered VRAM buffer. For updating the cursor image, each driver's cursor_set() functions fills the current back buffer and then makes it the front buffer. The patchset has been tested on ast and mgag200 hardware. Thomas Zimmermann (11): drm/vram: Add struct drm_vram_buffer to VRAM helpers drm/ast: Don't call ast_show_cursor() from ast_cursor_move() drm/ast: Move cursor update code to ast_show_cursor() drm/ast: Reserve space for double-buffered cursor image drm/ast: Store cursor in reserved memory area drm/mgag200: Rename cursor functions to use mgag200_ prefix drm/mgag200: Add init and fini functions for cursor handling drm/mgag200: Add separate move-cursor function drm/mgag200: Move cursor-image update to mgag200_show_cursor() drm/mgag200: Reserve video memory for cursor plane drm/mgag200: Implement cursor buffer with struct drm_vram_buffer Documentation/gpu/drm-mm.rst | 19 +- drivers/gpu/drm/ast/ast_drv.h | 5 +- drivers/gpu/drm/ast/ast_mode.c | 198 +++++++++-------- drivers/gpu/drm/ast/ast_ttm.c | 13 +- drivers/gpu/drm/drm_vram_helper_common.c | 259 ++++++++++++++++++++++- drivers/gpu/drm/mgag200/mgag200_cursor.c | 252 +++++++++++----------- drivers/gpu/drm/mgag200/mgag200_drv.h | 24 +-- drivers/gpu/drm/mgag200/mgag200_main.c | 20 +- drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +- drivers/gpu/drm/mgag200/mgag200_ttm.c | 15 +- include/drm/drm_vram_helper.h | 64 ++++++ 11 files changed, 607 insertions(+), 268 deletions(-) create mode 100644 include/drm/drm_vram_helper.h --- 2.23.0