File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -1900,11 +1900,21 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
1900
1900
int err ;
1901
1901
int i , bars = 0 ;
1902
1902
1903
- if (atomic_inc_return (& dev -> enable_cnt ) > 1 ) {
1904
- pci_update_current_state (dev , dev -> current_state );
1905
- return 0 ; /* already enabled */
1903
+ /*
1904
+ * Power state could be unknown at this point, either due to a fresh
1905
+ * boot or a device removal call. So get the current power state
1906
+ * so that things like MSI message writing will behave as expected
1907
+ * (e.g. if the device really is in D0 at enable time).
1908
+ */
1909
+ if (dev -> pm_cap ) {
1910
+ u16 pmcsr ;
1911
+ pci_read_config_word (dev , dev -> pm_cap + PCI_PM_CTRL , & pmcsr );
1912
+ dev -> current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK );
1906
1913
}
1907
1914
1915
+ if (atomic_inc_return (& dev -> enable_cnt ) > 1 )
1916
+ return 0 ; /* already enabled */
1917
+
1908
1918
bridge = pci_upstream_bridge (dev );
1909
1919
if (bridge )
1910
1920
pci_enable_bridge (bridge );
You can’t perform that action at this time.
0 commit comments