From patchwork Tue Aug 22 09:57:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9914757 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 04A8960381 for ; Tue, 22 Aug 2017 10:03:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12EAD2883F for ; Tue, 22 Aug 2017 10:03:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07EEE28854; Tue, 22 Aug 2017 10:03:07 +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=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C79B2883F for ; Tue, 22 Aug 2017 10:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YLlSyYOCK/KoPlFyM8UBDlQgcnsbxMncLHs1JMk11Dc=; b=ShIxTQUi03qBD5KjSOG3wcLNON eLwbWWK/vdMeYNltFHNeU69lUUYhMKwGAljAyLvQW/+9jgE/vefnuvy+72eDzK9TFdw6dCkJORV/Z n5tgFxl4aJqLbMnM5GNPLG7RhaLWI7TSqTg256UiY4P5ohtaFquuyzvVRUh72XEwONf0hbx0YJHQE ULJPT53Xg5SUhVsXvLplTgecYhCLVP3phBuct8Bo85cefjgRT4h7wgpp7Fw2pqyChgdod/rgMq6pL stmjsHClbMZkGMdkj2tHVkYPgjzutrxa/ZFxbV9Fze5k9XDDib2Y3wQkikCfvHcZU7whu/QpIo4yf jvRnZwGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dk61X-000386-9V; Tue, 22 Aug 2017 10:03:03 +0000 Received: from mail-wr0-f169.google.com ([209.85.128.169]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dk5y4-0007Ia-66 for linux-arm-kernel@lists.infradead.org; Tue, 22 Aug 2017 10:00:12 +0000 Received: by mail-wr0-f169.google.com with SMTP id a47so6419109wra.0 for ; Tue, 22 Aug 2017 02:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=deh6HtxSVaXqFusjjM6iBbypkdHKC4n+hP/E67T4ueQ=; b=EncsLrBMdZXBBIi+GD2hCByOyU+zkiFVygQwVsq6WAMdF1ZXJwTHbzLXvWI7EYo2Na Sp1+nNsNOL+XFqqd8eAGzB0e/hebiLTfGioSj++5OweQejHNqEr1hg6LB93z7pd2hsIT xG0YmdMVxwqvKt9Q0KsyjHTRQt4YqZhlvGwVI= 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:in-reply-to :references; bh=deh6HtxSVaXqFusjjM6iBbypkdHKC4n+hP/E67T4ueQ=; b=Ef/un5Ln4kgJzvnjwoIzZB/ARFPuWomD5//K9gDrU+tXyYYmPSXclf8X5svcavXxa5 sOcjFd2/4O6sam3x60u4ARSL1iNj0VETTRf0vwtA1ddEiqNiedxZkIgBj1v8VshLo9po /tUH7YZxVzkQSqCLXjymcT2wANXNq9rBt4xLyHfXv5PBqC0XZF4y6iHDb5piNbbMloAt eyCpF7iqKgC/pOwLacXcRKTBc+NxPih0Avt1F22aItaaeMWS4VEnRPjr7l6XeIPDqiXJ e6/BbYhtXfT7deL8ryGHXmCqRcFpZHMbpwS3OnQtP0Qu0ECU6u3Hg54PneASGyTJPJs/ qb3w== X-Gm-Message-State: AHYfb5gkqPRMs5uXpJXlkCmwz2BY9ZlkNirCg+Nd2W7ToXWDEr8B8E33 /qcHzpO+AZhsKQyp X-Received: by 10.223.186.69 with SMTP id t5mr96963wrg.58.1503395945984; Tue, 22 Aug 2017 02:59:05 -0700 (PDT) Received: from anup-HP-Compaq-8100-Elite-CMT-PC.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id e137sm12257913wma.29.2017.08.22.02.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Aug 2017 02:59:05 -0700 (PDT) From: Anup Patel To: Vinod Koul , Dan Williams Subject: [PATCH v3 15/17] dmaengine: bcm-sba-raid: Add debugfs support Date: Tue, 22 Aug 2017 15:27:04 +0530 Message-Id: <1503395827-19428-16-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> References: <1503395827-19428-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_025929_403994_D41783DD X-CRM114-Status: GOOD ( 14.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Anup Patel , Scott Branden , Ray Jui , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds debugfs support to report stats via debugfs which in-turn will help debug hang or error situations. Signed-off-by: Anup Patel Reviewed-by: Ray Jui Reviewed-by: Scott Branden --- drivers/dma/bcm-sba-raid.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index f0a0e80..12310aa 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -36,6 +36,7 @@ */ #include +#include #include #include #include @@ -162,6 +163,9 @@ struct sba_device { struct list_head reqs_completed_list; struct list_head reqs_aborted_list; struct list_head reqs_free_list; + /* DebugFS directory entries */ + struct dentry *root; + struct dentry *stats; }; /* ====== Command helper routines ===== */ @@ -486,6 +490,45 @@ static void sba_process_received_request(struct sba_device *sba, } } +static void sba_write_stats_in_seqfile(struct sba_device *sba, + struct seq_file *file) +{ + unsigned long flags; + struct sba_request *req; + u32 free_count = 0, alloced_count = 0, pending_count = 0; + u32 active_count = 0, aborted_count = 0, completed_count = 0; + + spin_lock_irqsave(&sba->reqs_lock, flags); + + list_for_each_entry(req, &sba->reqs_free_list, node) + free_count++; + + list_for_each_entry(req, &sba->reqs_alloc_list, node) + alloced_count++; + + list_for_each_entry(req, &sba->reqs_pending_list, node) + pending_count++; + + list_for_each_entry(req, &sba->reqs_active_list, node) + active_count++; + + list_for_each_entry(req, &sba->reqs_aborted_list, node) + aborted_count++; + + list_for_each_entry(req, &sba->reqs_completed_list, node) + completed_count++; + + spin_unlock_irqrestore(&sba->reqs_lock, flags); + + seq_printf(file, "maximum requests = %d\n", sba->max_req); + seq_printf(file, "free requests = %d\n", free_count); + seq_printf(file, "alloced requests = %d\n", alloced_count); + seq_printf(file, "pending requests = %d\n", pending_count); + seq_printf(file, "active requests = %d\n", active_count); + seq_printf(file, "aborted requests = %d\n", aborted_count); + seq_printf(file, "completed requests = %d\n", completed_count); +} + /* ====== DMAENGINE callbacks ===== */ static void sba_free_chan_resources(struct dma_chan *dchan) @@ -1451,6 +1494,19 @@ static void sba_receive_message(struct mbox_client *cl, void *msg) sba_process_received_request(sba, req); } +/* ====== Debugfs callbacks ====== */ + +static int sba_debugfs_stats_show(struct seq_file *file, void *offset) +{ + struct platform_device *pdev = to_platform_device(file->private); + struct sba_device *sba = platform_get_drvdata(pdev); + + /* Write stats in file */ + sba_write_stats_in_seqfile(sba, file); + + return 0; +} + /* ====== Platform driver routines ===== */ static int sba_prealloc_channel_resources(struct sba_device *sba) @@ -1721,6 +1777,25 @@ static int sba_probe(struct platform_device *pdev) if (ret) goto fail_free_mchans; + /* Check availability of debugfs */ + if (!debugfs_initialized()) + goto skip_debugfs; + + /* Create debugfs root entry */ + sba->root = debugfs_create_dir(dev_name(sba->dev), NULL); + if (IS_ERR_OR_NULL(sba->root)) { + dev_err(sba->dev, "failed to create debugfs root entry\n"); + sba->root = NULL; + goto skip_debugfs; + } + + /* Create debugfs stats entry */ + sba->stats = debugfs_create_devm_seqfile(sba->dev, "stats", sba->root, + sba_debugfs_stats_show); + if (IS_ERR_OR_NULL(sba->stats)) + dev_err(sba->dev, "failed to create debugfs stats file\n"); +skip_debugfs: + /* Register DMA device with Linux async framework */ ret = sba_async_register(sba); if (ret) @@ -1734,6 +1809,7 @@ static int sba_probe(struct platform_device *pdev) return 0; fail_free_resources: + debugfs_remove_recursive(sba->root); sba_freeup_channel_resources(sba); fail_free_mchans: for (i = 0; i < sba->mchans_count; i++) @@ -1748,6 +1824,8 @@ static int sba_remove(struct platform_device *pdev) dma_async_device_unregister(&sba->dma_dev); + debugfs_remove_recursive(sba->root); + sba_freeup_channel_resources(sba); for (i = 0; i < sba->mchans_count; i++)