Commit cdc87687 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Felipe Balbi

usb: gadget: udc: renesas_usb3: fix pm_runtime functions calling

This patch fixes an issue that this driver is possible to access
the registers before pm_runtime_get_sync() if a gadget driver is
installed first. After that, oops happens on R-Car Gen3 environment.
To avoid it, this patch changes the pm_runtime call timing from
probe/remove to udc_start/udc_stop.

Fixes: 746bfe63 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent dc9217b6
...@@ -1799,6 +1799,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget, ...@@ -1799,6 +1799,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
/* hook up the driver */ /* hook up the driver */
usb3->driver = driver; usb3->driver = driver;
pm_runtime_enable(usb3_to_dev(usb3));
pm_runtime_get_sync(usb3_to_dev(usb3));
renesas_usb3_init_controller(usb3); renesas_usb3_init_controller(usb3);
return 0; return 0;
...@@ -1816,6 +1819,9 @@ static int renesas_usb3_stop(struct usb_gadget *gadget) ...@@ -1816,6 +1819,9 @@ static int renesas_usb3_stop(struct usb_gadget *gadget)
renesas_usb3_stop_controller(usb3); renesas_usb3_stop_controller(usb3);
spin_unlock_irqrestore(&usb3->lock, flags); spin_unlock_irqrestore(&usb3->lock, flags);
pm_runtime_put(usb3_to_dev(usb3));
pm_runtime_disable(usb3_to_dev(usb3));
return 0; return 0;
} }
...@@ -1891,9 +1897,6 @@ static int renesas_usb3_remove(struct platform_device *pdev) ...@@ -1891,9 +1897,6 @@ static int renesas_usb3_remove(struct platform_device *pdev)
device_remove_file(&pdev->dev, &dev_attr_role); device_remove_file(&pdev->dev, &dev_attr_role);
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
usb_del_gadget_udc(&usb3->gadget); usb_del_gadget_udc(&usb3->gadget);
__renesas_usb3_ep_free_request(usb3->ep0_req); __renesas_usb3_ep_free_request(usb3->ep0_req);
...@@ -2099,9 +2102,6 @@ static int renesas_usb3_probe(struct platform_device *pdev) ...@@ -2099,9 +2102,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
usb3->workaround_for_vbus = priv->workaround_for_vbus; usb3->workaround_for_vbus = priv->workaround_for_vbus;
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);
dev_info(&pdev->dev, "probed\n"); dev_info(&pdev->dev, "probed\n");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment