if (obj->type != ACPI_TYPE_INTEGER) {
pci_err(pdev, FW_BUG "Enable DPC _DSM returned non integer\n");
status = -EIO;
}
if (obj->integer.value != 1) {
pci_err(pdev, "Enable DPC _DSM failed to enable DPC\n");
status = -EIO;
}
ACPI_FREE(obj);
return status;
}
/* * _DSM wrapper function to locate DPC port * @pdev : Device which received EDR event * * Returns pci_dev or NULL. Caller is responsible for dropping a reference * on the returned pci_dev with pci_dev_put().
*/ staticstruct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)
{ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); union acpi_object *obj;
u16 port;
/* * If EDR_PORT_LOCATE_DSM is not implemented under the target of * EDR, the target is the port that experienced the containment * event (PCI Firmware r3.3, sec 4.6.13).
*/ if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
1ULL << EDR_PORT_LOCATE_DSM)) return pci_dev_get(pdev);
if (obj->type != ACPI_TYPE_INTEGER) {
ACPI_FREE(obj);
pci_err(pdev, FW_BUG "Locate Port _DSM returned non integer\n"); return NULL;
}
/* * Bit 31 represents the success/failure of the operation. If bit * 31 is set, the operation failed.
*/ if (obj->integer.value & BIT(31)) {
ACPI_FREE(obj);
pci_err(pdev, "Locate Port _DSM failed\n"); return NULL;
}
/* * Firmware returns DPC port BDF details in following format: * 15:8 = bus * 7:3 = device * 2:0 = function
*/
port = obj->integer.value;
ACPI_FREE(obj);
return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
PCI_BUS_NUM(port), port & 0xff);
}
/* * _OST wrapper function to let firmware know the status of EDR event * @pdev : Device used to send _OST * @edev : Device which experienced EDR event * @status : Status of EDR event
*/ staticint acpi_send_edr_status(struct pci_dev *pdev, struct pci_dev *edev,
u16 status)
{ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
u32 ost_status;
pci_dbg(pdev, "Status for %s: %#x\n", pci_name(edev), status);
if (event != ACPI_NOTIFY_DISCONNECT_RECOVER) return;
/* * pdev is a Root Port or Downstream Port that is still present and * has triggered a containment event, e.g., DPC, so its child * devices have been disconnected (ACPI r6.5, sec 5.6.6).
*/
pci_info(pdev, "EDR event received\n");
/* * Locate the port that experienced the containment event. pdev * may be that port or a parent of it (PCI Firmware r3.3, sec * 4.6.13).
*/
edev = acpi_dpc_port_get(pdev); if (!edev) {
pci_err(pdev, "Firmware failed to locate DPC port\n"); return;
}
/* If port does not support DPC, just send the OST */ if (!edev->dpc_cap) {
pci_err(edev, FW_BUG "This device doesn't support DPC\n"); goto send_ost;
}
/* Check if there is a valid DPC trigger */
pci_read_config_word(edev, edev->dpc_cap + PCI_EXP_DPC_STATUS, &status); if (!(status & PCI_EXP_DPC_STATUS_TRIGGER)) {
pci_err(edev, "Invalid DPC trigger %#010x\n", status); goto send_ost;
}
/* * Irrespective of whether the DPC event is triggered by ERR_FATAL * or ERR_NONFATAL, since the link is already down, use the FATAL * error recovery path for both cases.
*/
estate = pcie_do_recovery(edev, pci_channel_io_frozen, dpc_reset_link);
send_ost:
/* * If recovery is successful, send _OST(0xF, BDF << 16 | 0x80) * to firmware. If not successful, send _OST(0xF, BDF << 16 | 0x81).
*/ if (estate == PCI_ERS_RESULT_RECOVERED) {
pci_dbg(edev, "DPC port successfully recovered\n");
pcie_clear_device_status(edev);
acpi_send_edr_status(pdev, edev, EDR_OST_SUCCESS);
} else {
pci_dbg(edev, "DPC port recovery failed\n");
acpi_send_edr_status(pdev, edev, EDR_OST_FAILED);
}
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.