forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Intel82599] Unbind PCI device before using it.
- Loading branch information
Showing
1 changed file
with
4 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks correct to me.
The same change is also needed anywhere else a PCI device is opened though, for example in the loadgen app.
I wonder what the best place to do this really is? Options:
intel_app
andloadgen
and other apps that use PCI drivers.intel10g
and any other drivers.pci
module e.g. before any/all calls that mess with the PCI device.what do you think?
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a second glance the code should be a bit different. In the
pci
module there is aopen_usable_devices
routine which is AFAIK unused and broken (it usesopen_device
of which I can not find the definition, might be a stub).I want to:
lib.hardware.pci
, that means finding out which functions are used/working and what for.pci
lib instead of extending it further. If callingunbind...
before using it is enough of general PCI initialization then I think it's reasonable to have a minimal API with functions X,Y,Z that requires you to callunbind...
first.M_sf:open
(edit: andM_pf:open
) inintel10g.lua
which would cover bothLoadGen
and our userspace driver.c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukego I noticed that we do enable PCI bus mastering (
pci.set_bus_master(self.pciaddress, true)
) but we never disable it (e.g.pci.set_bus_master(self.pciaddress, false)
) after closing/unmapping DMA memory. Is that intended?c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Shutting down bus mastering would be a good cleanup step. In fact, ideally we would do this even on abrupt shutdown (e.g. ^C or SEGV). Like the
trap
in bash scripts. ljsyscall and glibc both have mechanisms for this.I'd quite like to see the unused PCI scanning code deleted :).
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I see a conflict there. PCI bus mastering should really be disabled by
M_pf:close()
andM_sf:close()
and the handler for signals might not know which PCI devices do have bus mastering enabled. Add it to:close()
for now and see what happens?c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, start simple.
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable!
Could also replace the C code with Lua code using ljsyscall?
c1c0e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... I explored some options regarding clean shutdown on receiving various signals using
ljsyscall
(see this thread). It seems like the safest way would be to usesigprocmask
andsignalfd
to queue up fatal signals in a queue. The question is when to read/handle them? My first thought was to do it inbreathe
but then again Snabb won't always crash duringmain
meaning this could lead to becoming a zombie process.