1. 30 12月, 2022 1 次提交
    • H
      gpiolib: Fix using uninitialized lookup-flags on ACPI platforms · ba2dc1cb
      Hans de Goede 提交于
      Commit 8eb1f71e ("gpiolib: consolidate GPIO lookups") refactors
      fwnode_get_named_gpiod() and gpiod_get_index() into a unified
      gpiod_find_and_request() helper.
      
      The old functions both initialized their local lookupflags variable to
      GPIO_LOOKUP_FLAGS_DEFAULT, but the new code leaves it uninitialized.
      
      This is a problem for at least ACPI platforms, where acpi_find_gpio()
      only does a bunch of *lookupflags |= GPIO_* statements and thus relies
      on the variable being initialized.
      
      The variable not being initialized leads to:
      
      1. Potentially the wrong flags getting used
      2. The check for conflicting lookup flags in gpiod_configure_flags():
         "multiple pull-up, pull-down or pull-disable enabled, invalid config"
         sometimes triggering, making the GPIO unavailable
      
      Restore the initialization of lookupflags to GPIO_LOOKUP_FLAGS_DEFAULT
      to fix this.
      
      Fixes: 8eb1f71e ("gpiolib: consolidate GPIO lookups")
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      ba2dc1cb
  2. 07 12月, 2022 1 次提交
  3. 29 11月, 2022 2 次提交
  4. 28 11月, 2022 1 次提交
    • Z
      gpiolib: fix memory leak in gpiochip_setup_dev() · ec851b23
      Zeng Heng 提交于
      Here is a backtrace report about memory leak detected in
      gpiochip_setup_dev():
      
      unreferenced object 0xffff88810b406400 (size 512):
        comm "python3", pid 1682, jiffies 4295346908 (age 24.090s)
        backtrace:
          kmalloc_trace
          device_add		device_private_init at drivers/base/core.c:3361
      			(inlined by) device_add at drivers/base/core.c:3411
          cdev_device_add
          gpiolib_cdev_register
          gpiochip_setup_dev
          gpiochip_add_data_with_key
      
      gcdev_register() & gcdev_unregister() would call device_add() &
      device_del() (no matter CONFIG_GPIO_CDEV is enabled or not) to
      register/unregister device.
      
      However, if device_add() succeeds, some resource (like
      struct device_private allocated by device_private_init())
      is not released by device_del().
      
      Therefore, after device_add() succeeds by gcdev_register(), it
      needs to call put_device() to release resource in the error handle
      path.
      
      Here we move forward the register of release function, and let it
      release every piece of resource by put_device() instead of kfree().
      
      While at it, fix another subtle issue, i.e. when gc->ngpio is equal
      to 0, we still call kcalloc() and, in case of further error, kfree()
      on the ZERO_PTR pointer, which is not NULL. It's not a bug per se,
      but rather waste of the resources and potentially wrong expectation
      about contents of the gdev->descs variable.
      
      Fixes: 159f3cd9 ("gpiolib: Defer gpio device setup until after gpiolib initialization")
      Signed-off-by: NZeng Heng <zengheng4@huawei.com>
      Co-developed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      ec851b23
  5. 16 11月, 2022 1 次提交
    • B
      gpiolib: ensure that fwnode is properly set · 24c94060
      Brian Masney 提交于
      Note that this is a RFC patch and not meant to be merged. I looked into
      a problem with linux-next-20221110 on the Qualcomm SA8540P automotive
      board (sc8280xp) where the UFS host controller would fail to probe due
      to repeated probe deferrals when trying to get reset-gpios via
      devm_gpiod_get_optional().
      
      of_get_named_gpiod_flags() returns -EPROBE_DEFER, which is caused by
      of_gpiochip_match_node_and_xlate() returning 0 since the of_xlate function
      pointer is not set for the qcom,sc8280xp-tlmm pinctrl driver. The
      pinctrl driver doesn't define one, so of_gpiochip_add() should
      automatically setup of_gpio_simple_xlate() on it's behalf. This doesn't
      happen since the fwnode member on the struct gpiochip is set to null
      when of_gpiochip_add() is called. Let's work around this by ensuring
      that it's set if available.
      
      Note that this broke sometime within the last few weeks within
      linux-next and I haven't bisected this. I'm posting this in the hopes
      that someone may know offhand which patch(es) may have broken this.
      Signed-off-by: NBrian Masney <bmasney@redhat.com>
      Tested-by: NMarijn Suijten <marijn.suijten@somainline.org>
      Tested-by: NKonrad Dybcio <konrad.dybcio@linaro.org>
      Tested-by: Steev Klimaszewski <steev@kali.org> #Lenovo Thinkpad X13s
      Tested-by: NNeil Armstrong <neil.armstrong@linaro.org>
      Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      24c94060
  6. 15 11月, 2022 5 次提交
  7. 09 11月, 2022 1 次提交
  8. 17 10月, 2022 2 次提交
  9. 05 9月, 2022 1 次提交
  10. 19 7月, 2022 1 次提交
  11. 10 7月, 2022 2 次提交
  12. 04 5月, 2022 1 次提交
  13. 23 4月, 2022 1 次提交
  14. 19 4月, 2022 2 次提交
  15. 10 4月, 2022 5 次提交
  16. 05 4月, 2022 1 次提交
  17. 04 4月, 2022 1 次提交
  18. 16 3月, 2022 1 次提交
  19. 08 3月, 2022 1 次提交
  20. 07 3月, 2022 2 次提交
  21. 24 2月, 2022 1 次提交
    • S
      gpio: Return EPROBE_DEFER if gc->to_irq is NULL · ae42f928
      Shreeya Patel 提交于
      We are racing the registering of .to_irq when probing the
      i2c driver. This results in random failure of touchscreen
      devices.
      
      Following explains the race condition better.
      
      [gpio driver] gpio driver registers gpio chip
      [gpio consumer] gpio is acquired
      [gpio consumer] gpiod_to_irq() fails with -ENXIO
      [gpio driver] gpio driver registers irqchip
      gpiod_to_irq works at this point, but -ENXIO is fatal
      
      We could see the following errors in dmesg logs when gc->to_irq is NULL
      
      [2.101857] i2c_hid i2c-FTS3528:00: HID over i2c has not been provided an Int IRQ
      [2.101953] i2c_hid: probe of i2c-FTS3528:00 failed with error -22
      
      To avoid this situation, defer probing until to_irq is registered.
      Returning -EPROBE_DEFER would be the first step towards avoiding
      the failure of devices due to the race in registration of .to_irq.
      Final solution to this issue would be to avoid using gc irq members
      until they are fully initialized.
      
      This issue has been reported many times in past and people have been
      using workarounds like changing the pinctrl_amd to built-in instead
      of loading it as a module or by adding a softdep for pinctrl_amd into
      the config file.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209413Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NShreeya Patel <shreeya.patel@collabora.com>
      Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
      ae42f928
  22. 08 2月, 2022 3 次提交
  23. 17 12月, 2021 3 次提交