Skip to content

Commit

Permalink
lib.hardware.pci: cleanup previous commits
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Apr 19, 2022
1 parent 1c7497c commit 6dd5418
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/hardware/pci.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,19 @@ end

function map_pci_memory (f)
local st = assert(f:stat())
local mem, err
mem, err = f:mmap(nil, st.size, "read, write", "shared", 0)
local mem, err = f:mmap(nil, st.size, "read, write", "shared", 0)
-- mmap() returns EINVAL on Linux >= 4.5 if the device is still
-- claimed by the kernel driver. We assume that
-- unbind_device_from_linux() has already been called but it may take
-- some time for the driver to release the device.
if not mem then
if not mem and err.INVAL then
lib.waitfor2("mmap of "..filepath,
function ()
mem, err = f:mmap(nil, st.size, "read, write", "shared", 0)
assert(not err or err.INVAL)
return mem
return mem ~= nil or not err.INVAL
end, 5, 1000000)
end
assert(mem, err)
return ffi.cast("uint32_t *", mem)
end

Expand Down

0 comments on commit 6dd5418

Please sign in to comment.