Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: dwc3: meson-g12a: fix shared reset control use

reset_control_(de)assert() calls are called on a shared reset line when
reset_control_reset has been used. This is not allowed by the reset
framework.

Use reset_control_rearm() call in suspend() and remove() as a way to state
that the resource is no longer used, hence the shared reset line
may be triggered again by other devices. Use reset_control_rearm() also in
case probe fails after reset() has been called.

reset_control_rearm() keeps use of triggered_count sane in the reset
framework, use of reset_control_reset() on shared reset line should be
balanced with reset_control_rearm().

Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
Reported-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20211112162827.128319-3-aouledameur@baylibre.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Amjad Ouled-Ameur and committed by
Greg Kroah-Hartman
4ce3b457 433ba26f

+12 -5
+12 -5
drivers/usb/dwc3/dwc3-meson-g12a.c
··· 755 755 756 756 ret = dwc3_meson_g12a_get_phys(priv); 757 757 if (ret) 758 - goto err_disable_clks; 758 + goto err_rearm; 759 759 760 760 ret = priv->drvdata->setup_regmaps(priv, base); 761 761 if (ret) 762 - goto err_disable_clks; 762 + goto err_rearm; 763 763 764 764 if (priv->vbus) { 765 765 ret = regulator_enable(priv->vbus); 766 766 if (ret) 767 - goto err_disable_clks; 767 + goto err_rearm; 768 768 } 769 769 770 770 /* Get dr_mode */ ··· 825 825 if (priv->vbus) 826 826 regulator_disable(priv->vbus); 827 827 828 + err_rearm: 829 + reset_control_rearm(priv->reset); 830 + 828 831 err_disable_clks: 829 832 clk_bulk_disable_unprepare(priv->drvdata->num_clks, 830 833 priv->drvdata->clks); ··· 854 851 pm_runtime_disable(dev); 855 852 pm_runtime_put_noidle(dev); 856 853 pm_runtime_set_suspended(dev); 854 + 855 + reset_control_rearm(priv->reset); 857 856 858 857 clk_bulk_disable_unprepare(priv->drvdata->num_clks, 859 858 priv->drvdata->clks); ··· 897 892 phy_exit(priv->phys[i]); 898 893 } 899 894 900 - reset_control_assert(priv->reset); 895 + reset_control_rearm(priv->reset); 901 896 902 897 return 0; 903 898 } ··· 907 902 struct dwc3_meson_g12a *priv = dev_get_drvdata(dev); 908 903 int i, ret; 909 904 910 - reset_control_deassert(priv->reset); 905 + ret = reset_control_reset(priv->reset); 906 + if (ret) 907 + return ret; 911 908 912 909 ret = priv->drvdata->usb_init(priv); 913 910 if (ret)