From: Serge Semin <fancer.lancer@gmail.com>
To: Cai Huoqing <cai.huoqing@linux.dev>
Cc: "Gustavo Pimentel" <gustavo.pimentel@synopsys.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v8 4/4] dmaengine: dw-edma: Add HDMA DebugFS support
Date: Thu, 23 Mar 2023 13:03:25 +0300 [thread overview]
Message-ID: <20230323100325.zltk7emftkyfgsef@mobilestation> (raw)
In-Reply-To: <20230323034944.78357-5-cai.huoqing@linux.dev>
On Thu, Mar 23, 2023 at 11:49:41AM +0800, Cai Huoqing wrote:
> From: Cai huoqing <cai.huoqing@linux.dev>
>
> Add HDMA DebugFS support to show register information
s/register information/registers content.
>
> Signed-off-by: Cai huoqing <cai.huoqing@linux.dev>
> ---
> v7->v8:
> 1.Drop some unused field in dw_hdma_debugfs_entry.
>
> v7 link:
> https://lore.kernel.org/lkml/20230315012840.6986-5-cai.huoqing@linux.dev/
>
>
> drivers/dma/dw-edma/Makefile | 3 +-
> drivers/dma/dw-edma/dw-hdma-v0-core.c | 2 +
> drivers/dma/dw-edma/dw-hdma-v0-debugfs.c | 173 +++++++++++++++++++++++
> drivers/dma/dw-edma/dw-hdma-v0-debugfs.h | 22 +++
> 4 files changed, 199 insertions(+), 1 deletion(-)
> create mode 100644 drivers/dma/dw-edma/dw-hdma-v0-debugfs.c
> create mode 100644 drivers/dma/dw-edma/dw-hdma-v0-debugfs.h
>
> diff --git a/drivers/dma/dw-edma/Makefile b/drivers/dma/dw-edma/Makefile
> index b1c91ef2c63d..83ab58f87760 100644
> --- a/drivers/dma/dw-edma/Makefile
> +++ b/drivers/dma/dw-edma/Makefile
> @@ -1,7 +1,8 @@
> # SPDX-License-Identifier: GPL-2.0
>
> obj-$(CONFIG_DW_EDMA) += dw-edma.o
> -dw-edma-$(CONFIG_DEBUG_FS) := dw-edma-v0-debugfs.o
> +dw-edma-$(CONFIG_DEBUG_FS) := dw-edma-v0-debugfs.o \
> + dw-hdma-v0-debugfs.o
> dw-edma-objs := dw-edma-core.o \
> dw-edma-v0-core.o \
> dw-hdma-v0-core.o $(dw-edma-y)
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-core.c b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> index 22b7b0410deb..00b735a0202a 100644
> --- a/drivers/dma/dw-edma/dw-hdma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-core.c
> @@ -11,6 +11,7 @@
> #include "dw-edma-core.h"
> #include "dw-hdma-v0-core.h"
> #include "dw-hdma-v0-regs.h"
> +#include "dw-hdma-v0-debugfs.h"
>
> enum dw_hdma_control {
> DW_HDMA_V0_CB = BIT(0),
> @@ -276,6 +277,7 @@ static void dw_hdma_v0_core_ch_config(struct dw_edma_chan *chan)
> /* HDMA debugfs callbacks */
> static void dw_hdma_v0_core_debugfs_on(struct dw_edma *dw)
> {
> + dw_hdma_v0_debugfs_on(dw);
> }
>
> static const struct dw_edma_core_ops dw_hdma_v0_core = {
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-debugfs.c b/drivers/dma/dw-edma/dw-hdma-v0-debugfs.c
> new file mode 100644
> index 000000000000..c1f2c61e941e
> --- /dev/null
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-debugfs.c
> @@ -0,0 +1,173 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2023 Cai Huoqing
> + * Synopsys DesignWare HDMA v0 debugfs
> + *
> + * Author: Cai Huoqing <cai.huoqing@linux.dev>
> + */
> +
> +#include <linux/debugfs.h>
> +#include <linux/bitfield.h>
> +
> +#include "dw-hdma-v0-debugfs.h"
> +#include "dw-hdma-v0-regs.h"
> +#include "dw-edma-core.h"
> +
> +#define REGS_ADDR(dw, name) \
> + ({ \
> + struct dw_hdma_v0_regs __iomem *__regs = (dw)->chip->reg_base; \
> + \
> + (void __iomem *)&__regs->name; \
> + })
> +
> +#define REGS_CH_ADDR(dw, name, _dir, _ch) \
> + ({ \
> + struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \
> + \
> + if (_dir == EDMA_DIR_READ) \
> + __ch_regs = REGS_ADDR(dw, ch[_ch].rd); \
> + else \
> + __ch_regs = REGS_ADDR(dw, ch[_ch].wr); \
> + \
> + (void __iomem *)&__ch_regs->name; \
> + })
> +
> +#define CTX_REGISTER(dw, name, dir, ch) \
> + {#name, REGS_CH_ADDR(dw, name, dir, ch)}
> +
> +#define REGISTER(dw, name) \
> + { dw, #name, REGS_ADDR(dw, name) }
This macro appears to be unused. Please drop. Other than that the
patch looks good.
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Serge(y)
> +
> +#define WRITE_STR "write"
> +#define READ_STR "read"
> +#define CHANNEL_STR "channel"
> +#define REGISTERS_STR "registers"
> +
> +struct dw_hdma_debugfs_entry {
> + const char *name;
> + void __iomem *reg;
> +};
> +
> +static int dw_hdma_debugfs_u32_get(void *data, u64 *val)
> +{
> + struct dw_hdma_debugfs_entry *entry = data;
> + void __iomem *reg = entry->reg;
> +
> + *val = readl(reg);
> +
> + return 0;
> +}
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_hdma_debugfs_u32_get, NULL, "0x%08llx\n");
> +
> +static void dw_hdma_debugfs_create_x32(struct dw_edma *dw,
> + const struct dw_hdma_debugfs_entry ini[],
> + int nr_entries, struct dentry *dent)
> +{
> + struct dw_hdma_debugfs_entry *entries;
> + int i;
> +
> + entries = devm_kcalloc(dw->chip->dev, nr_entries, sizeof(*entries),
> + GFP_KERNEL);
> + if (!entries)
> + return;
> +
> + for (i = 0; i < nr_entries; i++) {
> + entries[i] = ini[i];
> +
> + debugfs_create_file_unsafe(entries[i].name, 0444, dent,
> + &entries[i], &fops_x32);
> + }
> +}
> +
> +static void dw_hdma_debugfs_regs_ch(struct dw_edma *dw, enum dw_edma_dir dir,
> + u16 ch, struct dentry *dent)
> +{
> + const struct dw_hdma_debugfs_entry debugfs_regs[] = {
> + CTX_REGISTER(dw, ch_en, dir, ch),
> + CTX_REGISTER(dw, doorbell, dir, ch),
> + CTX_REGISTER(dw, prefetch, dir, ch),
> + CTX_REGISTER(dw, handshake, dir, ch),
> + CTX_REGISTER(dw, llp.lsb, dir, ch),
> + CTX_REGISTER(dw, llp.msb, dir, ch),
> + CTX_REGISTER(dw, cycle_sync, dir, ch),
> + CTX_REGISTER(dw, transfer_size, dir, ch),
> + CTX_REGISTER(dw, sar.lsb, dir, ch),
> + CTX_REGISTER(dw, sar.msb, dir, ch),
> + CTX_REGISTER(dw, dar.lsb, dir, ch),
> + CTX_REGISTER(dw, dar.msb, dir, ch),
> + CTX_REGISTER(dw, watermark_en, dir, ch),
> + CTX_REGISTER(dw, control1, dir, ch),
> + CTX_REGISTER(dw, func_num, dir, ch),
> + CTX_REGISTER(dw, qos, dir, ch),
> + CTX_REGISTER(dw, ch_stat, dir, ch),
> + CTX_REGISTER(dw, int_stat, dir, ch),
> + CTX_REGISTER(dw, int_setup, dir, ch),
> + CTX_REGISTER(dw, int_clear, dir, ch),
> + CTX_REGISTER(dw, msi_stop.lsb, dir, ch),
> + CTX_REGISTER(dw, msi_stop.msb, dir, ch),
> + CTX_REGISTER(dw, msi_watermark.lsb, dir, ch),
> + CTX_REGISTER(dw, msi_watermark.msb, dir, ch),
> + CTX_REGISTER(dw, msi_abort.lsb, dir, ch),
> + CTX_REGISTER(dw, msi_abort.msb, dir, ch),
> + CTX_REGISTER(dw, msi_msgdata, dir, ch),
> + };
> + int nr_entries = ARRAY_SIZE(debugfs_regs);
> +
> + dw_hdma_debugfs_create_x32(dw, debugfs_regs, nr_entries, dent);
> +}
> +
> +static void dw_hdma_debugfs_regs_wr(struct dw_edma *dw, struct dentry *dent)
> +{
> + struct dentry *regs_dent, *ch_dent;
> + char name[16];
> + int i;
> +
> + regs_dent = debugfs_create_dir(WRITE_STR, dent);
> +
> + for (i = 0; i < dw->wr_ch_cnt; i++) {
> + snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
> +
> + ch_dent = debugfs_create_dir(name, regs_dent);
> +
> + dw_hdma_debugfs_regs_ch(dw, EDMA_DIR_WRITE, i, ch_dent);
> + }
> +}
> +
> +static void dw_hdma_debugfs_regs_rd(struct dw_edma *dw, struct dentry *dent)
> +{
> + struct dentry *regs_dent, *ch_dent;
> + char name[16];
> + int i;
> +
> + regs_dent = debugfs_create_dir(READ_STR, dent);
> +
> + for (i = 0; i < dw->rd_ch_cnt; i++) {
> + snprintf(name, sizeof(name), "%s:%d", CHANNEL_STR, i);
> +
> + ch_dent = debugfs_create_dir(name, regs_dent);
> +
> + dw_hdma_debugfs_regs_ch(dw, EDMA_DIR_READ, i, ch_dent);
> + }
> +}
> +
> +static void dw_hdma_debugfs_regs(struct dw_edma *dw)
> +{
> + struct dentry *regs_dent;
> +
> + regs_dent = debugfs_create_dir(REGISTERS_STR, dw->dma.dbg_dev_root);
> +
> + dw_hdma_debugfs_regs_wr(dw, regs_dent);
> + dw_hdma_debugfs_regs_rd(dw, regs_dent);
> +}
> +
> +void dw_hdma_v0_debugfs_on(struct dw_edma *dw)
> +{
> + if (!debugfs_initialized())
> + return;
> +
> + debugfs_create_u32("mf", 0444, dw->dma.dbg_dev_root, &dw->chip->mf);
> + debugfs_create_u16("wr_ch_cnt", 0444, dw->dma.dbg_dev_root, &dw->wr_ch_cnt);
> + debugfs_create_u16("rd_ch_cnt", 0444, dw->dma.dbg_dev_root, &dw->rd_ch_cnt);
> +
> + dw_hdma_debugfs_regs(dw);
> +}
> diff --git a/drivers/dma/dw-edma/dw-hdma-v0-debugfs.h b/drivers/dma/dw-edma/dw-hdma-v0-debugfs.h
> new file mode 100644
> index 000000000000..e6842c83777d
> --- /dev/null
> +++ b/drivers/dma/dw-edma/dw-hdma-v0-debugfs.h
> @@ -0,0 +1,22 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2023 Cai Huoqing
> + * Synopsys DesignWare HDMA v0 debugfs
> + *
> + * Author: Cai Huoqing <cai.huoqing@linux.dev>
> + */
> +
> +#ifndef _DW_HDMA_V0_DEBUG_FS_H
> +#define _DW_HDMA_V0_DEBUG_FS_H
> +
> +#include <linux/dma/edma.h>
> +
> +#ifdef CONFIG_DEBUG_FS
> +void dw_hdma_v0_debugfs_on(struct dw_edma *dw);
> +#else
> +static inline void dw_hdma_v0_debugfs_on(struct dw_edma *dw)
> +{
> +}
> +#endif /* CONFIG_DEBUG_FS */
> +
> +#endif /* _DW_HDMA_V0_DEBUG_FS_H */
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-03-23 10:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 3:49 [PATCH v8 0/4] dmaengine: dw-edma: Add support for native HDMA Cai Huoqing
2023-03-23 3:49 ` [PATCH v8 1/4] dmaengine: dw-edma: Rename dw_edma_core_ops structure to dw_edma_plat_ops Cai Huoqing
2023-03-23 3:49 ` [PATCH v8 2/4] dmaengine: dw-edma: Create a new dw_edma_core_ops structure to abstract controller operation Cai Huoqing
2023-03-23 3:49 ` [PATCH v8 3/4] dmaengine: dw-edma: Add support for native HDMA Cai Huoqing
2023-03-23 3:53 ` Cai Huoqing
2023-03-23 9:57 ` Serge Semin
2023-03-23 3:49 ` [PATCH v8 4/4] dmaengine: dw-edma: Add HDMA DebugFS support Cai Huoqing
2023-03-23 10:03 ` Serge Semin [this message]
2023-03-23 9:54 ` [PATCH v8 0/4] dmaengine: dw-edma: Add support for native HDMA Serge Semin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230323100325.zltk7emftkyfgsef@mobilestation \
--to=fancer.lancer@gmail.com \
--cc=bhelgaas@google.com \
--cc=cai.huoqing@linux.dev \
--cc=dmaengine@vger.kernel.org \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).