Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 307b4be8 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3-msm: Fix error path with dwc3_msm_probe() API



dwc3_msm driver probe is trying to unmap allocated per endpoint
buffer without SMMU attached. This results into below warning
when probe is encountering -EPROBE_DEFER.

WARNING: CPU: 0 PID: 4 at arch/arm/mm/dma-mapping.c:1018 __arm_dma_free+0xfc/0x11c
Freeing invalid buffer e0be9000
Modules linked in:
CPU: 0 PID: 4 Comm: kworker/0:0 Tainted: G W 4.14.83-18114-gf58b2b4-dirty #50
Workqueue: events deferred_probe_work_func
[<c010eacc>] (unwind_backtrace) from [<c010bdb8>] (show_stack+0x10/0x14)
[<c010bdb8>] (show_stack) from [<c011d034>] (__warn+0xa4/0xdc)
[<c011d034>] (__warn) from [<c011d0a0>] (warn_slowpath_fmt+0x34/0x44)
[<c011d0a0>] (warn_slowpath_fmt) from [<c01132fc>] (__arm_dma_free+0xfc/0x11c)
[<c01132fc>] (__arm_dma_free) from [<c056b8d4>] (dwc3_gadget_free_endpoints+0x124/0x1ac)
[<c056b8d4>] (dwc3_gadget_free_endpoints) from [<c056b974>] (dwc3_gadget_exit+0x18/0x13c)
[<c056b974>] (dwc3_gadget_exit) from [<c0564624>] (dwc3_remove+0x38/0x98)
[<c0564624>] (dwc3_remove) from [<c046ec44>] (platform_drv_remove+0x20/0x40)
[<c046ec44>] (platform_drv_remove) from [<c046cd1c>] (device_release_driver_internal+0x134/0x1dc)
[<c046cd1c>] (device_release_driver_internal) from [<c046b158>] (bus_remove_device+0xd4/0x114)
[<c046b158>] (bus_remove_device) from [<c04691a0>] (device_del+0x1e8/0x2a0)
[<c04691a0>] (device_del) from [<c046e9d8>] (platform_device_del+0x24/0x88)
[<c046e9d8>] (platform_device_del) from [<c046e5fc>] (platform_device_unregister+0xc/0x18)
[<c046e5fc>] (platform_device_unregister) from [<c064efdc>] (of_platform_device_destroy+0x78/0x84)
[<c064efdc>] (of_platform_device_destroy) from [<c04693d4>] (device_for_each_child+0x3c/0x6c)
[<c04693d4>] (device_for_each_child) from [<c064f014>] (of_platform_depopulate+0x2c/0x44)
[<c064f014>] (of_platform_depopulate) from [<c0576c78>] (dwc3_msm_probe+0x10c8/0x1444)
[<c0576c78>] (dwc3_msm_probe) from [<c046ebd8>] (platform_drv_probe+0x58/0xa4)

Fix this by attaching SMMU before trying to unmap allocated per
endpoint buffer.

Change-Id: I360c1759f709b8e919e3237d2903ed12808b5f7d
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 2913cfe3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -3728,7 +3728,7 @@ static int dwc3_msm_probe(struct platform_device *pdev)
	if (of_property_read_bool(node, "extcon")) {
		ret = dwc3_msm_extcon_register(mdwc);
		if (ret)
			goto put_dwc3;
			goto err_get_extcon;

		/*
		 * dpdm regulator will be turned on to perform apsd
@@ -3775,17 +3775,21 @@ static int dwc3_msm_probe(struct platform_device *pdev)

	return 0;

err_get_extcon:
	if (mdwc->iommu_map)
		arm_iommu_attach_device(mdwc->dev, mdwc->iommu_map);

put_dwc3:
	platform_device_put(mdwc->dwc3);
	if (mdwc->bus_perf_client)
		msm_bus_scale_unregister_client(mdwc->bus_perf_client);

uninit_iommu:
	of_platform_depopulate(&pdev->dev);
	if (mdwc->iommu_map) {
		arm_iommu_detach_device(mdwc->dev);
		arm_iommu_release_mapping(mdwc->iommu_map);
	}
	of_platform_depopulate(&pdev->dev);
err:
	destroy_workqueue(mdwc->sm_usb_wq);
	destroy_workqueue(mdwc->dwc3_wq);