linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 0/5] pinctrl fixes for generic functions and groups
@ 2018-07-05  9:10 Tony Lindgren
  2018-07-05  9:10 ` [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver Tony Lindgren
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	H. Nikolaus Schaller, Haojian Zhuang, Jacopo Mondi,
	Paul Cercueil, Sean Wang

Here is a resend of fixes for a race issues for generic group and
functions reported by H. Nikolaus Schaller <hns@goldelico.com>.

Regards,

Tony


Changes since v2:

- Added Nikolaus to Cc as Reported-by did not do it

Changes since v1:

- Check if a function or group already exists as suggested by
  Andy Shevchenko

- Make sure we always have a valid name for functions and groups
  as suggested by Christ van Willegen

- Prettify rza1 variables as suggested by Jacopo Mondi

Tony Lindgren (5):
  pinctrl: core: Return selector to the pinctrl driver
  pinctrl: pinmux: Return selector to the pinctrl driver
  pinctrl: single: Fix group and function selector use
  pinctrl: rza1: Fix selector use for groups and functions
  pinctrl: core: Remove broken remove_last group and pinmux functions

 drivers/pinctrl/core.c           | 35 ++++++++++--
 drivers/pinctrl/core.h           |  6 ---
 drivers/pinctrl/pinctrl-rza1.c   | 24 +++++----
 drivers/pinctrl/pinctrl-single.c | 91 +++++++++++++++++++-------------
 drivers/pinctrl/pinmux.c         | 16 ++++--
 drivers/pinctrl/pinmux.h         |  7 ---
 6 files changed, 112 insertions(+), 67 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
@ 2018-07-05  9:10 ` Tony Lindgren
  2018-07-05  9:10 ` [PATCH 2/5] pinctrl: pinmux: " Tony Lindgren
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	Haojian Zhuang, H . Nikolaus Schaller, Jacopo Mondi,
	Paul Cercueil, Sean Wang

We must return the selector from pinctrl_generic_add_group() so
pin controller device drivers can remove the right group if needed
for deferred probe for example. And we now must make sure that a
proper name is passed so we can use it to check if the entry already
exists.

Note that fixes are also needed for the pin controller drivers to
use the selector value.

Fixes: c7059c5ac70a ("pinctrl: core: Add generic pinctrl functions
for managing groups")
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/pinctrl/core.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -616,6 +616,26 @@ struct group_desc *pinctrl_generic_get_group(struct pinctrl_dev *pctldev,
 }
 EXPORT_SYMBOL_GPL(pinctrl_generic_get_group);
 
+static int pinctrl_generic_group_name_to_selector(struct pinctrl_dev *pctldev,
+						  const char *function)
+{
+	const struct pinctrl_ops *ops = pctldev->desc->pctlops;
+	int ngroups = ops->get_groups_count(pctldev);
+	int selector = 0;
+
+	/* See if this pctldev has this group */
+	while (selector < ngroups) {
+		const char *gname = ops->get_group_name(pctldev, selector);
+
+		if (!strcmp(function, gname))
+			return selector;
+
+		selector++;
+	}
+
+	return -EINVAL;
+}
+
 /**
  * pinctrl_generic_add_group() - adds a new pin group
  * @pctldev: pin controller device
@@ -630,6 +650,16 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
 			      int *pins, int num_pins, void *data)
 {
 	struct group_desc *group;
+	int selector;
+
+	if (!name)
+		return -EINVAL;
+
+	selector = pinctrl_generic_group_name_to_selector(pctldev, name);
+	if (selector >= 0)
+		return selector;
+
+	selector = pctldev->num_groups;
 
 	group = devm_kzalloc(pctldev->dev, sizeof(*group), GFP_KERNEL);
 	if (!group)
@@ -640,12 +670,11 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
 	group->num_pins = num_pins;
 	group->data = data;
 
-	radix_tree_insert(&pctldev->pin_group_tree, pctldev->num_groups,
-			  group);
+	radix_tree_insert(&pctldev->pin_group_tree, selector, group);
 
 	pctldev->num_groups++;
 
-	return 0;
+	return selector;
 }
 EXPORT_SYMBOL_GPL(pinctrl_generic_add_group);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/5] pinctrl: pinmux: Return selector to the pinctrl driver
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
  2018-07-05  9:10 ` [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver Tony Lindgren
@ 2018-07-05  9:10 ` Tony Lindgren
  2018-07-05  9:10 ` [PATCH 3/5] pinctrl: single: Fix group and function selector use Tony Lindgren
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	Haojian Zhuang, H . Nikolaus Schaller, Jacopo Mondi,
	Paul Cercueil, Sean Wang

We must return the selector from pinmux_generic_add_function() so
pin controller device drivers can remove the right group if needed
for deferred probe for example. And we now must make sure that a
proper name is passed so we can use it to check if the entry already
exists.

Note that fixes are also needed for the pin controller drivers to
use the selector value.

Fixes: a76edc89b100 ("pinctrl: core: Add generic pinctrl functions for
managing groups")
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/pinctrl/pinmux.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -307,7 +307,6 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
 		selector++;
 	}
 
-	dev_err(pctldev->dev, "function '%s' not supported\n", function);
 	return -EINVAL;
 }
 
