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
virtio changes 5/2016 #55
Conversation
This commit adds two new functions. pci_enable_device gives drivers finer control over how the PCI device is initialized and pci_restore_device is the shutdown path counterpart. adjust_pci_device is now implemented in terms of pci_enable_device and its functionality hasn't changed, i.e. it still unconditionally enables both memory and I/O space access, and makes sure that the PCI latency timer is set to a minimum value of 32. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Suggested-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Some of the regions may end up being unmapped, either because they are optional or because the attempt to map them has failed. Region types starting at 0 didn't make it easy to test for this condition. This commit bumps all valid region types up by 1 with 0 having the implicit 'unmapped' meaning. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
The driver enabled both memory and I/O access even if they were not usable, e.g. BAR not mapped by BIOS. This commit fixes it by enabling only the BAR types actually used. The device is also restored to the original state (in terms of the command PCI register) on removal. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
iPXE debug logging doesn't support %u. This commit replaces it with %d in virtio-pci debug format strings. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Friendly ping. |
On 09/06/16 07:41, Ladi Prosek wrote:
ACK. In the post-ARM64-work queue. Thanks for putting this into a git Michael |
On 09/06/16 07:41, Ladi Prosek wrote:
I've cherry-picked the two commits that seemed obviously correct to me: [virtio] Renumber virtio_pci_region flags I don't understand the motivation for the remaining two: [pci] Add pci_enable_device and pci_restore_device If a PCI device has no I/O BAR, then it can simply implement Do virtio devices treat PCI_COMMAND in some special way which requires Thanks, Michael |
Thanks - virtio devices may be configured to expose both I/O and memory BARs, with either type being enough to drive the device. It is basically a back-compat setup where older drivers can still use I/O ports and newer may choose to use the so called "modern" interface. We would like to avoid enabling PCI_COMMAND_IO / PCI_COMMAND_MEM if the driver is not going to use it. |
On 20/06/16 15:37, Ladi Prosek wrote:
Why? What goes wrong if iPXE just enables both? Does this prevent iPXE Michael |
On Mo, 2016-06-20 at 15:44 +0100, Michael Brown wrote:
It is nice to have. It will make sure the driver will only use the
Nothing (in theory). cheers, |
On 20/06/16 16:30, Gerd Hoffmann wrote:
OK. If that kind of safety check is wanted, it should probably be I don't think this "nice to have" justifies the code size increase, but Michael |
I'm fine with dropping this if @marcel-apf doesn't object. |
Hi, If every byte is important for ipxe you may leave the patches out, consciously creating an "unfriendly" driver (QEMU will create an io-region for that and will have some 'if' statements with politically correct comments: "Some drivers enable IO even if .." :) ) Bottom line, I would add the patches but definitely there are not a must. |
On 21/06/16 09:49, Marcel Apfelbaum wrote:
Thanks for the input! If the current code would potentially cause problems for the virtio host Looking at the current hw/virtio/virtio-pci.c in qemu: it seems to react Thanks, Michael |
Hi,
It does, but that happens in the generic pci code as it is the same for So, in general it is a good idea to leave stuff disabled if you don't But not doing so should not cause big problems either, especially in For reference: seabios recently started doing that too with this commit: https://code.coreboot.org/p/seabios/source/commit/f1b1d76159a8e7091e783bbc296b928226ccf153/ ... and switching all drivers over to use the new pci_enable_{io,mem}bar cheers, |
This commit adds two new functions. pci_enable_device gives drivers finer control over how the PCI device is initialized and pci_restore_device is the shutdown path counterpart. adjust_pci_device is now implemented in terms of pci_enable_device and its functionality hasn't changed, i.e. it still unconditionally enables both memory and I/O space access, and makes sure that the PCI latency timer is set to a minimum value of 32. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Suggested-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
The driver enabled both memory and I/O access even if they were not usable, e.g. BAR not mapped by BIOS. This commit fixes it by enabling only the BAR types actually used. The device is also restored to the original state (in terms of the command PCI register) on removal. Signed-off-by: Ladi Prosek <lprosek@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
ff1ab8b touches common PCI code but only the virtio-net driver is affected. Please let me know if there are any questions or concerns.
Thank you,
Ladi