Parcourir la source

[pci] Save and restore PCI command register

This seems to be necessary for some types of PCI devices. We had
problems when using gPXE in KVM virtual machines with direct
PCI device access.

Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Modified-by: Marty Connor <mdc@etherboot.org>
Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Bernhard Kohl il y a 14 ans
Parent
révision
466d8fc234
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5
    0
      src/drivers/bus/pciextra.c

+ 5
- 0
src/drivers/bus/pciextra.c Voir le fichier

@@ -60,8 +60,11 @@ int pci_find_capability ( struct pci_device *pci, int cap ) {
60 60
  * function.
61 61
  */
62 62
 unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) {
63
+	uint16_t cmd;
63 64
 	uint32_t start, size;
64 65
 
66
+	/* Save the original command register */
67
+	pci_read_config_word ( pci, PCI_COMMAND, &cmd );
65 68
 	/* Save the original bar */
66 69
 	pci_read_config_dword ( pci, reg, &start );
67 70
 	/* Compute which bits can be set */
@@ -70,6 +73,8 @@ unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg ) {
70 73
 	/* Restore the original size */
71 74
 	pci_write_config_dword ( pci, reg, start );
72 75
 	/* Find the significant bits */
76
+	/* Restore the original command register. This reenables decoding. */
77
+	pci_write_config_word ( pci, PCI_COMMAND, cmd );
73 78
 	if ( start & PCI_BASE_ADDRESS_SPACE_IO ) {
74 79
 		size &= PCI_BASE_ADDRESS_IO_MASK;
75 80
 	} else {

Chargement…
Annuler
Enregistrer