Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1510694pxy; Mon, 2 Aug 2021 03:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4dCkjg1HnZy2vd92OF80uBGAuQe8c6EVgmfeMV+PPiO+p/XgfJIk1oQ9DcGNlE2bndA9y X-Received: by 2002:a05:6e02:b43:: with SMTP id f3mr67049ilu.94.1627900530333; Mon, 02 Aug 2021 03:35:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1627900530; cv=pass; d=google.com; s=arc-20160816; b=g6iMAJnbjT7iTBKOc2bXRu/oWMUvr+qfi1/p5jPtvUwisWK1VIPzjMYhVRfyDB1PpL EW2VDVSJWTScPO/aw6bHbw+1qVXWsqz8qtea85r21Iyw7Tr9ZRLb2OZVCbuLglMkLpEa LcytN/HqG8oWpD2hMavJywjs4aOjbdQoFYisVrzJ6a8zmpTaftv5SNZ7k4Kw9pkj0J7I 8zdkIDB3mx7J7CbYFIInYyBvHAhABqD3Etq0ZqIKb8Hi9VbqfVfZZWW7GqaLmSTSjKWG tOneefw1+x9ws/3mJUXDtbTBZluAxgv1/OFtv+Yffv0pwvIaVkqrtNkMhpkeAo6OlDer QrAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pBMBZw8IzCQLXgPAOyKvrBO4tJA5PgdcnipSFvQOR5s=; b=qJo3GPNuCVkH9J1/f5IrKxMXIWbJNR2gtbP+QEpmTa791wuIX5ubgNoiS9cjx9phkM GmTC00WlvFXUVnhwTPYpwuLUIQA2XSsgFPgACX7GNuWS5X3fEax/pSgP/qyvpQTd4MJV 0JnUgA0u7KgPwsnmfwNFr1qdmIGZZwnXe9XuqjFSDyiBmRJJ72LlNL7e0/gvoLJM7ZQT neZ1y4u4cDF23rtkEP9Udqbc9MyAsQHCfh9pSNLs7X4FSzxHuxNTSPhTPdD7+JjMo9IB /q0IbtsWv5k4i7zuIK/bZSwZJRi1VyD6ruo8Tq/nqL5rWwtftJURTIkd2xDirpIyvuN3 z2lA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=eNdBZY6a; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si11706288ild.148.2021.08.02.03.35.18; Mon, 02 Aug 2021 03:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=eNdBZY6a; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233117AbhHBKdx (ORCPT + 99 others); Mon, 2 Aug 2021 06:33:53 -0400 Received: from mail-mw2nam12on2065.outbound.protection.outlook.com ([40.107.244.65]:31782 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233175AbhHBKdv (ORCPT ); Mon, 2 Aug 2021 06:33:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tg5NAEuk0+jPP2Rr71HHKEWZCUvu5PSLL/UoVzyuZj7m9K/0B4rvJz0LE0UTWsOBjiocA+JdXMR9V3uTxgbRYMsU5hvMcVX3m8e7lgmZ5UTP4y+TuIdL8AlKncZFawJ0nypekjRaZGzRUAb96hcB9hVjGDgQw/2/nRQ5ysbSMeyX6XpONizuwyIaKjTWiHLfhgKEqjvT+Rmcbv1NJGkM0r3xd8A3o7l+DKi1rgJTKQZdSMmymEXc4Y3jVPa7oCEcXQMsvJ/MqRM/V90p3+b0rsFfAhVN8HBixFlqgEZyVvxpK538OFKM/P5TRwbUNjpU3XA/0cj79ySdnqfBrUixag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pBMBZw8IzCQLXgPAOyKvrBO4tJA5PgdcnipSFvQOR5s=; b=hOTYx1y0eR0+ajXaFNtdGzNRq7geeB7taB3oU3Dop+OFkmz4xwfo0OmflcpFGZb7jvbEa2VAOHKgprSldLmQjthh9WQUq/nT2ezJEJDssNyCx3j1WXcy0B5gGs4qPkRX8ahjrSPLwe1lbWzn6MvIZ8ViXfL8aH9ALgGDB/eZEtKwE1vi1kABsOi2ktxyXJ71bNSsgq5moda+o5hnRFU4CrYYysXca263XawCfnvcd+f5hpstidm0Ah2zKIfaOLJTN3eLYaAJ9tqDDm1txSQte5dgh5AkVE5dJfrGT5JqLhjKjeL8CtDoyj9lItDfWH0BSieTY5MNFufJXXFb10Wajw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pBMBZw8IzCQLXgPAOyKvrBO4tJA5PgdcnipSFvQOR5s=; b=eNdBZY6a5Eeym/hq1o0C7QA8RnK3uZHlI80TmqCGUltXf4yrOsmy7yjysdKaNThENaNcNBK94/+uZNqv+A/nbF7TnUBKCJrqiiuejeIXqhqdD3xn/FNSVJhmJhlbeBQaCc+hV1kWoN9XQy6wOZgwf4L+wzEDOyXegMrN9yaRcJ8= Received: from BN0PR04CA0181.namprd04.prod.outlook.com (2603:10b6:408:e9::6) by BY5PR12MB5541.namprd12.prod.outlook.com (2603:10b6:a03:1c6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Mon, 2 Aug 2021 10:33:39 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::42) by BN0PR04CA0181.outlook.office365.com (2603:10b6:408:e9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 10:33:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 10:33:39 +0000 Received: from sanjuamdntb2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 2 Aug 2021 05:33:35 -0500 From: Sanjay R Mehta To: CC: , , , , , , , , , , Sanjay R Mehta Subject: [PATCH v11 3/3] dmaengine: ptdma: Add debugfs entries for PTDMA Date: Mon, 2 Aug 2021 05:32:55 -0500 Message-ID: <1627900375-80812-4-git-send-email-Sanju.Mehta@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1627900375-80812-1-git-send-email-Sanju.Mehta@amd.com> References: <1627900375-80812-1-git-send-email-Sanju.Mehta@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ff44697-f567-4acf-53c2-08d955a0fe2a X-MS-TrafficTypeDiagnostic: BY5PR12MB5541: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:22; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +e1lWi6bTJpJ2L8QaNZL+qw0cAIw465euJF8cjKshCaGWUOrD9GvNgYCRF44GtS6zn+jzKtgPOhWjr2Rb95LF7lGoTrJ/RffD+uGGBq94EwWGxD6KqpIgpDd9OV1OW/r2OzOmki4WhDAYd6Be+ey/gGAEdqGvKp/XOcXaj/pzM5xPOyUtzcTeBrb1J+ecn6HHLx6lvIj96BKaax/OCQ/dQVAHZDj9JalK7/PBDkqtGpeYvHwKPG2jKPk1DU3UC9Pug0LN3026rEQxbJ4hiOhcmj50R0gwGJtLMN13KRQDqbQSLx8ttqdwHwGl6GagUiFxo7zVEtzUPzuABUNB79Kg50DLmbvhgQ6B11JdQ10b7GLPDroaQptSFZGatzmKfCWbKTXAECgJWAGX9ZwpKSOwjZtIU3mpV7rhU+mjYhOmShNtpX+X86dULWjLStxYvNDV0L1Ot8ISxmbZkKVDbWlaL1Qcf+IihY/lxPrurWyGPOhTKn/D4Qzgn4yYFo2ze2OrAlWNeEmBtujGNJvCoWr1JNopf4yTXriYIJiEq7D9HFdl5mtTI7/7LpHYV0Oq06sPz3bWB+BH8EsnhZjW4tLBJGKBxBu/VGx+4sPy+mDf9n4pkzZ4GgW+T6zDFPRMvaRbolL01wtT6mTr1jLaGi2KN9M14RVZtwAVoMRcVc7F3Y5tV7HzeWbo7uX2RTRZPAImSxrGMjg1h0x7rIgajl2/jA4ycHhmfunbO/DDXdWhfk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(6916009)(336012)(6666004)(26005)(186003)(16526019)(4326008)(426003)(36756003)(70206006)(82310400003)(2616005)(508600001)(81166007)(7696005)(8676002)(86362001)(5660300002)(36860700001)(54906003)(70586007)(356005)(8936002)(83380400001)(47076005)(316002)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 10:33:39.6511 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ff44697-f567-4acf-53c2-08d955a0fe2a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5541 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sanjay R Mehta Expose data about the configuration and operation of the PTDMA through debugfs entries: device name, capabilities, configuration, statistics. Signed-off-by: Sanjay R Mehta --- drivers/dma/ptdma/Makefile | 2 +- drivers/dma/ptdma/ptdma-debugfs.c | 110 ++++++++++++++++++++++++++++++++++++++ drivers/dma/ptdma/ptdma-dev.c | 5 ++ drivers/dma/ptdma/ptdma.h | 6 +++ 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/ptdma/ptdma-debugfs.c diff --git a/drivers/dma/ptdma/Makefile b/drivers/dma/ptdma/Makefile index a528cb0..ce54102 100644 --- a/drivers/dma/ptdma/Makefile +++ b/drivers/dma/ptdma/Makefile @@ -5,6 +5,6 @@ obj-$(CONFIG_AMD_PTDMA) += ptdma.o -ptdma-objs := ptdma-dev.o ptdma-dmaengine.o +ptdma-objs := ptdma-dev.o ptdma-dmaengine.o ptdma-debugfs.o ptdma-$(CONFIG_PCI) += ptdma-pci.o diff --git a/drivers/dma/ptdma/ptdma-debugfs.c b/drivers/dma/ptdma/ptdma-debugfs.c new file mode 100644 index 0000000..5277a2a --- /dev/null +++ b/drivers/dma/ptdma/ptdma-debugfs.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * AMD Passthrough DMA device driver + * -- Based on the CCP driver + * + * Copyright (C) 2016,2021 Advanced Micro Devices, Inc. + * + * Author: Sanjay R Mehta + * Author: Gary R Hook + */ + +#include +#include + +#include "ptdma.h" + +/* DebugFS helpers */ +#define MAX_NAME_LEN 20 +#define RI_VERSION_NUM 0x0000003F + +#define RI_NUM_VQM 0x00078000 +#define RI_NVQM_SHIFT 15 + +static int pt_debugfs_info_show(struct seq_file *s, void *p) +{ + struct pt_device *pt = s->private; + unsigned int regval; + + seq_printf(s, "Device name: %s\n", dev_name(pt->dev)); + seq_printf(s, " # Queues: %d\n", 1); + seq_printf(s, " # Cmds: %d\n", pt->cmd_count); + + regval = ioread32(pt->io_regs + CMD_PT_VERSION); + + seq_printf(s, " Version: %d\n", regval & RI_VERSION_NUM); + seq_puts(s, " Engines:"); + seq_puts(s, "\n"); + seq_printf(s, " Queues: %d\n", (regval & RI_NUM_VQM) >> RI_NVQM_SHIFT); + + return 0; +} + +/* + * Return a formatted buffer containing the current + * statistics of queue for PTDMA + */ +static int pt_debugfs_stats_show(struct seq_file *s, void *p) +{ + struct pt_device *pt = s->private; + + seq_printf(s, "Total Interrupts Handled: %ld\n", pt->total_interrupts); + + return 0; +} + +static int pt_debugfs_queue_show(struct seq_file *s, void *p) +{ + struct pt_cmd_queue *cmd_q = s->private; + unsigned int regval; + + if (!cmd_q) + return 0; + + seq_printf(s, " Pass-Thru: %ld\n", cmd_q->total_pt_ops); + + regval = ioread32(cmd_q->reg_control + 0x000C); + + seq_puts(s, " Enabled Interrupts:"); + if (regval & INT_EMPTY_QUEUE) + seq_puts(s, " EMPTY"); + if (regval & INT_QUEUE_STOPPED) + seq_puts(s, " STOPPED"); + if (regval & INT_ERROR) + seq_puts(s, " ERROR"); + if (regval & INT_COMPLETION) + seq_puts(s, " COMPLETION"); + seq_puts(s, "\n"); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_info); +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_queue); +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_stats); + +void ptdma_debugfs_setup(struct pt_device *pt) +{ + struct pt_cmd_queue *cmd_q; + char name[MAX_NAME_LEN + 1]; + struct dentry *debugfs_q_instance; + + if (!debugfs_initialized()) + return; + + debugfs_create_file("info", 0400, pt->dma_dev.dbg_dev_root, pt, + &pt_debugfs_info_fops); + + debugfs_create_file("stats", 0400, pt->dma_dev.dbg_dev_root, pt, + &pt_debugfs_stats_fops); + + cmd_q = &pt->cmd_q; + + snprintf(name, MAX_NAME_LEN - 1, "q"); + + debugfs_q_instance = + debugfs_create_dir(name, pt->dma_dev.dbg_dev_root); + + debugfs_create_file("stats", 0400, debugfs_q_instance, cmd_q, + &pt_debugfs_queue_fops); +} diff --git a/drivers/dma/ptdma/ptdma-dev.c b/drivers/dma/ptdma/ptdma-dev.c index 42b9de3..354284a 100644 --- a/drivers/dma/ptdma/ptdma-dev.c +++ b/drivers/dma/ptdma/ptdma-dev.c @@ -102,6 +102,7 @@ int pt_core_perform_passthru(struct pt_cmd_queue *cmd_q, struct ptdma_desc desc; cmd_q->cmd_error = 0; + cmd_q->total_pt_ops++; memset(&desc, 0, sizeof(desc)); desc.dw0 = CMD_DESC_DW0_VAL; desc.length = pt_engine->src_len; @@ -151,6 +152,7 @@ static irqreturn_t pt_core_irq_handler(int irq, void *data) bool err = true; pt_core_disable_queue_interrupts(pt); + pt->total_interrupts++; status = ioread32(cmd_q->reg_control + 0x0010); if (status) { cmd_q->int_status = status; @@ -253,6 +255,9 @@ int pt_core_init(struct pt_device *pt) if (ret) goto e_dmaengine; + /* Set up debugfs entries */ + ptdma_debugfs_setup(pt); + return 0; e_dmaengine: diff --git a/drivers/dma/ptdma/ptdma.h b/drivers/dma/ptdma/ptdma.h index 1329c55..860e302 100644 --- a/drivers/dma/ptdma/ptdma.h +++ b/drivers/dma/ptdma/ptdma.h @@ -216,6 +216,8 @@ struct pt_cmd_queue { u32 q_status; u32 q_int_status; u32 cmd_error; + /* Queue Statistics */ + unsigned long total_pt_ops; } ____cacheline_aligned; struct pt_device { @@ -254,6 +256,9 @@ struct pt_device { wait_queue_head_t lsb_queue; + /* Device Statistics */ + unsigned long total_interrupts; + struct pt_tasklet_data tdata; }; @@ -307,6 +312,7 @@ struct pt_dev_vdata { int pt_dmaengine_register(struct pt_device *pt); void pt_dmaengine_unregister(struct pt_device *pt); +void ptdma_debugfs_setup(struct pt_device *pt); int pt_core_init(struct pt_device *pt); void pt_core_destroy(struct pt_device *pt); -- 2.7.4