diff options
| author | Amir Samuelov <amirs@codeaurora.org> | 2016-05-31 10:28:27 +0300 |
|---|---|---|
| committer | Kyle Yan <kyan@codeaurora.org> | 2016-05-31 15:26:28 -0700 |
| commit | f8a4373feae9b2df9490cb10315e5aa0087593b3 (patch) | |
| tree | 19bd05266d36004447bc9fbb145594ddc2eeec02 /drivers/soc | |
| parent | d8b33a2dac2e94dda2f0a09975ec7db9a7d1fcff (diff) | |
spcom: fix modify ion addr
It is expected that the 64 bit ion buffer address,
will be located on the request/response buffer at an offset
that is 64 bit aligned.
However, the user may pack the request/response on his own risk,
and the offset might not be 64 bit aligned.
Change-Id: I85e7644aa05d8c5249e2d204a61d03b5fb2f9220
Signed-off-by: Amir Samuelov <amirs@codeaurora.org>
Diffstat (limited to 'drivers/soc')
| -rw-r--r-- | drivers/soc/qcom/spcom.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c index 24c8d911ef17..584936c3910d 100644 --- a/drivers/soc/qcom/spcom.c +++ b/drivers/soc/qcom/spcom.c @@ -1372,11 +1372,12 @@ static int modify_ion_addr(void *buf, size_t len; int fd; uint32_t buf_offset; - uint64_t *addr; + char *ptr = (char *)buf; int ret; fd = ion_info.fd; buf_offset = ion_info.buf_offset; + ptr += buf_offset; if (fd < 0) { pr_err("invalid fd [%d].\n", fd); @@ -1403,13 +1404,14 @@ static int modify_ion_addr(void *buf, ion_free(spcom_dev->ion_client, handle); return -EINVAL; } - pr_debug("buf_offset [%d].\n", buf_offset); - addr = (uint64_t *) ((char *) buf + buf_offset); + if (buf_offset % sizeof(uint64_t)) + pr_debug("offset [%d] is NOT 64-bit aligned.\n", buf_offset); + else + pr_debug("offset [%d] is 64-bit aligned.\n", buf_offset); - /* Replace the user ION Virtual Address with the Physical Address */ - pr_debug("ion user vaddr = [0x%lx].\n", (long int) *addr); - *addr = (uint64_t) ion_phys_addr; - pr_debug("ion phys addr = [0x%lx].\n", (long int) *addr); + /* Set the ION Physical Address at the buffer offset */ + pr_debug("ion phys addr = [0x%lx].\n", (long int) ion_phys_addr); + memcpy(ptr, &ion_phys_addr, sizeof(uint64_t)); /* Release the ION handle */ ion_free(spcom_dev->ion_client, handle); |
