-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vmm: add pci_segment mmio aperture configs #6387
vmm: add pci_segment mmio aperture configs #6387
Conversation
899c697
to
4be3b0f
Compare
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.
I guess this is fine (the code and solution are excellent - i'm just always loathe to increase our feature set / API interface as there is more to test and maintain). When adding the segment support I considered only supporting devices with 32-bit BARs on segment 0 - unfortunately the experience would be frustrating as there is no way to know a device needs 32-bit bars until we call allocate_bars
which is relatively late in the device initialisation.
What about testing? Could do some unit tests - if you extracted a function create_mmio_allocators
then that could be unit tested - config changes should be unit tested too. Any scope for integration testing?
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.
The code LGTM.
Maybe it's better to add some description in docs/iommu.md.
Now that the solution / UI has high level approval, I will go back today and add unit tests, integration tests, and documentation. |
bbba421
to
6435866
Compare
Okay, I have added:
I can't think of a good integration test. If anyone has suggestions, I would be happy to add. Otherwise, I think this is g2g. |
6435866
to
06e2ed5
Compare
06e2ed5
to
0e3d26a
Compare
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.
I'm happy with unit tests - we should have more of those - we should aim to have more of those - they run much quicker and can also help structure the code for readability.
0e3d26a
to
427c3cd
Compare
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.
LGTM. Only couple of nits about documentation formatting. Thank you for the contributions.
427c3cd
to
87ae7fd
Compare
When using multiple PCI segments, the 32-bit and 64-bit mmio aperture is split equally between each segment. Add an option to configure the 'weight'. For example, a PCI segment with a `mmio32_aperture_weight` of 2 will be allocated twice as much 32-bit mmio space as a normal PCI segment. Signed-off-by: Thomas Barrett <tbarrett@crusoeenergy.com>
87ae7fd
to
2122a66
Compare
When using multiple PCI segments, the 32-bit and 64-bit mmio aperture is split equally between each segment. Add an option to configure the 'weight'. For example, a PCI segment with a
mmio32_aperture_weight
of 2 will be allocated twice as much 32-bit mmio space as a normal PCI segment.Alternatives Considered
I considered adding a
mmio32_aperture_size
config instead ofmmio32_aperture_weight
config to precisely configure the size of the mmio apertures for each segment. I chose to not implement this because the logic to implement that correctly was a lot more complicated. Also, allocating mmio space between PCI segments does not actually require that level of precision.Use Case
Unfortunately, some devices actually use quite a bit of 32-bit MMIO space. For example, a NVIDIA NVSwitch device uses 32 MB of 32-bit mmio. When using a few PCI segments and a few NVSwitch VFIO devices, you can quickly overwhelm the default 32-bit mmio allocation for a PCI segment.
Example
The following example allocates 2 PCI segments. The first segment is allocated 1/4 of the available mmio32 space. The second segment is allocated 3/4 of the available mmio32 space.
Backward Compatability
This is completely backwards compatible. By default, each PCI segment has a aperture weight of 1.