diff options
author | Russell King <rmk+cubox@arm.linux.org.uk> | 2013-12-05 18:44:51 +0000 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2013-12-05 18:44:51 +0000 |
commit | 6def9c19ccdfb0cb2c22a5f1dcfb3bb1aba60c99 (patch) | |
tree | 7c35ef927565e61d0c682108d43f151373cb91ad /bmm_lib.c | |
parent | 6c486964005d3968aee0897ce0e67ea53f8fcb4d (diff) |
Fix bmm_attach() followed by bmm_get_paddr()
Attaching to a buffer with an offset, and then subsequently asking for
it's physical address returned the non-offset buffer. Fix this by
tracking the physical offset.
Diffstat (limited to 'bmm_lib.c')
-rw-r--r-- | bmm_lib.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -61,6 +61,7 @@ struct bmm_phys_buffer { struct bmm_virt_buffer { void *vaddr; size_t size; + unsigned phys_offset; struct bmm_phys_buffer *phys; }; @@ -312,6 +313,7 @@ void *bmm_malloc_aligned_phys(unsigned long size, int attr, unsigned align, vbuf->vaddr = vaddr; vbuf->size = size; + vbuf->phys_offset = 0; vbuf->phys = pbuf; pthread_mutex_lock(&bmm_mutex); @@ -463,6 +465,7 @@ void *bmm_attach(unsigned long paddr, unsigned long len) if (!pbuf->virt) pbuf->virt = vbuf; + vbuf->phys_offset = paddr - pbuf->paddr; vbuf->phys = pbuf; bmm_rb_virt_insert(vbuf); @@ -538,7 +541,8 @@ unsigned long bmm_get_paddr(void *vaddr) pthread_mutex_lock(&bmm_mutex); vbuf = bmm_buf_find_virt(vaddr); if (vbuf) - pa = vbuf->phys->paddr + (vaddr - vbuf->vaddr); + pa = vbuf->phys->paddr + vbuf->phys_offset + + (vaddr - vbuf->vaddr); pthread_mutex_unlock(&bmm_mutex); return pa; |