* [PATCH v2] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle
@ 2021-09-20 21:32 Fabio Estevam
2021-09-21 6:46 ` Frieder Schrempf
0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2021-09-20 21:32 UTC (permalink / raw)
To: peter.chen
Cc: shawnguo, marex, linux-usb, heiko.thiery, frieder.schrempf,
Fabio Estevam
When passing 'phys' in the devicetree to describe the USB PHY phandle, the
following NULL pointer deference is observed on i.MX7 and i.MX8MM:
[ 1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
[ 1.498170] Mem abort info:
[ 1.500966] ESR = 0x96000044
[ 1.504030] EC = 0x25: DABT (current EL), IL = 32 bits
[ 1.509356] SET = 0, FnV = 0
[ 1.512416] EA = 0, S1PTW = 0
[ 1.515569] FSC = 0x04: level 0 translation fault
[ 1.520458] Data abort info:
[ 1.523349] ISV = 0, ISS = 0x00000044
[ 1.527196] CM = 0, WnR = 1
[ 1.530176] [0000000000000098] user address but active_mm is swapper
[ 1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
[ 1.542125] Modules linked in:
[ 1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
[ 1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
[ 1.557133] Workqueue: events_unbound deferred_probe_work_func
[ 1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
[ 1.568998] pc : imx7d_charger_detection+0x3f0/0x510
[ 1.573973] lr : imx7d_charger_detection+0x22c/0x510
This happens because the charger functions check for the phy presence
inside the imx_usbmisc_data structure, but the chipidea core populates
the 'phys' inside 'struct ci_hdrc' instead.
Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
Tested on a imx7s-warp board.
Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v1:
- Changes the commit log and Fixes tag.
Hi,
We could probably change the signature of the charger functions to
pass 'struct ci_hdrc *ci', but that would be a much more invasive
change, which would probably not fit in the stable kernel criteria.
drivers/usb/chipidea/ci_hdrc_imx.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 8b7bc10b6e8b..f1d100671ee6 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -420,11 +420,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
if (IS_ERR(data->phy)) {
ret = PTR_ERR(data->phy);
- /* Return -EINVAL if no usbphy is available */
- if (ret == -ENODEV)
- data->phy = NULL;
- else
- goto err_clk;
+ if (ret == -ENODEV) {
+ data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
+ if (IS_ERR(data->phy)) {
+ ret = PTR_ERR(data->phy);
+ if (ret == -ENODEV)
+ data->phy = NULL;
+ else
+ goto err_clk;
+ }
+ }
}
pdata.usb_phy = data->phy;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle
2021-09-20 21:32 [PATCH v2] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle Fabio Estevam
@ 2021-09-21 6:46 ` Frieder Schrempf
0 siblings, 0 replies; 2+ messages in thread
From: Frieder Schrempf @ 2021-09-21 6:46 UTC (permalink / raw)
To: Fabio Estevam, peter.chen; +Cc: shawnguo, marex, linux-usb, heiko.thiery
On 20.09.21 23:32, Fabio Estevam wrote:
> When passing 'phys' in the devicetree to describe the USB PHY phandle, the
> following NULL pointer deference is observed on i.MX7 and i.MX8MM:
>
> [ 1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
> [ 1.498170] Mem abort info:
> [ 1.500966] ESR = 0x96000044
> [ 1.504030] EC = 0x25: DABT (current EL), IL = 32 bits
> [ 1.509356] SET = 0, FnV = 0
> [ 1.512416] EA = 0, S1PTW = 0
> [ 1.515569] FSC = 0x04: level 0 translation fault
> [ 1.520458] Data abort info:
> [ 1.523349] ISV = 0, ISS = 0x00000044
> [ 1.527196] CM = 0, WnR = 1
> [ 1.530176] [0000000000000098] user address but active_mm is swapper
> [ 1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
> [ 1.542125] Modules linked in:
> [ 1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
> [ 1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
> [ 1.557133] Workqueue: events_unbound deferred_probe_work_func
> [ 1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
> [ 1.568998] pc : imx7d_charger_detection+0x3f0/0x510
> [ 1.573973] lr : imx7d_charger_detection+0x22c/0x510
>
> This happens because the charger functions check for the phy presence
> inside the imx_usbmisc_data structure, but the chipidea core populates
> the 'phys' inside 'struct ci_hdrc' instead.
>
> Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.
>
> Tested on a imx7s-warp board.
>
> Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection")
> Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> Changes since v1:
> - Changes the commit log and Fixes tag.
>
> Hi,
>
> We could probably change the signature of the charger functions to
> pass 'struct ci_hdrc *ci', but that would be a much more invasive
> change, which would probably not fit in the stable kernel criteria.
>
> drivers/usb/chipidea/ci_hdrc_imx.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 8b7bc10b6e8b..f1d100671ee6 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -420,11 +420,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> data->phy = devm_usb_get_phy_by_phandle(dev, "fsl,usbphy", 0);
> if (IS_ERR(data->phy)) {
> ret = PTR_ERR(data->phy);
> - /* Return -EINVAL if no usbphy is available */
> - if (ret == -ENODEV)
> - data->phy = NULL;
> - else
> - goto err_clk;
> + if (ret == -ENODEV) {
> + data->phy = devm_usb_get_phy_by_phandle(dev, "phys", 0);
> + if (IS_ERR(data->phy)) {
> + ret = PTR_ERR(data->phy);
> + if (ret == -ENODEV)
> + data->phy = NULL;
> + else
> + goto err_clk;
> + }
> + }
> }
>
> pdata.usb_phy = data->phy;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-21 6:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 21:32 [PATCH v2] usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle Fabio Estevam
2021-09-21 6:46 ` Frieder Schrempf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.