1. 19 9月, 2018 1 次提交
  2. 31 8月, 2018 1 次提交
    • V
      gpio: Fix crash due to registration race · d49b48f0
      Vincent Whitchurch 提交于
      gpiochip_add_data_with_key() adds the gpiochip to the gpio_devices list
      before of_gpiochip_add() is called, but it's only the latter which sets
      the ->of_xlate function pointer.  gpiochip_find() can be called by
      someone else between these two actions, and it can find the chip and
      call of_gpiochip_match_node_and_xlate() which leads to the following
      crash due to a NULL ->of_xlate().
      
       Unhandled prefetch abort: page domain fault (0x01b) at 0x00000000
       Modules linked in: leds_gpio(+) gpio_generic(+)
       CPU: 0 PID: 830 Comm: insmod Not tainted 4.18.0+ #43
       Hardware name: ARM-Versatile Express
       PC is at   (null)
       LR is at of_gpiochip_match_node_and_xlate+0x2c/0x38
       Process insmod (pid: 830, stack limit = 0x(ptrval))
        (of_gpiochip_match_node_and_xlate) from  (gpiochip_find+0x48/0x84)
        (gpiochip_find) from  (of_get_named_gpiod_flags+0xa8/0x238)
        (of_get_named_gpiod_flags) from  (gpiod_get_from_of_node+0x2c/0xc8)
        (gpiod_get_from_of_node) from  (devm_fwnode_get_index_gpiod_from_child+0xb8/0x144)
        (devm_fwnode_get_index_gpiod_from_child) from  (gpio_led_probe+0x208/0x3c4 [leds_gpio])
        (gpio_led_probe [leds_gpio]) from  (platform_drv_probe+0x48/0x9c)
        (platform_drv_probe) from  (really_probe+0x1d0/0x3d4)
        (really_probe) from  (driver_probe_device+0x78/0x1c0)
        (driver_probe_device) from  (__driver_attach+0x120/0x13c)
        (__driver_attach) from  (bus_for_each_dev+0x68/0xb4)
        (bus_for_each_dev) from  (bus_add_driver+0x1a8/0x268)
        (bus_add_driver) from  (driver_register+0x78/0x10c)
        (driver_register) from  (do_one_initcall+0x54/0x1fc)
        (do_one_initcall) from  (do_init_module+0x64/0x1f4)
        (do_init_module) from  (load_module+0x2198/0x26ac)
        (load_module) from  (sys_finit_module+0xe0/0x110)
        (sys_finit_module) from  (ret_fast_syscall+0x0/0x54)
      
      One way to fix this would be to rework the hairy registration sequence
      in gpiochip_add_data_with_key(), but since I'd probably introduce a
      couple of new bugs if I attempted that, simply add a check for a
      non-NULL of_xlate function pointer in
      of_gpiochip_match_node_and_xlate().  This works since the driver looking
      for the gpio will simply fail to find the gpio and defer its probe and
      be reprobed when the driver which is registering the gpiochip has fully
      completed its probe.
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      d49b48f0
  3. 29 8月, 2018 4 次提交
  4. 11 8月, 2018 9 次提交
  5. 07 8月, 2018 9 次提交
  6. 04 8月, 2018 1 次提交
    • D
      gpio: tegra: Move driver registration to subsys_init level · 40b25bce
      Dmitry Osipenko 提交于
      There is a bug in regards to deferred probing within the drivers core
      that causes GPIO-driver to suspend after its users. The bug appears if
      GPIO-driver probe is getting deferred, which happens after introducing
      dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges"
      property in device-tree. The bug in the drivers core is old (more than 4
      years now) and is well known, unfortunately there is no easy fix for it.
      The good news is that we can workaround the deferred probe issue by
      changing GPIO / PINCTRL drivers registration order and hence by moving
      PINCTRL driver registration to the arch_init level and GPIO to the
      subsys_init.
      Signed-off-by: NDmitry Osipenko <digetx@gmail.com>
      Acked-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      40b25bce
  7. 03 8月, 2018 1 次提交
  8. 01 8月, 2018 1 次提交
    • B
      gpiolib-acpi: make sure we trigger edge events at least once on boot · ca876c74
      Benjamin Tissoires 提交于
      On some systems using edge triggered ACPI Event Interrupts, the initial
      state at boot is not setup by the firmware, instead relying on the edge
      irq event handler running at least once to setup the initial state.
      
      2 known examples of this are:
      
      1) The Surface 3 has its _LID state controlled by an ACPI operation region
       triggered by a GPIO event:
      
       OperationRegion (GPOR, GeneralPurposeIo, Zero, One)
       Field (GPOR, ByteAcc, NoLock, Preserve)
       {
           Connection (
               GpioIo (Shared, PullNone, 0x0000, 0x0000, IoRestrictionNone,
                   "\\_SB.GPO0", 0x00, ResourceConsumer, ,
                   )
                   {   // Pin list
                       0x004C
                   }
           ),
           HELD,   1
       }
      
       Method (_E4C, 0, Serialized)  // _Exx: Edge-Triggered GPE
       {
           If ((HELD == One))
           {
               ^^LID.LIDB = One
           }
           Else
           {
               ^^LID.LIDB = Zero
               Notify (LID, 0x80) // Status Change
           }
      
           Notify (^^PCI0.SPI1.NTRG, One) // Device Check
       }
      
       Currently, the state of LIDB is wrong until the user actually closes or
       open the cover. We need to trigger the GPIO event once to update the
       internal ACPI state.
      
       Coincidentally, this also enables the Surface 2 integrated HID sensor hub
       which also requires an ACPI gpio operation region to start initialization.
      
      2) Various Bay Trail based tablets come with an external USB mux and
       TI T1210B USB phy to enable USB gadget mode. The mux is controlled by a
       GPIO which is controlled by an edge triggered ACPI Event Interrupt which
       monitors the micro-USB ID pin.
      
       When the tablet is connected to a PC (or no cable is plugged in), the ID
       pin is high and the tablet should be in gadget mode. But the GPIO
       controlling the mux is initialized by the firmware so that the USB data
       lines are muxed to the host controller.
      
       This means that if the user wants to use gadget mode, the user needs to
       first plug in a host-cable to force the ID pin low and then unplug it
       and connect the tablet to a PC, to get the ACPI event handler to run and
       switch the mux to device mode,
      
      This commit fixes both by running the event-handler once on boot.
      
      Note that the running of the event-handler is done from a late_initcall,
      this is done because the handler AML code may rely on OperationRegions
      registered by other builtin drivers. This avoids errors like these:
      
      [    0.133026] ACPI Error: No handler for Region [XSCG] ((____ptrval____)) [GenericSerialBus] (20180531/evregion-132)
      [    0.133036] ACPI Error: Region GenericSerialBus (ID=9) has no handler (20180531/exfldio-265)
      [    0.133046] ACPI Error: Method parse/execution failed \_SB.GPO2._E12, AE_NOT_EXIST (20180531/psparse-516)
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      [hdegoede: Document BYT USB mux reliance on initial trigger]
      [hdegoede: Run event handler from a late_initcall, rather then immediately]
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ca876c74
  9. 30 7月, 2018 10 次提交
  10. 24 7月, 2018 2 次提交
  11. 23 7月, 2018 1 次提交