@@ -98,13 +98,25 @@ static void p2sb_scan_and_cache_devfn(struct pci_bus *bus, unsigned int devfn)
98
98
99
99
static int p2sb_scan_and_cache (struct pci_bus * bus , unsigned int devfn )
100
100
{
101
+ /*
102
+ * The BIOS prevents the P2SB device from being enumerated by the PCI
103
+ * subsystem, so we need to unhide and hide it back to lookup the BAR.
104
+ * Unhide the P2SB device here, if needed.
105
+ */
106
+ if (p2sb_hidden_by_bios )
107
+ pci_bus_write_config_dword (bus , devfn , P2SBC , 0 );
108
+
101
109
/* Scan the P2SB device and cache its BAR0 */
102
110
p2sb_scan_and_cache_devfn (bus , devfn );
103
111
104
112
/* On Goldmont p2sb_bar() also gets called for the SPI controller */
105
113
if (devfn == P2SB_DEVFN_GOLDMONT )
106
114
p2sb_scan_and_cache_devfn (bus , SPI_DEVFN_GOLDMONT );
107
115
116
+ /* Hide the P2SB device, if it was hidden */
117
+ if (p2sb_hidden_by_bios )
118
+ pci_bus_write_config_dword (bus , devfn , P2SBC , P2SBC_HIDE );
119
+
108
120
if (!p2sb_valid_resource (& p2sb_resources [PCI_FUNC (devfn )].res ))
109
121
return - ENOENT ;
110
122
@@ -153,22 +165,11 @@ static int p2sb_cache_resources(void)
153
165
*/
154
166
pci_lock_rescan_remove ();
155
167
156
- /*
157
- * The BIOS prevents the P2SB device from being enumerated by the PCI
158
- * subsystem, so we need to unhide and hide it back to lookup the BAR.
159
- * Unhide the P2SB device here, if needed.
160
- */
161
168
pci_bus_read_config_dword (bus , devfn_p2sb , P2SBC , & value );
162
169
p2sb_hidden_by_bios = value & P2SBC_HIDE ;
163
- if (p2sb_hidden_by_bios )
164
- pci_bus_write_config_dword (bus , devfn_p2sb , P2SBC , 0 );
165
170
166
171
ret = p2sb_scan_and_cache (bus , devfn_p2sb );
167
172
168
- /* Hide the P2SB device, if it was hidden */
169
- if (p2sb_hidden_by_bios )
170
- pci_bus_write_config_dword (bus , devfn_p2sb , P2SBC , P2SBC_HIDE );
171
-
172
173
pci_unlock_rescan_remove ();
173
174
174
175
return ret ;
0 commit comments