From patchwork Fri Sep 21 16:42:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10610719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FF1A913 for ; Fri, 21 Sep 2018 16:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 802DA2887A for ; Fri, 21 Sep 2018 16:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7081528994; Fri, 21 Sep 2018 16:43:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5CEE27480 for ; Fri, 21 Sep 2018 16:43:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA1F06E862; Fri, 21 Sep 2018 16:42:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAAC36E862 for ; Fri, 21 Sep 2018 16:42:57 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:36908 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1g3OW7-00013c-Uo; Fri, 21 Sep 2018 18:42:55 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [RFC 0/3] drm/gem: Add drm_gem_object_funcs Date: Fri, 21 Sep 2018 18:42:27 +0200 Message-Id: <20180921164230.51838-1-noralf@tronnes.org> X-Mailer: git-send-email 2.15.1 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi, I've found it odd that the GEM object has its callbacks on drm_driver and not a vtable of its own. But something being odd isn't enough to make a change (me thinks). After working on the GEM shmem helper I saw that a few drivers have runtime support for 2 memory types for their buffers (shmem,vram,cma). I have realised that if the shmem helper was self contained wrt the callbacks, it would be easier for these types of drivers to use the helper. All they needed to do was to determine the buffer type on GEM object creation time and let the helper handle the rest of the callbacks. No sure if this makes sense or if the approach is to simplistic. Hence the RFC. I've added a patch to give an example of how this would look for the CMA helper and vc4 (I'm not volunteering to refactor the CMA helper and drivers). Noralf. Noralf Trønnes (3): drm/driver: Add defaults for .gem_prime_export/import callbacks drm/gem: Add drm_gem_object_funcs drm/cma: Use drm_gem_object_funcs Documentation/gpu/todo.rst | 7 ++ drivers/gpu/drm/drm_client.c | 12 ++- drivers/gpu/drm/drm_fb_helper.c | 8 +- drivers/gpu/drm/drm_gem.c | 108 +++++++++++++++++++++++++-- drivers/gpu/drm/drm_gem_cma_helper.c | 99 +++++++++---------------- drivers/gpu/drm/drm_prime.c | 50 +++++++------ drivers/gpu/drm/vc4/vc4_bo.c | 46 ++++++------ drivers/gpu/drm/vc4/vc4_drv.c | 26 +------ drivers/gpu/drm/vc4/vc4_drv.h | 6 +- include/drm/drm_drv.h | 4 + include/drm/drm_gem.h | 138 +++++++++++++++++++++++++++++++++++ include/drm/drm_gem_cma_helper.h | 17 +---- 12 files changed, 350 insertions(+), 171 deletions(-)