@@ -774,6 +773,16 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 				void *data)
 {
 	struct function_desc *function;
+	int selector;
+
+	if (!name)
+		return -EINVAL;
+
+	selector = pinmux_func_name_to_selector(pctldev, name);
+	if (selector >= 0)
+		return selector;
+
+	selector = pctldev->num_functions;
 
 	function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
 	if (!function)
@@ -784,12 +793,11 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 	function->num_group_names = num_groups;
 	function->data = data;
 
-	radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions,
-			  function);
+	radix_tree_insert(&pctldev->pin_function_tree, selector, function);
 
 	pctldev->num_functions++;
 
-	return 0;
+	return selector;
 }
 EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/5] pinctrl: single: Fix group and function selector use
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
  2018-07-05  9:10 ` [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver Tony Lindgren
  2018-07-05  9:10 ` [PATCH 2/5] pinctrl: pinmux: " Tony Lindgren
@ 2018-07-05  9:10 ` Tony Lindgren
  2018-07-05  9:10 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	Haojian Zhuang, H . Nikolaus Schaller, Jacopo Mondi,
	Paul Cercueil, Sean Wang

We must use a mutex around the generic_add functions and save the
function and group selector in case we need to remove them. Otherwise
the selector use will be racy for deferred probe at least.

Note that struct device_node *np is unused in pcs_add_function() we
remove that too and fix a checkpatch warning for bare unsigned while
at it.

Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for
managing functions")
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/pinctrl/pinctrl-single.c | 91 +++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 36 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -747,38 +747,44 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 /**
  * pcs_add_function() - adds a new function to the function list
  * @pcs: pcs driver instance
- * @np: device node of the mux entry
+ * @fcn: new function allocated
  * @name: name of the function
  * @vals: array of mux register value pairs used by the function
  * @nvals: number of mux register value pairs
  * @pgnames: array of pingroup names for the function
  * @npgnames: number of pingroup names
+ *
+ * Caller must take care of locking.
  */
-static struct pcs_function *pcs_add_function(struct pcs_device *pcs,
-					struct device_node *np,
-					const char *name,
-					struct pcs_func_vals *vals,
-					unsigned nvals,
-					const char **pgnames,
-					unsigned npgnames)
+static int pcs_add_function(struct pcs_device *pcs,
+			    struct pcs_function **fcn,
+			    const char *name,
+			    struct pcs_func_vals *vals,
+			    unsigned int nvals,
+			    const char **pgnames,
+			    unsigned int npgnames)
 {
 	struct pcs_function *function;
-	int res;
+	int selector;
 
 	function = devm_kzalloc(pcs->dev, sizeof(*function), GFP_KERNEL);
 	if (!function)
-		return NULL;
+		return -ENOMEM;
 
 	function->vals = vals;
 	function->nvals = nvals;
 
-	res = pinmux_generic_add_function(pcs->pctl, name,
-					  pgnames, npgnames,
-					  function);
-	if (res)
-		return NULL;
+	selector = pinmux_generic_add_function(pcs->pctl, name,
+					       pgnames, npgnames,
+					       function);
+	if (selector < 0) {
+		devm_kfree(pcs->dev, function);
+		*fcn = NULL;
+	} else {
+		*fcn = function;
+	}
 
-	return function;
+	return selector;
 }
 
 /**
@@ -979,8 +985,8 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
 {
 	const char *name = "pinctrl-single,pins";
 	struct pcs_func_vals *vals;
-	int rows, *pins, found = 0, res = -ENOMEM, i;
-	struct pcs_function *function;
+	int rows, *pins, found = 0, res = -ENOMEM, i, fsel, gsel;
+	struct pcs_function *function = NULL;
 
 	rows = pinctrl_count_index_with_args(np, name);
 	if (rows <= 0) {
@@ -1030,21 +1036,25 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
 	}
 
 	pgnames[0] = np->name;
-	function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1);
-	if (!function) {
-		res = -ENOMEM;
+	mutex_lock(&pcs->mutex);
+	fsel = pcs_add_function(pcs, &function, np->name, vals, found,
+				pgnames, 1);
+	if (fsel < 0) {
+		res = fsel;
 		goto free_pins;
 	}
 
-	res = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
-	if (res < 0)
+	gsel = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
+	if (gsel < 0) {
+		res = gsel;
 		goto free_function;
+	}
 
 	(*map)->type = PIN_MAP_TYPE_MUX_GROUP;
 	(*map)->data.mux.group = np->name;
 	(*map)->data.mux.function = np->name;
 
-	if (PCS_HAS_PINCONF) {
+	if (PCS_HAS_PINCONF && function) {
 		res = pcs_parse_pinconf(pcs, np, function, map);
 		if (res)
 			goto free_pingroups;
@@ -1052,14 +1062,16 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
 	} else {
 		*num_maps = 1;
 	}
+	mutex_unlock(&pcs->mutex);
+
 	return 0;
 
 free_pingroups:
-	pinctrl_generic_remove_last_group(pcs->pctl);
+	pinctrl_generic_remove_group(pcs->pctl, gsel);
 	*num_maps = 1;
 free_function:
-	pinmux_generic_remove_last_function(pcs->pctl);
-
+	pinmux_generic_remove_function(pcs->pctl, fsel);
+	mutex_unlock(&pcs->mutex);
 free_pins:
 	devm_kfree(pcs->dev, pins);
 
@@ -1077,9 +1089,9 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 {
 	const char *name = "pinctrl-single,bits";
 	struct pcs_func_vals *vals;
-	int rows, *pins, found = 0, res = -ENOMEM, i;
+	int rows, *pins, found = 0, res = -ENOMEM, i, fsel, gsel;
 	int npins_in_row;
-	struct pcs_function *function;
+	struct pcs_function *function = NULL;
 
 	rows = pinctrl_count_index_with_args(np, name);
 	if (rows <= 0) {
@@ -1166,15 +1178,19 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	}
 
 	pgnames[0] = np->name;
-	function = pcs_add_function(pcs, np, np->name, vals, found, pgnames, 1);
-	if (!function) {
-		res = -ENOMEM;
+	mutex_lock(&pcs->mutex);
+	fsel = pcs_add_function(pcs, &function, np->name, vals, found,
+				pgnames, 1);
+	if (fsel < 0) {
+		res = fsel;
 		goto free_pins;
 	}
 
-	res = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
-	if (res < 0)
+	gsel = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
+	if (gsel < 0) {
+		res = gsel;
 		goto free_function;
+	}
 
 	(*map)->type = PIN_MAP_TYPE_MUX_GROUP;
 	(*map)->data.mux.group = np->name;
@@ -1186,13 +1202,16 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	}
 
 	*num_maps = 1;
+	mutex_unlock(&pcs->mutex);
+
 	return 0;
 
 free_pingroups:
-	pinctrl_generic_remove_last_group(pcs->pctl);
+	pinctrl_generic_remove_group(pcs->pctl, gsel);
 	*num_maps = 1;
 free_function:
-	pinmux_generic_remove_last_function(pcs->pctl);
+	pinmux_generic_remove_function(pcs->pctl, fsel);
+	mutex_unlock(&pcs->mutex);
 free_pins:
 	devm_kfree(pcs->dev, pins);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
                   ` (2 preceding siblings ...)
  2018-07-05  9:10 ` [PATCH 3/5] pinctrl: single: Fix group and function selector use Tony Lindgren
@ 2018-07-05  9:10 ` Tony Lindgren
  2018-07-05  9:10 ` [PATCH 5/5] pinctrl: core: Remove broken remove_last group and pinmux functions Tony Lindgren
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	Haojian Zhuang, H . Nikolaus Schaller, Paul Cercueil, Sean Wang,
	Jacopo Mondi

We must use a mutex around the generic_add functions and save the
function and group selector in case we need to remove them. Otherwise
the selector use will be racy for deferred probe at least.

Fixes: 5a49b644b307 ("pinctrl: Renesas RZ/A1 pin and gpio controller")
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/pinctrl/pinctrl-rza1.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rza1.c b/drivers/pinctrl/pinctrl-rza1.c
--- a/drivers/pinctrl/pinctrl-rza1.c
+++ b/drivers/pinctrl/pinctrl-rza1.c
@@ -1006,6 +1006,7 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const char *grpname;
 	const char **fngrps;
 	int ret, npins;
+	int gsel, fsel;
 
 	npins = rza1_dt_node_pin_count(np);
 	if (npins < 0) {
@@ -1055,18 +1056,19 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	fngrps[0] = grpname;
 
 	mutex_lock(&rza1_pctl->mutex);
-	ret = pinctrl_generic_add_group(pctldev, grpname, grpins, npins,
-					NULL);
-	if (ret) {
+	gsel = pinctrl_generic_add_group(pctldev, grpname, grpins, npins,
+					 NULL);
+	if (gsel < 0) {
 		mutex_unlock(&rza1_pctl->mutex);
-		return ret;
+		return gsel;
 	}
 
-	ret = pinmux_generic_add_function(pctldev, grpname, fngrps, 1,
-					  mux_confs);
-	if (ret)
+	fsel = pinmux_generic_add_function(pctldev, grpname, fngrps, 1,
+					   mux_confs);
+	if (fsel < 0) {
+		ret = fsel;
 		goto remove_group;
-	mutex_unlock(&rza1_pctl->mutex);
+	}
 
 	dev_info(rza1_pctl->dev, "Parsed function and group %s with %d pins\n",
 				 grpname, npins);
@@ -1083,15 +1085,15 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	(*map)->data.mux.group = np->name;
 	(*map)->data.mux.function = np->name;
 	*num_maps = 1;
+	mutex_unlock(&rza1_pctl->mutex);
 
 	return 0;
 
 remove_function:
-	mutex_lock(&rza1_pctl->mutex);
-	pinmux_generic_remove_last_function(pctldev);
+	pinmux_generic_remove_function(pctldev, fsel);
 
 remove_group:
-	pinctrl_generic_remove_last_group(pctldev);
+	pinctrl_generic_remove_group(pctldev, gsel);
 	mutex_unlock(&rza1_pctl->mutex);
 
 	dev_info(rza1_pctl->dev, "Unable to parse function and group %s\n",
-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/5] pinctrl: core: Remove broken remove_last group and pinmux functions
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
                   ` (3 preceding siblings ...)
  2018-07-05  9:10 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
@ 2018-07-05  9:10 ` Tony Lindgren
  2018-07-05 13:28 ` [PATCHv3 0/5] pinctrl fixes for generic functions and groups H. Nikolaus Schaller
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-05  9:10 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio, linux-kernel, Andy Shevchenko, Christ van Willegen,
	Haojian Zhuang, H . Nikolaus Schaller, Jacopo Mondi,
	Paul Cercueil, Sean Wang

With no users left for these functions let's remove them.

Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/pinctrl/core.h   | 6 ------
 drivers/pinctrl/pinmux.h | 7 -------
 2 files changed, 13 deletions(-)

diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -218,12 +218,6 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
 int pinctrl_generic_remove_group(struct pinctrl_dev *pctldev,
 				 unsigned int group_selector);
 
-static inline int
-pinctrl_generic_remove_last_group(struct pinctrl_dev *pctldev)
-{
-	return pinctrl_generic_remove_group(pctldev, pctldev->num_groups - 1);
-}
-
 #endif	/* CONFIG_GENERIC_PINCTRL_GROUPS */
 
 struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -150,13 +150,6 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
 int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
 				   unsigned int selector);
 
-static inline int
-pinmux_generic_remove_last_function(struct pinctrl_dev *pctldev)
-{
-	return pinmux_generic_remove_function(pctldev,
-					      pctldev->num_functions - 1);
-}
-
 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
 
 #else
-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv3 0/5] pinctrl fixes for generic functions and groups
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
                   ` (4 preceding siblings ...)
  2018-07-05  9:10 ` [PATCH 5/5] pinctrl: core: Remove broken remove_last group and pinmux functions Tony Lindgren
@ 2018-07-05 13:28 ` H. Nikolaus Schaller
  2018-07-05 13:55 ` Andy Shevchenko
  2018-07-09 12:59 ` Linus Walleij
  7 siblings, 0 replies; 10+ messages in thread
From: H. Nikolaus Schaller @ 2018-07-05 13:28 UTC (permalink / raw)
  To: Tony Lindgren, Linus Walleij
  Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List,
	Andy Shevchenko, Christ van Willegen, Haojian Zhuang,
	Jacopo Mondi, Paul Cercueil, Sean Wang

Hi Tony and Linus,

> Am 05.07.2018 um 11:10 schrieb Tony Lindgren <tony@atomide.com>:
> 
> Here is a resend of fixes for a race issues for generic group and
> functions reported by H. Nikolaus Schaller <hns@goldelico.com>.

Thanks for adding me.

I have tested these patches on our OMAP3 based device where the problem
was quite reproducible and testable by adding some printk. With
these patches it seems now to be correct. Each group selector is
assigned only once, even if driver probing fails and is redone later.

Code review of the call paths has convinced us that we now have
proper mutex around the radix tree function calls and races are
no longer a problem.

So you can add my

	Tested-By: H. Nikolaus Schaller <hns@goldelico.com>

BR and thanks,
Nikolaus

> 
> Regards,
> 
> Tony
> 
> 
> Changes since v2:
> 
> - Added Nikolaus to Cc as Reported-by did not do it
> 
> Changes since v1:
> 
> - Check if a function or group already exists as suggested by
>  Andy Shevchenko
> 
> - Make sure we always have a valid name for functions and groups
>  as suggested by Christ van Willegen
> 
> - Prettify rza1 variables as suggested by Jacopo Mondi
> 
> Tony Lindgren (5):
>  pinctrl: core: Return selector to the pinctrl driver
>  pinctrl: pinmux: Return selector to the pinctrl driver
>  pinctrl: single: Fix group and function selector use
>  pinctrl: rza1: Fix selector use for groups and functions
>  pinctrl: core: Remove broken remove_last group and pinmux functions
> 
> drivers/pinctrl/core.c           | 35 ++++++++++--
> drivers/pinctrl/core.h           |  6 ---
> drivers/pinctrl/pinctrl-rza1.c   | 24 +++++----
> drivers/pinctrl/pinctrl-single.c | 91 +++++++++++++++++++-------------
> drivers/pinctrl/pinmux.c         | 16 ++++--
> drivers/pinctrl/pinmux.h         |  7 ---
> 6 files changed, 112 insertions(+), 67 deletions(-)
> 
> -- 
> 2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv3 0/5] pinctrl fixes for generic functions and groups
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
                   ` (5 preceding siblings ...)
  2018-07-05 13:28 ` [PATCHv3 0/5] pinctrl fixes for generic functions and groups H. Nikolaus Schaller
@ 2018-07-05 13:55 ` Andy Shevchenko
  2018-07-09 12:59 ` Linus Walleij
  7 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2018-07-05 13:55 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Linus Walleij, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Christ van Willegen,
	H. Nikolaus Schaller, Haojian Zhuang, Jacopo Mondi,
	Paul Cercueil, Sean Wang

On Thu, Jul 5, 2018 at 12:10 PM, Tony Lindgren <tony@atomide.com> wrote:
> Here is a resend of fixes for a race issues for generic group and
> functions reported by H. Nikolaus Schaller <hns@goldelico.com>.
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

I think for ACPI case we would use generic helpers, so this change is
quite useful to not screw up with new stuff.

> Regards,
>
> Tony
>
>
> Changes since v2:
>
> - Added Nikolaus to Cc as Reported-by did not do it
>
> Changes since v1:
>
> - Check if a function or group already exists as suggested by
>   Andy Shevchenko
>
> - Make sure we always have a valid name for functions and groups
>   as suggested by Christ van Willegen
>
> - Prettify rza1 variables as suggested by Jacopo Mondi
>
> Tony Lindgren (5):
>   pinctrl: core: Return selector to the pinctrl driver
>   pinctrl: pinmux: Return selector to the pinctrl driver
>   pinctrl: single: Fix group and function selector use
>   pinctrl: rza1: Fix selector use for groups and functions
>   pinctrl: core: Remove broken remove_last group and pinmux functions
>
>  drivers/pinctrl/core.c           | 35 ++++++++++--
>  drivers/pinctrl/core.h           |  6 ---
>  drivers/pinctrl/pinctrl-rza1.c   | 24 +++++----
>  drivers/pinctrl/pinctrl-single.c | 91 +++++++++++++++++++-------------
>  drivers/pinctrl/pinmux.c         | 16 ++++--
>  drivers/pinctrl/pinmux.h         |  7 ---
>  6 files changed, 112 insertions(+), 67 deletions(-)
>
> --
> 2.17.1



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv3 0/5] pinctrl fixes for generic functions and groups
  2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
                   ` (6 preceding siblings ...)
  2018-07-05 13:55 ` Andy Shevchenko
@ 2018-07-09 12:59 ` Linus Walleij
  2018-07-09 13:11   ` Tony Lindgren
  7 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2018-07-09 12:59 UTC (permalink / raw)
  To: ext Tony Lindgren
  Cc: open list:GPIO SUBSYSTEM, linux-kernel, Andy Shevchenko,
	cvwillegen, Dr. H. Nikolaus Schaller, Haojian Zhuang,
	Jacopo Mondi, Paul Cercueil, Sean Wang

On Thu, Jul 5, 2018 at 11:10 AM Tony Lindgren <tony@atomide.com> wrote:

> Here is a resend of fixes for a race issues for generic group and
> functions reported by H. Nikolaus Schaller <hns@goldelico.com>.

I applied these 5 for fixes (no choice I guess) will push them to the
zeroday build for testing and then to next. Added the tags from H.
Nikolaus and Andy on this.

Should this stuff even be tagged for stable? Else I target it
for v4.18.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv3 0/5] pinctrl fixes for generic functions and groups
  2018-07-09 12:59 ` Linus Walleij
@ 2018-07-09 13:11   ` Tony Lindgren
  0 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-07-09 13:11 UTC (permalink / raw)
  To: Linus Walleij
  Cc: open list:GPIO SUBSYSTEM, linux-kernel, Andy Shevchenko,
	cvwillegen, Dr. H. Nikolaus Schaller, Haojian Zhuang,
	Jacopo Mondi, Paul Cercueil, Sean Wang

* Linus Walleij <linus.walleij@linaro.org> [180709 13:02]:
> On Thu, Jul 5, 2018 at 11:10 AM Tony Lindgren <tony@atomide.com> wrote:
> 
> > Here is a resend of fixes for a race issues for generic group and
> > functions reported by H. Nikolaus Schaller <hns@goldelico.com>.
> 
> I applied these 5 for fixes (no choice I guess) will push them to the
> zeroday build for testing and then to next. Added the tags from H.
> Nikolaus and Andy on this.

OK thanks.

> Should this stuff even be tagged for stable? Else I target it
> for v4.18.

Probably should. The fixes tags should do the trick already
hopefully though.

Regards,

Tony

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-09 13:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05  9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
2018-07-05  9:10 ` [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver Tony Lindgren
2018-07-05  9:10 ` [PATCH 2/5] pinctrl: pinmux: " Tony Lindgren
2018-07-05  9:10 ` [PATCH 3/5] pinctrl: single: Fix group and function selector use Tony Lindgren
2018-07-05  9:10 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
2018-07-05  9:10 ` [PATCH 5/5] pinctrl: core: Remove broken remove_last group and pinmux functions Tony Lindgren
2018-07-05 13:28 ` [PATCHv3 0/5] pinctrl fixes for generic functions and groups H. Nikolaus Schaller
2018-07-05 13:55 ` Andy Shevchenko
2018-07-09 12:59 ` Linus Walleij
2018-07-09 13:11   ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).