Skip to content

Commit

Permalink
dmaengine: dw-edma: Convert debugfs descs to being heap-allocated
Browse files Browse the repository at this point in the history
Currently DW eDMA debugfs node descriptors are allocated on the stack,
which won't work for multi-eDMA platforms. As a preparation to supporting
multi-eDMA systems, allocate each debugfs node separately.  Afterwards
we'll add info like Read/Write channel flag, channel ID, DW eDMA private
data reference.

Note: this conversion is mainly required due to having the legacy DW eDMA
controllers with indirect Read/Write channels context CSRs access. If we
didn't need to synchronize access to these registers, the debugfs code of
the driver would have been much simpler.

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Manivannan Sadhasivam <[email protected]>
Signed-off-by: Serge Semin <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Acked-by: Vinod Koul <[email protected]>
  • Loading branch information
fancer authored and Lorenzo Pieralisi committed Jan 27, 2023
1 parent 345e3a9 commit 782536a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/dma/dw-edma/dw-edma-v0-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct dw_edma_debugfs_entry {

static int dw_edma_debugfs_u32_get(void *data, u64 *val)
{
void __iomem *reg = data;
struct dw_edma_debugfs_entry *entry = data;
void __iomem *reg = entry->reg;

if (dw->chip->mf == EDMA_MF_EDMA_LEGACY &&
reg >= (void __iomem *)&regs->type.legacy.ch) {
Expand Down Expand Up @@ -94,14 +95,22 @@ static int dw_edma_debugfs_u32_get(void *data, u64 *val)
}
DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_edma_debugfs_u32_get, NULL, "0x%08llx\n");

static void dw_edma_debugfs_create_x32(const struct dw_edma_debugfs_entry entries[],
static void dw_edma_debugfs_create_x32(const struct dw_edma_debugfs_entry ini[],
int nr_entries, struct dentry *dir)
{
struct dw_edma_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, dir,
entries[i].reg, &fops_x32);
&entries[i], &fops_x32);
}
}

Expand Down

0 comments on commit 782536a

Please sign in to comment.