mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
pci: Clear active PME# and disable PME# generation
The PCI power management specification requires that the OS clear any pending PME# interrupt and generation of PME# interrupts during "initial operating system load". Note that clearing a pending PME# interrupt requires writing a 1 to the Read/Write-Clear PME bit in the power management status register. To handle the boot time case, clear PME# state in pci_read_cap() when scanning new PCI devices. This should also cover hotplug devices. In addition, clear this state on every PCI device after resume from sleep in pci_resume_child before invoking the driver's DEVICE_RESUME method. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D49222
This commit is contained in:
parent
7a5b9c4abc
commit
82d6927712
5 changed files with 29 additions and 0 deletions
|
|
@ -1790,6 +1790,7 @@ MLINKS+=panic.9 vpanic.9 \
|
|||
panic.9 KERNEL_PANICKED.9
|
||||
MLINKS+=pci.9 pci_alloc_msi.9 \
|
||||
pci.9 pci_alloc_msix.9 \
|
||||
pci.9 pci_clear_pme.9 \
|
||||
pci.9 pci_disable_busmaster.9 \
|
||||
pci.9 pci_disable_io.9 \
|
||||
pci.9 pci_enable_busmaster.9 \
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
.Nm pci ,
|
||||
.Nm pci_alloc_msi ,
|
||||
.Nm pci_alloc_msix ,
|
||||
.Nm pci_clear_pme ,
|
||||
.Nm pci_disable_busmaster ,
|
||||
.Nm pci_disable_io ,
|
||||
.Nm pci_enable_busmaster ,
|
||||
|
|
@ -81,6 +82,8 @@
|
|||
.Fn pci_alloc_msi "device_t dev" "int *count"
|
||||
.Ft int
|
||||
.Fn pci_alloc_msix "device_t dev" "int *count"
|
||||
.Ft void
|
||||
.Fn pci_clear_pme "device_t dev"
|
||||
.Ft int
|
||||
.Fn pci_disable_busmaster "device_t dev"
|
||||
.Ft int
|
||||
|
|
@ -670,6 +673,11 @@ then the function will fail with
|
|||
.Er EOPNOTSUPP .
|
||||
.Pp
|
||||
The
|
||||
.Fn pci_clear_pme
|
||||
function is used to clear any pending PME# signal and disable generation
|
||||
of power management events.
|
||||
.Pp
|
||||
The
|
||||
.Fn pci_iov_attach
|
||||
function is used to advertise that the given device
|
||||
.Pq and associated device driver
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ cardbus_attach_card(device_t cbdev)
|
|||
DEVPRINTF((cbdev, "Warning: Bogus CIS ignored\n"));
|
||||
pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 0);
|
||||
pci_cfg_restore(dinfo->pci.cfg.dev, &dinfo->pci);
|
||||
pci_clear_pme(child);
|
||||
cardbus_device_setup_regs(&dinfo->pci.cfg);
|
||||
pci_add_resources(cbdev, child, 1, dinfo->mprefetchable);
|
||||
pci_print_verbose(&dinfo->pci);
|
||||
|
|
|
|||
|
|
@ -2936,6 +2936,22 @@ pci_get_powerstate_method(device_t dev, device_t child)
|
|||
return (result);
|
||||
}
|
||||
|
||||
/* Clear any active PME# and disable PME# generation. */
|
||||
void
|
||||
pci_clear_pme(device_t dev)
|
||||
{
|
||||
struct pci_devinfo *dinfo = device_get_ivars(dev);
|
||||
pcicfgregs *cfg = &dinfo->cfg;
|
||||
uint16_t status;
|
||||
|
||||
if (cfg->pp.pp_cap != 0) {
|
||||
status = pci_read_config(dev, dinfo->cfg.pp.pp_status, 2);
|
||||
status &= ~PCIM_PSTAT_PMEENABLE;
|
||||
status |= PCIM_PSTAT_PME;
|
||||
pci_write_config(dev, dinfo->cfg.pp.pp_status, status, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some convenience functions for PCI device drivers.
|
||||
*/
|
||||
|
|
@ -4472,6 +4488,7 @@ pci_add_child(device_t bus, struct pci_devinfo *dinfo)
|
|||
resource_list_init(&dinfo->resources);
|
||||
pci_cfg_save(dev, dinfo, 0);
|
||||
pci_cfg_restore(dev, dinfo);
|
||||
pci_clear_pme(dev);
|
||||
pci_print_verbose(dinfo);
|
||||
pci_add_resources(bus, dev, 0, 0);
|
||||
if (pci_enable_mps_tune)
|
||||
|
|
@ -4662,6 +4679,7 @@ pci_resume_child(device_t dev, device_t child)
|
|||
|
||||
dinfo = device_get_ivars(child);
|
||||
pci_cfg_restore(child, dinfo);
|
||||
pci_clear_pme(child);
|
||||
if (!device_is_attached(child))
|
||||
pci_cfg_save(child, dinfo, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@ void pci_restore_state(device_t dev);
|
|||
void pci_save_state(device_t dev);
|
||||
int pci_set_max_read_req(device_t dev, int size);
|
||||
int pci_power_reset(device_t dev);
|
||||
void pci_clear_pme(device_t dev);
|
||||
uint32_t pcie_read_config(device_t dev, int reg, int width);
|
||||
void pcie_write_config(device_t dev, int reg, uint32_t value, int width);
|
||||
uint32_t pcie_adjust_config(device_t dev, int reg, uint32_t mask,
|
||||
|
|
|
|||
Loading…
Reference in a new issue