Skip to content

Commit cc8d0a4

Browse files
jonhunterthierryreding
authored andcommitted
firmware: tegra: Prepare for supporting in-band debugfs
Currently, BPMP debug information is accessible via the Linux debugfs file-system using a shared-memory scheme. More recent BPMP firmware now supports accessing the debug information by in-band messaging which does not require shared-memory. To prepare for adding in-band debugfs support for the BPMP, move the shared-memory specific initialisation from the tegra_bpmp_init_debugfs() into a sub-function. Signed-off-by: Jon Hunter <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent edb2bca commit cc8d0a4

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

drivers/firmware/tegra/bpmp-debugfs.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -354,32 +354,43 @@ static int bpmp_populate_dir(struct tegra_bpmp *bpmp, struct seqbuf *seqbuf,
354354
return 0;
355355
}
356356

357-
static int create_debugfs_mirror(struct tegra_bpmp *bpmp, void *buf,
358-
size_t bufsize, struct dentry *root)
357+
static int bpmp_populate_debugfs_shmem(struct tegra_bpmp *bpmp,
358+
struct dentry *root)
359359
{
360360
struct seqbuf seqbuf;
361+
const size_t sz = SZ_512K;
362+
dma_addr_t phys;
363+
size_t nbytes;
364+
void *virt;
361365
int err;
362366

363367
bpmp->debugfs_mirror = debugfs_create_dir("debug", root);
364368
if (!bpmp->debugfs_mirror)
365369
return -ENOMEM;
366370

367-
seqbuf_init(&seqbuf, buf, bufsize);
368-
err = bpmp_populate_dir(bpmp, &seqbuf, bpmp->debugfs_mirror, 0);
371+
virt = dma_alloc_coherent(bpmp->dev, sz, &phys,
372+
GFP_KERNEL | GFP_DMA32);
373+
if (!virt)
374+
return -ENOMEM;
375+
376+
err = mrq_debugfs_dumpdir(bpmp, phys, sz, &nbytes);
369377
if (err < 0) {
370-
debugfs_remove_recursive(bpmp->debugfs_mirror);
371-
bpmp->debugfs_mirror = NULL;
378+
goto free;
379+
} else if (nbytes > sz) {
380+
err = -EINVAL;
381+
goto free;
372382
}
373383

384+
seqbuf_init(&seqbuf, virt, nbytes);
385+
err = bpmp_populate_dir(bpmp, &seqbuf, bpmp->debugfs_mirror, 0);
386+
free:
387+
dma_free_coherent(bpmp->dev, sz, virt, phys);
388+
374389
return err;
375390
}
376391

377392
int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
378393
{
379-
dma_addr_t phys;
380-
void *virt;
381-
const size_t sz = SZ_512K;
382-
size_t nbytes;
383394
struct dentry *root;
384395
int err;
385396

@@ -390,27 +401,9 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
390401
if (!root)
391402
return -ENOMEM;
392403

393-
virt = dma_alloc_coherent(bpmp->dev, sz, &phys,
394-
GFP_KERNEL | GFP_DMA32);
395-
if (!virt) {
396-
err = -ENOMEM;
397-
goto out;
398-
}
399-
400-
err = mrq_debugfs_dumpdir(bpmp, phys, sz, &nbytes);
401-
if (err < 0) {
402-
goto free;
403-
} else if (nbytes > sz) {
404-
err = -EINVAL;
405-
goto free;
406-
}
407-
408-
err = create_debugfs_mirror(bpmp, virt, nbytes, root);
409-
free:
410-
dma_free_coherent(bpmp->dev, sz, virt, phys);
411-
out:
404+
err = bpmp_populate_debugfs_shmem(bpmp, root);
412405
if (err < 0)
413-
debugfs_remove(root);
406+
debugfs_remove_recursive(root);
414407

415408
return err;
416409
}

0 commit comments

Comments
 (0)