From patchwork Thu Feb 16 11:39:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Nicolai_H=C3=A4hnle?= X-Patchwork-Id: 9576891 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 CA29A600C5 for ; Thu, 16 Feb 2017 11:40:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE96A201F3 for ; Thu, 16 Feb 2017 11:40:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1B00285BE; Thu, 16 Feb 2017 11:40:02 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 989C2201F3 for ; Thu, 16 Feb 2017 11:40:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EF7D6EAB7; Thu, 16 Feb 2017 11:40:00 +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 BB38C6EAB8; Thu, 16 Feb 2017 11:39:58 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id c85so2691274wmi.1; Thu, 16 Feb 2017 03:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H/rJGmni7X36s/OvqZ6zslD4xvVsZGIcrgbAJ0Aolhw=; b=XY5pBvRWEf+ra7pl6t4m3zUZdehw3k/FEP5WeDMQeN24KPN4fybJKZR3R0FOklkDwN IquBHgojL4xCQV/xRRYV+vStpw03esJfmrUjB8pmG5xnAmdPmw9GlI2Dk6MCNJVdWexn jVjM4dx+h88c+9bl5ltRcCdMvwJ1SsZR0f+0feioGT9bsKOaRjwf5pilzWJP9OcglHgJ Bo/x4cljPf0Dl4FHlgAq7+W/1MENk1/SDG9u42LX6NIWtkWoKLbgNKIOhx92WwipZPMC wOiohMTID+StfhcCaKEi/pWROPuDBLxoZ7VJo2032Dj2elxLk2g8qBsBmrszNIPCme9Q KTxA== 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:mime-version :content-transfer-encoding; bh=H/rJGmni7X36s/OvqZ6zslD4xvVsZGIcrgbAJ0Aolhw=; b=pHYQZJ2jDxzCi+pdlbdkDGK7ZOTBMUzJMgAgZv01yvagGtwOgg0Gdcck3ww5AtazMm zLqhA4b2FDyc3whuBL173WeZZj0l6qrP9zJdmViGT4xagtKRritDL9LFyRQSQCWldVye HlBAax6UTNVxuP6vjIFD1+PRyvX+IyiRDy+D6zRwc1H0yoGMNK62oaT9nqA3szMNYKng KJhZQnzPR1QpO4rhJel+DWt4hicSdjXCWpr3FB8bwZvThOmWnIr+yLI3ga6udfBdhSJj 6HeMqIAWDMf6TkfL7fLmZDxTBSYn62eZUomLO57FpX8tifCm1mCoX6rYhhRkEyKMQHMV FEAQ== X-Gm-Message-State: AMke39kX3HyZvPQh2DotF0NmnZF5Sra13lg4VlQMVnYHldV5rFwWeI5R5iQexQkWP7MVkQ== X-Received: by 10.28.15.2 with SMTP id 2mr12668139wmp.66.1487245197210; Thu, 16 Feb 2017 03:39:57 -0800 (PST) Received: from capella.localdomain (x55b544e3.dyn.telefonica.de. [85.181.68.227]) by smtp.gmail.com with ESMTPSA id c202sm3167038wmd.10.2017.02.16.03.39.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:39:56 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: amd-gfx@lists.freedesktop.org Subject: [PATCH v3 1/3] drm/ttm: fix the documentation of ttm_bo_init Date: Thu, 16 Feb 2017 12:39:44 +0100 Message-Id: <20170216113946.22046-1-nhaehnle@gmail.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Cc: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Nicolai Hähnle As the comment says: callers of ttm_bo_init cannot rely on having the only reference to the BO when the function returns successfully. Signed-off-by: Nicolai Hähnle --- include/drm/ttm/ttm_bo_api.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index f195899..c0ebbd6 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -476,7 +476,11 @@ size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev, * As this object may be part of a larger structure, this function, * together with the @destroy function, * enables driver-specific objects derived from a ttm_buffer_object. - * On successful return, the object kref and list_kref are set to 1. + * + * On successful return, the caller owns an object kref to @bo. The kref and + * list_kref are usually set to 1, but note that in some situations, other + * tasks may already be holding references to @bo as well. + * * If a failure occurs, the function will call the @destroy function, or * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is * illegal and will likely cause memory corruption.