pinctrl: devicetree: Fix pctldev pointer overwrite
Subsystems (3)
PATCH 1/1 pinctrl: devicetree: Fix pctldev pointer overwrite
From: Fabio Estevam <[email protected]>
Commit b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs") causes the pinctrl hog pins to not get initialized on i.MX platforms leaving them with the IOMUX settings untouched.
This causes several regressions on i.MX such as:
- OV5640 camera driver can not be probed anymore on imx6qdl-sabresd because the camera clock pin is in a pinctrl_hog group and since its pinctrl initialization is skipped, the camera clock is kept in GPIO functionality instead of CLK_CKO function.
- Audio stopped working on imx6qdl-wandboard and imx53-qsb for the same reason.
Richard Fitzgerald explains the problem:
"I see the bug. If the hog node isn't a 1st level child of the pinctrl parent node it will go around the for(;;) loop again but on the first pass I overwrite pctldev with the result of get_pinctrl_dev_from_of_node() so it doesn't point to the pinctrl driver any more."
Fix the issue by stashing the original pctldev so it doesn't get overwritten.
--- drivers/pinctrl/devicetree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pinctrl/devicetree.c +5 -2
@@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np) }static int dt_to_map_one_config (struct pinctrl *p, -struct pinctrl_dev *pctldev, +struct pinctrl_dev *hog_pctldev,const char *statename,struct device_node *np_config) { +struct pinctrl_dev *pctldev =NULL ;struct device_node *np_pctldev;const struct pinctrl_ops *ops;int ret;
@@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p,return -EPROBE_DEFER ; }/* If we're creating a hog we can use the passed pctldev */ -if (pctldev && (np_pctldev == p->dev->of_node)) +if (hog_pctldev && (np_pctldev == p->dev->of_node)) { + pctldev = hog_pctldev;break ; + } pctldev =get_pinctrl_dev_from_of_node (np_pctldev);if (pctldev)break ;
Signature · 1 line
2.7.4
Quoted 36 lines
-----Original Message-----
From: Fabio Estevam [mailto:[email protected]]
Sent: Friday, June 8, 2018 12:52 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; Fabio Estevam <[email protected]>; [email protected]
Subject: [PATCH] pinctrl: devicetree: Fix pctldev pointer overwriteFrom: Fabio Estevam <[email protected]>
Commit
b89405b6102f("pinctrl: devicetree: Fixdt_to_map_one_confighandling of hogs") causes the pinctrl hog pins to not get initialized on i.MX platforms leaving them with the IOMUX settings untouched.This causes several regressions on i.MX such as:
- OV5640 camera driver can not be probed anymore on imx6qdl-sabresd because the camera clock pin is in a
pinctrl_hoggroup and since its pinctrl initialization is skipped, the camera clock is kept in GPIO functionality instead ofCLK_CKOfunction.- Audio stopped working on imx6qdl-wandboard and imx53-qsb for the same reason.
Richard Fitzgerald explains the problem:
"I see the bug. If the hog node isn't a 1st level child of the pinctrl parent node it will go around the for(;;) loop again but on the first pass I overwrite pctldev with the result of
get_pinctrl_dev_from_of_node()so it doesn't point to the pinctrl driver any more."Fix the issue by stashing the original pctldev so it doesn't get overwritten.
Quoted 7 lines
Fixes b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_confighandling of hogs")
Cc <[email protected]>Reported-by Mika Penttilä <[email protected]>Reported-by Steve Longerbeam <[email protected]>Suggested-by Richard Fitzgerald <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
Looks good to me.
Regards
Dong Aisheng
Quoted 35 lines
--- drivers/pinctrl/devicetree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/pinctrl/devicetree.c index renamed from drivers/pinctrl/devicetree.c +0
-0b601039..c4aa411 100644
drivers/pinctrl/devicetree.c +5
-3@@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np) }static int dt_to_map_one_config (struct pinctrl *p, -struct pinctrl_dev *pctldev, +struct pinctrl_dev *hog_pctldev,const char *statename,struct device_node *np_config) { +struct pinctrl_dev *pctldev =NULL ;struct device_node *np_pctldev;const struct pinctrl_ops *ops;int ret;@@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p,return -EPROBE_DEFER ; }/* If we're creating a hog we can use the passed pctldev */ -if (pctldev && (np_pctldev == p->dev->of_node)) +if (hog_pctldev && (np_pctldev == p->dev->of_node)) { + pctldev = hog_pctldev;break ; + } pctldev =get_pinctrl_dev_from_of_node (np_pctldev);if (pctldev)break ; --2.7.4
Quoted 57 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Commit
b89405b6102f("pinctrl: devicetree: Fixdt_to_map_one_confighandling of hogs") causes the pinctrl hog pins to not get initialized on i.MX platforms leaving them with the IOMUX settings untouched.This causes several regressions on i.MX such as:
- OV5640 camera driver can not be probed anymore on imx6qdl-sabresd because the camera clock pin is in a
pinctrl_hoggroup and since its pinctrl initialization is skipped, the camera clock is kept in GPIO functionality instead ofCLK_CKOfunction.- Audio stopped working on imx6qdl-wandboard and imx53-qsb for the same reason.
Richard Fitzgerald explains the problem:
"I see the bug. If the hog node isn't a 1st level child of the pinctrl parent node it will go around the for(;;) loop again but on the first pass I overwrite pctldev with the result of
get_pinctrl_dev_from_of_node()so it doesn't point to the pinctrl driver any more."Fix the issue by stashing the original pctldev so it doesn't get overwritten.
Fixes b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs")Cc <[email protected]>Reported-by Mika Penttilä <[email protected]>Reported-by Steve Longerbeam <[email protected]>Suggested-by Richard Fitzgerald <[email protected]>Signed-off-by Fabio Estevam <[email protected]>--- drivers/pinctrl/devicetree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/pinctrl/devicetree.c +2
-1@@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np) }static int dt_to_map_one_config (struct pinctrl *p, -struct pinctrl_dev *pctldev, +struct pinctrl_dev *hog_pctldev,const char *statename,struct device_node *np_config) { +struct pinctrl_dev *pctldev =NULL ;struct device_node *np_pctldev;const struct pinctrl_ops *ops;int ret;@@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p,return -EPROBE_DEFER ;
drivers/pinctrl/devicetree.c static int dt_to_map_one_config(struct pinctrl *p, · line 133
Quoted 10 lines
drivers/pinctrl/devicetree.c +3
-1}/* If we're creating a hog we can use the passed pctldev */ -if (pctldev && (np_pctldev == p->dev->of_node)) +if (hog_pctldev && (np_pctldev == p->dev->of_node)) { + pctldev = hog_pctldev;break ; + } pctldev =get_pinctrl_dev_from_of_node (np_pctldev);if (pctldev)break ;
Thanks for creating this patch. Looks ok to me.
Quoted 27 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Commit
b89405b6102f("pinctrl: devicetree: Fixdt_to_map_one_confighandling of hogs") causes the pinctrl hog pins to not get initialized on i.MX platforms leaving them with the IOMUX settings untouched.This causes several regressions on i.MX such as:
- OV5640 camera driver can not be probed anymore on imx6qdl-sabresd because the camera clock pin is in a
pinctrl_hoggroup and since its pinctrl initialization is skipped, the camera clock is kept in GPIO functionality instead ofCLK_CKOfunction.- Audio stopped working on imx6qdl-wandboard and imx53-qsb for the same reason.
Richard Fitzgerald explains the problem:
"I see the bug. If the hog node isn't a 1st level child of the pinctrl parent node it will go around the for(;;) loop again but on the first pass I overwrite pctldev with the result of
get_pinctrl_dev_from_of_node()so it doesn't point to the pinctrl driver any more."Fix the issue by stashing the original pctldev so it doesn't get overwritten.
Quoted 6 lines
Fixes b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs")Cc <[email protected]>Reported-by Mika Penttilä <[email protected]>Reported-by Steve Longerbeam <[email protected]>Suggested-by Richard Fitzgerald <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
Patch applied for fixes with the ACKs!
Thanks for digging into this and fixing it up!
Yours,
Linus Walleij