From patchwork Tue Mar 18 21:22:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 3849491 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73692BF540 for ; Tue, 18 Mar 2014 21:23:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AF5A2038F for ; Tue, 18 Mar 2014 21:23:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A91892038E for ; Tue, 18 Mar 2014 21:23:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F11826F648; Tue, 18 Mar 2014 14:23:40 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B1576FCA7 for ; Tue, 18 Mar 2014 14:23:39 -0700 (PDT) Received: by mail-qc0-f171.google.com with SMTP id c9so2842442qcz.30 for ; Tue, 18 Mar 2014 14:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cDxXUy+TAlDdx8xK5jmQxRb+D75LRMg3NamsRBEXlvY=; b=0W8xLhLo+iXy8kZKOsQO984WoRtchroFKobrpuhmofMOH1dwYAL4SP28bJT1+DG8dd h4X0mJOXDHFkH6AdsJn9nqyDZ2WvF5hAJJb5A2oFKYpkcCD93rlYvRmwctA0FVvEKknm Gq9TE80yu/l4eKzZlO0ntlPe4Fa5AHGP8qiv0VGDZB9JuKSZovT06RHYM+o/Dp3hLh79 Rwk2Me7NnsPDFbKp1QiWzzqrlf1qq+vjXOSbs2v7kt8DdhqmzOoE3tl4fPlC6Cr7bO03 KETWO4hU1W6N8QcEBNm82vhEk23EdgCyTHatA1N6Q4O3fRBNjRVxiqcIV3pLEBr+qcXR nGlQ== X-Received: by 10.140.49.207 with SMTP id q73mr5454048qga.103.1395177819060; Tue, 18 Mar 2014 14:23:39 -0700 (PDT) Received: from localhost (pool-108-20-254-15.bstnma.east.verizon.net. [108.20.254.15]) by mx.google.com with ESMTPSA id f3sm8612366qag.7.2014.03.18.14.23.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 14:23:38 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/16] drm: allow FB's in drm_mode_object_find Date: Tue, 18 Mar 2014 17:22:47 -0400 Message-Id: <1395177773-800-11-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395177773-800-1-git-send-email-robdclark@gmail.com> References: <1395177773-800-1-git-send-email-robdclark@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We do actually want to permit FB's in atomic case, since FB will be looked up like any other object property value in a few code paths (like property value validation). So split out into an internal function without the WARN_ON() which we can use in those special cases. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_crtc.c | 33 ++++++++++++++++++++++----------- include/drm/drm_crtc.h | 6 ------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d5a2469..fbe4b74 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -459,6 +459,21 @@ static void drm_mode_object_put(struct drm_device *dev, mutex_unlock(&dev->mode_config.idr_mutex); } +static struct drm_mode_object *_object_find(struct drm_device *dev, + uint32_t id, uint32_t type) +{ + struct drm_mode_object *obj = NULL; + + mutex_lock(&dev->mode_config.idr_mutex); + obj = idr_find(&dev->mode_config.crtc_idr, id); + if (!obj || (type != DRM_MODE_OBJECT_ANY && obj->type != type) || + (obj->id != id)) + obj = NULL; + mutex_unlock(&dev->mode_config.idr_mutex); + + return obj; +} + /** * drm_mode_object_find - look up a drm object with static lifetime * @dev: drm device @@ -471,23 +486,19 @@ static void drm_mode_object_put(struct drm_device *dev, struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type) { - struct drm_mode_object *obj = NULL; - /* Framebuffers are reference counted and need their own lookup * function.*/ WARN_ON(type == DRM_MODE_OBJECT_FB); - - mutex_lock(&dev->mode_config.idr_mutex); - obj = idr_find(&dev->mode_config.crtc_idr, id); - if (!obj || (type != DRM_MODE_OBJECT_ANY && obj->type != type) || - (obj->id != id)) - obj = NULL; - mutex_unlock(&dev->mode_config.idr_mutex); - - return obj; + return _object_find(dev, id, type); } EXPORT_SYMBOL(drm_mode_object_find); +static struct drm_mode_object * +drm_property_get_obj(struct drm_property *property, uint64_t value) +{ + return _object_find(property->dev, value, property->values[0]); +} + /** * drm_framebuffer_init - initialize a framebuffer * @dev: DRM device diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index ec21952..b8cd088 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1298,12 +1298,6 @@ extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type); -static inline struct drm_mode_object * -drm_property_get_obj(struct drm_property *property, uint64_t value) -{ - return drm_mode_object_find(property->dev, value, property->values[0]); -} - /* IOCTLs */ extern int drm_mode_getresources(struct drm_device *dev, void *data, struct drm_file *file_priv);