// SPDX-License-Identifier: GPL-2.0 /* * PCI Backend - Handles the virtual fields found on the capability lists * in the configuration space. * * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/
staticint pm_caps_read(struct pci_dev *dev, int offset, u16 *value, void *data)
{ int err;
u16 real_value;
err = pci_read_config_word(dev, offset, &real_value); if (err) goto out;
*value = real_value & ~PCI_PM_CAP_PME_MASK;
out: return err;
}
/* PM_OK_BITS specifies the bits that the driver domain is allowed to change.
* Can't allow driver domain to enable PMEs - they're shared */ #define PM_OK_BITS (PCI_PM_CTRL_PME_STATUS|PCI_PM_CTRL_DATA_SEL_MASK)
staticint pm_ctrl_write(struct pci_dev *dev, int offset, u16 new_value, void *data)
{ int err;
u16 old_value;
pci_power_t new_state;
err = pci_read_config_word(dev, offset, &old_value); if (err) goto out;
/* Let pci core handle the power management change */
dev_dbg(&dev->dev, "set power state to %x\n", new_state);
err = pci_set_power_state(dev, new_state); if (err) {
err = PCIBIOS_SET_FAILED; goto out;
}
out: return err;
}
/* Ensure PMEs are disabled */ staticvoid *pm_ctrl_init(struct pci_dev *dev, int offset)
{ int err;
u16 value;
err = pci_read_config_word(dev, offset, &value); if (err) goto out;
if (value & PCI_PM_CTRL_PME_ENABLE) {
value &= ~PCI_PM_CTRL_PME_ENABLE;
err = pci_write_config_word(dev, offset, value);
}
if (xen_pcibk_permissive || dev_data->permissive) goto write;
err = pci_read_config_word(dev, offset, &old_value); if (err) return err;
if (new_value == old_value) return 0;
if (!dev_data->allow_interrupt_control ||
(new_value ^ old_value) & ~field_config->allowed_bits) return PCIBIOS_SET_FAILED;
if (new_value & field_config->enable_bit) { /* * Don't allow enabling together with other interrupt type, but do * allow enabling MSI(-X) while INTx is still active to please Linuxes * MSI(-X) startup sequence. It is safe to do, as according to PCI * spec, device with enabled MSI(-X) shouldn't use INTx.
*/ int int_type = xen_pcibk_get_interrupt_type(dev);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.