I am playing with Juno board and its Mali T624 GPU. Basically, i am trying to read/write the I/O registers from GPU. In my case, i know the physical address of the registers and i can map the registers to the virtual memory space of the application processor. However, i don't really know how to make Mali access these registers.
The ARM computer library provides a nice support for the OpenCL APIs, so I tried to use OpenCL first. I mapped the registers to virtual memory space, and use clCreateBuffer with CL_MEM_USE_HOST_PTR to make the virtual memory accessible to Mali. The problem is that the buffer accessed by Mali is actually a copy, and writing to the buffer won't directly write back to the registers. I might use map/unmap operations to achieve the write back, but this is not what i really want. The manual tells that the flag CL_MEM_ALLOC_HOST_PTR is the only way to avoid data copying, but if i create a buffer with CL_MEM_ALLOC_HOST_PTR, i cannot get an efficient way to map the I/O registers to the allocated buffer.
I also tried to look through the provided open source kernel GPU driver. Since the source code does not contain a formal documentation and the GPU manual is not publicly avaliable, i am totally lost in the code.
Does anyone have any experience on similar problem? Thanks for any suggestions and discussions!
For a normal application this won't be possible - the GPU registers are privileged access only (enforced by the GPU MMU page tables for that process), and it would be a security problem if user-space workloads were allowed to reconfigure the GPU on the fly.
Thanks for your reply! I am sorry that i didn't make my question clear enough. Actually, i didn't mean to access the registers of the GPU, i attempt to access the I/O registers from GPU. For example, there are a lot of memory-mapped registers in the system (e.g., NIC, GIC, and so on), and the physical address of these registers is known, can we access them from the GPU?
The same answer applies. The process running on the GPU has the same level of privilege as the user-space process which is calling the high level API. It would be a horrifically bad design choice and a massive security hole to let a user-space application memory map and then rewrite hardware peripheral registers, so no it's not possible.