Merge tag 'iommu-updates-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/joro...
[sfrench/cifs-2.6.git] / drivers / acpi / scan.c
index 340ba720c72129972694841b22b3ad5f65966a01..e6ed1ba91e5c9152c7eeec242c302f91fda42d5d 100644 (file)
@@ -1532,7 +1532,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
                        r->cpu_start = rentry->res->start;
                        r->dma_start = rentry->res->start - rentry->offset;
                        r->size = resource_size(rentry->res);
-                       r->offset = rentry->offset;
                        r++;
                }
        }
@@ -1736,6 +1735,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
         * Some ACPI devs contain SerialBus resources even though they are not
         * attached to a serial bus at all.
         */
+               {ACPI_VIDEO_HID, },
                {"MSHW0028", },
        /*
         * HIDs of device with an UartSerialBusV2 resource for which userspace
@@ -1985,10 +1985,9 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
        }
 }
 
-static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
+static u32 acpi_scan_check_dep(acpi_handle handle)
 {
        struct acpi_handle_list dep_devices;
-       acpi_status status;
        u32 count;
        int i;
 
@@ -1998,12 +1997,10 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
         * 2. ACPI nodes describing USB ports.
         * Still, checking for _HID catches more then just these cases ...
         */
-       if (!check_dep || !acpi_has_method(handle, "_DEP") ||
-           !acpi_has_method(handle, "_HID"))
+       if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID"))
                return 0;
 
-       status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices);
-       if (ACPI_FAILURE(status)) {
+       if (!acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices)) {
                acpi_handle_debug(handle, "Failed to evaluate _DEP.\n");
                return 0;
        }
@@ -2012,6 +2009,7 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
                struct acpi_device_info *info;
                struct acpi_dep_data *dep;
                bool skip, honor_dep;
+               acpi_status status;
 
                status = acpi_get_object_info(dep_devices.handles[i], &info);
                if (ACPI_FAILURE(status)) {
@@ -2045,7 +2043,13 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)
        return count;
 }
 
-static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
+static acpi_status acpi_scan_check_crs_csi2_cb(acpi_handle handle, u32 a, void *b, void **c)
+{
+       acpi_mipi_check_crs_csi2(handle);
+       return AE_OK;
+}
+
+static acpi_status acpi_bus_check_add(acpi_handle handle, bool first_pass,
                                      struct acpi_device **adev_p)
 {
        struct acpi_device *device = acpi_fetch_acpi_dev(handle);
@@ -2063,9 +2067,25 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
                if (acpi_device_should_be_hidden(handle))
                        return AE_OK;
 
-               /* Bail out if there are dependencies. */
-               if (acpi_scan_check_dep(handle, check_dep) > 0)
-                       return AE_CTRL_DEPTH;
+               if (first_pass) {
+                       acpi_mipi_check_crs_csi2(handle);
+
+                       /* Bail out if there are dependencies. */
+                       if (acpi_scan_check_dep(handle) > 0) {
+                               /*
+                                * The entire CSI-2 connection graph needs to be
+                                * extracted before any drivers or scan handlers
+                                * are bound to struct device objects, so scan
+                                * _CRS CSI-2 resource descriptors for all
+                                * devices below the current handle.
+                                */
+                               acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
+                                                   ACPI_UINT32_MAX,
+                                                   acpi_scan_check_crs_csi2_cb,
+                                                   NULL, NULL, NULL);
+                               return AE_CTRL_DEPTH;
+                       }
+               }
 
                fallthrough;
        case ACPI_TYPE_ANY:     /* for ACPI_ROOT_OBJECT */
@@ -2088,10 +2108,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
        }
 
        /*
-        * If check_dep is true at this point, the device has no dependencies,
+        * If first_pass is true at this point, the device has no dependencies,
         * or the creation of the device object would have been postponed above.
         */
-       acpi_add_single_object(&device, handle, type, !check_dep);
+       acpi_add_single_object(&device, handle, type, !first_pass);
        if (!device)
                return AE_CTRL_DEPTH;
 
@@ -2435,6 +2455,13 @@ static void acpi_scan_postponed_branch(acpi_handle handle)
 
        acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
                            acpi_bus_check_add_2, NULL, NULL, (void **)&adev);
+
+       /*
+        * Populate the ACPI _CRS CSI-2 software nodes for the ACPI devices that
+        * have been added above.
+        */
+       acpi_mipi_init_crs_csi2_swnodes();
+
        acpi_bus_attach(adev, NULL);
 }
 
@@ -2503,12 +2530,22 @@ int acpi_bus_scan(acpi_handle handle)
        if (!device)
                return -ENODEV;
 
+       /*
+        * Set up ACPI _CRS CSI-2 software nodes using information extracted
+        * from the _CRS CSI-2 resource descriptors during the ACPI namespace
+        * walk above and MIPI DisCo for Imaging device properties.
+        */
+       acpi_mipi_scan_crs_csi2();
+       acpi_mipi_init_crs_csi2_swnodes();
+
        acpi_bus_attach(device, (void *)true);
 
        /* Pass 2: Enumerate all of the remaining devices. */
 
        acpi_scan_postponed();
 
+       acpi_mipi_crs_csi2_cleanup();
+
        return 0;
 }
 EXPORT_SYMBOL(acpi_bus_scan);