Skip to contentSkip to conversation

Do not try loading option ROM for hotplug PCI device in pc-0.11 compat mode

PATCH Superseded [email protected] 2 participants 8 messages Jul 23, 2010 – Jul 31, 2010

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not try loading option ROM for hotplug PCI device in pc-0.11 compat mode

From: Jes Sorensen <[email protected]>

pc-0.11 and older uses fw_cfg to provide option ROMs. As fw_cfg is setup at init time, it is not possible to load an option ROM for a hotplug device when running in compat mode.

v2: Alex Williamson pointed out that one can get to qdev directly from pci_dev, so no need to pass it down.

---
 hw/pci.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
hw/pci.c +6 -2
index a98d6f3..2d38643 100644
@@ -1810,11 +1810,15 @@ static int pci_add_option_rom(PCIDevice *pdev)
         return 0;
 
     if (!pdev->rom_bar) {
+        int class;
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
-         * for 0.11 compatibility.
+         * for 0.11 compatibility. fw_cfg is initialized at boot, so
+         * we cannot do hotplug load of option roms.
          */
-        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+        if (pdev->qdev.hotplugged)
+            return 0;
+        class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
         if (class == 0x0300) {
             rom_add_vga(pdev->romfile);
         } else {
Signature · 1 line
1.7.1.1
#1 lore raw
Quoted 22 lines · On Fri, Jul 23, 2010 at 05:56:38PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

pc-0.11 and older uses fw_cfg to provide option ROMs. As fw_cfg is setup at init time, it is not possible to load an option ROM for a hotplug device when running in compat mode.

v2: Alex Williamson pointed out that one can get to qdev directly from pci_dev, so no need to pass it down.

---
 hw/pci.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
hw/pci.c +0 -0
index a98d6f3..2d38643 100644
@@ -1810,11 +1810,15 @@ static int pci_add_option_rom(PCIDevice *pdev)
         return 0;
 
     if (!pdev->rom_bar) {

hw/pci.c static int pci_add_option_rom(PCIDevice *pdev) · line 1820

Quoted 10 lines
hw/pci.c +5 -2
+        int class;
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
-         * for 0.11 compatibility.
+         * for 0.11 compatibility. fw_cfg is initialized at boot, so
+         * we cannot do hotplug load of option roms.
          */
-        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+        if (pdev->qdev.hotplugged)
+            return 0;

Missing braces around the return 0 line.

Quoted 6 lines
hw/pci.c +1 -0
+        class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
         if (class == 0x0300) {
             rom_add_vga(pdev->romfile);
         } else {
Signature · 1 line
1.7.1.1

Otherwise looks good.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#2 lore raw
Quoted 22 lines · Aurelien Jarno
Quoted 21 lines · On Fri, Jul 23, 2010 at 05:56:38PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

pc-0.11 and older uses fw_cfg to provide option ROMs. As fw_cfg is setup at init time, it is not possible to load an option ROM for a hotplug device when running in compat mode.

v2: Alex Williamson pointed out that one can get to qdev directly from pci_dev, so no need to pass it down.

---
 hw/pci.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
hw/pci.c +0 -0
index a98d6f3..2d38643 100644
@@ -1810,11 +1810,15 @@ static int pci_add_option_rom(PCIDevice *pdev)
         return 0;
 
Quoted 13 lines

hw/pci.c static int pci_add_option_rom(PCIDevice *pdev) · line 1820

Quoted 11 lines
hw/pci.c +5 -2
     if (!pdev->rom_bar) {
+        int class;
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
-         * for 0.11 compatibility.
+         * for 0.11 compatibility. fw_cfg is initialized at boot, so
+         * we cannot do hotplug load of option roms.
          */
-        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+        if (pdev->qdev.hotplugged)
+            return 0;

Missing braces around the return 0 line.

Half the QEMU code base doesn't have braces around single line if statements, including in hw/pci.c. Adding braces here would be inconsistent.

Jes

#3 lore raw
Quoted 37 lines · Jes Sorensen
Quoted 22 lines · Aurelien Jarno
Quoted 21 lines · On Fri, Jul 23, 2010 at 05:56:38PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

pc-0.11 and older uses fw_cfg to provide option ROMs. As fw_cfg is setup at init time, it is not possible to load an option ROM for a hotplug device when running in compat mode.

v2: Alex Williamson pointed out that one can get to qdev directly from pci_dev, so no need to pass it down.

---
 hw/pci.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
hw/pci.c +0 -0
index a98d6f3..2d38643 100644
@@ -1810,11 +1810,15 @@ static int pci_add_option_rom(PCIDevice *pdev)
         return 0;
 
Quoted 13 lines

hw/pci.c static int pci_add_option_rom(PCIDevice *pdev) · line 1820

Quoted 11 lines
hw/pci.c +5 -2
     if (!pdev->rom_bar) {
+        int class;
         /*
          * Load rom via fw_cfg instead of creating a rom bar,
-         * for 0.11 compatibility.
+         * for 0.11 compatibility. fw_cfg is initialized at boot, so
+         * we cannot do hotplug load of option roms.
          */
-        int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+        if (pdev->qdev.hotplugged)
+            return 0;

Missing braces around the return 0 line.

Quoted 3 lines

Half the QEMU code base doesn't have braces around single line if statements, including in hw/pci.c. Adding braces here would be inconsistent.

If we follow the coding style in new patches, it will eventually become consistent.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#4 lore raw
Quoted 11 lines · Aurelien Jarno
Quoted 6 lines · Jes Sorensen
Quoted 1 line · Aurelien Jarno

Missing braces around the return 0 line.

Half the QEMU code base doesn't have braces around single line if statements, including in hw/pci.c. Adding braces here would be inconsistent.

If we follow the coding style in new patches, it will eventually become consistent.

If you want that, please do it in a separate patch for the entire file, otherwise it will never become consistent. However it doesn't change the issue either that putting braces around a single line like this is bad coding style.

Jes

#5 lore raw
Quoted 9 lines · Jes Sorensen
Quoted 8 lines · Aurelien Jarno
Quoted 6 lines · Jes Sorensen
Quoted 1 line · Aurelien Jarno

Missing braces around the return 0 line.

Half the QEMU code base doesn't have braces around single line if statements, including in hw/pci.c. Adding braces here would be inconsistent.

Quoted 8 lines
Quoted 3 lines

If we follow the coding style in new patches, it will eventually become consistent.

If you want that, please do it in a separate patch for the entire file, otherwise it will never become consistent. However it doesn't change the issue either that putting braces around a single line like this is bad coding style.

We got this discussions numerous times, and I am not going to start it again. If you want to see the patch applied, just follow the rules.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#6 lore raw
Quoted 9 lines · Aurelien Jarno
Quoted 4 lines · Jes Sorensen

If you want that, please do it in a separate patch for the entire file, otherwise it will never become consistent. However it doesn't change the issue either that putting braces around a single line like this is bad coding style.

We got this discussions numerous times, and I am not going to start it again. If you want to see the patch applied, just follow the rules.

Then I would like to know why you do not apply this silly rule to every patch submitted. There's patches going in almost every day that doesn't use this hopeless formatting.

Jes

#7 lore raw
Quoted 7 lines · Jes Sorensen
Quoted 6 lines · Aurelien Jarno
Quoted 4 lines · Jes Sorensen

If you want that, please do it in a separate patch for the entire file, otherwise it will never become consistent. However it doesn't change the issue either that putting braces around a single line like this is bad coding style.

Quoted 8 lines
Quoted 3 lines

We got this discussions numerous times, and I am not going to start it again. If you want to see the patch applied, just follow the rules.

Then I would like to know why you do not apply this silly rule to every patch submitted. There's patches going in almost every day that doesn't use this hopeless formatting.

Because not everyone try to enforce the rules.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net