lib/system/linux: pass correct offset to metal_map()

According to UIO documentation, the offset device tree property
purpose is to be used "if the device’s memory is not page aligned".
Quoting the same documentation:
"To map the memory of mapping N, you have to use N times the page
size as your offset"
So wee need to pass i * getpagesize() to get the correct mapping,
otherwise, we end up with all io_region pointing to the same area.

Signed-off-by: Leo Sartre <sartre.l@ecagroup.com>
This commit is contained in:
Leo Sartre
2020-12-15 12:49:38 -08:00
committed by Ed Mooring
parent 9c807f04e7
commit 73f746ecf6
+1 -1
View File
@@ -238,7 +238,7 @@ static int metal_uio_dev_open(struct linux_bus *lbus, struct linux_device *ldev)
result = (result ? result :
metal_uio_read_map_attr(ldev, i, "size", &size));
result = (result ? result :
metal_map(ldev->fd, offset, size, 0, 0, &virt));
metal_map(ldev->fd, i * getpagesize(), size, 0, 0, &virt));
if (!result) {
io = &ldev->device.regions[ldev->device.num_regions];
metal_io_init(io, virt, phys, size, -1, 0, NULL);