Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1159623ybh; Thu, 16 Jul 2020 05:01:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPkvkGP8REittlMMPaLHQnAhr/S7xMk7v25MwwmWmootDo44Ut+tZwAn+Ns4ShixCyfYS/ X-Received: by 2002:a05:6402:559:: with SMTP id i25mr4035941edx.35.1594900879557; Thu, 16 Jul 2020 05:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594900879; cv=none; d=google.com; s=arc-20160816; b=ZJg95Ss9vkry5S7qoLR6QzWEBM8s86VldOaMbr37ZT5Ut9jm1MCS4CHEoTLSqqB+j4 Jp/s8JR5/yl47DHy8u62UPXQxw76nC19DimlVYzuLME5qsn7jTHjvvIFJq1Q6g0opTfn gluVu09J605JY6SCBZ0Q7xj6MLJAIMiA0RCGUr/rpMbPvGYjxitINzON2SAea+Fy40IG rfkFxiuzOAW4pWu/NNu+usV92PbJbty/BwCz8EbQem7HL0diEJWoONaknxo/lqWfvNEk JJpD1wFfZBA7OumuNl7Y1dodOVIL3BpQQNDS+R6u3EeypvTtyd56O6XxLtN44UVwNopV QHKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=vtx3jeBSZlkSSE4CJuzfTrNlTUg36EUyD3G4y4muTe8=; b=G0NnhpNS2hGFKHE8Yd9gXRCwhzhv+lenZ0thWmT0JVNov6xkKVa9PGRFnchAEMRMYo PkQO0Nq6kyaAGg+Mt0a3ImRoWnZWIIdYG2Gs5msdgmXt3KLn0h8ebYqUfx4A5oamsSei GrHp54U50Au14mHhRfFANP0WQIKhkHAtThj4DVbtaO2kUS/LV+jem+7/BX1CKoN2BL1T HPja6eotSgd1cvodrIA6/J1z6Fk3vGH8HnU7zQ9VB3uLSN4CR3LPWUlUqxTXRYxaLim7 kcjE2AQJnJbFIEXIlGPMmm4vydYgbcM8d9WI69PUK5haP1mmCSP70/J1HBZtex5Z9RbC F3vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AaTJyHJQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si3159007ejr.664.2020.07.16.05.00.51; Thu, 16 Jul 2020 05:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AaTJyHJQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728301AbgGPL6j (ORCPT + 99 others); Thu, 16 Jul 2020 07:58:39 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:46008 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgGPL6i (ORCPT ); Thu, 16 Jul 2020 07:58:38 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200716115836euoutp01e2eb5fe07d074874bac89043c06a0f9f~iOcBKnV9V2534025340euoutp01O for ; Thu, 16 Jul 2020 11:58:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200716115836euoutp01e2eb5fe07d074874bac89043c06a0f9f~iOcBKnV9V2534025340euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594900716; bh=vtx3jeBSZlkSSE4CJuzfTrNlTUg36EUyD3G4y4muTe8=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=AaTJyHJQW2ofA4QbDc6V/lCCUPtbJYZBjuATPdYAkWxO8c4ZfNe79UDOf9XpvT7uG fxjttRBsZVM4sxYx8yj35nRtYvQNBY8eh/OaUXG1hCqzZqLg8FMYrggvMvrJoqgrKN sHFkDZoJITtlk1aUT1l1K8EHgs1a+NZpsa4Ox5co= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200716115835eucas1p2243942f608670002fb43b0d2d513988f~iOcA9N5py0372703727eucas1p2C; Thu, 16 Jul 2020 11:58:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FD.7C.06318.BE0401F5; Thu, 16 Jul 2020 12:58:35 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200716115835eucas1p10870e0f4058f8f3fee0e13eb76aaee66~iOcAMA5oe0970809708eucas1p1U; Thu, 16 Jul 2020 11:58:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200716115835eusmtrp2d90da11c2ad9eb66f15db8ddec2f96a0~iOcALaCV11205812058eusmtrp2U; Thu, 16 Jul 2020 11:58:35 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-59-5f1040ebe23d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 57.C5.06017.AE0401F5; Thu, 16 Jul 2020 12:58:34 +0100 (BST) Received: from [106.210.88.143] (unknown [106.210.88.143]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200716115834eusmtip2f562092237cfa95a0d4f328a9481f700~iOb-xFRrG2935029350eusmtip2f; Thu, 16 Jul 2020 11:58:34 +0000 (GMT) Subject: Re: [PATCH] usb: dwc2: Fix error path in gadget registration To: Minas Harutyunyan , "linux-usb@vger.kernel.org" Cc: "linux-kernel@vger.kernel.org" , Felipe Balbi , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman From: Marek Szyprowski Message-ID: <3bfb9bf3-3139-6447-fe0b-25473dabb0a0@samsung.com> Date: Thu, 16 Jul 2020 13:58:36 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <13bfcc28-17d6-f399-2617-2edfb0cb8819@synopsys.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsWy7djP87qvHQTiDXpvGFpsnLGe1eJY2xN2 i+bF69ksLu+aw2axaFkrs8W7KbeZHdg8Nq3qZPPYP3cNu0ffllWMHlv2f2b0+LxJLoA1issm JTUnsyy1SN8ugSvj1Yz3LAW/QiuWfOpnbWC869XFyMkhIWAi0bJtBVsXIxeHkMAKRokVr3cw QjhfGCUOTdzBCuF8ZpSYuWECC0zLpnU/oVqWM0ps+vqEBcJ5zyhxd/ZMVpAqYQFXiX2vXrOB 2CIChRIv3h4HK2IWOMsocbNrOxNIgk3AUKLrbRdYEa+AncSCg7vAbBYBVYmONf/B1okKxEms fwlRzysgKHFy5hOwOKeAg8Sfu2fB6pkF5CWat85mhrDFJW49mc8EskxCYBW7RM/3j0ANHECO i8Td3awQLwhLvDq+hR3ClpH4vxOmvplR4uG5tewQTg+jxOWmGYwQVdYSd879YgMZxCygKbF+ lz5E2FGi/8k3Roj5fBI33gpC3MAnMWnbdGaIMK9ER5sQRLWaxKzj6+DWHrxwiXkCo9IsJJ/N QvLNLCTfzELYu4CRZRWjeGppcW56arFxXmq5XnFibnFpXrpecn7uJkZg8jn97/jXHYz7/iQd YhTgYFTi4a34zRcvxJpYVlyZe4hRgoNZSYTX6ezpOCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8 xotexgoJpCeWpGanphakFsFkmTg4pRoYd0ce0hac1ly41mf/+SMMWzWXqZpuOXT08pJvMX26 WUc9jDJrfJjD+Oc+1GpjXVrgPm/tVDOe/2sXFz81ORw0e+OxrT9nMO169CexMIzrafZ6QbU5 jEWTDfP7bm10TKtoP697JReYjB6zSuWcS359YPuTC30Jd1Yrqpe8mig/mX3Nu+Mx198HKbEU ZyQaajEXFScCAFSG9IE6AwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRmVeSWpSXmKPExsVy+t/xe7qvHATiDTZctLHYOGM9q8Wxtifs Fs2L17NZXN41h81i0bJWZot3U24zO7B5bFrVyeaxf+4ado++LasYPbbs/8zo8XmTXABrlJ5N UX5pSapCRn5xia1StKGFkZ6hpYWekYmlnqGxeayVkamSvp1NSmpOZllqkb5dgl7GqxnvWQp+ hVYs+dTP2sB416uLkZNDQsBEYtO6n2xdjFwcQgJLGSXaT61ngkjISJyc1sAKYQtL/LnWxQZi Cwm8ZZSYMjMJxBYWcJXY9+o1WFxEoFBiZfdFsEHMAucZJaYf+cgIMXUTk8TV7/vZQarYBAwl ut5CTOIVsJNYcHAXmM0ioCrRseY/C4gtKhAnsXzLfHaIGkGJkzOfgMU5BRwk/tw9C1bPLGAm MW/zQ2YIW16ieetsKFtc4taT+UwTGIVmIWmfhaRlFpKWWUhaFjCyrGIUSS0tzk3PLTbSK07M LS7NS9dLzs/dxAiMtm3Hfm7Zwdj1LvgQowAHoxIPr8JPvngh1sSy4srcQ4wSHMxKIrxOZ0/H CfGmJFZWpRblxxeV5qQWH2I0BXpuIrOUaHI+MBHklcQbmhqaW1gamhubG5tZKInzdggcjBES SE8sSc1OTS1ILYLpY+LglGpgVIpev1Iny0Y8m3XvS8ntV5bIemSIWV2u7DM6eGTLs18fd0Z1 z5Y12/1VQzhQwb3uotPlzQf6+Xg5mH/9dO+b4Cy65Q0PwzLdTa9dvaKZE2/xH9r+4D0zc47u 4sweF76DSjrKyqIFzfmZ67aLuEZmcj2Xt+E475hSmJujtmTmgZX2U2fYtJopsRRnJBpqMRcV JwIAMzPxnswCAAA= X-CMS-MailID: 20200716115835eucas1p10870e0f4058f8f3fee0e13eb76aaee66 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200714084807eucas1p1f6e680d162573c6a0660037172a65805 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200714084807eucas1p1f6e680d162573c6a0660037172a65805 References: <20200714084800.11340-1-m.szyprowski@samsung.com> <40bfbfd6-6516-5995-8250-c8e3df16e11e@synopsys.com> <13bfcc28-17d6-f399-2617-2edfb0cb8819@synopsys.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Minas, On 15.07.2020 15:54, Minas Harutyunyan wrote: > On 7/15/2020 12:42 PM, Marek Szyprowski wrote: >> On 14.07.2020 14:32, Minas Harutyunyan wrote: >>> On 7/14/2020 12:48 PM, Marek Szyprowski wrote: >>>> When gadget registration fails, one should not call usb_del_gadget_udc(). >>>> Ensure this by setting gadget->udc to NULL. Also in case of a failure >>> I was able to reproduce issue. I'm Ok with this fix. >>> >>>> there is no need to disable low-level hardware, so return immiedetly >>>> instead of jumping to error_init label. >>>> >>> Why do you think that disable low-level hardware not required which was >>> enabled before? Also for some platforms required to call >>> regulator_disable() which was enabled earlier in probe function. >>> So, I suggest to keep jump to error_init label. >> If I keep the jump to error_init label, then there is unbalanced call to >> dwc2_lowlevel_hw_disable(). usb_add_gadget_udc() can fail in 2 places: >> on gadget->bind() or during udc_start(). In the first case, the HW was >> not yet enabled, so there is no need to disable it. In the latter one, >> the error might be returned only from the dwc2_lowlevel_hw_enable(), so >> again there is no need to call dwc2_lowlevel_hw_disable(). >> >> If I keep the "goto error_init;" line, I get the following errors: >> >> dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter besl=1 >> dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter >> g_np_tx_fifo_size=1024 >> dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM >> Mass Storage Function, version: 2009/09/11 >> LUN: removable file: (no medium) >> no file given for LUN0 >> g_mass_storage 12480000.hsotg: failed to start g_mass_storage: -22 >> ------------[ cut here ]------------ >> WARNING: CPU: 3 PID: 49 at drivers/clk/clk.c:958 >> clk_core_disable+0x1e4/0x314 >> usb_device already disabled >> Modules linked in: >> CPU: 3 PID: 49 Comm: kworker/3:1 Not tainted >> 5.8.0-rc5-next-20200714-00003-g105f360ba595-dirty #8758 >> Hardware name: Samsung Exynos (Flattened Device Tree) >> Workqueue: events deferred_probe_work_func >> [] (unwind_backtrace) from [] (show_stack+0x10/0x14) >> [] (show_stack) from [] (dump_stack+0xbc/0xe8) >> [] (dump_stack) from [] (__warn+0xf0/0x108) >> [] (__warn) from [] (warn_slowpath_fmt+0x74/0xb8) >> [] (warn_slowpath_fmt) from [] >> (clk_core_disable+0x1e4/0x314) >> [] (clk_core_disable) from [] >> (clk_core_disable_lock+0x18/0x24) >> [] (clk_core_disable_lock) from [] >> (__dwc2_lowlevel_hw_disable+0x3c/0xa0) >> [] (__dwc2_lowlevel_hw_disable) from [] >> (dwc2_driver_probe+0x2d4/0x6ac) >> [] (dwc2_driver_probe) from [] >> (platform_drv_probe+0x6c/0xa4) >> [] (platform_drv_probe) from [] >> (really_probe+0x200/0x4fc) >> [] (really_probe) from [] >> (driver_probe_device+0x78/0x1fc) >> [] (driver_probe_device) from [] >> (bus_for_each_drv+0x74/0xb8) >> [] (bus_for_each_drv) from [] >> (__device_attach+0xd4/0x16c) >> [] (__device_attach) from [] >> (bus_probe_device+0x88/0x90) >> [] (bus_probe_device) from [] >> (deferred_probe_work_func+0x3c/0xd0) >> [] (deferred_probe_work_func) from [] >> (process_one_work+0x234/0x7dc) >> [] (process_one_work) from [] (worker_thread+0x44/0x51c) >> [] (worker_thread) from [] (kthread+0x158/0x1a0) >> [] (kthread) from [] (ret_from_fork+0x14/0x20) >> Exception stack(0xee923fb0 to 0xee923ff8) >> ... >> irq event stamp: 36966 >> hardirqs last  enabled at (36965): [] kfree+0x1a4/0x3f0 >> hardirqs last disabled at (36966): [] clk_enable_lock+0x14/0x134 >> softirqs last  enabled at (36814): [] __do_softirq+0x50c/0x608 >> softirqs last disabled at (36803): [] irq_exit+0x168/0x16c >> ---[ end trace f55f4b28f3080c12 ]--- >> ------------[ cut here ]------------ >> WARNING: CPU: 3 PID: 49 at drivers/clk/clk.c:817 >> clk_core_unprepare+0x33c/0x470 >> usb_device already unprepared >> Modules linked in: >> CPU: 3 PID: 49 Comm: kworker/3:1 Tainted: G        W >> 5.8.0-rc5-next-20200714-00003-g105f360ba595-dirty #8758 >> Hardware name: Samsung Exynos (Flattened Device Tree) >> Workqueue: events deferred_probe_work_func >> [] (unwind_backtrace) from [] (show_stack+0x10/0x14) >> [] (show_stack) from [] (dump_stack+0xbc/0xe8) >> [] (dump_stack) from [] (__warn+0xf0/0x108) >> [] (__warn) from [] (warn_slowpath_fmt+0x74/0xb8) >> [] (warn_slowpath_fmt) from [] >> (clk_core_unprepare+0x33c/0x470) >> [] (clk_core_unprepare) from [] >> (clk_unprepare+0x24/0x2c) >> [] (clk_unprepare) from [] >> (__dwc2_lowlevel_hw_disable+0x44/0xa0) >> [] (__dwc2_lowlevel_hw_disable) from [] >> (dwc2_driver_probe+0x2d4/0x6ac) >> [] (dwc2_driver_probe) from [] >> (platform_drv_probe+0x6c/0xa4) >> [] (platform_drv_probe) from [] >> (really_probe+0x200/0x4fc) >> [] (really_probe) from [] >> (driver_probe_device+0x78/0x1fc) >> [] (driver_probe_device) from [] >> (bus_for_each_drv+0x74/0xb8) >> [] (bus_for_each_drv) from [] >> (__device_attach+0xd4/0x16c) >> [] (__device_attach) from [] >> (bus_probe_device+0x88/0x90) >> [] (bus_probe_device) from [] >> (deferred_probe_work_func+0x3c/0xd0) >> [] (deferred_probe_work_func) from [] >> (process_one_work+0x234/0x7dc) >> [] (process_one_work) from [] (worker_thread+0x44/0x51c) >> [] (worker_thread) from [] (kthread+0x158/0x1a0) >> [] (kthread) from [] (ret_from_fork+0x14/0x20) >> Exception stack(0xee923fb0 to 0xee923ff8) >> ... >> irq event stamp: 37073 >> hardirqs last  enabled at (37081): [] console_unlock+0x430/0x6cc >> hardirqs last disabled at (37108): [] console_unlock+0x154/0x6cc >> softirqs last  enabled at (37124): [] __do_softirq+0x50c/0x608 >> softirqs last disabled at (37135): [] irq_exit+0x168/0x16c >> ---[ end trace f55f4b28f3080c13 ]--- >> ------------[ cut here ]------------ >> WARNING: CPU: 3 PID: 49 at drivers/regulator/core.c:2603 >> _regulator_disable+0x180/0x1d8 >> unbalanced disables for VUOTG_3.0V >> Modules linked in: >> CPU: 3 PID: 49 Comm: kworker/3:1 Tainted: G        W >> 5.8.0-rc5-next-20200714-00003-g105f360ba595-dirty #8758 >> Hardware name: Samsung Exynos (Flattened Device Tree) >> Workqueue: events deferred_probe_work_func >> [] (unwind_backtrace) from [] (show_stack+0x10/0x14) >> [] (show_stack) from [] (dump_stack+0xbc/0xe8) >> [] (dump_stack) from [] (__warn+0xf0/0x108) >> [] (__warn) from [] (warn_slowpath_fmt+0x74/0xb8) >> [] (warn_slowpath_fmt) from [] >> (_regulator_disable+0x180/0x1d8) >> [] (_regulator_disable) from [] >> (regulator_disable+0x34/0xe0) >> [] (regulator_disable) from [] >> (regulator_bulk_disable+0x28/0xb0) >> [] (regulator_bulk_disable) from [] >> (dwc2_driver_probe+0x2d4/0x6ac) >> [] (dwc2_driver_probe) from [] >> (platform_drv_probe+0x6c/0xa4) >> [] (platform_drv_probe) from [] >> (really_probe+0x200/0x4fc) >> [] (really_probe) from [] >> (driver_probe_device+0x78/0x1fc) >> [] (driver_probe_device) from [] >> (bus_for_each_drv+0x74/0xb8) >> [] (bus_for_each_drv) from [] >> (__device_attach+0xd4/0x16c) >> [] (__device_attach) from [] >> (bus_probe_device+0x88/0x90) >> [] (bus_probe_device) from [] >> (deferred_probe_work_func+0x3c/0xd0) >> [] (deferred_probe_work_func) from [] >> (process_one_work+0x234/0x7dc) >> [] (process_one_work) from [] (worker_thread+0x44/0x51c) >> [] (worker_thread) from [] (kthread+0x158/0x1a0) >> [] (kthread) from [] (ret_from_fork+0x14/0x20) >> Exception stack(0xee923fb0 to 0xee923ff8) >> ... >> irq event stamp: 37243 >> hardirqs last  enabled at (37251): [] console_unlock+0x430/0x6cc >> hardirqs last disabled at (37274): [] __schedule+0xd8/0x860 >> softirqs last  enabled at (37270): [] __do_softirq+0x50c/0x608 >> softirqs last disabled at (37291): [] irq_exit+0x168/0x16c >> ---[ end trace f55f4b28f3080c14 ]--- >> Failed to disable vusb_a: -5 >> dwc2: probe of 12480000.hsotg failed with error -22 >> 8<--- cut here --- >> Unable to handle kernel NULL pointer dereference at virtual address 00000004 >> pgd = (ptrval) >> [00000004] *pgd=00000000 >> Internal error: Oops: 5 [#1] PREEMPT SMP ARM >> Modules linked in: >> CPU: 3 PID: 87 Comm: kworker/3:2 Tainted: G        W >> 5.8.0-rc5-next-20200714-00003-g105f360ba595-dirty #8758 >> Hardware name: Samsung Exynos (Flattened Device Tree) >> Workqueue:  0x0 (rcu_gp) >> PC is at process_one_work+0x44/0x7dc >> LR is at 0xedc226d0 >> ... >> Process kworker/3:2 (pid: 87, stack limit = 0x(ptrval)) >> Stack: (0xeda03f00 to 0xeda04000) >> ... >> [] (process_one_work) from [] (worker_thread+0x44/0x51c) >> [] (worker_thread) from [] (kthread+0x158/0x1a0) >> [] (kthread) from [] (ret_from_fork+0x14/0x20) >> Exception stack(0xeda03fb0 to 0xeda03ff8) >> ... >> ---[ end trace f55f4b28f3080c15 ]--- >> note: kworker/3:2[87] exited with preempt_count 1 >> >> Best regards >> > I guess you build driver in (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) > and this is why call of dwc2_lowlevel_hw_disable() at 'error:' label > create issue. Could you please test on your setup follow implementation: > ... > error: > if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) > dwc2_lowlevel_hw_disable(hsotg); > return retval; > } > ... Right, this will work. However, I would also change the order of operations - disabling usb33d regulator should be done after disabling lowlevel hardware to properly pair with the enable operations. While playing with this I've also found an issue in UDC core: https://lore.kernel.org/linux-usb/20200716115525.27519-1-m.szyprowski@samsung.com/T/#u Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland