From patchwork Wed Jul 26 05:36:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 9864209 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 9E6D06038C for ; Wed, 26 Jul 2017 05:39:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9588028634 for ; Wed, 26 Jul 2017 05:39:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A5582866D; Wed, 26 Jul 2017 05:39:52 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE 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 293A928634 for ; Wed, 26 Jul 2017 05:39:52 +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=bT1QhJRyq4QPvFvIShNOin5drbSX0onSoZVREcalIps=; b=iaTP3kVe3PWtYINcpOiYMaRmAx haiFnLyEqwPZrQ9QgN72uaxc1bV7S6DSz7StczQ7EhWoOp1GXOoG0/TqM+RMs/X/XTjIVNCVSZp79 q73wMWfneJW3FlhV0BTraAsYKttlA8u7558rHgHGqwiDLQuxuZvFWpfA9ZS0nJ5c6QjmHMTKlT6Hl nRxPTMgTn2MyLYq52gYkdqarCVI0Q7rkp8aZRvxpBbMwG9kHDbk1+PsC3FzFnW0ghaaDAyPEWKBTv tnb+5iSz5jcEAu7iJWXCVjvxuJXerdfYRVN9oT53EM2ZPMNfInWMo0yFKokQ/a6hV6f4nQzEM9PVc psOAgcgA==; 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 1daF2y-0005TE-Qr; Wed, 26 Jul 2017 05:39:48 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1daF1j-0004Es-55 for linux-arm-kernel@lists.infradead.org; Wed, 26 Jul 2017 05:38:49 +0000 Received: by mail-wm0-x22b.google.com with SMTP id l81so31588023wmg.1 for ; Tue, 25 Jul 2017 22:38:10 -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=D5+4ZZFF9P0FoekV7DW5JJhM4pEGLLofs8nEtyhNtZI=; b=SKU2PT0xsDRf3U/gXp+ZRNxXVfkOPozCO2lAEZOyQdu2nKyH+B7LIDNq4e6vB8SAqk eiGFIT83v2vNHjN0Uo2mvA1ZYD1AAD8PyyiIQPJinxFite17tQa0s377rrGDGuAqmGNm a0nc10MoZk4Oc9BesXVQU/kjEFaAJQ1yryr8g= 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=D5+4ZZFF9P0FoekV7DW5JJhM4pEGLLofs8nEtyhNtZI=; b=njRhTe2Y59yPfbZfFdewqiAzYckkBT/OF5e5mGyg7C7zx9tgeuFencKk/HMA8ynPO/ 5yqQWOH9MTDB0lOs1k7IV2LNRTUASCDK1MD8VYnarOwP8nLEWaXlUA0lK34M/gsyGHIT v+muBngfWC6zJwBL4ZADc0Nwnx0RMNnYq0I3mOHDaxXLCaWCItwd8VznZtnQNpWVc7hO TGccaK3JbuRV0GkkDPcTSkqiySvK1QvssU/XFba2kIurt8FB8GusiwtPfNTmbAqAysu4 lZplVgSNl2iKcQjamntbcNOcUXujF8MrjTdMERZnnaXJeEJfsxTdd2FI4wP9KvySNiy4 qg2A== X-Gm-Message-State: AIVw1113sjbLVNa4nMJlK2es5jkFcheOHHahkCEesiXl35TlZOUbCi5t p+Dp8uqKaM7cpKPc X-Received: by 10.28.86.68 with SMTP id k65mr9156291wmb.18.1501047489317; Tue, 25 Jul 2017 22:38:09 -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 34sm17417595wrt.36.2017.07.25.22.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 22:38:08 -0700 (PDT) From: Anup Patel To: Rob Herring , Mark Rutland , Vinod Koul , Dan Williams Subject: [PATCH 5/6] dma: bcm-sba-raid: Add debugfs support Date: Wed, 26 Jul 2017 11:06:43 +0530 Message-Id: <1501047404-14456-6-git-send-email-anup.patel@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501047404-14456-1-git-send-email-anup.patel@broadcom.com> References: <1501047404-14456-1-git-send-email-anup.patel@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170725_223831_739360_C1BF5947 X-CRM114-Status: GOOD ( 15.62 ) 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: devicetree@vger.kernel.org, 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 situations. Signed-off-by: Anup Patel Reviewed-by: Ray Jui Reviewed-by: Scott Branden --- drivers/dma/bcm-sba-raid.c | 82 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/dma/bcm-sba-raid.c b/drivers/dma/bcm-sba-raid.c index b92c756..dd1e89e 100644 --- a/drivers/dma/bcm-sba-raid.c +++ b/drivers/dma/bcm-sba-raid.c @@ -36,6 +36,7 @@ */ #include +#include #include #include #include @@ -161,6 +162,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 ===== */ @@ -485,6 +489,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) @@ -1450,6 +1493,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,10 +1777,30 @@ 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)) { + ret = PTR_ERR_OR_ZERO(sba->root); + goto fail_free_resources; + } + + /* 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)) { + ret = PTR_ERR_OR_ZERO(sba->stats); + goto fail_free_debugfs_root; + } +skip_debugfs: + /* Register DMA device with linux async framework */ ret = sba_async_register(sba); if (ret) - goto fail_free_resources; + goto fail_free_debugfs_root; /* Print device info */ dev_info(sba->dev, "%s using SBAv%d and %d mailbox channels", @@ -1733,6 +1809,8 @@ static int sba_probe(struct platform_device *pdev) return 0; +fail_free_debugfs_root: + debugfs_remove_recursive(sba->root); fail_free_resources: sba_freeup_channel_resources(sba); fail_free_mchans: @@ -1748,6 +1826,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++)