From patchwork Thu Mar 22 08:02:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10300931 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 6BF6960349 for ; Thu, 22 Mar 2018 08:02:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6224D26E76 for ; Thu, 22 Mar 2018 08:02:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 600DA289E5; Thu, 22 Mar 2018 08:02:51 +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 E680228A41 for ; Thu, 22 Mar 2018 08:02:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D97D6EB9A; Thu, 22 Mar 2018 08:02:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25CEF6EB9A for ; Thu, 22 Mar 2018 08:02:48 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id f125so14218342wme.4 for ; Thu, 22 Mar 2018 01:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id; bh=D8fHIMJCsYfSv7Wb4usjt3NS6Z0G6pyghoGbJfidNdQ=; b=c0kDsUddT4b7VPpxNuP0ebnleLiGXny2xfsl1k/BjqxG9aErRyTxv8N5DFIN/hVY0A xrVpoInHZsv+jxtcNC+2OM/E0SU+lbadR4TxY9AJ9mvJlKe3TA1Pr0UHuzHX4szT7tmJ TFn5v/SWSr/Eu4N8JHBlMBEuu9SoBBdHmW1Xg= 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=D8fHIMJCsYfSv7Wb4usjt3NS6Z0G6pyghoGbJfidNdQ=; b=tLmL18DGlMZzTd8Sr/YTi5UPGrBBCxuLbd0B9efq+XVZtg4wl833t1bB50RPZdFOwl yemNBHG3kW4xZE1KMWUHRClgsCB2cWZttVXqz04YLbW6CURgdEQhVQRF59qgXvcW1UC/ Xf/AZ39sZzPzk1YL3J0YqHSE7kXFGawzPnB3oOX1Fjg54OFuTFTUpmS8V2J5nZbhUQ48 MwkkXxtlG3WJ3U4BjceQ9QjDkGQVc2Mix7RoN+ay9BuAWQhoz018rqx9dN7B5nGhJZIc mPZ2dOmoTz06MdQZfoWFsK0dj3mSh2D7JW/l5wD7GcrzUs/knMQVxspm3G2gt9oGe2Nc XpCw== X-Gm-Message-State: AElRT7Ggb3cDfWTj7qlUxsQ5jKPeJJrRD2ofOMKstDe6ihbUGuW3EuKW G0jg6wGvT0ISpjETwXpg84+SdziD X-Google-Smtp-Source: AG47ELszcF0XWtlLP94ZlA6Q9+q4C02EA9EARsXOW6K/IDKLkqDP/qcPSBqi224dHzTUNsPBRVHpJA== X-Received: by 10.80.175.129 with SMTP id h1mr24118290edd.79.1521705766522; Thu, 22 Mar 2018 01:02:46 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id c56sm3205000eda.41.2018.03.22.01.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 01:02:45 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/gem: Document that handle_create must be the last step Date: Thu, 22 Mar 2018 09:02:33 +0100 Message-Id: <20180322080233.17266-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.16.2 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: , Cc: Daniel Vetter , Daniel Vetter , Oleksandr Andrushchenko MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP It published the gem object to userspace, by that point other threads can guess the id and start using it. And gem IDs are _very_ easy to guess (it's just an idr). Since gem objects is the only thing we allow drivers to create themselves (all the kms/prime/syncobj stuff is handled by the core) no other functions seem to be in need of this clarification. Motivated by reviewing the xen-front kms driver. Cc: Oleksandr Andrushchenko Signed-off-by: Daniel Vetter Reviewed-by: Oleksandr Andrushchenko --- drivers/gpu/drm/drm_gem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 4975ba9a7bc8..4a16d7b26c89 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -436,9 +436,12 @@ drm_gem_handle_create_tail(struct drm_file *file_priv, * @obj: object to register * @handlep: pionter to return the created handle to the caller * - * Create a handle for this object. This adds a handle reference - * to the object, which includes a regular reference count. Callers - * will likely want to dereference the object afterwards. + * Create a handle for this object. This adds a handle reference to the object, + * which includes a regular reference count. Callers will likely want to + * dereference the object afterwards. + * + * Since this publishes @obj to userspace it must be fully set up by this point, + * drivers must call this last in their buffer object creation callbacks. */ int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj,