From patchwork Mon Jul 1 18:32:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2809101 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D52BC9F3C3 for ; Mon, 1 Jul 2013 18:35:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E27C20118 for ; Mon, 1 Jul 2013 18:35:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4112F20115 for ; Mon, 1 Jul 2013 18:35:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50FC4E60D3 for ; Mon, 1 Jul 2013 11:35:15 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) by gabe.freedesktop.org (Postfix) with ESMTP id 90E21E5CB7 for ; Mon, 1 Jul 2013 11:33:22 -0700 (PDT) Received: by mail-bk0-f51.google.com with SMTP id ji1so1896255bkc.38 for ; Mon, 01 Jul 2013 11:33:21 -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:x-mailer:in-reply-to:references; bh=A+hatuEc0fABVqnNr3x+2HcSlz4mfik4DMn/rr4zt6g=; b=jJCihTZ/eKkS8IhN92GhvYHfQy5woTpeQdbkcL0OM/RwkB0mJb42JkYhnktAGE4wrK WMYryTVovMPE7CSMt6hA2sWY15ab9MCsg083j96RygLhGOEEuegWDQ4eUBwcAUuPGScx MJhk7dnC7g+nrcvFfFAo862sJIqCM6UxMZiskvM/uYkjBZMHx9xhKwqxCywprQS349fz xRQ7jJh8189FdaPNa01iwpqmzNWtwshKkCPR39y2N9O/YEiVjU/IXKzdrfmJ6tN58sE0 LmfOKMYUcCnYqmfegAwDHVQi9j05NS9Ew6f8Sq87IEs5QewKxLvkUDZonuFrvEqV9qX/ xi5A== X-Received: by 10.205.8.202 with SMTP id ot10mr3409976bkb.21.1372703601798; Mon, 01 Jul 2013 11:33:21 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71ba80.pool.mediaWays.net. [95.113.186.128]) by mx.google.com with ESMTPSA id qw6sm9456670bkb.4.2013.07.01.11.33.20 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jul 2013 11:33:21 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm: mm: add drm_mm_node_linked() helper Date: Mon, 1 Jul 2013 20:32:59 +0200 Message-Id: <1372703583-9550-3-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1372703583-9550-1-git-send-email-dh.herrmann@gmail.com> References: <1372703583-9550-1-git-send-email-dh.herrmann@gmail.com> Cc: Dave Airlie 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 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, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This helper tests whether a given node is currently linked into a drm_mm manager. We use the node->mm pointer for that as it is set for all linked objects. We also reset node->mm whenever a node is removed. All such access is currently safe as everyone calls kfree() on the object directly after removing it. Furthermore, no-one is supposed to access node->mm from outside drm_mm.c, anyway. Signed-off-by: David Herrmann --- drivers/gpu/drm/drm_mm.c | 1 + include/drm/drm_mm.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 7917729..3bd43ce 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -374,6 +374,7 @@ void drm_mm_remove_node(struct drm_mm_node *node) list_del(&node->node_list); node->allocated = 0; + node->mm = NULL; } EXPORT_SYMBOL(drm_mm_remove_node); diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index de92425..d83b966 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h @@ -85,6 +85,11 @@ static inline bool drm_mm_node_allocated(struct drm_mm_node *node) return node->allocated; } +static inline bool drm_mm_node_linked(struct drm_mm_node *node) +{ + return node->mm; +} + static inline bool drm_mm_initialized(struct drm_mm *mm) { return mm->hole_stack.next;