From patchwork Wed Jun 12 21:48:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chenbo Feng X-Patchwork-Id: 10991295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC1A014E5 for ; Thu, 13 Jun 2019 07:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB644204C1 for ; Thu, 13 Jun 2019 07:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFC3C2887B; Thu, 13 Jun 2019 07:29:45 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 7340F204C1 for ; Thu, 13 Jun 2019 07:29:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14AA6893B9; Thu, 13 Jun 2019 07:28:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-x24a.google.com (mail-oi1-x24a.google.com [IPv6:2607:f8b0:4864:20::24a]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD3E689255 for ; Wed, 12 Jun 2019 21:48:34 +0000 (UTC) Received: by mail-oi1-x24a.google.com with SMTP id t198so6028811oih.20 for ; Wed, 12 Jun 2019 14:48:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xFZI9Cn8XQ9WD/uM2zeIjsdArEKjTB6MEJpCpF8H2cY=; b=Yb0kfnphvJpARkZEYpoV8WdHFu8YkW8lZ1aomaua75sQP3jfWB9lIkhXtSK7MQ01vz +XkhgDJxrF9HuI2r7NNzAPHcb/VSu4xE62poHQUw8esWXT1/wcMdhKTP5P4n6sCHhwz/ kY406ExKg0NTZjvDGPbUdq6Nh2Qg8qs8Fdy0i9Jq6/4XU1xop8/NOG6fgD3dogykYLXJ rKphL1D2RZdZOqgtPc8XeNNYq7Ha57VgYz8KOyCl3qphYnGQhLUZ9XV2Vwelx1FdbjDV xcw7Z2EDN3dWOkyVTlftsm3Dcs62GWGZkBG2FIvXO6Nl4zqF19er/5d8OvwV2OoTZFnX 2yRQ== X-Gm-Message-State: APjAAAUfH6OsPamUBbETKBpbeaC6H0LI1hgfPcCOafevyrOVdWbI2Enf OmUrdbp1Wxr695ljOu0nupDgIMM0mA== X-Google-Smtp-Source: APXvYqxn5WIL38quMvWm0NFNVoCMoq509G4lVulP6aIh3DMM/7wKweu86NGynkKEkLolsMXyoApH36EYpQ== X-Received: by 2002:a9d:7650:: with SMTP id o16mr19689292otl.0.1560376114065; Wed, 12 Jun 2019 14:48:34 -0700 (PDT) Date: Wed, 12 Jun 2019 14:48:23 -0700 In-Reply-To: <20190612214823.251491-1-fengc@google.com> Message-Id: <20190612214823.251491-4-fengc@google.com> Mime-Version: 1.0 References: <20190612214823.251491-1-fengc@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v4 3/3] dma-buf: add show_fdinfo handler From: Chenbo Feng To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-Mailman-Approved-At: Thu, 13 Jun 2019 07:27:23 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xFZI9Cn8XQ9WD/uM2zeIjsdArEKjTB6MEJpCpF8H2cY=; b=svuswpTBA4Vx+DLei1h+oVomOQmLsZNHTti0CIQZQVpzQDIyHeME0lAHPve5gT8exd E79eA8Ev5/qmWH+q1GOZI/aoxL+R3S0AW9XY83rHhXMkYf3xYQNqMgX+ONGiiVasflGI eI4w2zUXmOl99uOnNm49b46Ho4C7q5YMdGb57vi+f+sAvCHkeXb/szZbGc1dYp0RHLUX Bb7SqaKZDqXDMG/xtvv6j+JphFCnnBeglrzOcsw04pOqmrnqEZOKJYQBPtYglaBDlDdo k8HUtS4ismdMPZzP+d61mUgOI2udfdS0JqERvV7uLB3RxgaFRt3+YQiwnIdWGJ5Hgvtl 5Usw== 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: kernel-team@android.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Greg Hackmann The show_fdinfo handler exports the same information available through debugfs on a per-buffer basis. Signed-off-by: Greg Hackmann Signed-off-by: Chenbo Feng --- drivers/dma-buf/dma-buf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 87a928c93c1a..ff8421668331 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -396,6 +396,20 @@ static long dma_buf_ioctl(struct file *file, } } +static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct dma_buf *dmabuf = file->private_data; + + seq_printf(m, "size:\t%zu\n", dmabuf->size); + /* Don't count the temporary reference taken inside procfs seq_show */ + seq_printf(m, "count:\t%ld\n", file_count(dmabuf->file) - 1); + seq_printf(m, "exp_name:\t%s\n", dmabuf->exp_name); + mutex_lock(&dmabuf->lock); + if (dmabuf->name) + seq_printf(m, "name:\t%s\n", dmabuf->name); + mutex_unlock(&dmabuf->lock); +} + static const struct file_operations dma_buf_fops = { .release = dma_buf_release, .mmap = dma_buf_mmap_internal, @@ -405,6 +419,7 @@ static const struct file_operations dma_buf_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = dma_buf_ioctl, #endif + .show_fdinfo = dma_buf_show_fdinfo, }; /*