From patchwork Wed Dec 12 13:07:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1866411 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D29BDF2EE for ; Wed, 12 Dec 2012 13:57:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 09622E65B0 for ; Wed, 12 Dec 2012 05:57:58 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id ECB3FE6533 for ; Wed, 12 Dec 2012 05:13:09 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c4so428805eek.36 for ; Wed, 12 Dec 2012 05:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=4NFobEy99Z+btWqVvholDcp8jmyBkNOt/27dxPMhbGs=; b=DoacsWAhA39Ub7ntxAFCoJtjipMO1pCJNgen2b6PoVW4NgBdb0dNz6BWAhdmbU6rYO VCMM94SG9KVzhtEWco7ixEw0019iA2vlkMdjN6YPT7bfUUl5BZNpbTKO3WIPYZTAzVYX JjzHxKwWisiWzlPZwpKcxODwoR4SJL1CPZb5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=4NFobEy99Z+btWqVvholDcp8jmyBkNOt/27dxPMhbGs=; b=jcW+kWec5MULwBRe3Dc6CVXmeoZ9617W0ZoOWDNTQxFaZjvO/cNbc5bw6f8SCv2skf 6tdNX0Oi3r/f3cMfV2+t1BTi9/RFzLZOinBaDEjEPqF8EYPEKh8Y2uKvi/NIQIGcn4NK 5w6rDa22LMLK2W4zfq/JwecRYswD1ryw10jiEDcYE5ndJpV3bUf3mNrOlJEaBh2P8tpH siMuvCwqGBYTzPy38QB6M7LB8IW4fSWopB+q/cvif5//gS9XnEMN6pJ/ie9BIu+9SOYB deSwogchI1VIXvPrvKqvqyp475qHb3YCbf0LHBoW3gZNEW+JGW6tAEteD2N07KYTapL5 P5Xg== Received: by 10.14.2.66 with SMTP id 42mr2486961eee.7.1355317668514; Wed, 12 Dec 2012 05:07:48 -0800 (PST) Received: from biers.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id r1sm55868541eeo.2.2012.12.12.05.07.47 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 05:07:47 -0800 (PST) From: Daniel Vetter To: DRI Development Date: Wed, 12 Dec 2012 14:07:05 +0100 Message-Id: <1355317637-16742-26-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355317637-16742-1-git-send-email-daniel.vetter@ffwll.ch> References: <1355317637-16742-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQkmw6VR/QfmiJeG91AfceVO8+QoOWQhTsV2KyJJQpCqQbQC7lkbUSG4zVqoXi4sdCD/m3Dw Cc: Nouveau Dev , Intel Graphics Development , Radeon Dev , Daniel Vetter Subject: [Intel-gfx] [PATCH 25/37] drm: don't take modeset locks in getfb ioctl X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org We only need to push the fb unreference a bit down. While at it, properly pass the return value from ->create_handle back to userspace. Most drivers either return -ENODEV if they don't have a concept of buffer objects (ast, cirrus, ...) or just install a handle for the underlying gem object (which is ok since we hold a reference on that through the framebuffer). But a few drivers needed tiny fixups: - cirrus/ast/mga200: Return a consistent -ENODEV to signal to userspace that these drivers don't bother with implementing the ->create_handle callback, since it's rather pointless for them to do so with no accel support. - udl: Didn't even bother with a callback, leading to a nice userspace-triggerable OOPS. Nice work. Fix this up and return -ENODEV like the other simple drivers. It could be somewhat useful to implement the real ->create_handle since udl buffers could be used with prime, but alas ... - vmwgfx: This driver bothered with an implementation to return 0 as the handle (which is the canonical nofb handle). Dunno what this is for, but I've lost myself in vmwgfx too often. Just leave this as-is. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/ast/ast_main.c | 2 +- drivers/gpu/drm/cirrus/cirrus_main.c | 2 +- drivers/gpu/drm/drm_crtc.c | 17 ++++++----------- drivers/gpu/drm/mgag200/mgag200_main.c | 2 +- drivers/gpu/drm/udl/udl_fb.c | 9 ++++++++- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index d5ba709..a94f13e 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -250,7 +250,7 @@ static int ast_user_framebuffer_create_handle(struct drm_framebuffer *fb, struct drm_file *file, unsigned int *handle) { - return -EINVAL; + return -ENODEV; } static const struct drm_framebuffer_funcs ast_fb_funcs = { diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c index 2eac87b..e9de084 100644 --- a/drivers/gpu/drm/cirrus/cirrus_main.c +++ b/drivers/gpu/drm/cirrus/cirrus_main.c @@ -27,7 +27,7 @@ static int cirrus_user_framebuffer_create_handle(struct drm_framebuffer *fb, struct drm_file *file_priv, unsigned int *handle) { - return 0; + return -NODEV; } static const struct drm_framebuffer_funcs cirrus_fb_funcs = { diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 9ad807d..28838cf 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2526,29 +2526,24 @@ int drm_mode_getfb(struct drm_device *dev, { struct drm_mode_fb_cmd *r = data; struct drm_framebuffer *fb; - int ret = 0; + int ret; if (!drm_core_check_feature(dev, DRIVER_MODESET)) return -EINVAL; - drm_modeset_lock_all(dev); fb = drm_framebuffer_lookup(dev, r->fb_id); - if (!fb) { - ret = -EINVAL; - goto out; - } - /* fb is protect by the mode_config lock, so drop the ref immediately */ - drm_framebuffer_unreference(fb); + if (!fb) + return -EINVAL; r->height = fb->height; r->width = fb->width; r->depth = fb->depth; r->bpp = fb->bits_per_pixel; r->pitch = fb->pitches[0]; - fb->funcs->create_handle(fb, file_priv, &r->handle); + ret = fb->funcs->create_handle(fb, file_priv, &r->handle); + + drm_framebuffer_unreference(fb); -out: - drm_modeset_unlock_all(dev); return ret; } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 266438a..90fd681 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -27,7 +27,7 @@ static int mga_user_framebuffer_create_handle(struct drm_framebuffer *fb, struct drm_file *file_priv, unsigned int *handle) { - return 0; + return -ENODEV; } static const struct drm_framebuffer_funcs mga_fb_funcs = { diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index c09c04e..cb61ff7 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -419,10 +419,17 @@ static void udl_user_framebuffer_destroy(struct drm_framebuffer *fb) kfree(ufb); } +static int udl_user_framebuffer_create_handle(struct drm_framebuffer *fb, + struct drm_file *file_priv, + unsigned int *handle) +{ + return -ENODEV; +} + static const struct drm_framebuffer_funcs udlfb_funcs = { .destroy = udl_user_framebuffer_destroy, .dirty = udl_user_framebuffer_dirty, - .create_handle = NULL, + .create_handle = udl_user_framebuffer_create_handle, };