1. 07 4月, 2017 1 次提交
    • T
      pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable() · 61187142
      Tony Lindgren 提交于
      Recent pinctrl changes to allow dynamic allocation of pins exposed one
      more issue with the pinctrl pins claimed early by the controller itself.
      This caused a regression for IMX6 pinctrl hogs.
      
      Before enabling the pin controller driver we need to wait until it has
      been properly initialized, then claim the hogs, and only then enable it.
      
      To fix the regression, split the code into pinctrl_claim_hogs() and
      pinctrl_enable(). And then let's require that pinctrl_enable() is always
      called by the pin controller driver when ready after calling
      pinctrl_register_and_init().
      
      Depends-on: 950b0d91 ("pinctrl: core: Fix regression caused by delayed
      work for hogs")
      Fixes: df61b366af26 ("pinctrl: core: Use delayed work for hogs")
      Fixes: e566fc11 ("pinctrl: imx: use generic pinctrl helpers for
      managing groups")
      Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Mika Penttilä <mika.penttila@nextfour.com>
      Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
      Cc: Nishanth Menon <nm@ti.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Stefan Agner <stefan@agner.ch>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: NGary Bisson <gary.bisson@boundarydevices.com>
      Tested-by: NFabio Estevam <fabio.estevam@nxp.com>
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      61187142
  2. 26 1月, 2017 1 次提交
  3. 13 1月, 2017 2 次提交
    • T
      pinctrl: Initialize pinctrl_dev.node · 46daed6e
      Thierry Reding 提交于
      The struct pinctrl_dev's node field is not properly set up, which means
      the .prev and .next fields will be NULL. That's not something that the
      linked list code can deal with, so extra care must be taken when using
      these fields. An example of this is introduced in commit 3429fb3c
      ("pinctrl: Fix panic when pinctrl devices with hogs are unregistered")
      where list_del() is made conditional on the pinctrl device being part
      of the pinctrl device list. This is to ensure that list_del() won't
      crash upon encountering a NULL pointer in .prev and/or .next.
      
      After initializing the list head there's no need to jump through these
      extra hoops and list_del() will work unconditionally. This is because
      the initialized list head points to itself and therefore the .prev and
      .next fields can be properly dereferenced.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Acked-by: NJon Hunter <jonathanh@nvidia.com>
      Tested-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      46daed6e
    • T
      pinctrl: core: Fix regression caused by delayed work for hogs · 950b0d91
      Tony Lindgren 提交于
      Commit df61b366af26 ("pinctrl: core: Use delayed work for hogs") caused a
      regression at least with sh-pfc that is also a GPIO controller as
      noted by Geert Uytterhoeven <geert@linux-m68k.org>.
      
      As the original pinctrl_register() has issues calling pin controller
      driver functions early before the controller has finished registering,
      we can't just revert commit df61b366af26. That would break the drivers
      using GENERIC_PINCTRL_GROUPS or GENERIC_PINMUX_FUNCTIONS.
      
      So let's fix the issue with the following steps as a single patch:
      
      1. Revert the late_init parts of commit df61b366af26.
      
         The late_init clearly won't work and we have to just give up
         on fixing pinctrl_register() for GENERIC_PINCTRL_GROUPS and
         GENERIC_PINMUX_FUNCTIONS.
      
      2. Split pinctrl_register() into two parts
      
         By splitting pinctrl_register() into pinctrl_init_controller()
         and pinctrl_create_and_start() we have better control over when
         it's safe to call pinctrl_create().
      
      3. Introduce a new pinctrl_register_and_init() function
      
         As suggested by Linus Walleij <linus.walleij@linaro.org>, we
         can just introduce a new function for the controllers that need
         pinctrl_create() called later.
      
      4. Convert the four known problem cases to use new function
      
         Let's convert pinctrl-imx, pinctrl-single, sh-pfc and ti-iodelay
         to use the new function to fix the issues. The rest of the drivers
         can be converted later. Let's also update Documentation/pinctrl.txt
         accordingly because of the known issues with pinctrl_register().
      
      Fixes: df61b366af26 ("pinctrl: core: Use delayed work for hogs")
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gary Bisson <gary.bisson@boundarydevices.com>
      Signed-off-by: NTony Lindgren <tony@atomide.com>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      950b0d91
  4. 11 1月, 2017 1 次提交
  5. 10 1月, 2017 1 次提交
  6. 06 1月, 2017 1 次提交
    • J
      pinctrl: Fix panic when pinctrl devices with hogs are unregistered · 3429fb3c
      Jon Hunter 提交于
      Commit df61b366af26 ('pinctrl: core: Use delayed work for hogs')
      deferred part of the registration for pinctrl devices if the pinctrl
      device has hogs. This introduced a window where if the pinctrl device
      with hogs was sucessfully registered, but then unregistered again
      (which could be caused by parent device being probe deferred) before
      the delayed work has chanced to run, then this will cause a kernel
      panic to occur because:
      
      1. The 'pctldev->p' has not yet been initialised and when unregistering
         the pinctrl device we only check to see if it is an error value, but
         now it could also be NULL.
      2. The pinctrl device may not have been added to the 'pinctrldev_list'
         list and we don't check to see if it was added before removing.
      
      Fix up the above by checking to see if the 'pctldev->p' pointer is an
      error value or NULL before putting the pinctrl device and verifying
      that the pinctrl device is present in 'pinctrldev_list' before removing.
      
      Fixes: df61b366af26 ('pinctrl: core: Use delayed work for hogs')
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      3429fb3c
  7. 03 1月, 2017 5 次提交
  8. 31 5月, 2016 2 次提交
  9. 21 4月, 2016 2 次提交
  10. 07 3月, 2016 1 次提交
  11. 27 10月, 2015 1 次提交
    • D
      drivers/pinctrl: Add the concept of an "init" state · ef0eebc0
      Douglas Anderson 提交于
      For pinctrl the "default" state is applied to pins before the driver's
      probe function is called.  This is normally a sensible thing to do,
      but in some cases can cause problems.  That's because the pins will
      change state before the driver is given a chance to program how those
      pins should behave.
      
      As an example you might have a regulator that is controlled by a PWM
      (output high = high voltage, output low = low voltage).  The firmware
      might leave this pin as driven high.  If we allow the driver core to
      reconfigure this pin as a PWM pin before the PWM's probe function runs
      then you might end up running at too low of a voltage while we probe.
      
      Let's introudce a new "init" state.  If this is defined we'll set
      pinctrl to this state before probe and then "default" after probe
      (unless the driver explicitly changed states already).
      
      An alternative idea that was thought of was to use the pre-existing
      "sleep" or "idle" states and add a boolean property that we should
      start in that mode.  This was not done because the "init" state is
      needed for correctness and those other states are only present (and
      only transitioned in to and out of) when (optional) power management
      is enabled.
      
      Changes in v3:
      - Moved declarations to pinctrl/devinfo.h
      - Fixed author/SoB
      
      Changes in v2:
      - Added comment to pinctrl_init_done() as per Linus W.
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: NCaesar Wang <wxt@rock-chips.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ef0eebc0
  12. 14 9月, 2015 1 次提交
  13. 27 7月, 2015 1 次提交
  14. 10 6月, 2015 1 次提交
  15. 02 6月, 2015 1 次提交
  16. 12 5月, 2015 1 次提交
  17. 06 5月, 2015 1 次提交
    • D
      pinctrl: Don't just pretend to protect pinctrl_maps, do it for real · c5272a28
      Doug Anderson 提交于
      Way back, when the world was a simpler place and there was no war, no
      evil, and no kernel bugs, there was just a single pinctrl lock.  That
      was how the world was when (57291ce2 pinctrl: core device tree mapping
      table parsing support) was written.  In that case, there were
      instances where the pinctrl mutex was already held when
      pinctrl_register_map() was called, hence a "locked" parameter was
      passed to the function to indicate that the mutex was already locked
      (so we shouldn't lock it again).
      
      A few years ago in (42fed7ba pinctrl: move subsystem mutex to
      pinctrl_dev struct), we switched to a separate pinctrl_maps_mutex.
      ...but (oops) we forgot to re-think about the whole "locked" parameter
      for pinctrl_register_map().  Basically the "locked" parameter appears
      to still refer to whether the bigger pinctrl_dev mutex is locked, but
      we're using it to skip locks of our (now separate) pinctrl_maps_mutex.
      
      That's kind of a bad thing(TM).  Probably nobody noticed because most
      of the calls to pinctrl_register_map happen at boot time and we've got
      synchronous device probing.  ...and even cases where we're
      asynchronous don't end up actually hitting the race too often.  ...but
      after banging my head against the wall for a bug that reproduced 1 out
      of 1000 reboots and lots of looking through kgdb, I finally noticed
      this.
      
      Anyway, we can now safely remove the "locked" parameter and go back to
      a war-free, evil-free, and kernel-bug-free world.
      
      Fixes: 42fed7ba ("pinctrl: move subsystem mutex to pinctrl_dev struct")
      Signed-off-by: NDoug Anderson <dianders@chromium.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      c5272a28
  18. 14 1月, 2015 1 次提交
    • J
      pinctrl: Fix two deadlocks · db93facf
      Jim Lin 提交于
      This patch is to fix two deadlock cases.
      Deadlock 1:
      CPU #1
       pinctrl_register-> pinctrl_get ->
       create_pinctrl
       (Holding lock pinctrl_maps_mutex)
       -> get_pinctrl_dev_from_devname
       (Trying to acquire lock pinctrldev_list_mutex)
      CPU #0
       pinctrl_unregister
       (Holding lock pinctrldev_list_mutex)
       -> pinctrl_put ->> pinctrl_free ->
       pinctrl_dt_free_maps -> pinctrl_unregister_map
       (Trying to acquire lock pinctrl_maps_mutex)
      
      Simply to say
      CPU#1 is holding lock A and trying to acquire lock B,
      CPU#0 is holding lock B and trying to acquire lock A.
      
      Deadlock 2:
      CPU #3
       pinctrl_register-> pinctrl_get ->
       create_pinctrl
       (Holding lock pinctrl_maps_mutex)
       -> get_pinctrl_dev_from_devname
       (Trying to acquire lock pinctrldev_list_mutex)
      CPU #2
       pinctrl_unregister
       (Holding lock pctldev->mutex)
       -> pinctrl_put ->> pinctrl_free ->
       pinctrl_dt_free_maps -> pinctrl_unregister_map
       (Trying to acquire lock pinctrl_maps_mutex)
      CPU #0
       tegra_gpio_request
       (Holding lock pinctrldev_list_mutex)
       -> pinctrl_get_device_gpio_range
       (Trying to acquire lock pctldev->mutex)
      
      Simply to say
      CPU#3 is holding lock A and trying to acquire lock D,
      CPU#2 is holding lock B and trying to acquire lock A,
      CPU#0 is holding lock D and trying to acquire lock B.
      
      Cc: Stable <stable@vger.kernel.org>
      Signed-off-by: NJim Lin <jilin@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      db93facf
  19. 11 7月, 2014 1 次提交
    • F
      pinctrl: avoid duplicated calling enable_pinmux_setting for a pin · 2243a87d
      Fan Wu 提交于
      What the patch does:
      1. Call pinmux_disable_setting ahead of pinmux_enable_setting
        each time pinctrl_select_state is called
      2. Remove the HW disable operation in pinmux_disable_setting function.
      3. Remove the disable ops in struct pinmux_ops
      4. Remove all the disable ops users in current code base.
      
      Notes:
      1. Great thanks for the suggestion from Linus, Tony Lindgren and
         Stephen Warren and Everyone that shared comments on this patch.
      2. The patch also includes comment fixes from Stephen Warren.
      
      The reason why we do this:
      1. To avoid duplicated calling of the enable_setting operation
         without disabling operation inbetween which will let the pin
         descriptor desc->mux_usecount increase monotonously.
      2. The HW pin disable operation is not useful for any of the
         existing platforms.
         And this can be used to avoid the HW glitch after using the
         item #1 modification.
      
      In the following case, the issue can be reproduced:
      1. There is a driver that need to switch pin state dynamically,
         e.g. between "sleep" and "default" state
      2. The pin setting configuration in a DTS node may be like this:
      
        component a {
      	pinctrl-names = "default", "sleep";
      	pinctrl-0 = <&a_grp_setting &c_grp_setting>;
      	pinctrl-1 = <&b_grp_setting &c_grp_setting>;
        }
      
        The "c_grp_setting" config node is totally identical, maybe like
        following one:
      
        c_grp_setting: c_grp_setting {
      	pinctrl-single,pins = <GPIO48 AF6>;
        }
      
      3. When switching the pin state in the following official pinctrl
         sequence:
      	pin = pinctrl_get();
      	state = pinctrl_lookup_state(wanted_state);
      	pinctrl_select_state(state);
      	pinctrl_put();
      
      Test Result:
      1. The switch is completed as expected, that is: the device's
         pin configuration is changed according to the description in the
         "wanted_state" group setting
      2. The "desc->mux_usecount" of the corresponding pins in "c_group"
         is increased without being decreased, because the "desc" is for
         each physical pin while the setting is for each setting node
         in the DTS.
         Thus, if the "c_grp_setting" in pinctrl-0 is not disabled ahead
         of enabling "c_grp_setting" in pinctrl-1, the desc->mux_usecount
         will keep increasing without any chance to be decreased.
      
      According to the comments in the original code, only the setting,
      in old state but not in new state, will be "disabled" (calling
      pinmux_disable_setting), which is correct logic but not intact. We
      still need consider case that the setting is in both old state
      and new state. We can do this in the following two ways:
      
      1. Avoid to "enable"(calling pinmux_enable_setting) the "same pin
         setting" repeatedly
      2. "Disable"(calling pinmux_disable_setting) the "same pin setting",
         actually two setting instances, ahead of enabling them.
      
      Analysis:
      1. The solution #2 is better because it can avoid too much
         iteration.
      2. If we disable all of the settings in the old state and one of
         the setting(s) exist in the new state, the pins mux function
         change may happen when some SoC vendors defined the
         "pinctrl-single,function-off"
         in their DTS file.
         old_setting => disabled_setting => new_setting.
      3. In the pinmux framework, when a pin state is switched, the
         setting in the old state should be marked as "disabled".
      
      Conclusion:
      1. To Remove the HW disabling operation to above the glitch mentioned
         above.
      2. Handle the issue mentioned above by disabling all of the settings
         in old state and then enable the all of the settings in new state.
      Signed-off-by: NFan Wu <fwu@marvell.com>
      Acked-by: NStephen Warren <swarren@nvidia.com>
      Acked-by: NPatrice Chotard <patrice.chotard@st.com>
      Acked-by: NHeiko Stuebner <heiko@sntech.de>
      Acked-by: NMaxime Coquelin <maxime.coquelin@st.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      2243a87d
  20. 22 4月, 2014 1 次提交
    • A
      pinctrl: allows not to define the get_group_pins operation · e5b3b2d9
      Antoine Ténart 提交于
      When using a group only pinctrl driver, which does not have any
      information on the pins it is useless to define a get_group_pins
      always returning an empty list of pins.
      
      When not using get_group_pin[1], a driver must implement it so
      pins = NULL and num_pins = 0. This patch makes it the default
      behaviour if not defined in the pinctrl driver when used in
      pinmux enable and disable funtions and in pinctrl_groups_show.
      
      It also adds a check in pinctrl_get_group_pins and return -EINVAL if
      not defined. This function is called in the gpiolib when adding when
      pingroup range. It cannot be used if no group is defined, so this seams
      reasonable.
      
      [1] get_group_pin(struct pinctrl_dev *pctldev,
      		  unsigned selector,
      		  const unsigned **pins,
      		  unsigned *num_pins);
      Signed-off-by: NAntoine Ténart <antoine.tenart@free-electrons.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      e5b3b2d9
  21. 06 2月, 2014 1 次提交
  22. 05 2月, 2014 1 次提交
  23. 16 10月, 2013 1 次提交
  24. 28 8月, 2013 1 次提交
  25. 23 8月, 2013 3 次提交
  26. 25 7月, 2013 1 次提交
  27. 23 7月, 2013 1 次提交
  28. 18 6月, 2013 4 次提交