Skip to content

Commit 0286070

Browse files
kawasakiij-intel
authored andcommitted
p2sb: Move P2SB hide and unhide code to p2sb_scan_and_cache()
To prepare for the following fix, move the code to hide and unhide the P2SB device from p2sb_cache_resources() to p2sb_scan_and_cache(). Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent ae3e6eb commit 0286070

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/platform/x86/p2sb.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,25 @@ static void p2sb_scan_and_cache_devfn(struct pci_bus *bus, unsigned int devfn)
9898

9999
static int p2sb_scan_and_cache(struct pci_bus *bus, unsigned int devfn)
100100
{
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+
101109
/* Scan the P2SB device and cache its BAR0 */
102110
p2sb_scan_and_cache_devfn(bus, devfn);
103111

104112
/* On Goldmont p2sb_bar() also gets called for the SPI controller */
105113
if (devfn == P2SB_DEVFN_GOLDMONT)
106114
p2sb_scan_and_cache_devfn(bus, SPI_DEVFN_GOLDMONT);
107115

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+
108120
if (!p2sb_valid_resource(&p2sb_resources[PCI_FUNC(devfn)].res))
109121
return -ENOENT;
110122

@@ -153,22 +165,11 @@ static int p2sb_cache_resources(void)
153165
*/
154166
pci_lock_rescan_remove();
155167

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-
*/
161168
pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value);
162169
p2sb_hidden_by_bios = value & P2SBC_HIDE;
163-
if (p2sb_hidden_by_bios)
164-
pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0);
165170

166171
ret = p2sb_scan_and_cache(bus, devfn_p2sb);
167172

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-
172173
pci_unlock_rescan_remove();
173174

174175
return ret;

0 commit comments

Comments
 (0)