aboutsummaryrefslogtreecommitdiff
path: root/src/hw
AgeCommit message (Collapse)AuthorFilesLines
2017-11-02timer: Avoid integer overflows in usec and nsec calculationsKevin O'Connor1-24/+31
When timer_calc_usec() is used with large timeout values, such as 60s, the integer math can overflow and produce different results than when using timer_calc(time / 1000) for the same timeout. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-14nvme: Use the Maximum Queue Entries Supported (MQES) to initialize I/O queuesFilippo Sironi1-2/+8
Use the Maximum Queue Entries Supported (MQES) to initialize I/O queues depth rather than picking a fixed number (256) which might not be supported by some NVMe controllers (the NVMe specification says that an NVMe controller may support any number between 2 to 4096). Still cap the I/O queues depth to 256 since, during my testing, SeaBIOS was running out of memory when using something higher than 256 (4096 on the NVMe controller that I've had a chance to try). Signed-off-by: Filippo Sironi <sironi@amazon.de>
2017-10-09xhci: Verify the device is still present in xhci_cmd_submit()Kevin O'Connor1-0/+11
Make sure the USB device is still present before altering the xhci "slot" for it. It appears some controllers will hang if a request is sent to a port no longer connected. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-06nvme: fix out of memory behaviorJulian Stecklina1-36/+111
If the allocation of I/O queues ran out of memory, the code would fail to detect that and happily use these queues at address zero. For me this happens for systems with more than 7 NVMe controllers. Fix the out of memory handling to gracefully handle this case. Signed-off-by: Julian Stecklina <jsteckli@amazon.de>
2017-10-03xhci: Build TRBs directly in xhci_trb_queue()Kevin O'Connor1-105/+59
Use the logic for building a 'struct xhci_trb' that was in xhci_xfer_queue() up so that command and ring TRBs can also use that functionality. This eliminates the need to manually generate the xhci_trb struct from those code paths. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27virtio: Allocate drive_s storage in low memoryKevin O'Connor3-9/+7
Use the "low" memory segment instead of the f-segment for the drive_s storage. This can help avoid running out of memory in the f-segment. Tested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27block: Rename disk_op_s->drive_gf to drive_flKevin O'Connor16-42/+42
Now that the drive_s struct does not need to be in the f-segment, rename references to drive_gf in the generic drive code to drive_fl. This is just variable renames - no code changes. Tested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27disk: Don't require the 'struct drive_s' to be in the f-segmentKevin O'Connor1-2/+2
Allow the 'struct drive_s' drive description structure to be in either the "low" memory segment or the f-segment. Tested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-14pci: enable RedHat PCI bridges to reserve additional resources on PCI initAleksandr Bezzubikov1-0/+3
In case of Red Hat Generic PCIE Root Port reserve additional buses and/or IO/MEM/PREF space, which values are provided in a vendor-specific capability. Signed-off-by: Aleksandr Bezzubikov <zuban32s@gmail.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
2017-09-14pci: refactor pci_find_capapibilty to get bdf as the first argument instead ↵Aleksandr Bezzubikov5-28/+28
of the whole pci_device Refactor pci_find_capability function to get bdf instead of a whole pci_device* as the only necessary field for this function is still bdf. Signed-off-by: Aleksandr Bezzubikov <zuban32s@gmail.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
2017-07-25usb-xhci: use hub portmapGerd Hoffmann1-4/+41
xhci controllers have two virtual ports per (usb3 capable) physical port, one for usb2 and one for usb3 devices. Add a hub portmap callback to map the virtual ports to physical ports. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-07-25usb: add hub portmapGerd Hoffmann1-0/+1
Allow usb hubs to map (software) ports to physical ports via op callback. This is needed to make bootorder work in case there isn't a simple linear mapping. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2017-07-07virtio: IOMMU supportJason Wang3-2/+5
Since we don't enable IOMMU at all, we can then simply enable the IOMMU support by claiming the support of VIRITO_F_IOMMU_PLATFORM. This fixes booting failure when iommu_platform is set from qemu cli. Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
2017-07-02ahci: Disable Native Command QueueingZeh, Werner1-1/+0
The AHCI driver currently sets the NCQ bit for every command that is issued to the SATA drive. This is not needed as there is always only one command active at a time and in turn can lead to a hanging AHCI controller (true for Marvel 88SE9170). The following patch disables the usage of NCQ completely. With this patch the Marvel AHCI controller works just fine without any issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-12nvme: Enable NVMe support for non-qemu hardwareYouness Alaoui1-2/+1
NVMe support was tested on purism/librem13 laptops and SeaBIOS has no problems in detecting and booting the drives. This is a continuation of commit 235a8190 which was incomplete. Signed-off-by: Youness Alaoui <youness.alaoui@puri.sm> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-12Revert "lsi-scsi: reset in case of a serious problem"Roman Kagan1-2/+0
This reverts commit 11277846e819b9eef3db5ac833a6a47f95f5ef15. It was originally introduced to deal with the case when REPORT_LUNS caused an error in QEMU implementation of lsi53c895a and left it in a "confused" state making further interaction impossible. However the remedy was worse than the disease: the reset was controller-wide causing all luns to reset, losing all in-flight requests; upon that all luns lit up unit_attention condition, so that any non-informational request would fail with check_condition status. As a result, the lun enumeration succeeded and I saw the respective entries in the boot menu during my testing, but the read from those luns ended with an error and booting failed, which I didn't bother to test. So this reverts to the original error handling behavior. The problem with the failing REPORT_LUNS is addressed in the preceding patch, by making it unlikely to fail. Reported-by: Maciej Józefczyk <maciej.jozefczyk@corp.ovh.com> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-06-12blockcmd: start REPORT_LUNS with the smallest bufferRoman Kagan1-1/+3
A number of emulated SCSI devices in QEMU incorrectly return an error to REPORT_LUNS command when the size of the data returned is smaller than the allocation length passed in. To work it around, start with the smallest allocation length possible: for 1 entry. This is a slight pessimization because it would require another REPORT_LUNS iteration if the target has more than a single LUN, but this appears to have negligible impact on boot times, and makes REPORT_LUNS enumeration work for more QEMU devices (lsi53c895a, mptsas1068). Reported-by: Maciej Józefczyk <maciej.jozefczyk@corp.ovh.com> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-10NVMe: Allow NVMe to be enabled on real hardwareKevin O'Connor1-1/+1
A couple of users have reported success with the NVMe driver on real hardware, so allow it to be enabled outside of QEMU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-02src: Minor - remove tab characters that slipped into SeaBIOS C codeKevin O'Connor1-4/+4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-02lsi-scsi: try to enumerate luns with REPORT LUNSRoman Kagan1-11/+26
Enumerate active luns with REPORT LUNS and, if that fails[*], fall back to sequentially enumerating them up to (arbitrarily chosen) #8 [**]. [*] in current QEMU, REPORT LUNS does fail in lsi53c895a because the returned data is smaller than the allocation length which is (wrongly) considered an underflow [**] in current QEMU, luns above 0 are not supported in lsi53c895a, so this patch is here only for completeness. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02lsi-scsi: reset in case of a serious problemRoman Kagan1-0/+2
When the device reports a serious problem via SIST[01] registers, it needs to be reset, otherwise the following requests will most likely fail, too. In particular, REPORT LUNS which fails (wrongly) with underflow in QEMU makes all the following requests fail, too, rendering the device unusable. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02mpt-scsi: try to enumerate luns with REPORT LUNSRoman Kagan1-14/+26
Enumerate active luns with REPORT LUNS and, if that fails[*], fall back to sequentially enumerating them up to (arbitrarily chosen) #8. Note that this patch also makes mpt_scsi_cmd accept luns other than 0; I've no idea what was the original motivation not to, and what can break due to this change (nothing broke in my basic tests with QEMU). [*] in current QEMU, REPORT LUNS does fail in mptsas1068 because the returned data is smaller than the allocation length which is (wrongly) considered an underflow. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02pvscsi: fix the comment about lun enumerationRoman Kagan1-1/+1
The comment in pvscsi_scan_target (presumably c&p-ed from another driver) reads that REPORTS LUNS should better be used to enumerate the luns on the target. However, according to the Linux driver, the device supports no more than a single lun per target. So adjust the comment to tell exactly that. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02usb-uas: enumerate luns with REPORT LUNSRoman Kagan1-16/+29
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02esp-scsi: enumerate luns with REPORT LUNSRoman Kagan1-10/+25
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02virtio-scsi: enumerate luns with REPORT LUNSRoman Kagan1-12/+26
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02blockcmd: generic SCSI luns enumerationRoman Kagan2-0/+98
Add two generic functions to discover active LUNs on a SCSI target. The functions take a temporary drive descriptor on the target, and a callback to create a new drive descriptor with a new LUN using the temporary one as a template. One of the functions performs REPORT LUNS on the temporary drive to obtain the list of candidate luns; the other sequentially iterates the lun numbers up to the given maximum, and is meant as a fallback. Both functions return the number of successfully created drive descriptors, or a negative number if an error occured. This will allow to lift the limitation of most of the SCSI drivers that support booting off the LUN #0 only. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-05-02blockcmd: accept only disks and CD-ROMsRoman Kagan1-0/+3
Luns that report to INQUIRY with a type other than CD-ROM are considered disks. This isn't necessarily the case; working with such luns as disks may lead to unpredictable results. So bail out if the lun is neither CD-ROM nor disk. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2017-03-13resume: Don't attempt to use generic reboot mechanisms on QEMUKevin O'Connor2-1/+2
On QEMU it's necessary to manually reset the BIOS memory region between 0xc0000-0x100000 on a reboot. After this manual memory reset is completed, it's not valid to use the generic reset mechanisms. Rename qemu_prep_reset() to qemu_reboot() and change the function to immediately reboot after the code memcpy. This fixes a bug that could cause code corruption on reboots - calling the udelay() function (as invoked by i8042_reboot and/or pci_reboot) was not valid after the BIOS was memcpy'd. Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com> Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-02nvme: fix copy-paste mistake in commentDaniel Verkamp1-1/+1
Signed-off-by: Daniel Verkamp <daniel@drv.nu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
2017-03-02nvme: fix extraction of status code bitsDaniel Verkamp1-1/+1
The status code field is 8 bits wide starting at bit 1; the previous code would truncate the top bit. Signed-off-by: Daniel Verkamp <daniel@drv.nu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
2017-03-02nvme: fix reversed loop condition in cmd_readwriteDaniel Verkamp1-1/+1
It looks like the intent was to exit the loop if a command failed, but the current code would actually continue looping in that case. Signed-off-by: Daniel Verkamp <daniel@drv.nu> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
2017-03-02nvme: extend command timeout to 5 secondsDaniel Verkamp1-1/+1
500 ms is not sufficient for the admin commands used during initialization on some real hardware. Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2017-03-02nvme: support NVMe 1.0 controllersDaniel Verkamp1-33/+6
Rather than using the Identify command with CNS 01b (GET_NS_LIST), which was added in NVMe 1.1, we can just enumerate all of the possible namespace IDs. The relevant part of the NVMe spec reads: Namespaces shall be allocated in order (starting with 1) and packed sequentially. Since the previously-used GET_NS_LIST only returns active namespaces, we also need a check in nvme_probe_ns() to ensure that inactive namespaces are not reported as boot devices. This can be accomplished by checking for non-zero block count - the spec indicates that Identify Namespace for an inactive namespace ID will return all zeroes. This should have no impact on the QEMU NVMe device model, since it always reports exactly one namespace (NSID 1). Signed-off-by: Daniel Verkamp <daniel@drv.nu>
2017-02-20block: add NVMe boot supportJulian Stecklina4-0/+872
This patch enables SeaBIOS to boot from NVMe. Finding namespaces and basic I/O works. Testing has been done in qemu and so far it works with Grub, syslinux, and the FreeBSD loader. You need a recent Qemu (>= 2.7.0), because older versions have buggy NVMe support. The NVMe code is currently only enabled on Qemu due to lack of testing on real hardware. Signed-off-by: Julian Stecklina <jsteckli@amazon.de>
2017-02-11ps2port: Disable keyboard/mouse prior to resetting ps2 controllerKevin O'Connor1-1/+12
If one of the ps2 ports is enabled prior to the ps2 controller reset then it is possible a device event (eg, key press or mouse move) could be mistaken for the controller reset response code. This would result in a failure and the keyboard would be disabled during the boot. Always disabling the keyboard and mouse prior to reset ensures that the controller reset return code can be read properly. Tested-by: Paul Menzel <paulepanter@users.sourceforge.net> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-01-17ahci: Set upper 32-bit registers to zeroLadi Prosek1-0/+5
If the HBA supports 64-bit addressing, the registers may contain non-zero values, for example after reboot as a leftover from the OS driving the adapter. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
2016-12-30serialio: Support for mmap serial portsRicardo Ribalda Delgado1-10/+34
Some chipsets have memory mapped serial ports. The protocol is the same as an standard uart, but with memory read/write instead of inb/outb. Tested-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-26usb: Make usb_time_sigatt variable staticKevin O'Connor1-1/+1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-16virtio: fix virtio-pciGerd Hoffmann1-2/+2
virtio-pci calls pci_enable_{io,mem}bar with the bar number, but the functions expect the bar base register offset. Reported-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-09-12usb-hid: Generate Ctrl+Break and Alt+SysReq keysKevin O'Connor1-20/+30
Detect the sequences for generating Ctrl+Break and Alt+SysReq on USB keyboards and produce the appropriate legacy scancodes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-26pic: The default hardware interrupt handlers should not take a parameterKevin O'Connor1-2/+2
Hardware interrupt handlers don't take a parameter. Remove the incorrect (and unused) parameter from handle_hwpic1/2(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-14ps2: Remove stale check for timeout warning on resetKevin O'Connor1-3/+1
Commit 4ce5d207 removed the code to wait for a possible second byte from a keyboard reset command, but it did not remove the extra check when warning in ps2_recvbyte(). Remove the now stale code in ps2_recvbyte(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05pvscsi: Use high memory for ringsDana Rubin1-4/+4
Avoid using the scarce ZoneLow memory. This limits max number of pvscsi controllers. As driver runs in 32bit mode, use ZoneHigh allocation instead. Signed-off-by: Dana Rubin <dana.rubin@ravellosystems.com> Signed-off-by: Shmulik Ladkani <shmulik.ladkani@ravellosystems.com>
2016-08-05pvscsi: Fix incorrect arguments order in call to memalign_lowDana Rubin1-1/+1
First argument should be 'align' and second 'size'. Signed-off-by: <dana.rubin@ravellosystems.com> Signed-off-by: <shmulik.ladkani@ravellosystems.com>
2016-08-04blockcmd: CMD_SCSI op is only used in 32bit modeKevin O'Connor1-1/+6
Reduce the size of the 16bit code slightly by recognizing that CMD_SCSI is only used in 32bit mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-06-20virtio: pci cfg accessGerd Hoffmann2-25/+178
virtio regions can also be accessed using a window in pci cfg space. Add support for it. Enable it in case the virtio regions are mapped high (above 4g), so direct mmio access doesn't work for us even in 32bit mode. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-06-20virtio: uninline _vp_{read,write}Gerd Hoffmann2-78/+81
Next patch makes it larger, and I don't think it makes sense to continue inlining it. Uninline and move from header to c file. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2016-05-16usb-xhci: Remove unused const variablesKevin O'Connor1-14/+0
Remove the unused arrays `eptype_to_xhci_in` and `eptype_to_xhci_out` to fix GCC 6 warnings. Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-04-06scsi: Launch a thread when scanning for drives in the scsi driversKevin O'Connor5-29/+25
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>