Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * PCI Error Disconnect Recover support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Author: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2020 Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define dev_fmt(fmt) "EDR: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/pci-acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "portdrv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "../pci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define EDR_PORT_DPC_ENABLE_DSM		0x0C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define EDR_PORT_LOCATE_DSM		0x0D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define EDR_OST_SUCCESS			0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define EDR_OST_FAILED			0x81
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * _DSM wrapper function to enable/disable DPC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * @pdev   : PCI device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * returns 0 on success or errno on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static int acpi_enable_dpc(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	union acpi_object *obj, argv4, req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	 * Behavior when calling unsupported _DSM functions is undefined,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * so check whether EDR_PORT_DPC_ENABLE_DSM is supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			    1ULL << EDR_PORT_DPC_ENABLE_DSM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	req.type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	req.integer.value = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	argv4.type = ACPI_TYPE_PACKAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	argv4.package.count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	argv4.package.elements = &req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 * Per Downstream Port Containment Related Enhancements ECN to PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 * Firmware Specification r3.2, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 * optional.  Return success if it's not implemented.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 				EDR_PORT_DPC_ENABLE_DSM, &argv4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (!obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	if (obj->type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		pci_err(pdev, FW_BUG "Enable DPC _DSM returned non integer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (obj->integer.value != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		pci_err(pdev, "Enable DPC _DSM failed to enable DPC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ACPI_FREE(obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * _DSM wrapper function to locate DPC port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @pdev   : Device which received EDR event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * Returns pci_dev or NULL.  Caller is responsible for dropping a reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * on the returned pci_dev with pci_dev_put().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	union acpi_object *obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	u16 port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * Behavior when calling unsupported _DSM functions is undefined,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 * so check whether EDR_PORT_DPC_ENABLE_DSM is supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			    1ULL << EDR_PORT_LOCATE_DSM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return pci_dev_get(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 				EDR_PORT_LOCATE_DSM, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (!obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return pci_dev_get(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (obj->type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		ACPI_FREE(obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		pci_err(pdev, FW_BUG "Locate Port _DSM returned non integer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 * Firmware returns DPC port BDF details in following format:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 *	15:8 = bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	 *	 7:3 = device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 *	 2:0 = function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	port = obj->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	ACPI_FREE(obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 					   PCI_BUS_NUM(port), port & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * _OST wrapper function to let firmware know the status of EDR event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * @pdev   : Device used to send _OST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * @edev   : Device which experienced EDR event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * @status : Status of EDR event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int acpi_send_edr_status(struct pci_dev *pdev, struct pci_dev *edev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 				u16 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	u32 ost_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	pci_dbg(pdev, "Status for %s: %#x\n", pci_name(edev), status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	ost_status = PCI_DEVID(edev->bus->number, edev->devfn) << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	ost_status |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	status = acpi_evaluate_ost(adev->handle, ACPI_NOTIFY_DISCONNECT_RECOVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 				   ost_status, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void edr_handle_event(acpi_handle handle, u32 event, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct pci_dev *pdev = data, *edev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	pci_ers_result_t estate = PCI_ERS_RESULT_DISCONNECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	u16 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (event != ACPI_NOTIFY_DISCONNECT_RECOVER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	pci_info(pdev, "EDR event received\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	/* Locate the port which issued EDR event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	edev = acpi_dpc_port_get(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (!edev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		pci_err(pdev, "Firmware failed to locate DPC port\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	pci_dbg(pdev, "Reported EDR dev: %s\n", pci_name(edev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	/* If port does not support DPC, just send the OST */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	if (!edev->dpc_cap) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		pci_err(edev, FW_BUG "This device doesn't support DPC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		goto send_ost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* Check if there is a valid DPC trigger */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	pci_read_config_word(edev, edev->dpc_cap + PCI_EXP_DPC_STATUS, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (!(status & PCI_EXP_DPC_STATUS_TRIGGER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		pci_err(edev, "Invalid DPC trigger %#010x\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		goto send_ost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	dpc_process_error(edev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	pci_aer_raw_clear_status(edev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 * Irrespective of whether the DPC event is triggered by ERR_FATAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 * or ERR_NONFATAL, since the link is already down, use the FATAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	 * error recovery path for both cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	estate = pcie_do_recovery(edev, pci_channel_io_frozen, dpc_reset_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) send_ost:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	 * If recovery is successful, send _OST(0xF, BDF << 16 | 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	 * to firmware. If not successful, send _OST(0xF, BDF << 16 | 0x81).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (estate == PCI_ERS_RESULT_RECOVERED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		pci_dbg(edev, "DPC port successfully recovered\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		acpi_send_edr_status(pdev, edev, EDR_OST_SUCCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		pci_dbg(edev, "DPC port recovery failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		acpi_send_edr_status(pdev, edev, EDR_OST_FAILED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	pci_dev_put(edev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) void pci_acpi_add_edr_notifier(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (!adev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		pci_dbg(pdev, "No valid ACPI node, skipping EDR init\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 					     edr_handle_event, pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		pci_err(pdev, "Failed to install notify handler\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (acpi_enable_dpc(pdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		acpi_remove_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 					   edr_handle_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		pci_dbg(pdev, "Notify handler installed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) void pci_acpi_remove_edr_notifier(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (!adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	acpi_remove_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 				   edr_handle_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	pci_dbg(pdev, "Notify handler removed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }