hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/acpi/scan.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * scan.c - support for transforming the ACPI namespace into individual objects
34 */
....@@ -12,10 +13,9 @@
1213 #include <linux/kthread.h>
1314 #include <linux/dmi.h>
1415 #include <linux/nls.h>
15
-#include <linux/dma-mapping.h>
16
+#include <linux/dma-map-ops.h>
1617 #include <linux/platform_data/x86/apple.h>
17
-
18
-#include <asm/pgtable.h>
18
+#include <linux/pgtable.h>
1919
2020 #include "internal.h"
2121
....@@ -797,17 +797,15 @@
797797 }
798798 EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
799799
800
-static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
801
- struct acpi_device_wakeup *wakeup)
800
+static int acpi_bus_extract_wakeup_device_power_package(struct acpi_device *dev)
802801 {
802
+ acpi_handle handle = dev->handle;
803
+ struct acpi_device_wakeup *wakeup = &dev->wakeup;
803804 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
804805 union acpi_object *package = NULL;
805806 union acpi_object *element = NULL;
806807 acpi_status status;
807808 int err = -ENODATA;
808
-
809
- if (!wakeup)
810
- return -EINVAL;
811809
812810 INIT_LIST_HEAD(&wakeup->resources);
813811
....@@ -882,9 +880,9 @@
882880 static bool acpi_wakeup_gpe_init(struct acpi_device *device)
883881 {
884882 static const struct acpi_device_id button_device_ids[] = {
885
- {"PNP0C0C", 0},
886
- {"PNP0C0D", 0},
887
- {"PNP0C0E", 0},
883
+ {"PNP0C0C", 0}, /* Power button */
884
+ {"PNP0C0D", 0}, /* Lid */
885
+ {"PNP0C0E", 0}, /* Sleep button */
888886 {"", 0},
889887 };
890888 struct acpi_device_wakeup *wakeup = &device->wakeup;
....@@ -917,8 +915,7 @@
917915 if (!acpi_has_method(device->handle, "_PRW"))
918916 return;
919917
920
- err = acpi_bus_extract_wakeup_device_power_package(device->handle,
921
- &device->wakeup);
918
+ err = acpi_bus_extract_wakeup_device_power_package(device);
922919 if (err) {
923920 dev_err(&device->dev, "_PRW evaluation error: %d\n", err);
924921 return;
....@@ -929,14 +926,13 @@
929926 /*
930927 * Call _PSW/_DSW object to disable its ability to wake the sleeping
931928 * system for the ACPI device with the _PRW object.
932
- * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
929
+ * The _PSW object is deprecated in ACPI 3.0 and is replaced by _DSW.
933930 * So it is necessary to call _DSW object first. Only when it is not
934931 * present will the _PSW object used.
935932 */
936933 err = acpi_device_sleep_wake(device, 0, 0, 0);
937934 if (err)
938
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
939
- "error in _DSW or _PSW evaluation\n"));
935
+ pr_debug("error in _DSW or _PSW evaluation\n");
940936 }
941937
942938 static void acpi_bus_init_power_state(struct acpi_device *device, int state)
....@@ -1491,19 +1487,26 @@
14911487 }
14921488
14931489 /**
1494
- * acpi_dma_configure - Set-up DMA configuration for the device.
1490
+ * acpi_dma_configure_id - Set-up DMA configuration for the device.
14951491 * @dev: The pointer to the device
14961492 * @attr: device dma attributes
1493
+ * @input_id: input device id const value pointer
14971494 */
1498
-int acpi_dma_configure(struct device *dev, enum dev_dma_attr attr)
1495
+int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
1496
+ const u32 *input_id)
14991497 {
15001498 const struct iommu_ops *iommu;
15011499 u64 dma_addr = 0, size = 0;
15021500
1501
+ if (attr == DEV_DMA_NOT_SUPPORTED) {
1502
+ set_dma_ops(dev, &dma_dummy_ops);
1503
+ return 0;
1504
+ }
1505
+
15031506 iort_dma_setup(dev, &dma_addr, &size);
15041507
1505
- iommu = iort_iommu_configure(dev);
1506
- if (IS_ERR(iommu) && PTR_ERR(iommu) == -EPROBE_DEFER)
1508
+ iommu = iort_iommu_configure_id(dev, input_id);
1509
+ if (PTR_ERR(iommu) == -EPROBE_DEFER)
15071510 return -EPROBE_DEFER;
15081511
15091512 arch_setup_dma_ops(dev, dma_addr, size,
....@@ -1511,17 +1514,7 @@
15111514
15121515 return 0;
15131516 }
1514
-EXPORT_SYMBOL_GPL(acpi_dma_configure);
1515
-
1516
-/**
1517
- * acpi_dma_deconfigure - Tear-down DMA configuration for the device.
1518
- * @dev: The pointer to the device
1519
- */
1520
-void acpi_dma_deconfigure(struct device *dev)
1521
-{
1522
- arch_teardown_dma_ops(dev);
1523
-}
1524
-EXPORT_SYMBOL_GPL(acpi_dma_deconfigure);
1517
+EXPORT_SYMBOL_GPL(acpi_dma_configure_id);
15251518
15261519 static void acpi_init_coherency(struct acpi_device *adev)
15271520 {
....@@ -1584,6 +1577,7 @@
15841577 {
15851578 struct list_head resource_list;
15861579 bool is_serial_bus_slave = false;
1580
+ static const struct acpi_device_id ignore_serial_bus_ids[] = {
15871581 /*
15881582 * These devices have multiple I2cSerialBus resources and an i2c-client
15891583 * must be instantiated for each, each with its own i2c_device_id.
....@@ -1592,9 +1586,18 @@
15921586 * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows
15931587 * which i2c_device_id to use for each resource.
15941588 */
1595
- static const struct acpi_device_id i2c_multi_instantiate_ids[] = {
15961589 {"BSG1160", },
1590
+ {"BSG2150", },
15971591 {"INT33FE", },
1592
+ {"INT3515", },
1593
+ /*
1594
+ * HIDs of device with an UartSerialBusV2 resource for which userspace
1595
+ * expects a regular tty cdev to be created (instead of the in kernel
1596
+ * serdev) and which have a kernel driver which expects a platform_dev
1597
+ * such as the rfkill-gpio driver.
1598
+ */
1599
+ {"BCM4752", },
1600
+ {"LNV4752", },
15981601 {}
15991602 };
16001603
....@@ -1608,8 +1611,7 @@
16081611 fwnode_property_present(&device->fwnode, "baud")))
16091612 return true;
16101613
1611
- /* Instantiate a pdev for the i2c-multi-instantiate drv to bind to */
1612
- if (!acpi_match_device_ids(device, i2c_multi_instantiate_ids))
1614
+ if (!acpi_match_device_ids(device, ignore_serial_bus_ids))
16131615 return false;
16141616
16151617 INIT_LIST_HEAD(&resource_list);
....@@ -1628,7 +1630,7 @@
16281630 device->device_type = type;
16291631 device->handle = handle;
16301632 device->parent = acpi_bus_get_parent(handle);
1631
- device->fwnode.ops = &acpi_device_fwnode_ops;
1633
+ fwnode_init(&device->fwnode, &acpi_device_fwnode_ops);
16321634 acpi_set_device_status(device, sta);
16331635 acpi_device_get_busid(device);
16341636 acpi_set_pnp_ids(handle, &device->pnp, type);
....@@ -2206,10 +2208,13 @@
22062208
22072209 status = acpi_get_table(ACPI_SIG_SPCR, 0,
22082210 (struct acpi_table_header **)&spcr_ptr);
2209
- if (ACPI_SUCCESS(status))
2210
- spcr_uart_addr = spcr_ptr->serial_port.address;
2211
- else
2212
- printk(KERN_WARNING PREFIX "STAO table present, but SPCR is missing\n");
2211
+ if (ACPI_FAILURE(status)) {
2212
+ pr_warn(PREFIX "STAO table present, but SPCR is missing\n");
2213
+ return;
2214
+ }
2215
+
2216
+ spcr_uart_addr = spcr_ptr->serial_port.address;
2217
+ acpi_put_table((struct acpi_table_header *)spcr_ptr);
22132218 }
22142219
22152220 static bool acpi_scan_initialized;
....@@ -2223,6 +2228,7 @@
22232228 acpi_pci_root_init();
22242229 acpi_pci_link_init();
22252230 acpi_processor_init();
2231
+ acpi_platform_init();
22262232 acpi_lpss_init();
22272233 acpi_apd_init();
22282234 acpi_cmos_rtc_init();
....@@ -2244,15 +2250,23 @@
22442250 (struct acpi_table_header **)&stao_ptr);
22452251 if (ACPI_SUCCESS(status)) {
22462252 if (stao_ptr->header.length > sizeof(struct acpi_table_stao))
2247
- printk(KERN_INFO PREFIX "STAO Name List not yet supported.");
2253
+ pr_info(PREFIX "STAO Name List not yet supported.\n");
22482254
22492255 if (stao_ptr->ignore_uart)
22502256 acpi_get_spcr_uart_addr();
2257
+
2258
+ acpi_put_table((struct acpi_table_header *)stao_ptr);
22512259 }
22522260
22532261 acpi_gpe_apply_masked_gpes();
22542262 acpi_update_all_gpes();
22552263
2264
+ /*
2265
+ * Although we call __add_memory() that is documented to require the
2266
+ * device_hotplug_lock, it is not necessary here because this is an
2267
+ * early code when userspace or any other code path cannot trigger
2268
+ * hotplug/hotunplug operations.
2269
+ */
22562270 mutex_lock(&acpi_scan_lock);
22572271 /*
22582272 * Enumerate devices in the ACPI namespace.
....@@ -2288,10 +2302,10 @@
22882302 static int acpi_probe_count;
22892303 static DEFINE_MUTEX(acpi_probe_mutex);
22902304
2291
-static int __init acpi_match_madt(struct acpi_subtable_header *header,
2305
+static int __init acpi_match_madt(union acpi_subtable_headers *header,
22922306 const unsigned long end)
22932307 {
2294
- if (!ape->subtable_valid || ape->subtable_valid(header, ape))
2308
+ if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape))
22952309 if (!ape->probe_subtbl(header, end))
22962310 acpi_probe_count++;
22972311
....@@ -2307,7 +2321,7 @@
23072321
23082322 mutex_lock(&acpi_probe_mutex);
23092323 for (ape = ap_head; nr; ape++, nr--) {
2310
- if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
2324
+ if (ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id)) {
23112325 acpi_probe_count = 0;
23122326 acpi_table_parse_madt(ape->type, acpi_match_madt, 0);
23132327 count += acpi_probe_count;