1. 21 4月, 2016 1 次提交
  2. 07 3月, 2016 1 次提交
  3. 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
  4. 14 9月, 2015 1 次提交
  5. 27 7月, 2015 1 次提交
  6. 10 6月, 2015 1 次提交
  7. 02 6月, 2015 1 次提交
  8. 12 5月, 2015 1 次提交
  9. 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
  10. 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
  11. 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
  12. 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
  13. 06 2月, 2014 1 次提交
  14. 05 2月, 2014 1 次提交
  15. 16 10月, 2013 1 次提交
  16. 28 8月, 2013 1 次提交
  17. 23 8月, 2013 3 次提交
  18. 25 7月, 2013 1 次提交
  19. 23 7月, 2013 1 次提交
  20. 18 6月, 2013 4 次提交
  21. 16 6月, 2013 2 次提交
  22. 30 4月, 2013 1 次提交
  23. 26 4月, 2013 1 次提交
    • P
      pinctrl: move subsystem mutex to pinctrl_dev struct · 42fed7ba
      Patrice Chotard 提交于
      This mutex avoids deadlock in case of use of multiple pin
      controllers. Before this modification, by using a global
      mutex, deadlock appeared when, for example, a call to
      pinctrl_pins_show() locked the pinctrl_mutex, called the
      ops->pin_dbg_show of a particular pin controller. If this
      pin controller needs I2C access to retrieve configuration
      information and I2C driver is using pinctrl to drive its
      pins, a call to pinctrl_select_state() try to lock again
      pinctrl_mutex which leads to a deadlock.
      
      Notice that the mutex grab from the two direction functions
      was moved into pinctrl_gpio_direction().
      
      For several cases, we can't replace pinctrl_mutex by
      pctldev->mutex, because at this stage, pctldev is
      not accessible :
      	- pinctrl_get()/pinctrl_put()
      	- pinctrl_register_maps()
      
      So add respectively pinctrl_list_mutex and
      pinctrl_maps_mutex in order to protect
      pinctrl_list and pinctrl_maps list instead.
      
      Reintroduce pinctrldev_list_mutex in
      find_pinctrl_by_of_node(),
      pinctrl_find_and_add_gpio_range()
      pinctrl_request_gpio(), pinctrl_free_gpio(),
      pinctrl_gpio_direction(), pinctrl_devices_show(),
      pinctrl_register() and pinctrl_unregister() to
      protect pinctrldev_list.
      
      Changes v2->v3:
      - Fix a missing EXPORT_SYMBOL_GPL() for pinctrl_select_state().
      
      Changes v1->v2:
      - pinctrl_select_state_locked() is removed, all lock mechanism
        is located inside pinctrl_select_state(). When parsing
        the state->setting list, take the per-pin-controller driver
        lock. (Patrice).
      - Introduce pinctrldev_list_mutex to protect pinctrldev_list
        in all functions which parse or modify pictrldev_list.
        (Patrice).
      - move find_pinctrl_by_of_node() from pinctrl/devicetree.c to
        pinctrl/core.c in order to protect pinctrldev_list.
        (Patrice).
      - Sink mutex:es into some functions and remove some _locked
        variants down to where the lists are actually accessed to
        make things simpler. (Linus)
      - Drop *all* mutexes completely from pinctrl_lookup_state()
        and pinctrl_select_state() - no relevant mutex was taken
        and it was unclear what this was protecting against. (Linus)
      
      Reported by : Seraphin Bonnaffe <seraphin.bonnaffe@stericsson.com>
      Signed-off-by: NPatrice Chotard <patrice.chotard@st.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      42fed7ba
  24. 03 4月, 2013 6 次提交
  25. 28 3月, 2013 3 次提交
  26. 07 3月, 2013 2 次提交