From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7E2C1779AE; Wed, 5 Feb 2025 14:43:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738766633; cv=none; b=ZLbyjGkr8moZfi2AHkPxai/67i6Lyt0PIl+ExaOyAQvDeCF3AZpH6Xv5gi5PAodLmhjBOVC63y9Mg5bvtKYc+CHSeRlsNDHXotdPDA4n5xRGpjzsMjXc7kSlRs/8HJDr/EHw6U0jYciPABhIkgoipibv9cfn/JCBOgnXpGNdDGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738766633; c=relaxed/simple; bh=w3jeCt59HhBnpo6Go5lAj23tPqE8cZp0FnUAOEMGz44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B8iXzKRwFcHrKywBA9VVtbFAeFIkK5k3DOmteCVQSDPMsC+LRV952m/KlVHGhCzdPcBZIUKfQt/HqQx9O0xbY9FjvpGcMvAhGUL80RrWDxihY+h0brolZIOpMTzKt4qLYppLcx6hL7JAwtCsE2KILOJwq1c5mUCwwFymfYraf0o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ij/dS7dw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ij/dS7dw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3D90C4CED1; Wed, 5 Feb 2025 14:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738766632; bh=w3jeCt59HhBnpo6Go5lAj23tPqE8cZp0FnUAOEMGz44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ij/dS7dwGEBJaB3HxbVHosOsP7g8KdzAtxxZlihZvOhVyD2ZAKYZmp3OEnYL0CMNC o2fJbp+R5YK1otRtJ9CDvhAadxX4IT7buZUCCd4SDs7iiBv4uGYMRFqlGSoJ9zEuvI 6J66bPmViCCh5tChDGYdVbDFgzk/UgUrHdksGZRQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Kyle Tso , Thinh Nguyen Subject: [PATCH 6.6 380/393] usb: dwc3: core: Defer the probe until USB power supply ready Date: Wed, 5 Feb 2025 14:44:59 +0100 Message-ID: <20250205134434.833960025@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134420.279368572@linuxfoundation.org> References: <20250205134420.279368572@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kyle Tso commit 66e0ea341a2a78d14336117f19763bd9be26d45d upstream. Currently, DWC3 driver attempts to acquire the USB power supply only once during the probe. If the USB power supply is not ready at that time, the driver simply ignores the failure and continues the probe, leading to permanent non-functioning of the gadget vbus_draw callback. Address this problem by delaying the dwc3 driver initialization until the USB power supply is registered. Fixes: 6f0764b5adea ("usb: dwc3: add a power supply for current control") Cc: stable Signed-off-by: Kyle Tso Acked-by: Thinh Nguyen Link: https://lore.kernel.org/r/20250115044548.2701138-1-kyletso@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1505,8 +1505,6 @@ static void dwc3_get_properties(struct d u8 tx_thr_num_pkt_prd = 0; u8 tx_max_burst_prd = 0; u8 tx_fifo_resize_max_num; - const char *usb_psy_name; - int ret; /* default to highest possible threshold */ lpm_nyet_threshold = 0xf; @@ -1541,13 +1539,6 @@ static void dwc3_get_properties(struct d dwc->sys_wakeup = device_may_wakeup(dwc->sysdev); - ret = device_property_read_string(dev, "usb-psy-name", &usb_psy_name); - if (ret >= 0) { - dwc->usb_psy = power_supply_get_by_name(usb_psy_name); - if (!dwc->usb_psy) - dev_err(dev, "couldn't get usb power supply\n"); - } - dwc->has_lpm_erratum = device_property_read_bool(dev, "snps,has-lpm-erratum"); device_property_read_u8(dev, "snps,lpm-nyet-threshold", @@ -1887,6 +1878,23 @@ static int dwc3_get_clocks(struct dwc3 * return 0; } +static struct power_supply *dwc3_get_usb_power_supply(struct dwc3 *dwc) +{ + struct power_supply *usb_psy; + const char *usb_psy_name; + int ret; + + ret = device_property_read_string(dwc->dev, "usb-psy-name", &usb_psy_name); + if (ret < 0) + return NULL; + + usb_psy = power_supply_get_by_name(usb_psy_name); + if (!usb_psy) + return ERR_PTR(-EPROBE_DEFER); + + return usb_psy; +} + static int dwc3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1940,6 +1948,10 @@ static int dwc3_probe(struct platform_de dwc3_get_properties(dwc); + dwc->usb_psy = dwc3_get_usb_power_supply(dwc); + if (IS_ERR(dwc->usb_psy)) + return dev_err_probe(dev, PTR_ERR(dwc->usb_psy), "couldn't get usb power supply\n"); + dwc->reset = devm_reset_control_array_get_optional_shared(dev); if (IS_ERR(dwc->reset)) { ret = PTR_ERR(dwc->reset);