From patchwork Thu Dec 7 03:01:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 10097579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37E7F602BF for ; Thu, 7 Dec 2017 03:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 204C12A0CF for ; Thu, 7 Dec 2017 03:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116B72A0EB; Thu, 7 Dec 2017 03:02:00 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 EB35A2A0CF for ; Thu, 7 Dec 2017 03:01:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0096A6E01B; Thu, 7 Dec 2017 03:01:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-it0-x244.google.com (mail-it0-x244.google.com [IPv6:2607:f8b0:4001:c0b::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id C32B26E01B for ; Thu, 7 Dec 2017 03:01:53 +0000 (UTC) Received: by mail-it0-x244.google.com with SMTP id o130so22781425itg.0 for ; Wed, 06 Dec 2017 19:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=fKNT6g6Dc+/5VSpJsJxBimud3YIaXDt1acaZV/0R58M=; b=Nizwkf5gvm0cUiX5Xb1umeZ9LovKKUiahYqRpd+F4j31B3nbNwvyzSx49UUwqR90id jeKEpyVW4AFwJnSHhIaEabfpOEPrzXFB+SvzGfsw+756gcHeRULXBPZyDbrEBcN0e+pN 7CuQGNDtWQFXj4ALQeu2Ek/qGIRMUmjcJCz10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fKNT6g6Dc+/5VSpJsJxBimud3YIaXDt1acaZV/0R58M=; b=KvYAQrAiPXt66dWyefmW6u+uIYuzEHxeDNpm2LI5nq8YwFTLsihmO1ffvPEyeSPsof jAizH5U84morfTerqyYFonE2FURsdl9bTTw+PP0DYiq6+e8/GKnB64wgxXrCW2Bwr7uO fnJPLeHeVV/fpExf9Wn+RUJoJtitvWJ5GfEAXoCYpf54+IA5cHSI7taF25esZ1R8Eddf jOv9kmCPLyanCzZkHb4/TUgGAuO5gm5CqVgqxD0HWbtvQ9hycjZzU4ZHBsp7QjBDPlT0 /eiLivtOAojFiDpBy/JAuG9V6jxKOHvEQAA/GoAbYX9C4l7tTyTZA9jIjQUXhxZsb1oA X7DA== X-Gm-Message-State: AJaThX5XdeT9iFoPFFvN2c6Nlth4fBnGmV6lYh8ogk7DhBZ8NIveVoiz zn5jbcbvRsUPclEa4yBNSDZFPBASdzQ= X-Google-Smtp-Source: AGs4zMb88xFi7vKa30xZ6e48kw7RD5MzO9HAjxecAhhZQqQi6BmSFgcFfL7GZ5fR4zoxWTzXx/zrJQ== X-Received: by 10.36.154.71 with SMTP id l68mr23791259ite.57.1512615712835; Wed, 06 Dec 2017 19:01:52 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:0:1000:1600:7073:55d4:f7c8:dd60]) by smtp.gmail.com with ESMTPSA id i63sm2294737itb.35.2017.12.06.19.01.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Dec 2017 19:01:51 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: add field in drm_framebuffer to identify internally owned fbs Date: Wed, 6 Dec 2017 19:01:42 -0800 Message-Id: <20171207030142.2954-1-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.13.5 Cc: Gurchetan Singh , laurent.pinchart@ideasonboard.com, daniel.vetter@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We create an internal framebuffer when using the legacy cursor ioctls, but using the legacy API, userspace has no way of freeing this resource. This patch introduces a field in struct drm_framebuffer to keep track of internally owned framebuffers. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/drm_crtc_internal.h | 3 ++- drivers/gpu/drm/drm_framebuffer.c | 7 +++++-- drivers/gpu/drm/drm_plane.c | 4 +++- include/drm/drm_framebuffer.h | 5 +++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 9ebb8841778c..338c583b3d60 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -153,7 +153,8 @@ int drm_mode_getconnector(struct drm_device *dev, struct drm_framebuffer * drm_internal_framebuffer_create(struct drm_device *dev, const struct drm_mode_fb_cmd2 *r, - struct drm_file *file_priv); + struct drm_file *file_priv, + bool internal); void drm_framebuffer_free(struct kref *kref); int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index d63d4c2ac4c8..bcd9d3004064 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -262,7 +262,8 @@ static int framebuffer_check(struct drm_device *dev, struct drm_framebuffer * drm_internal_framebuffer_create(struct drm_device *dev, const struct drm_mode_fb_cmd2 *r, - struct drm_file *file_priv) + struct drm_file *file_priv, + bool internal) { struct drm_mode_config *config = &dev->mode_config; struct drm_framebuffer *fb; @@ -300,6 +301,8 @@ drm_internal_framebuffer_create(struct drm_device *dev, return fb; } + fb->internal = internal; + return fb; } @@ -327,7 +330,7 @@ int drm_mode_addfb2(struct drm_device *dev, if (!drm_core_check_feature(dev, DRIVER_MODESET)) return -EINVAL; - fb = drm_internal_framebuffer_create(dev, r, file_priv); + fb = drm_internal_framebuffer_create(dev, r, file_priv, false); if (IS_ERR(fb)) return PTR_ERR(fb); diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 19404e34cd59..f2d1fba4c6d8 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -757,7 +757,9 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, */ if (req->flags & DRM_MODE_CURSOR_BO) { if (req->handle) { - fb = drm_internal_framebuffer_create(dev, &fbreq, file_priv); + fb = drm_internal_framebuffer_create(dev, &fbreq, + file_priv, + true); if (IS_ERR(fb)) { DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n"); return PTR_ERR(fb); diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h index dccb897951ba..7fe856d403c5 100644 --- a/include/drm/drm_framebuffer.h +++ b/include/drm/drm_framebuffer.h @@ -187,6 +187,11 @@ struct drm_framebuffer { */ int hot_y; /** + * @internal: Indicates the framebuffer was created internally and not + * as the result of the drm_mode_fb_cmd* ioctl. + */ + bool internal; + /** * @filp_head: Placed on &drm_file.fbs, protected by &drm_file.fbs_lock. */ struct list_head filp_head;