Commit 4ce3b457 authored by Amjad Ouled-Ameur's avatar Amjad Ouled-Ameur Committed by Greg Kroah-Hartman
Browse files

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: default avatarAmjad Ouled-Ameur <aouledameur@baylibre.com>
Reported-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20211112162827.128319-3-aouledameur@baylibre.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 433ba26f
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -755,16 +755,16 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)

	ret = dwc3_meson_g12a_get_phys(priv);
	if (ret)
		goto err_disable_clks;
		goto err_rearm;

	ret = priv->drvdata->setup_regmaps(priv, base);
	if (ret)
		goto err_disable_clks;
		goto err_rearm;

	if (priv->vbus) {
		ret = regulator_enable(priv->vbus);
		if (ret)
			goto err_disable_clks;
			goto err_rearm;
	}

	/* Get dr_mode */
@@ -825,6 +825,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
	if (priv->vbus)
		regulator_disable(priv->vbus);

err_rearm:
	reset_control_rearm(priv->reset);

err_disable_clks:
	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
				   priv->drvdata->clks);
@@ -852,6 +855,8 @@ static int dwc3_meson_g12a_remove(struct platform_device *pdev)
	pm_runtime_put_noidle(dev);
	pm_runtime_set_suspended(dev);

	reset_control_rearm(priv->reset);

	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
				   priv->drvdata->clks);

@@ -892,7 +897,7 @@ static int __maybe_unused dwc3_meson_g12a_suspend(struct device *dev)
		phy_exit(priv->phys[i]);
	}

	reset_control_assert(priv->reset);
	reset_control_rearm(priv->reset);

	return 0;
}
@@ -902,7 +907,9 @@ static int __maybe_unused dwc3_meson_g12a_resume(struct device *dev)
	struct dwc3_meson_g12a *priv = dev_get_drvdata(dev);
	int i, ret;

	reset_control_deassert(priv->reset);
	ret = reset_control_reset(priv->reset);
	if (ret)
		return ret;

	ret = priv->drvdata->usb_init(priv);
	if (ret)