Skip to content

Commit 3805b84

Browse files
authored
On Linux, xrt-runner should use MAP_SHARED for readonly memory mapped… (Xilinx#9838)
* On Linux, xrt-runner should use MAP_SHARED for readonly memory mapped artifcats or else amdxdna returns EFAULT error code when creating BO Signed-off-by: Sonal Santan <sonal.santan@amd.com> * Improve userptr details in xrt::bo inline documentation Signed-off-by: Sonal Santan <sonal.santan@amd.com> --------- Signed-off-by: Sonal Santan <sonal.santan@amd.com>
1 parent 307a964 commit 3805b84

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

  • src/runtime_src/core

src/runtime_src/core/common/runner/detail/linux/mmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct mmap_artifact
9797
static void*
9898
map_region(int fd, std::size_t size)
9999
{
100-
void* ptr = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0);
100+
void* ptr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
101101
if (ptr == MAP_FAILED)
102102
{
103103
close(fd);

src/runtime_src/core/include/xrt/xrt_bo.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ class bo
160160
* @param device
161161
* The device on which to allocate this buffer
162162
* @param userptr
163-
* Pointer to aligned user memory
163+
* Pointer to 4K aligned user memory allocated using OS provided aligned
164+
* allocator.
165+
* A readonly pointer may be obtained via a readonly mmap of a file
166+
* opened in readonly mode.
164167
* @param sz
165168
* Size of buffer
166169
* @param flags
@@ -181,7 +184,10 @@ class bo
181184
* @param device
182185
* The device on which to allocate this buffer
183186
* @param userptr
184-
* Pointer to aligned user memory
187+
* Pointer to 4K aligned user memory allocated using OS provided aligned
188+
* allocator.
189+
* A readonly pointer may be obtained via a readonly mmap of a file
190+
* opened in readonly mode.
185191
* @param sz
186192
* Size of buffer
187193
* @param grp
@@ -272,7 +278,10 @@ class bo
272278
* @param hwctx
273279
* The hardware context in which to allocate this buffer
274280
* @param userptr
275-
* Pointer to aligned user memory
281+
* Pointer to 4K aligned user memory allocated using OS provided aligned
282+
* allocator.
283+
* A readonly pointer may be obtained via a readonly mmap of
284+
* a file opened in readonly mode.
276285
* @param sz
277286
* Size of buffer
278287
* @param flags
@@ -293,7 +302,10 @@ class bo
293302
* @param hwctx
294303
* The hardware context in which to allocate this buffer
295304
* @param userptr
296-
* Pointer to aligned user memory
305+
* Pointer to 4K aligned user memory allocated using OS provided aligned
306+
* allocator.
307+
* A readonly pointer may be obtained via a readonly mmap of a file
308+
* opened in readonly mode.
297309
* @param sz
298310
* Size of buffer
299311
* @param grp

0 commit comments

Comments
 (0)