msm: adsprpc: Verbose logging in case of dma attachment failures
When dma attachment fails during mmap_create, status of HLOS memory is logged with sizes occupied by heap and non heap buffers mapped in fl maps. The purpose of this data is to get a snapshot of memory usage. Change-Id: Ie913702a743a8572d9f68c9b58233d28541167b9 Signed-off-by: Ansa Ahmed <quic_ansa@quicinc.com>
Este commit está contenido en:

cometido por
Gerrit - the friendly Code Review server

padre
543b55072d
commit
15b180fee9
@@ -1089,6 +1089,14 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags)
|
||||
if (!IS_ERR_OR_NULL(map->buf))
|
||||
dma_buf_put(map->buf);
|
||||
}
|
||||
if (fl) {
|
||||
spin_lock(&fl->hlock);
|
||||
if ((map->flags == ADSP_MMAP_ADD_PAGES) || (map->flags == ADSP_MMAP_ADD_PAGES_LLC))
|
||||
fl->mem_snap.heap_bufs_size -= map->size;
|
||||
else
|
||||
fl->mem_snap.nonheap_bufs_size -= map->size;
|
||||
spin_unlock(&fl->hlock);
|
||||
}
|
||||
bail:
|
||||
if (!map->is_persistent)
|
||||
kfree(map);
|
||||
@@ -1163,6 +1171,8 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct dma_buf *
|
||||
struct fastrpc_mmap *map = NULL;
|
||||
int err = 0, vmid, sgl_index = 0;
|
||||
struct scatterlist *sgl = NULL;
|
||||
bool dma_attach_fail = false;
|
||||
size_t tot_bufs_size = 0;
|
||||
|
||||
if (!fl) {
|
||||
err = -EBADF;
|
||||
@@ -1227,6 +1237,7 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct dma_buf *
|
||||
ADSPRPC_ERR(
|
||||
"dma_buf_attach for fd %d for len 0x%zx failed to map buffer on SMMU device %s ret %ld\n",
|
||||
fd, len, dev_name(me->dev), PTR_ERR(map->attach));
|
||||
dma_attach_fail = true;
|
||||
err = -EFAULT;
|
||||
goto bail;
|
||||
}
|
||||
@@ -1319,6 +1330,7 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct dma_buf *
|
||||
"dma_buf_attach for fd %d failed for len 0x%zx to map buffer on SMMU device %s ret %ld\n",
|
||||
fd, len, dev_name(sess->smmu.dev),
|
||||
PTR_ERR(map->attach));
|
||||
dma_attach_fail = true;
|
||||
err = -EFAULT;
|
||||
goto bail;
|
||||
}
|
||||
@@ -1398,10 +1410,24 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct dma_buf *
|
||||
}
|
||||
map->len = len;
|
||||
|
||||
spin_lock(&fl->hlock);
|
||||
if ((mflags == ADSP_MMAP_ADD_PAGES) || (mflags == ADSP_MMAP_ADD_PAGES_LLC))
|
||||
fl->mem_snap.heap_bufs_size += map->size;
|
||||
else
|
||||
fl->mem_snap.nonheap_bufs_size += map->size;
|
||||
spin_unlock(&fl->hlock);
|
||||
|
||||
fastrpc_mmap_add(map);
|
||||
*ppmap = map;
|
||||
|
||||
bail:
|
||||
if (dma_attach_fail && fl) {
|
||||
tot_bufs_size = fl->mem_snap.heap_bufs_size
|
||||
+ fl->mem_snap.nonheap_bufs_size;
|
||||
ADSPRPC_INFO("Heapbufs size: %zu, non-heapbufs size: %zu, total size: %zu\n",
|
||||
fl->mem_snap.heap_bufs_size, fl->mem_snap.nonheap_bufs_size,
|
||||
tot_bufs_size);
|
||||
}
|
||||
if (map)
|
||||
ktime_get_real_ts64(&map->map_end_time);
|
||||
if (err && map)
|
||||
|
@@ -827,6 +827,13 @@ struct fastrpc_dspsignal {
|
||||
int state;
|
||||
};
|
||||
|
||||
struct memory_snapshot {
|
||||
/* Total size of heap buffers allocated in userspace */
|
||||
size_t heap_bufs_size;
|
||||
/* Total size of non-heap buffers allocated in userspace */
|
||||
size_t nonheap_bufs_size;
|
||||
};
|
||||
|
||||
struct fastrpc_file {
|
||||
struct hlist_node hn;
|
||||
spinlock_t hlock;
|
||||
@@ -844,6 +851,8 @@ struct fastrpc_file {
|
||||
struct fastrpc_buf *pers_hdr_buf;
|
||||
/* Pre-allocated buffer divided into N chunks */
|
||||
struct fastrpc_buf *hdr_bufs;
|
||||
/* Store snapshot of memory occupied by different buffers */
|
||||
struct memory_snapshot mem_snap;
|
||||
|
||||
struct fastrpc_session_ctx *secsctx;
|
||||
uint32_t mode;
|
||||
|
Referencia en una nueva incidencia
Block a user