mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
soc: rockchip: restruct the rk_dmabuf procfs
This patch add a DMABUF_DEBUG_ADVANCED to try to attach and map
dmabufs who have no valid scatter list table.
Update the rk_dmabuf_procfs node to be a directory tree as:
/proc/rk_dmabuf/
/proc/rk_dmabuf/dev
/proc/rk_dmabuf/sgt
/proc/rk_dmabuf/size
The "dev" to show all attached devices, such as:
ffffff816f8bb600 (null) system-uncached 8288 KiB display-subsystem fb000000.gpu fb000000.gpu
The "sgt" to show scatter list table address range, such as
ffffff8124856200 (null) system-uncached 52 KiB 0: 0x00000001712d0000..0x00000001712d0fff ( 4 KiB)
1: 0x00000001712d2000..0x00000001712d2fff ( 4 KiB)
2: 0x00000001712c6000..0x00000001712c6fff ( 4 KiB)
3: 0x00000001712c8000..0x00000001712c8fff ( 4 KiB)
4: 0x00000001712ca000..0x00000001712cafff ( 4 KiB)
5: 0x00000001712cc000..0x00000001712ccfff ( 4 KiB)
6: 0x00000001712ce000..0x00000001712cefff ( 4 KiB)
7: 0x00000001712d1000..0x00000001712d1fff ( 4 KiB)
8: 0x00000001712c7000..0x00000001712c7fff ( 4 KiB)
9: 0x00000001712c9000..0x00000001712c9fff ( 4 KiB)
10: 0x00000001712cb000..0x00000001712cbfff ( 4 KiB)
11: 0x00000001712cd000..0x00000001712cdfff ( 4 KiB)
12: 0x00000001712cf000..0x00000001712cffff ( 4 KiB)
The "size" to show total dmabuf size, such as:
Total: 79836 KiB
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: I62292094407696e410e2ce2973a60f569964e8bd
This commit is contained in:
@@ -17,6 +17,13 @@ config DMABUF_DEBUG
|
||||
This option support to debug all the dmabuf on db_list, allows to set
|
||||
a name for dmabuf. If not sure, say N
|
||||
|
||||
config DMABUF_DEBUG_ADVANCED
|
||||
bool "DMABUF debug advanced option"
|
||||
depends on DMABUF_DEBUG
|
||||
help
|
||||
This option support to debug all the dmabuf on db_list, allows to attach
|
||||
and map a dmabuf who has no attachment. If not sure, say N
|
||||
|
||||
config SYNC_FILE
|
||||
bool "Explicit Synchronization Framework"
|
||||
default n
|
||||
|
||||
@@ -16,7 +16,6 @@ static struct device *dmabuf_dev;
|
||||
|
||||
static void rk_dmabuf_dump_empty_sgt(struct dma_buf *dmabuf, void *private)
|
||||
{
|
||||
struct dma_buf *db = (struct dma_buf *)dmabuf;
|
||||
struct dma_buf_attachment *a;
|
||||
struct seq_file *s = private;
|
||||
struct scatterlist *sg;
|
||||
@@ -24,13 +23,13 @@ static void rk_dmabuf_dump_empty_sgt(struct dma_buf *dmabuf, void *private)
|
||||
phys_addr_t end, len;
|
||||
int i;
|
||||
|
||||
a = dma_buf_attach(db, dmabuf_dev);
|
||||
a = dma_buf_attach(dmabuf, dmabuf_dev);
|
||||
if (IS_ERR(a))
|
||||
return;
|
||||
|
||||
sgt = dma_buf_map_attachment(a, DMA_BIDIRECTIONAL);
|
||||
if (IS_ERR(sgt)) {
|
||||
dma_buf_detach(db, a);
|
||||
dma_buf_detach(dmabuf, a);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,10 +37,10 @@ static void rk_dmabuf_dump_empty_sgt(struct dma_buf *dmabuf, void *private)
|
||||
end = sg->dma_address + sg->length - 1;
|
||||
len = sg->length;
|
||||
if (i)
|
||||
seq_printf(s, "%48s", " ");
|
||||
seq_printf(s, "%65s", " ");
|
||||
else
|
||||
seq_printf(s, "%-16.16s %-16.16s %10lu KiB",
|
||||
dmabuf->name,
|
||||
seq_printf(s, "%px %-16.16s %-16.16s %10lu KiB",
|
||||
dmabuf, dmabuf->name,
|
||||
dmabuf->exp_name, K(dmabuf->size));
|
||||
seq_printf(s, "%4d: %pa..%pa (%10lu %s)\n", i,
|
||||
&sg->dma_address, &end,
|
||||
@@ -49,10 +48,10 @@ static void rk_dmabuf_dump_empty_sgt(struct dma_buf *dmabuf, void *private)
|
||||
(len >> 10) ? "KiB" : "Bytes");
|
||||
}
|
||||
dma_buf_unmap_attachment(a, sgt, DMA_BIDIRECTIONAL);
|
||||
dma_buf_detach(db, a);
|
||||
dma_buf_detach(dmabuf, a);
|
||||
}
|
||||
|
||||
static void rk_dmabuf_dump_sgt(struct dma_buf *dmabuf, void *private)
|
||||
static void rk_dmabuf_dump_sgt(const struct dma_buf *dmabuf, void *private)
|
||||
{
|
||||
struct seq_file *s = private;
|
||||
struct scatterlist *sg;
|
||||
@@ -60,9 +59,6 @@ static void rk_dmabuf_dump_sgt(struct dma_buf *dmabuf, void *private)
|
||||
phys_addr_t end, len;
|
||||
int i;
|
||||
|
||||
if (list_empty(&dmabuf->attachments))
|
||||
return rk_dmabuf_dump_empty_sgt(dmabuf, s);
|
||||
|
||||
list_for_each_entry_safe(a, t, &dmabuf->attachments, node) {
|
||||
if (!a->sgt)
|
||||
continue;
|
||||
@@ -70,26 +66,33 @@ static void rk_dmabuf_dump_sgt(struct dma_buf *dmabuf, void *private)
|
||||
end = sg->dma_address + sg->length - 1;
|
||||
len = sg->length;
|
||||
if (i)
|
||||
seq_printf(s, "%48s", " ");
|
||||
seq_printf(s, "%65s", " ");
|
||||
else
|
||||
seq_printf(s, "%-16.16s %-16.16s %10lu KiB",
|
||||
dmabuf->name,
|
||||
seq_printf(s, "%px %-16.16s %-16.16s %10lu KiB",
|
||||
dmabuf, dmabuf->name,
|
||||
dmabuf->exp_name, K(dmabuf->size));
|
||||
seq_printf(s, "%4d: %pa..%pa (%10lu %s)\n", i,
|
||||
&sg->dma_address, &end,
|
||||
(len >> 10) ? (K(len)) : (unsigned long)len,
|
||||
(len >> 10) ? "KiB" : "Bytes");
|
||||
}
|
||||
break;
|
||||
return;
|
||||
}
|
||||
/* Try to attach and map the dmabufs without sgt. */
|
||||
if (IS_ENABLED(CONFIG_DMABUF_DEBUG_ADVANCED)) {
|
||||
struct dma_buf *dbuf = (struct dma_buf *)dmabuf;
|
||||
|
||||
get_dma_buf(dbuf);
|
||||
rk_dmabuf_dump_empty_sgt(dbuf, s);
|
||||
dma_buf_put(dbuf);
|
||||
}
|
||||
}
|
||||
|
||||
static int rk_dmabuf_cb(const struct dma_buf *dmabuf, void *private)
|
||||
{
|
||||
struct seq_file *s = private;
|
||||
struct dma_buf *db = (struct dma_buf *)dmabuf;
|
||||
|
||||
rk_dmabuf_dump_sgt(db, s);
|
||||
rk_dmabuf_dump_sgt(dmabuf, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -101,22 +104,43 @@ static int rk_dmabuf_cb2(const struct dma_buf *dmabuf, void *private)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rk_dmabuf_show(struct seq_file *s, void *v)
|
||||
static int rk_dmabuf_cb3(const struct dma_buf *dmabuf, void *private)
|
||||
{
|
||||
struct seq_file *s = private;
|
||||
struct dma_buf_attachment *a, *t;
|
||||
|
||||
seq_printf(s, "%px %-16.16s %-16.16s %10lu KiB",
|
||||
dmabuf, dmabuf->name,
|
||||
dmabuf->exp_name, K(dmabuf->size));
|
||||
list_for_each_entry_safe(a, t, &dmabuf->attachments, node) {
|
||||
seq_printf(s, " %s", dev_name(a->dev));
|
||||
}
|
||||
seq_puts(s, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rk_dmabuf_sgt_show(struct seq_file *s, void *v)
|
||||
{
|
||||
seq_printf(s, "%16s %-16s %-16s %14s %8s\n\n",
|
||||
"DMABUF", "NAME", "EXPORT", "SIZE:KiB", "SGLIST");
|
||||
|
||||
return get_each_dmabuf(rk_dmabuf_cb, s);
|
||||
}
|
||||
|
||||
static int rk_dmabuf_dev_show(struct seq_file *s, void *v)
|
||||
{
|
||||
seq_printf(s, "%16s %-16s %-16s %14s %8s\n\n",
|
||||
"DMABUF", "NAME", "EXPORT", "SIZE:KiB", "AttachedDevices");
|
||||
|
||||
return get_each_dmabuf(rk_dmabuf_cb3, s);
|
||||
}
|
||||
|
||||
static int rk_dmabuf_size_show(struct seq_file *s, void *v)
|
||||
{
|
||||
int ret;
|
||||
unsigned long total_size = 0;
|
||||
|
||||
seq_printf(s, "%-16s %-16s %14s %8s\n\n",
|
||||
"NAME", "EXPORT", "SIZE:KiB", "SGLIST");
|
||||
|
||||
ret = get_each_dmabuf(rk_dmabuf_cb, s);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = get_each_dmabuf(rk_dmabuf_cb2, &total_size);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
get_each_dmabuf(rk_dmabuf_cb2, &total_size);
|
||||
seq_printf(s, "Total: %lu KiB\n", K(total_size));
|
||||
|
||||
return 0;
|
||||
@@ -130,12 +154,15 @@ static int __init rk_dmabuf_init(void)
|
||||
.id = PLATFORM_DEVID_NONE,
|
||||
.dma_mask = DMA_BIT_MASK(64),
|
||||
};
|
||||
struct proc_dir_entry *root = proc_mkdir("rk_dmabuf", NULL);
|
||||
|
||||
pdev = platform_device_register_full(&dev_info);
|
||||
dma_set_max_seg_size(&pdev->dev, (unsigned int)DMA_BIT_MASK(64));
|
||||
dmabuf_dev = pdev ? &pdev->dev : NULL;
|
||||
|
||||
proc_create_single("rk_dmabuf", 0, NULL, rk_dmabuf_show);
|
||||
proc_create_single("sgt", 0, root, rk_dmabuf_sgt_show);
|
||||
proc_create_single("dev", 0, root, rk_dmabuf_dev_show);
|
||||
proc_create_single("size", 0, root, rk_dmabuf_size_show);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user