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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * IOAPIC/IOxAPIC/IOSAPIC driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2009 Fujitsu Limited.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * (c) Copyright 2009 Hewlett-Packard Development Company, L.P.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Copyright (C) 2014 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Based on original drivers/pci/ioapic.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *	Yinghai Lu <yinghai@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *	Jiang Liu <jiang.liu@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * This driver manages I/O APICs added by hotplug after boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * We try to claim all I/O APIC devices, but those present at boot were
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * registered when we parsed the ACPI MADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define pr_fmt(fmt) "ACPI: IOAPIC: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct acpi_pci_ioapic {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	acpi_handle	root_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	acpi_handle	handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u32		gsi_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct resource	res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct pci_dev	*pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static LIST_HEAD(ioapic_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static DEFINE_MUTEX(ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static acpi_status setup_res(struct acpi_resource *acpi_res, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct resource *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct resource_win win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 * We might assign this to 'res' later, make sure all pointers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 * cleared before the resource is added to the global list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	memset(&win, 0, sizeof(win));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	res->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if (acpi_dev_filter_resource_type(acpi_res, IORESOURCE_MEM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (!acpi_dev_resource_memory(acpi_res, res)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		if (acpi_dev_resource_address_space(acpi_res, &win) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		    acpi_dev_resource_ext_address_space(acpi_res, &win))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			*res = win.res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if ((res->flags & IORESOURCE_PREFETCH) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	    (res->flags & IORESOURCE_DISABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		res->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return AE_CTRL_TERMINATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static bool acpi_is_ioapic(acpi_handle handle, char **type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct acpi_device_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	char *hid = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	bool match = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (!acpi_has_method(handle, "_GSB"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	status = acpi_get_object_info(handle, &info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		if (info->valid & ACPI_VALID_HID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			hid = info->hardware_id.string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		if (hid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			if (strcmp(hid, "ACPI0009") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 				*type = "IOxAPIC";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 				match = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			} else if (strcmp(hid, "ACPI000A") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 				*type = "IOAPIC";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				match = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		kfree(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static acpi_status handle_ioapic_add(acpi_handle handle, u32 lvl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				     void *context, void **rv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	unsigned long long gsi_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct acpi_pci_ioapic *ioapic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct pci_dev *dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	struct resource *res = NULL, *pci_res = NULL, *crs_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	char *type = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	if (!acpi_is_ioapic(handle, &type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	mutex_lock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	list_for_each_entry(ioapic, &ioapic_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		if (ioapic->handle == handle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			mutex_unlock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	status = acpi_evaluate_integer(handle, "_GSB", NULL, &gsi_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		acpi_handle_warn(handle, "failed to evaluate _GSB method\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	ioapic = kzalloc(sizeof(*ioapic), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (!ioapic) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		pr_err("cannot allocate memory for new IOAPIC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		ioapic->root_handle = (acpi_handle)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		ioapic->handle = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		ioapic->gsi_base = (u32)gsi_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		INIT_LIST_HEAD(&ioapic->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (acpi_ioapic_registered(handle, (u32)gsi_base))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	dev = acpi_get_pci_dev(handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (dev && pci_resource_len(dev, 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		if (pci_enable_device(dev) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			goto exit_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		pci_set_master(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		if (pci_request_region(dev, 0, type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			goto exit_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		pci_res = &dev->resource[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		ioapic->pdev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		pci_dev_put(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	crs_res = &ioapic->res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	acpi_walk_resources(handle, METHOD_NAME__CRS, setup_res, crs_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	crs_res->name = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	crs_res->flags |= IORESOURCE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (crs_res->flags == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		acpi_handle_warn(handle, "failed to get resource\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		goto exit_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	} else if (insert_resource(&iomem_resource, crs_res)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		acpi_handle_warn(handle, "failed to insert resource\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		goto exit_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	/* try pci resource first, then "_CRS" resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	res = pci_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (!res || !res->flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		res = crs_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (acpi_register_ioapic(handle, res->start, (u32)gsi_base)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		acpi_handle_warn(handle, "failed to register IOAPIC\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		goto exit_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	list_add(&ioapic->list, &ioapic_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	mutex_unlock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		dev_info(&dev->dev, "%s at %pR, GSI %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			 type, res, (u32)gsi_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		acpi_handle_info(handle, "%s at %pR, GSI %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				 type, res, (u32)gsi_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) exit_release:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		pci_release_region(dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (ioapic->res.flags && ioapic->res.parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		release_resource(&ioapic->res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) exit_disable:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		pci_disable_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) exit_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	pci_dev_put(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	kfree(ioapic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	mutex_unlock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	*(acpi_status *)rv = AE_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) int acpi_ioapic_add(acpi_handle root_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	acpi_status status, retval = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, root_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				     UINT_MAX, handle_ioapic_add, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				     root_handle, (void **)&retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	return ACPI_SUCCESS(status) && ACPI_SUCCESS(retval) ? 0 : -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) void pci_ioapic_remove(struct acpi_pci_root *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	struct acpi_pci_ioapic *ioapic, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	mutex_lock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	list_for_each_entry_safe(ioapic, tmp, &ioapic_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		if (root->device->handle != ioapic->root_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		if (ioapic->pdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			pci_release_region(ioapic->pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			pci_disable_device(ioapic->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			pci_dev_put(ioapic->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	mutex_unlock(&ioapic_list_lock);
^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) int acpi_ioapic_remove(struct acpi_pci_root *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	int retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	struct acpi_pci_ioapic *ioapic, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	mutex_lock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	list_for_each_entry_safe(ioapic, tmp, &ioapic_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		if (root->device->handle != ioapic->root_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		if (acpi_unregister_ioapic(ioapic->handle, ioapic->gsi_base))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			retval = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		if (ioapic->res.flags && ioapic->res.parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			release_resource(&ioapic->res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		list_del(&ioapic->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		kfree(ioapic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	mutex_unlock(&ioapic_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }