linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] pinctrl: single: fixes for davinci
@ 2016-11-09 14:53 Axel Haslam
  2016-11-09 14:54 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Axel Haslam
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Axel Haslam @ 2016-11-09 14:53 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij, khilman, nsekhar
  Cc: linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, Axel Haslam

After recent pinctl patches we see a warning when booting davinci
due to a bad memory allocation:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:3511 __alloc_pages_nodemask+0x16c/0xb18
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.0-rc2-00023-g22d5127-dirty #1019
Hardware name: Generic DA850/OMAP-L138/AM18x
Backtrace: 
[<c000d670>] (dump_backtrace) from [<c000d794>] (show_stack+0x18/0x1c)
[<c000d77c>] (show_stack) from [<c021a0d0>] (dump_stack+0x20/0x28)
[<c021a0b0>] (dump_stack) from [<c001bb10>] (__warn+0xe8/0x100)
[<c001ba28>] (__warn) from [<c001bb50>] (warn_slowpath_null+0x28/0x30)
[<c001bb28>] (warn_slowpath_null) from [<c0097e7c>] (__alloc_pages_nodemask+0x16c/0xb18)
[<c0097d10>] (__alloc_pages_nodemask) from [<c00afef4>] (kmalloc_order+0x20/0x58)
[<c00afed4>] (kmalloc_order) from [<c00ce7ac>] (__kmalloc_track_caller+0x188/0x190)
[<c00ce624>] (__kmalloc_track_caller) from [<c02a762c>] (devm_kmalloc+0x24/0x70)
[<c02a7608>] (devm_kmalloc) from [<c0247d10>] (pcs_dt_node_to_map+0x1d0/0xa40)
[<c0245ec8>] (pinctrl_dt_to_map) from [<c0242fd0>] (pinctrl_get+0xe8/0x484)
[snip]

This series fixes this error.

Changes form v1 -> v2
* Add an error message, and correct also other places where the
issue is seen

* Add patch to parse for bits instead of pins

Axel Haslam (2):
  pinctrl: single: check for any error when getting rows
  pinctrl: single: search for the bits property when parsing bits

 drivers/pinctrl/pinctrl-single.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

-- 
2.10.1

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

* [PATCH v2 1/2] pinctrl: single: check for any error when getting rows
  2016-11-09 14:53 [PATCH v2 0/2] pinctrl: single: fixes for davinci Axel Haslam
@ 2016-11-09 14:54 ` Axel Haslam
  2016-11-11 20:29   ` Linus Walleij
  2016-11-09 14:54 ` [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits Axel Haslam
  2016-11-09 15:20 ` [PATCH v2 0/2] pinctrl: single: fixes for davinci Tony Lindgren
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Haslam @ 2016-11-09 14:54 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij, khilman, nsekhar
  Cc: linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, Axel Haslam

pinctrl_count_index_with_args returns -ENOENT not
-EINVAL. The return check would pass, and we would
try to kzalloc with a negative error size throwing
a warning.

Instead of checking for -EINVAL specifically, lets
check for any error and avoid negative size allocations.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/pinctrl/pinctrl-single.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 539f31c..f36a9f1 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1133,8 +1133,10 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
 	struct pcs_function *function;
 
 	rows = pinctrl_count_index_with_args(np, name);
-	if (rows == -EINVAL)
-		return rows;
+	if (rows <= 0) {
+		dev_err(pcs->dev, "Ivalid number of rows: %d\n", rows);
+		return -EINVAL;
+	}
 
 	vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
 	if (!vals)
@@ -1228,8 +1230,10 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	struct pcs_function *function;
 
 	rows = pinctrl_count_index_with_args(np, name);
-	if (rows == -EINVAL)
-		return rows;
+	if (rows <= 0) {
+		dev_err(pcs->dev, "Invalid number of rows: %d\n", rows);
+		return -EINVAL;
+	}
 
 	npins_in_row = pcs->width / pcs->bits_per_pin;
 
-- 
2.10.1

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

* [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits
  2016-11-09 14:53 [PATCH v2 0/2] pinctrl: single: fixes for davinci Axel Haslam
  2016-11-09 14:54 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Axel Haslam
@ 2016-11-09 14:54 ` Axel Haslam
  2016-11-11 20:30   ` Linus Walleij
  2016-11-09 15:20 ` [PATCH v2 0/2] pinctrl: single: fixes for davinci Tony Lindgren
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Haslam @ 2016-11-09 14:54 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij, khilman, nsekhar
  Cc: linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, Axel Haslam

The pcs_parse_bits_in_pinctrl_entry function should search
for the "pinctrl-single,bits" and not "pinctrl-single,pins"

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/pinctrl/pinctrl-single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index f36a9f1..2b196e5 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1223,7 +1223,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 						unsigned *num_maps,
 						const char **pgnames)
 {
-	const char *name = "pinctrl-single,pins";
+	const char *name = "pinctrl-single,bits";
 	struct pcs_func_vals *vals;
 	int rows, *pins, found = 0, res = -ENOMEM, i;
 	int npins_in_row;
-- 
2.10.1

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

* Re: [PATCH v2 0/2] pinctrl: single: fixes for davinci
  2016-11-09 14:53 [PATCH v2 0/2] pinctrl: single: fixes for davinci Axel Haslam
  2016-11-09 14:54 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Axel Haslam
  2016-11-09 14:54 ` [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits Axel Haslam
@ 2016-11-09 15:20 ` Tony Lindgren
  2 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2016-11-09 15:20 UTC (permalink / raw)
  To: Axel Haslam
  Cc: haojian.zhuang, linus.walleij, khilman, nsekhar,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel

* Axel Haslam <ahaslam@baylibre.com> [161109 07:54]:
> After recent pinctl patches we see a warning when booting davinci
> due to a bad memory allocation:
> 
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:3511 __alloc_pages_nodemask+0x16c/0xb18
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.0-rc2-00023-g22d5127-dirty #1019
> Hardware name: Generic DA850/OMAP-L138/AM18x
> Backtrace: 
> [<c000d670>] (dump_backtrace) from [<c000d794>] (show_stack+0x18/0x1c)
> [<c000d77c>] (show_stack) from [<c021a0d0>] (dump_stack+0x20/0x28)
> [<c021a0b0>] (dump_stack) from [<c001bb10>] (__warn+0xe8/0x100)
> [<c001ba28>] (__warn) from [<c001bb50>] (warn_slowpath_null+0x28/0x30)
> [<c001bb28>] (warn_slowpath_null) from [<c0097e7c>] (__alloc_pages_nodemask+0x16c/0xb18)
> [<c0097d10>] (__alloc_pages_nodemask) from [<c00afef4>] (kmalloc_order+0x20/0x58)
> [<c00afed4>] (kmalloc_order) from [<c00ce7ac>] (__kmalloc_track_caller+0x188/0x190)
> [<c00ce624>] (__kmalloc_track_caller) from [<c02a762c>] (devm_kmalloc+0x24/0x70)
> [<c02a7608>] (devm_kmalloc) from [<c0247d10>] (pcs_dt_node_to_map+0x1d0/0xa40)
> [<c0245ec8>] (pinctrl_dt_to_map) from [<c0242fd0>] (pinctrl_get+0xe8/0x484)
> [snip]
> 
> This series fixes this error.

Thanks for fixing these and sorry about breaking pinctrl-bits:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH v2 1/2] pinctrl: single: check for any error when getting rows
  2016-11-09 14:54 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Axel Haslam
@ 2016-11-11 20:29   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2016-11-11 20:29 UTC (permalink / raw)
  To: Axel Haslam
  Cc: ext Tony Lindgren, Haojian Zhuang, Kevin Hilman, Nori, Sekhar,
	linux-arm-kernel, Linux-OMAP, linux-gpio, linux-kernel

On Wed, Nov 9, 2016 at 3:54 PM, Axel Haslam <ahaslam@baylibre.com> wrote:

> pinctrl_count_index_with_args returns -ENOENT not
> -EINVAL. The return check would pass, and we would
> try to kzalloc with a negative error size throwing
> a warning.
>
> Instead of checking for -EINVAL specifically, lets
> check for any error and avoid negative size allocations.
>
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>

Patch applied with Tony's ACK.

Yours,
Linus Walleij

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

* Re: [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits
  2016-11-09 14:54 ` [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits Axel Haslam
@ 2016-11-11 20:30   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2016-11-11 20:30 UTC (permalink / raw)
  To: Axel Haslam
  Cc: ext Tony Lindgren, Haojian Zhuang, Kevin Hilman, Nori, Sekhar,
	linux-arm-kernel, Linux-OMAP, linux-gpio, linux-kernel

On Wed, Nov 9, 2016 at 3:54 PM, Axel Haslam <ahaslam@baylibre.com> wrote:

> The pcs_parse_bits_in_pinctrl_entry function should search
> for the "pinctrl-single,bits" and not "pinctrl-single,pins"
>
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>

Patch applied with Tony's ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2016-11-11 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-09 14:53 [PATCH v2 0/2] pinctrl: single: fixes for davinci Axel Haslam
2016-11-09 14:54 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Axel Haslam
2016-11-11 20:29   ` Linus Walleij
2016-11-09 14:54 ` [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits Axel Haslam
2016-11-11 20:30   ` Linus Walleij
2016-11-09 15:20 ` [PATCH v2 0/2] pinctrl: single: fixes for davinci 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).