Merge tag 'driver-core-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Feb 2021 18:13:55 +0000 (10:13 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Feb 2021 18:13:55 +0000 (10:13 -0800)
Pull driver core / debugfs update from Greg KH:
 "Here is the "big" driver core and debugfs update for 5.12-rc1

  This set of driver core patches caused a bunch of problems in
  linux-next for the past few weeks, when Saravana tried to set
  fw_devlink=on as the default functionality. This caused a number of
  systems to stop booting, and lots of bugs were fixed in this area for
  almost all of the reported systems, but this option is not ready to be
  turned on just yet for the default operation based on this testing, so
  I've reverted that change at the very end so we don't have to worry
  about regressions in 5.12

  We will try to turn this on for 5.13 if testing goes better over the
  next few months.

  Other than the fixes caused by the fw_devlink testing in here, there's
  not much more:

   - debugfs fixes for invalid input into debugfs_lookup()

   - kerneldoc cleanups

   - warn message if platform drivers return an error on their remove
     callback (a futile effort, but good to catch).

  All of these have been in linux-next for a while now, and the
  regressions have gone away with the revert of the fw_devlink change"

* tag 'driver-core-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (35 commits)
  Revert "driver core: Set fw_devlink=on by default"
  of: property: fw_devlink: Ignore interrupts property for some configs
  debugfs: do not attempt to create a new file before the filesystem is initalized
  debugfs: be more robust at handling improper input in debugfs_lookup()
  driver core: auxiliary bus: Fix calling stage for auxiliary bus init
  of: irq: Fix the return value for of_irq_parse_one() stub
  of: irq: make a stub for of_irq_parse_one()
  clk: Mark fwnodes when their clock provider is added/removed
  PM: domains: Mark fwnodes when their powerdomain is added/removed
  irqdomain: Mark fwnodes when their irqdomain is added/removed
  driver core: fw_devlink: Handle suppliers that don't use driver core
  of: property: Add fw_devlink support for optional properties
  driver core: Add fw_devlink.strict kernel param
  of: property: Don't add links to absent suppliers
  driver core: fw_devlink: Detect supplier devices that will never be added
  driver core: platform: Emit a warning if a remove callback returned non-zero
  of: property: Fix fw_devlink handling of interrupts/interrupts-extended
  gpiolib: Don't probe gpio_device if it's not the primary device
  device.h: Remove bogus "the" in kerneldoc
  gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default
  ...

1  2 
Documentation/admin-guide/kernel-parameters.txt
drivers/base/core.c
drivers/base/platform.c
drivers/base/power/domain.c
drivers/clk/clk.c
drivers/gpio/gpiolib.c
fs/debugfs/inode.c
include/linux/fwnode.h

        arcrimi=        [HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards
                        Format: <io>,<irq>,<nodeID>
  
 +      arm64.nobti     [ARM64] Unconditionally disable Branch Target
 +                      Identification support
 +
 +      arm64.nopauth   [ARM64] Unconditionally disable Pointer Authentication
 +                      support
 +
        ataflop=        [HW,M68k]
  
        atarimouse=     [HW,MOUSE] Atari Mouse
                        kernel/dma/contiguous.c
  
        cma_pernuma=nn[MG]
 -                      [ARM64,KNL]
 +                      [ARM64,KNL,CMA]
                        Sets the size of kernel per-numa memory area for
                        contiguous memory allocations. A value of 0 disables
                        per-numa CMA altogether. And If this option is not
                        insecure, please do not use on production kernels.
  
        debug_locks_verbose=
 -                      [KNL] verbose self-tests
 -                      Format=<0|1>
 +                      [KNL] verbose locking self-tests
 +                      Format: <int>
                        Print debugging info while doing the locking API
                        self-tests.
 -                      We default to 0 (no extra messages), setting it to
 -                      1 will print _a lot_ more information - normally
 -                      only useful to kernel developers.
 +                      Bitmask for the various LOCKTYPE_ tests. Defaults to 0
 +                      (no extra messages), setting it to -1 (all bits set)
 +                      will print _a_lot_ more information - normally only
 +                      useful to lockdep developers.
  
        debug_objects   [KNL] Enable object debugging
  
                        causing system reset or hang due to sending
                        INIT from AP to BSP.
  
 -      perf_v4_pmi=    [X86,INTEL]
 -                      Format: <bool>
 -                      Disable Intel PMU counter freezing feature.
 -                      The feature only exists starting from
 -                      Arch Perfmon v4 (Skylake and newer).
 -
        disable_ddw     [PPC/PSERIES]
                        Disable Dynamic DMA Window support. Use this
                        to workaround buggy firmware.
                                to enforce probe and suspend/resume ordering.
                        rpm --  Like "on", but also use to order runtime PM.
  
+       fw_devlink.strict=<bool>
+                       [KNL] Treat all inferred dependencies as mandatory
+                       dependencies. This only applies for fw_devlink=on|rpm.
+                       Format: <bool>
        gamecon.map[2|3]=
                        [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
                        support via parallel port (up to 5 devices per port)
        hpet_mmap=      [X86, HPET_MMAP] Allow userspace to mmap HPET
                        registers.  Default set by CONFIG_HPET_MMAP_DEFAULT.
  
 -      hugetlb_cma=    [HW] The size of a cma area used for allocation
 +      hugetlb_cma=    [HW,CMA] The size of a CMA area used for allocation
                        of gigantic hugepages.
                        Format: nn[KMGTPE]
  
 -                      Reserve a cma area of given size and allocate gigantic
 -                      hugepages using the cma allocator. If enabled, the
 +                      Reserve a CMA area of given size and allocate gigantic
 +                      hugepages using the CMA allocator. If enabled, the
                        boot-time allocation of gigantic hugepages is skipped.
  
        hugepages=      [HW] Number of HugeTLB pages to allocate at boot.
                        In such case C2/C3 won't be used again.
                        idle=nomwait: Disable mwait for CPU C-states
  
 +      idxd.sva=       [HW]
 +                      Format: <bool>
 +                      Allow force disabling of Shared Virtual Memory (SVA)
 +                      support for the idxd driver. By default it is set to
 +                      true (1).
 +
        ieee754=        [MIPS] Select IEEE Std 754 conformance mode
                        Format: { strict | legacy | 2008 | relaxed }
                        Default: strict
        ima_policy=     [IMA]
                        The builtin policies to load during IMA setup.
                        Format: "tcb | appraise_tcb | secure_boot |
 -                               fail_securely"
 +                               fail_securely | critical_data"
  
                        The "tcb" policy measures all programs exec'd, files
                        mmap'd for exec, and all files opened with the read
                        filesystems with the SB_I_UNVERIFIABLE_SIGNATURE
                        flag.
  
 +                      The "critical_data" policy measures kernel integrity
 +                      critical data.
 +
        ima_tcb         [IMA] Deprecated.  Use ima_policy= instead.
                        Load a policy which meets the needs of the Trusted
                        Computing Base.  This means IMA will measure all
        kvm-arm.mode=
                        [KVM,ARM] Select one of KVM/arm64's modes of operation.
  
 +                      nvhe: Standard nVHE-based mode, without support for
 +                            protected guests.
 +
                        protected: nVHE-based mode with support for guests whose
                                   state is kept private from the host.
                                   Not valid if the kernel is running in EL2.
                        parameter, xsave area per process might occupy more
                        memory on xsaves enabled systems.
  
 -      nohlt           [BUGS=ARM,SH] Tells the kernel that the sleep(SH) or
 -                      wfi(ARM) instruction doesn't work correctly and not to
 -                      use it. This is also useful when using JTAG debugger.
 +      nohlt           [ARM,ARM64,MICROBLAZE,SH] Forces the kernel to busy wait
 +                      in do_idle() and not use the arch_cpu_idle()
 +                      implementation; requires CONFIG_GENERIC_IDLE_POLL_SETUP
 +                      to be effective. This is useful on platforms where the
 +                      sleep(SH) or wfi(ARM,ARM64) instructions do not work
 +                      correctly or when doing power measurements to evalute
 +                      the impact of the sleep instructions. This is also
 +                      useful when using JTAG debugger.
  
        no_file_caps    Tells the kernel not to honor file capabilities.  The
                        only way then for a file to be executed with privilege
                        in certain environments such as networked servers or
                        real-time systems.
  
 +      no_hash_pointers
 +                      Force pointers printed to the console or buffers to be
 +                      unhashed.  By default, when a pointer is printed via %p
 +                      format string, that pointer is "hashed", i.e. obscured
 +                      by hashing the pointer value.  This is a security feature
 +                      that hides actual kernel addresses from unprivileged
 +                      users, but it also makes debugging the kernel more
 +                      difficult since unequal pointers can no longer be
 +                      compared.  However, if this command-line option is
 +                      specified, then all normal pointers will have their true
 +                      value printed.  Pointers printed via %pK may still be
 +                      hashed.  This option should only be specified when
 +                      debugging the kernel.  Please do not use on production
 +                      kernels.
 +
        nohibernate     [HIBERNATION] Disable hibernation and resume.
  
        nohz=           [KNL] Boottime enable/disable dynamic ticks
                        For example, to override I2C bus2:
                        omap_mux=i2c2_scl.i2c2_scl=0x100,i2c2_sda.i2c2_sda=0x100
  
 -      oprofile.timer= [HW]
 -                      Use timer interrupt instead of performance counters
 -
 -      oprofile.cpu_type=      Force an oprofile cpu type
 -                      This might be useful if you have an older oprofile
 -                      userland or if you want common events.
 -                      Format: { arch_perfmon }
 -                      arch_perfmon: [X86] Force use of architectural
 -                              perfmon on Intel CPUs instead of the
 -                              CPU specific event set.
 -                      timer: [X86] Force use of architectural NMI
 -                              timer mode (see also oprofile.timer
 -                              for generic hr timer mode)
 -
        oops=panic      Always panic on oopses. Default is to just kill the
                        process, but there is a small probability of
                        deadlocking the machine.
                        Format: {"off"}
                        Disable Hardware Transactional Memory
  
 +      preempt=        [KNL]
 +                      Select preemption mode if you have CONFIG_PREEMPT_DYNAMIC
 +                      none - Limited to cond_resched() calls
 +                      voluntary - Limited to cond_resched() and might_sleep() calls
 +                      full - Any section that isn't explicitly preempt disabled
 +                             can be preempted anytime.
 +
        print-fatal-signals=
                        [KNL] debug: print fatal signals
  
                        value, meaning that RCU_SOFTIRQ is used by default.
                        Specify rcutree.use_softirq=0 to use rcuc kthreads.
  
 +                      But note that CONFIG_PREEMPT_RT=y kernels disable
 +                      this kernel boot parameter, forcibly setting it
 +                      to zero.
 +
        rcutree.rcu_fanout_exact= [KNL]
                        Disable autobalancing of the rcu_node combining
                        tree.  This is used by rcutorture, and might
                        Set wakeup interval for idle CPUs that have
                        RCU callbacks (RCU_FAST_NO_HZ=y).
  
 -      rcutree.rcu_idle_lazy_gp_delay= [KNL]
 -                      Set wakeup interval for idle CPUs that have
 -                      only "lazy" RCU callbacks (RCU_FAST_NO_HZ=y).
 -                      Lazy RCU callbacks are those which RCU can
 -                      prove do nothing more than free memory.
 -
        rcutree.rcu_kick_kthreads= [KNL]
                        Cause the grace-period kthread to get an extra
                        wake_up() if it sleeps three times longer than
                        stress RCU, they don't participate in the actual
                        test, hence the "fake".
  
 +      rcutorture.nocbs_nthreads= [KNL]
 +                      Set number of RCU callback-offload togglers.
 +                      Zero (the default) disables toggling.
 +
 +      rcutorture.nocbs_toggle= [KNL]
 +                      Set the delay in milliseconds between successive
 +                      callback-offload toggling attempts.
 +
        rcutorture.nreaders= [KNL]
                        Set number of RCU readers.  The value -1 selects
                        N-1, where N is the number of CPUs.  A value
                        only normal grace-period primitives.  No effect
                        on CONFIG_TINY_RCU kernels.
  
 +                      But note that CONFIG_PREEMPT_RT=y kernels enables
 +                      this kernel boot parameter, forcibly setting
 +                      it to the value one, that is, converting any
 +                      post-boot attempt at an expedited RCU grace
 +                      period to instead use normal non-expedited
 +                      grace-period processing.
 +
        rcupdate.rcu_task_ipi_delay= [KNL]
                        Set time in jiffies during which RCU tasks will
                        avoid sending IPIs, starting with the beginning
        refscale.verbose= [KNL]
                        Enable additional printk() statements.
  
 +      refscale.verbose_batched= [KNL]
 +                      Batch the additional printk() statements.  If zero
 +                      (the default) or negative, print everything.  Otherwise,
 +                      print every Nth verbose statement, where N is the value
 +                      specified.
 +
        relax_domain_level=
                        [KNL, SMP] Set scheduler's default relax_domain_level.
                        See Documentation/admin-guide/cgroup-v1/cpusets.rst.
                        are running concurrently, especially on systems
                        with rotating-rust storage.
  
 +      torture.verbose_sleep_frequency= [KNL]
 +                      Specifies how many verbose printk()s should be
 +                      emitted between each sleep.  The default of zero
 +                      disables verbose-printk() sleeping.
 +
 +      torture.verbose_sleep_duration= [KNL]
 +                      Duration of each verbose-printk() sleep in jiffies.
 +
        tp720=          [HW,PS2]
  
        tpm_suspend_pcr=[HW,TPM]
diff --combined drivers/base/core.c
@@@ -28,7 -28,6 +28,7 @@@
  #include <linux/sched/signal.h>
  #include <linux/sched/mm.h>
  #include <linux/sysfs.h>
 +#include <linux/dma-map-ops.h> /* for dma_default_coherent */
  
  #include "base.h"
  #include "power/power.h"
@@@ -149,6 -148,21 +149,21 @@@ void fwnode_links_purge(struct fwnode_h
        fwnode_links_purge_consumers(fwnode);
  }
  
+ static void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode)
+ {
+       struct fwnode_handle *child;
+       /* Don't purge consumer links of an added child */
+       if (fwnode->dev)
+               return;
+       fwnode->flags |= FWNODE_FLAG_NOT_DEVICE;
+       fwnode_links_purge_consumers(fwnode);
+       fwnode_for_each_available_child_node(fwnode, child)
+               fw_devlink_purge_absent_suppliers(child);
+ }
  #ifdef CONFIG_SRCU
  static DEFINE_MUTEX(device_links_lock);
  DEFINE_STATIC_SRCU(device_links_srcu);
@@@ -245,7 -259,8 +260,8 @@@ int device_is_dependent(struct device *
                return ret;
  
        list_for_each_entry(link, &dev->links.consumers, s_node) {
-               if (link->flags == (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
+               if ((link->flags & ~DL_FLAG_INFERRED) ==
+                   (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
                        continue;
  
                if (link->consumer == target)
@@@ -318,7 -333,8 +334,8 @@@ static int device_reorder_to_tail(struc
  
        device_for_each_child(dev, NULL, device_reorder_to_tail);
        list_for_each_entry(link, &dev->links.consumers, s_node) {
-               if (link->flags == (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
+               if ((link->flags & ~DL_FLAG_INFERRED) ==
+                   (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
                        continue;
                device_reorder_to_tail(link->consumer, NULL);
        }
@@@ -566,7 -582,8 +583,8 @@@ postcore_initcall(devlink_class_init)
  #define DL_MANAGED_LINK_FLAGS (DL_FLAG_AUTOREMOVE_CONSUMER | \
                               DL_FLAG_AUTOREMOVE_SUPPLIER | \
                               DL_FLAG_AUTOPROBE_CONSUMER  | \
-                              DL_FLAG_SYNC_STATE_ONLY)
+                              DL_FLAG_SYNC_STATE_ONLY | \
+                              DL_FLAG_INFERRED)
  
  #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
                            DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
@@@ -635,7 -652,7 +653,7 @@@ struct device_link *device_link_add(str
        if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
            (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
            (flags & DL_FLAG_SYNC_STATE_ONLY &&
-            flags != DL_FLAG_SYNC_STATE_ONLY) ||
+            (flags & ~DL_FLAG_INFERRED) != DL_FLAG_SYNC_STATE_ONLY) ||
            (flags & DL_FLAG_AUTOPROBE_CONSUMER &&
             flags & (DL_FLAG_AUTOREMOVE_CONSUMER |
                      DL_FLAG_AUTOREMOVE_SUPPLIER)))
                if (link->consumer != consumer)
                        continue;
  
+               if (link->flags & DL_FLAG_INFERRED &&
+                   !(flags & DL_FLAG_INFERRED))
+                       link->flags &= ~DL_FLAG_INFERRED;
                if (flags & DL_FLAG_PM_RUNTIME) {
                        if (!(link->flags & DL_FLAG_PM_RUNTIME)) {
                                pm_runtime_new_link(consumer);
@@@ -950,6 -971,10 +972,10 @@@ int device_links_check_suppliers(struc
        mutex_lock(&fwnode_link_lock);
        if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
            !fw_devlink_is_permissive()) {
+               dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n",
+                       list_first_entry(&dev->fwnode->suppliers,
+                       struct fwnode_link,
+                       c_hook)->supplier);
                mutex_unlock(&fwnode_link_lock);
                return -EPROBE_DEFER;
        }
                if (link->status != DL_STATE_AVAILABLE &&
                    !(link->flags & DL_FLAG_SYNC_STATE_ONLY)) {
                        device_links_missing_supplier(dev);
+                       dev_dbg(dev, "probe deferral - supplier %s not ready\n",
+                               dev_name(link->supplier));
                        ret = -EPROBE_DEFER;
                        break;
                }
@@@ -1142,12 -1169,22 +1170,22 @@@ void device_links_driver_bound(struct d
        LIST_HEAD(sync_list);
  
        /*
-        * If a device probes successfully, it's expected to have created all
+        * If a device binds successfully, it's expected to have created all
         * the device links it needs to or make new device links as it needs
-        * them. So, it no longer needs to wait on any suppliers.
+        * them. So, fw_devlink no longer needs to create device links to any
+        * of the device's suppliers.
+        *
+        * Also, if a child firmware node of this bound device is not added as
+        * a device by now, assume it is never going to be added and make sure
+        * other devices don't defer probe indefinitely by waiting for such a
+        * child device.
         */
-       if (dev->fwnode && dev->fwnode->dev == dev)
+       if (dev->fwnode && dev->fwnode->dev == dev) {
+               struct fwnode_handle *child;
                fwnode_links_purge_suppliers(dev->fwnode);
+               fwnode_for_each_available_child_node(dev->fwnode, child)
+                       fw_devlink_purge_absent_suppliers(child);
+       }
        device_remove_file(dev, &dev_attr_waiting_for_supplier);
  
        device_links_write_lock();
@@@ -1458,7 -1495,14 +1496,14 @@@ static void device_links_purge(struct d
        device_links_write_unlock();
  }
  
- static u32 fw_devlink_flags = DL_FLAG_SYNC_STATE_ONLY;
+ #define FW_DEVLINK_FLAGS_PERMISSIVE   (DL_FLAG_INFERRED | \
+                                        DL_FLAG_SYNC_STATE_ONLY)
+ #define FW_DEVLINK_FLAGS_ON           (DL_FLAG_INFERRED | \
+                                        DL_FLAG_AUTOPROBE_CONSUMER)
+ #define FW_DEVLINK_FLAGS_RPM          (FW_DEVLINK_FLAGS_ON | \
+                                        DL_FLAG_PM_RUNTIME)
+ static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
  static int __init fw_devlink_setup(char *arg)
  {
        if (!arg)
        if (strcmp(arg, "off") == 0) {
                fw_devlink_flags = 0;
        } else if (strcmp(arg, "permissive") == 0) {
-               fw_devlink_flags = DL_FLAG_SYNC_STATE_ONLY;
+               fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
        } else if (strcmp(arg, "on") == 0) {
-               fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER;
+               fw_devlink_flags = FW_DEVLINK_FLAGS_ON;
        } else if (strcmp(arg, "rpm") == 0) {
-               fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER |
-                                  DL_FLAG_PM_RUNTIME;
+               fw_devlink_flags = FW_DEVLINK_FLAGS_RPM;
        }
        return 0;
  }
  early_param("fw_devlink", fw_devlink_setup);
  
+ static bool fw_devlink_strict;
+ static int __init fw_devlink_strict_setup(char *arg)
+ {
+       return strtobool(arg, &fw_devlink_strict);
+ }
+ early_param("fw_devlink.strict", fw_devlink_strict_setup);
  u32 fw_devlink_get_flags(void)
  {
        return fw_devlink_flags;
  
  static bool fw_devlink_is_permissive(void)
  {
-       return fw_devlink_flags == DL_FLAG_SYNC_STATE_ONLY;
+       return fw_devlink_flags == FW_DEVLINK_FLAGS_PERMISSIVE;
+ }
+ bool fw_devlink_is_strict(void)
+ {
+       return fw_devlink_strict && !fw_devlink_is_permissive();
  }
  
  static void fw_devlink_parse_fwnode(struct fwnode_handle *fwnode)
@@@ -1508,6 -1563,53 +1564,53 @@@ static void fw_devlink_parse_fwtree(str
  }
  
  /**
+  * fw_devlink_relax_cycle - Convert cyclic links to SYNC_STATE_ONLY links
+  * @con: Device to check dependencies for.
+  * @sup: Device to check against.
+  *
+  * Check if @sup depends on @con or any device dependent on it (its child or
+  * its consumer etc).  When such a cyclic dependency is found, convert all
+  * device links created solely by fw_devlink into SYNC_STATE_ONLY device links.
+  * This is the equivalent of doing fw_devlink=permissive just between the
+  * devices in the cycle. We need to do this because, at this point, fw_devlink
+  * can't tell which of these dependencies is not a real dependency.
+  *
+  * Return 1 if a cycle is found. Otherwise, return 0.
+  */
+ static int fw_devlink_relax_cycle(struct device *con, void *sup)
+ {
+       struct device_link *link;
+       int ret;
+       if (con == sup)
+               return 1;
+       ret = device_for_each_child(con, sup, fw_devlink_relax_cycle);
+       if (ret)
+               return ret;
+       list_for_each_entry(link, &con->links.consumers, s_node) {
+               if ((link->flags & ~DL_FLAG_INFERRED) ==
+                   (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
+                       continue;
+               if (!fw_devlink_relax_cycle(link->consumer, sup))
+                       continue;
+               ret = 1;
+               if (!(link->flags & DL_FLAG_INFERRED))
+                       continue;
+               pm_runtime_drop_link(link);
+               link->flags = DL_FLAG_MANAGED | FW_DEVLINK_FLAGS_PERMISSIVE;
+               dev_dbg(link->consumer, "Relaxing link with %s\n",
+                       dev_name(link->supplier));
+       }
+       return ret;
+ }
+ /**
   * fw_devlink_create_devlink - Create a device link from a consumer to fwnode
   * @con - Consumer device for the device link
   * @sup_handle - fwnode handle of supplier
@@@ -1535,15 -1637,39 +1638,39 @@@ static int fw_devlink_create_devlink(st
        sup_dev = get_dev_from_fwnode(sup_handle);
        if (sup_dev) {
                /*
+                * If it's one of those drivers that don't actually bind to
+                * their device using driver core, then don't wait on this
+                * supplier device indefinitely.
+                */
+               if (sup_dev->links.status == DL_DEV_NO_DRIVER &&
+                   sup_handle->flags & FWNODE_FLAG_INITIALIZED) {
+                       ret = -EINVAL;
+                       goto out;
+               }
+               /*
                 * If this fails, it is due to cycles in device links.  Just
                 * give up on this link and treat it as invalid.
                 */
-               if (!device_link_add(con, sup_dev, flags))
+               if (!device_link_add(con, sup_dev, flags) &&
+                   !(flags & DL_FLAG_SYNC_STATE_ONLY)) {
+                       dev_info(con, "Fixing up cyclic dependency with %s\n",
+                                dev_name(sup_dev));
+                       device_links_write_lock();
+                       fw_devlink_relax_cycle(con, sup_dev);
+                       device_links_write_unlock();
+                       device_link_add(con, sup_dev,
+                                       FW_DEVLINK_FLAGS_PERMISSIVE);
                        ret = -EINVAL;
+               }
  
                goto out;
        }
  
+       /* Supplier that's already initialized without a struct device. */
+       if (sup_handle->flags & FWNODE_FLAG_INITIALIZED)
+               return -EINVAL;
        /*
         * DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports
         * cycles. So cycle detection isn't necessary and shouldn't be
@@@ -1632,7 -1758,7 +1759,7 @@@ static void __fw_devlink_link_to_consum
                                con_dev = NULL;
                        } else {
                                own_link = false;
-                               dl_flags = DL_FLAG_SYNC_STATE_ONLY;
+                               dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
                        }
                }
  
@@@ -1687,7 -1813,7 +1814,7 @@@ static void __fw_devlink_link_to_suppli
        if (own_link)
                dl_flags = fw_devlink_get_flags();
        else
-               dl_flags = DL_FLAG_SYNC_STATE_ONLY;
+               dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
  
        list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) {
                int ret;
@@@ -2604,11 -2730,6 +2731,11 @@@ void device_initialize(struct device *d
        INIT_LIST_HEAD(&dev->links.suppliers);
        INIT_LIST_HEAD(&dev->links.defer_sync);
        dev->links.status = DL_DEV_NO_DRIVER;
 +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
 +    defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
 +    defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
 +      dev->dma_coherent = dma_default_coherent;
 +#endif
  }
  EXPORT_SYMBOL_GPL(device_initialize);
  
diff --combined drivers/base/platform.c
@@@ -573,7 -573,7 +573,7 @@@ static void platform_device_release(str
        struct platform_object *pa = container_of(dev, struct platform_object,
                                                  pdev.dev);
  
 -      of_device_node_put(&pa->pdev.dev);
 +      of_node_put(pa->pdev.dev.of_node);
        kfree(pa->pdev.dev.platform_data);
        kfree(pa->pdev.mfd_cell);
        kfree(pa->pdev.resource);
@@@ -1463,13 -1463,16 +1463,16 @@@ static int platform_remove(struct devic
  {
        struct platform_driver *drv = to_platform_driver(_dev->driver);
        struct platform_device *dev = to_platform_device(_dev);
-       int ret = 0;
  
-       if (drv->remove)
-               ret = drv->remove(dev);
+       if (drv->remove) {
+               int ret = drv->remove(dev);
+               if (ret)
+                       dev_warn(_dev, "remove callback returned a non-zero value. This will be ignored.\n");
+       }
        dev_pm_domain_detach(_dev, true);
  
-       return ret;
+       return 0;
  }
  
  static void platform_shutdown(struct device *_dev)
@@@ -297,18 -297,6 +297,18 @@@ static int _genpd_reeval_performance_st
        return state;
  }
  
 +static int genpd_xlate_performance_state(struct generic_pm_domain *genpd,
 +                                       struct generic_pm_domain *parent,
 +                                       unsigned int pstate)
 +{
 +      if (!parent->set_performance_state)
 +              return pstate;
 +
 +      return dev_pm_opp_xlate_performance_state(genpd->opp_table,
 +                                                parent->opp_table,
 +                                                pstate);
 +}
 +
  static int _genpd_set_performance_state(struct generic_pm_domain *genpd,
                                        unsigned int state, int depth)
  {
        list_for_each_entry(link, &genpd->child_links, child_node) {
                parent = link->parent;
  
 -              if (!parent->set_performance_state)
 -                      continue;
 -
                /* Find parent's performance state */
 -              ret = dev_pm_opp_xlate_performance_state(genpd->opp_table,
 -                                                       parent->opp_table,
 -                                                       state);
 +              ret = genpd_xlate_performance_state(genpd, parent, state);
                if (unlikely(ret < 0))
                        goto err;
  
                        goto err;
        }
  
 -      ret = genpd->set_performance_state(genpd, state);
 -      if (ret)
 -              goto err;
 +      if (genpd->set_performance_state) {
 +              ret = genpd->set_performance_state(genpd, state);
 +              if (ret)
 +                      goto err;
 +      }
  
        genpd->performance_state = state;
        return 0;
@@@ -361,6 -352,9 +361,6 @@@ err
                                             child_node) {
                parent = link->parent;
  
 -              if (!parent->set_performance_state)
 -                      continue;
 -
                genpd_lock_nested(parent, depth + 1);
  
                parent_state = link->prev_performance_state;
@@@ -405,6 -399,9 +405,6 @@@ int dev_pm_genpd_set_performance_state(
        if (!genpd)
                return -ENODEV;
  
 -      if (unlikely(!genpd->set_performance_state))
 -              return -EINVAL;
 -
        if (WARN_ON(!dev->power.subsys_data ||
                     !dev->power.subsys_data->domain_data))
                return -EINVAL;
  }
  EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state);
  
 +/**
 + * dev_pm_genpd_set_next_wakeup - Notify PM framework of an impending wakeup.
 + *
 + * @dev: Device to handle
 + * @next: impending interrupt/wakeup for the device
 + *
 + *
 + * Allow devices to inform of the next wakeup. It's assumed that the users
 + * guarantee that the genpd wouldn't be detached while this routine is getting
 + * called. Additionally, it's also assumed that @dev isn't runtime suspended
 + * (RPM_SUSPENDED)."
 + * Although devices are expected to update the next_wakeup after the end of
 + * their usecase as well, it is possible the devices themselves may not know
 + * about that, so stale @next will be ignored when powering off the domain.
 + */
 +void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next)
 +{
 +      struct generic_pm_domain_data *gpd_data;
 +      struct generic_pm_domain *genpd;
 +
 +      genpd = dev_to_genpd_safe(dev);
 +      if (!genpd)
 +              return;
 +
 +      gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
 +      gpd_data->next_wakeup = next;
 +}
 +EXPORT_SYMBOL_GPL(dev_pm_genpd_set_next_wakeup);
 +
  static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
  {
        unsigned int state_idx = genpd->state_idx;
@@@ -966,7 -934,8 +966,7 @@@ static int genpd_runtime_resume(struct 
  err_stop:
        genpd_stop_dev(genpd, dev);
  err_poweroff:
 -      if (!pm_runtime_is_irq_safe(dev) ||
 -              (pm_runtime_is_irq_safe(dev) && genpd_is_irq_safe(genpd))) {
 +      if (!pm_runtime_is_irq_safe(dev) || genpd_is_irq_safe(genpd)) {
                genpd_lock(genpd);
                genpd_power_off(genpd, true, 0);
                genpd_unlock(genpd);
@@@ -1496,7 -1465,6 +1496,7 @@@ static struct generic_pm_domain_data *g
        gpd_data->td.constraint_changed = true;
        gpd_data->td.effective_constraint_ns = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT_NS;
        gpd_data->nb.notifier_call = genpd_dev_pm_qos_notifier;
 +      gpd_data->next_wakeup = KTIME_MAX;
  
        spin_lock_irq(&dev->power.lock);
  
@@@ -2196,6 -2164,7 +2196,7 @@@ static int genpd_add_provider(struct de
        cp->node = of_node_get(np);
        cp->data = data;
        cp->xlate = xlate;
+       fwnode_dev_initialized(&np->fwnode, true);
  
        mutex_lock(&of_genpd_mutex);
        list_add(&cp->link, &of_genpd_providers);
@@@ -2385,6 -2354,7 +2386,7 @@@ void of_genpd_del_provider(struct devic
                                }
                        }
  
+                       fwnode_dev_initialized(&cp->node->fwnode, false);
                        list_del(&cp->link);
                        of_node_put(cp->node);
                        kfree(cp);
@@@ -2495,7 -2465,7 +2497,7 @@@ int of_genpd_add_subdomain(struct of_ph
  out:
        mutex_unlock(&gpd_list_lock);
  
 -      return ret;
 +      return ret == -ENOENT ? -EPROBE_DEFER : ret;
  }
  EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
  
@@@ -2984,15 -2954,7 +2986,15 @@@ static void rtpm_status_str(struct seq_
        else
                WARN_ON(1);
  
 -      seq_puts(s, p);
 +      seq_printf(s, "%-25s  ", p);
 +}
 +
 +static void perf_status_str(struct seq_file *s, struct device *dev)
 +{
 +      struct generic_pm_domain_data *gpd_data;
 +
 +      gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
 +      seq_put_decimal_ull(s, "", gpd_data->performance_state);
  }
  
  static int genpd_summary_one(struct seq_file *s,
        else
                snprintf(state, sizeof(state), "%s",
                         status_lookup[genpd->status]);
 -      seq_printf(s, "%-30s  %-15s ", genpd->name, state);
 +      seq_printf(s, "%-30s  %-50s %u", genpd->name, state, genpd->performance_state);
  
        /*
         * Modifications on the list require holding locks on both
         * Also genpd->name is immutable.
         */
        list_for_each_entry(link, &genpd->parent_links, parent_node) {
 +              if (list_is_first(&link->parent_node, &genpd->parent_links))
 +                      seq_printf(s, "\n%48s", " ");
                seq_printf(s, "%s", link->child->name);
                if (!list_is_last(&link->parent_node, &genpd->parent_links))
                        seq_puts(s, ", ");
  
                seq_printf(s, "\n    %-50s  ", kobj_path);
                rtpm_status_str(s, pm_data->dev);
 +              perf_status_str(s, pm_data->dev);
                kfree(kobj_path);
        }
  
@@@ -3060,9 -3019,9 +3062,9 @@@ static int summary_show(struct seq_fil
        struct generic_pm_domain *genpd;
        int ret = 0;
  
 -      seq_puts(s, "domain                          status          children\n");
 +      seq_puts(s, "domain                          status          children                           performance\n");
        seq_puts(s, "    /device                                             runtime status\n");
 -      seq_puts(s, "----------------------------------------------------------------------\n");
 +      seq_puts(s, "----------------------------------------------------------------------------------------------\n");
  
        ret = mutex_lock_interruptible(&gpd_list_lock);
        if (ret)
diff --combined drivers/clk/clk.c
@@@ -1164,27 -1164,6 +1164,27 @@@ int clk_enable(struct clk *clk
  }
  EXPORT_SYMBOL_GPL(clk_enable);
  
 +/**
 + * clk_is_enabled_when_prepared - indicate if preparing a clock also enables it.
 + * @clk: clock source
 + *
 + * Returns true if clk_prepare() implicitly enables the clock, effectively
 + * making clk_enable()/clk_disable() no-ops, false otherwise.
 + *
 + * This is of interest mainly to power management code where actually
 + * disabling the clock also requires unpreparing it to have any material
 + * effect.
 + *
 + * Regardless of the value returned here, the caller must always invoke
 + * clk_enable() or clk_prepare_enable()  and counterparts for usage counts
 + * to be right.
 + */
 +bool clk_is_enabled_when_prepared(struct clk *clk)
 +{
 +      return clk && !(clk->core->ops->enable && clk->core->ops->disable);
 +}
 +EXPORT_SYMBOL_GPL(clk_is_enabled_when_prepared);
 +
  static int clk_core_prepare_enable(struct clk_core *core)
  {
        int ret;
@@@ -4576,6 -4555,8 +4576,8 @@@ int of_clk_add_provider(struct device_n
        if (ret < 0)
                of_clk_del_provider(np);
  
+       fwnode_dev_initialized(&np->fwnode, true);
        return ret;
  }
  EXPORT_SYMBOL_GPL(of_clk_add_provider);
@@@ -4693,6 -4674,7 +4695,7 @@@ void of_clk_del_provider(struct device_
        list_for_each_entry(cp, &of_clk_providers, link) {
                if (cp->node == np) {
                        list_del(&cp->link);
+                       fwnode_dev_initialized(&np->fwnode, false);
                        of_node_put(cp->node);
                        kfree(cp);
                        break;
diff --combined drivers/gpio/gpiolib.c
  static DEFINE_IDA(gpio_ida);
  static dev_t gpio_devt;
  #define GPIO_DEV_MAX 256 /* 256 GPIO chip devices supported */
+ static int gpio_bus_match(struct device *dev, struct device_driver *drv);
  static struct bus_type gpio_bus_type = {
        .name = "gpio",
+       .match = gpio_bus_match,
  };
  
  /*
@@@ -590,24 -592,14 +592,18 @@@ int gpiochip_add_data_with_key(struct g
                gdev->dev.of_node = gc->parent->of_node;
        }
  
- #ifdef CONFIG_OF_GPIO
-       /* If the gpiochip has an assigned OF node this takes precedence */
-       if (gc->of_node)
-               gdev->dev.of_node = gc->of_node;
-       else
-               gc->of_node = gdev->dev.of_node;
- #endif
+       of_gpio_dev_init(gc, gdev);
  
        gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
        if (gdev->id < 0) {
                ret = gdev->id;
                goto err_free_gdev;
        }
 -      dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
 +
 +      ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
 +      if (ret)
 +              goto err_free_ida;
 +
        device_initialize(&gdev->dev);
        dev_set_drvdata(&gdev->dev, gdev);
        if (gc->parent && gc->parent->driver)
        gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
        if (!gdev->descs) {
                ret = -ENOMEM;
 -              goto err_free_ida;
 +              goto err_free_dev_name;
        }
  
        if (gc->ngpio == 0) {
@@@ -772,8 -764,6 +768,8 @@@ err_free_label
        kfree_const(gdev->label);
  err_free_descs:
        kfree(gdev->descs);
 +err_free_dev_name:
 +      kfree(dev_name(&gdev->dev));
  err_free_ida:
        ida_free(&gpio_ida, gdev->id);
  err_free_gdev:
@@@ -2557,7 -2547,7 +2553,7 @@@ int gpiod_get_array_value_complex(bool 
                struct gpio_chip *gc = desc_array[i]->gdev->chip;
                unsigned long fastpath[2 * BITS_TO_LONGS(FASTPATH_NGPIO)];
                unsigned long *mask, *bits;
 -              int first, j, ret;
 +              int first, j;
  
                if (likely(gc->ngpio <= FASTPATH_NGPIO)) {
                        mask = fastpath;
@@@ -3469,10 -3459,6 +3465,10 @@@ EXPORT_SYMBOL_GPL(gpiod_add_lookup_tabl
   */
  void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
  {
 +      /* Nothing to remove */
 +      if (!table)
 +              return;
 +
        mutex_lock(&gpio_lookup_lock);
  
        list_del(&table->list);
@@@ -4215,6 -4201,41 +4211,41 @@@ void gpiod_put_array(struct gpio_descs 
  }
  EXPORT_SYMBOL_GPL(gpiod_put_array);
  
+ static int gpio_bus_match(struct device *dev, struct device_driver *drv)
+ {
+       /*
+        * Only match if the fwnode doesn't already have a proper struct device
+        * created for it.
+        */
+       if (dev->fwnode && dev->fwnode->dev != dev)
+               return 0;
+       return 1;
+ }
+ static int gpio_stub_drv_probe(struct device *dev)
+ {
+       /*
+        * The DT node of some GPIO chips have a "compatible" property, but
+        * never have a struct device added and probed by a driver to register
+        * the GPIO chip with gpiolib. In such cases, fw_devlink=on will cause
+        * the consumers of the GPIO chip to get probe deferred forever because
+        * they will be waiting for a device associated with the GPIO chip
+        * firmware node to get added and bound to a driver.
+        *
+        * To allow these consumers to probe, we associate the struct
+        * gpio_device of the GPIO chip with the firmware node and then simply
+        * bind it to this stub driver.
+        */
+       return 0;
+ }
+ static struct device_driver gpio_stub_drv = {
+       .name = "gpio_stub_drv",
+       .bus = &gpio_bus_type,
+       .probe = gpio_stub_drv_probe,
+ };
  static int __init gpiolib_dev_init(void)
  {
        int ret;
                return ret;
        }
  
+       if (driver_register(&gpio_stub_drv) < 0) {
+               pr_err("gpiolib: could not register GPIO stub driver\n");
+               bus_unregister(&gpio_bus_type);
+               return ret;
+       }
        ret = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, GPIOCHIP_NAME);
        if (ret < 0) {
                pr_err("gpiolib: failed to allocate char dev region\n");
+               driver_unregister(&gpio_stub_drv);
                bus_unregister(&gpio_bus_type);
                return ret;
        }
diff --combined fs/debugfs/inode.c
@@@ -42,14 -42,13 +42,14 @@@ static unsigned int debugfs_allow = DEF
   * so that we can use the file mode as part of a heuristic to determine whether
   * to lock down individual files.
   */
 -static int debugfs_setattr(struct dentry *dentry, struct iattr *ia)
 +static int debugfs_setattr(struct user_namespace *mnt_userns,
 +                         struct dentry *dentry, struct iattr *ia)
  {
        int ret = security_locked_down(LOCKDOWN_DEBUGFS);
  
        if (ret && (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)))
                return ret;
 -      return simple_setattr(dentry, ia);
 +      return simple_setattr(&init_user_ns, dentry, ia);
  }
  
  static const struct inode_operations debugfs_file_inode_operations = {
@@@ -298,7 -297,7 +298,7 @@@ struct dentry *debugfs_lookup(const cha
  {
        struct dentry *dentry;
  
-       if (IS_ERR(parent))
+       if (!debugfs_initialized() || IS_ERR_OR_NULL(name) || IS_ERR(parent))
                return NULL;
  
        if (!parent)
@@@ -319,6 -318,9 +319,9 @@@ static struct dentry *start_creating(co
        if (!(debugfs_allow & DEBUGFS_ALLOW_API))
                return ERR_PTR(-EPERM);
  
+       if (!debugfs_initialized())
+               return ERR_PTR(-ENOENT);
        pr_debug("creating file '%s'\n", name);
  
        if (IS_ERR(parent))
@@@ -776,8 -778,8 +779,8 @@@ struct dentry *debugfs_rename(struct de
  
        take_dentry_name_snapshot(&old_name, old_dentry);
  
 -      error = simple_rename(d_inode(old_dir), old_dentry, d_inode(new_dir),
 -                            dentry, 0);
 +      error = simple_rename(&init_user_ns, d_inode(old_dir), old_dentry,
 +                            d_inode(new_dir), dentry, 0);
        if (error) {
                release_dentry_name_snapshot(&old_name);
                goto exit;
diff --combined include/linux/fwnode.h
@@@ -11,6 -11,7 +11,7 @@@
  
  #include <linux/types.h>
  #include <linux/list.h>
+ #include <linux/err.h>
  
  struct fwnode_operations;
  struct device;
  /*
   * fwnode link flags
   *
-  * LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
+  * LINKS_ADDED:       The fwnode has already be parsed to add fwnode links.
+  * NOT_DEVICE:        The fwnode will never be populated as a struct device.
+  * INITIALIZED: The hardware corresponding to fwnode has been initialized.
   */
  #define FWNODE_FLAG_LINKS_ADDED               BIT(0)
+ #define FWNODE_FLAG_NOT_DEVICE                BIT(1)
+ #define FWNODE_FLAG_INITIALIZED               BIT(2)
  
  struct fwnode_handle {
        struct fwnode_handle *secondary;
@@@ -50,13 -55,6 +55,13 @@@ struct fwnode_endpoint 
        const struct fwnode_handle *local_fwnode;
  };
  
 +/*
 + * ports and endpoints defined as software_nodes should all follow a common
 + * naming scheme; use these macros to ensure commonality.
 + */
 +#define SWNODE_GRAPH_PORT_NAME_FMT            "port@%u"
 +#define SWNODE_GRAPH_ENDPOINT_NAME_FMT                "endpoint@%u"
 +
  #define NR_FWNODE_REFERENCE_ARGS      8
  
  /**
@@@ -166,7 -164,20 +171,20 @@@ static inline void fwnode_init(struct f
        INIT_LIST_HEAD(&fwnode->suppliers);
  }
  
+ static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode,
+                                         bool initialized)
+ {
+       if (IS_ERR_OR_NULL(fwnode))
+               return;
+       if (initialized)
+               fwnode->flags |= FWNODE_FLAG_INITIALIZED;
+       else
+               fwnode->flags &= ~FWNODE_FLAG_INITIALIZED;
+ }
  extern u32 fw_devlink_get_flags(void);
+ extern bool fw_devlink_is_strict(void);
  int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
  void fwnode_links_purge(struct fwnode_handle *fwnode);