瀏覽代碼

[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 14 年之前
父節點
當前提交
466d8fc234
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5
    0
      src/drivers/bus/pciextra.c

+ 5
- 0
src/drivers/bus/pciextra.c 查看文件

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

Loading…
取消
儲存