Skip to content

Commit 714fccb

Browse files
yuranuogabbay
authored andcommitted
habanalabs: save pid per userptr
Currently userptr endpoint in debugfs prints out virtual addresses in the user process memory space, without specifying their owner process ID. User space virtual address is meaningless without knowing the owner process. Signed-off-by: Yuri Nudelman <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 83f14f2 commit 714fccb

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

drivers/misc/habanalabs/common/debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ static int userptr_show(struct seq_file *s, void *data)
209209
if (first) {
210210
first = false;
211211
seq_puts(s, "\n");
212-
seq_puts(s, " user virtual address size dma dir\n");
212+
seq_puts(s, " pid user virtual address size dma dir\n");
213213
seq_puts(s, "----------------------------------------------------------\n");
214214
}
215-
seq_printf(s,
216-
" 0x%-14llx %-10llu %-30s\n",
217-
userptr->addr, userptr->size, dma_dir[userptr->dir]);
215+
seq_printf(s, " %-7d 0x%-14llx %-10llu %-30s\n",
216+
userptr->pid, userptr->addr, userptr->size,
217+
dma_dir[userptr->dir]);
218218
}
219219

220220
spin_unlock(&dev_entry->userptr_spinlock);

drivers/misc/habanalabs/common/habanalabs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,7 @@ struct hl_ctx_mgr {
14341434
* @sgt: pointer to the scatter-gather table that holds the pages.
14351435
* @dir: for DMA unmapping, the direction must be supplied, so save it.
14361436
* @debugfs_list: node in debugfs list of command submissions.
1437+
* @pid: the pid of the user process owning the memory
14371438
* @addr: user-space virtual address of the start of the memory area.
14381439
* @size: size of the memory area to pin & map.
14391440
* @dma_mapped: true if the SG was mapped to DMA addresses, false otherwise.
@@ -1446,6 +1447,7 @@ struct hl_userptr {
14461447
struct sg_table *sgt;
14471448
enum dma_data_direction dir;
14481449
struct list_head debugfs_list;
1450+
pid_t pid;
14491451
u64 addr;
14501452
u64 size;
14511453
u8 dma_mapped;

drivers/misc/habanalabs/common/memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,7 @@ int hl_pin_host_memory(struct hl_device *hdev, u64 addr, u64 size,
17621762
return -EINVAL;
17631763
}
17641764

1765+
userptr->pid = current->pid;
17651766
userptr->sgt = kzalloc(sizeof(*userptr->sgt), GFP_KERNEL);
17661767
if (!userptr->sgt)
17671768
return -ENOMEM;

0 commit comments

Comments
 (0)