From patchwork Wed Dec 12 13:07:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1867131 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id E85A63FC81 for ; Wed, 12 Dec 2012 14:36:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB37EE6620 for ; Wed, 12 Dec 2012 06:36:42 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 0621EE5D3F for ; Wed, 12 Dec 2012 05:15:34 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c4so430731eek.36 for ; Wed, 12 Dec 2012 05:15:34 -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=YPyr12Qo/FLI78ErftgzS5AionlVKSfBanqbcY7HM+4=; b=ICdoIdokYY1HTcDUSbaFy6pc03BIfn/ybK0Od0KfXIMcxzlVE2b6Cj5C7IiLvqc8Ho iv4t0F9be3r2k8QdI5hw3pSDD6pEZOYe3pT8lOdTShgHIAKvGQ+hAtA2pxNHP/NUIdGw PGjKo6nrRyBeV7rNHIbD9Rx5XzaPcDAanHOuk= 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=YPyr12Qo/FLI78ErftgzS5AionlVKSfBanqbcY7HM+4=; b=Jd6uRadNKbSmemH1wiQvn+oaayi5zNlZyV2ljC3gf2R+Ik5wizAxUOcUYTOo2RGchV oAwxKlmzYY/6NeKzZ9r5gjB/uoF2HfWXqOk8aav9sPeJfquWefi7LzxYHiYVr/E2kkka Z3Z77bkqo6wAL6nVNu6JVsjbK02IhnuKgD6gehIYiuHjUT++L1619cJAzcR3ZdUNflf4 iFoEQYBWTP3lguT67hLZG/5goaMfOT81QomkL8qbiw3Pi1J1DhgQ+Ncxkpg63fhHjjh9 A4sL1kVJhM0AcefCrhXACSHsQnf8i44qX5n1fLG9ac5i/yWqW6XmiTw0RqayE7UYqhxX kTqA== Received: by 10.14.174.198 with SMTP id x46mr2712250eel.23.1355317667498; Wed, 12 Dec 2012 05:07:47 -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.46 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 05:07:47 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 24/37] drm: push modeset_lock_all into ->fb_create driver callbacks Date: Wed, 12 Dec 2012 14:07:04 +0100 Message-Id: <1355317637-16742-25-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: ALoCoQkc2rBszvL7OPwJHI1EPPD++IoQwkw+tYwTJ0y0UdH20nWCH/+tYN5HCsxq7+rEELRYp40N Cc: Nouveau Dev , Intel Graphics Development , Radeon Dev , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org And drop it where it's not needed. Most driver just lookup the gem object, allocate an fb struct, fill in all the useful fields and then register it with drm_framebuffer_init. All of these operations are already separately locked, and since we only put the fb into the fpriv->fbs list _after_ having called ->fb_create, we can't also race with rmfb. We can otoh race with other ioctls that put the framebuffer to use, but all drivers have been reorganized already to call drm_framebuffer_init last in the fb creation sequence. So essentially, we can completely remove any modeset locks from the addfb ioctl paths. Yeah! Also, reference-counting is solid - we get a reference from fb_create which we transfer to the fpriv->fbs list. And after unlocking the fpriv->fbs_lock we don't touch the framebuffer any longer. Furthermore drm_framebuffer_init has added a 2nd reference for the idr lookup, and any access through that table will do it's own refcounting. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_crtc.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 33e95bb..9ad807d 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2255,18 +2255,12 @@ int drm_mode_addfb(struct drm_device *dev, if ((config->min_height > r.height) || (r.height > config->max_height)) return -EINVAL; - drm_modeset_lock_all(dev); - - /* TODO check buffer is sufficiently large */ - /* TODO setup destructor callback */ - fb = dev->mode_config.funcs->fb_create(dev, file_priv, &r); if (IS_ERR(fb)) { DRM_DEBUG_KMS("could not create framebuffer\n"); drm_modeset_unlock_all(dev); return PTR_ERR(fb); } - drm_modeset_unlock_all(dev); mutex_lock(&file_priv->fbs_lock); or->fb_id = fb->base.id; @@ -2441,15 +2435,12 @@ int drm_mode_addfb2(struct drm_device *dev, if (ret) return ret; - drm_modeset_lock_all(dev); - fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); if (IS_ERR(fb)) { DRM_DEBUG_KMS("could not create framebuffer\n"); drm_modeset_unlock_all(dev); return PTR_ERR(fb); } - drm_modeset_unlock_all(dev); mutex_lock(&file_priv->fbs_lock); r->fb_id = fb->base.id;