From nobody Wed Dec 17 10:44:56 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 DA9B9213E6A for ; Tue, 18 Mar 2025 19:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742324722; cv=none; b=LN3PugjgjbtQcxqGgUoUY17sG8g0w5rWjGeBxCANpK6oMCImKsfO7fWUy458x9rM9oJigZOR0KaimbZM8lpz/7QjtSXsw7OkSkQ2bZh26vYkTs0L5ZwfrtIXn8K7Wh0ztxA5Qa40iqe8JoVGEePG3XsJpZRL7w+7wA74RqbbZFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742324722; c=relaxed/simple; bh=eQkqYxpWSanYKxPhcGDRdC42rK/h4DBAcc6ryt80h+Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=USjg2aPeajc6gJRTu9NEdusLKwErg1XElwy6dO4dPs1QgDzy7bv6LH3Q1rTeF3dSlcaK8PFJj6jR8V3poghVp6CdrZeZE0snCfFOOt6IrLGEo5qgvJMHRSfN+0VQWQrlEkezt2DPVCAcYfQ7AWv/cQzz6A7iB3j2P8ljRMgP2NA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=d6LUS1h2; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="d6LUS1h2" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 52IIlbwm011322 for ; Tue, 18 Mar 2025 19:05:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ZKt7fy4k+zqCf24blu7hfnZkf8U4C+xUpHuJMgA8+D0=; b=d6LUS1h2tAhJOwmt xjbjgDuiIKtVs8vf0n+10D/QQJy7xDWkbCXg3kgI0I1yHmYarN+UfOc95bbimK5p t1rUtAhDwv/KhgJo5Od4RxIH0wQd1Q6WDUTZwh2C2ePF/RoKIBvBkHQLlcxg10NK 8JtC51wDUyk6psHoLmjyO8MYpS1y2n0e8hAyFBrFP0gVsYXRkVdd5XhxUYcuYgTB 6/2QlhDZwn6Ehu3XPRtn0TRungtEnbNo7ihipnYbdqd+4y7dG/CrbCFptWfkKbWa 1AWDEJ90WM5ztGNpdY0VMhjv82jBGtRK0r0gTi1DwdGbQBwmorN/9bP9WgYI0QMw /RNx3w== Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45exx32yfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 18 Mar 2025 19:05:18 +0000 (GMT) Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3f91e867e49so4971278b6e.0 for ; Tue, 18 Mar 2025 12:05:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742324718; x=1742929518; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZKt7fy4k+zqCf24blu7hfnZkf8U4C+xUpHuJMgA8+D0=; b=s3h1weUVDqEupqws2ZZ6ZD5ScYgJORw8MAOChX42b/fwkzXaPzdRV082WvHjGTFlQz 5Uz1Itju01qp6SKzKp2brwoiGFQFC1HjJqMM6ED7GTrMr35xlWpzg/Sl/TxZCvrOg7ZV zGokSVsR4aDrXEch3g2nicopok7NJ63wXiCHaLvIJplA5cBNQy6WuiSW22+tmFSvJfhX LgfahRoPAyljP4KsxmryKwRyyWRjBeGQSDYJ80BcNkxAdA++shRVz4DbPSYJUoDBcJ7P ot0wmhlHLX9zon1FccMZLedGxWDfRiHTG+cykuBNw/Np0fxGFIz2zTizDx9BEkCO4poI YNew== X-Forwarded-Encrypted: i=1; AJvYcCXka2h/hKrX+e1VHOMG9DHK6+nOX6ML5GrHWB/U8sGP92yyymNVfgcRWKvAb+FSPYKfw8Nyw5M2J5fTeG0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3m8b8jtQQpLzp2e78d3ej4UI6xtvfoXP40OOBLudSAFOT7nsk s914JbgQNmQu1lwCELCO9DraOYPVtpaPe7+ygjrGZa/ardI07JoYWO9DNbaFoAzxHXWWxQEFeN7 m2GrTD1ZvoUyWrW9MARI3AnedbNFZ2/Wr/g9rw22DBBbGJo/3eLZZbkQDZH8Ni1E= X-Gm-Gg: ASbGncsYnSLc3jtbxAINXu3a6CFOvOWJ66hXnkJCciqSaoFqRInAtU7aNfZhXOoWF37 un+MFrd1+6yLFc7DuUNvAFara0AcTEkHFd4XkMDRNZEZOi6jH5jCNdHKuKuklhLpFDKCPtWu8SX v+etNIfVPvxTnLE6YjljHVcYtyXpOJSns1E8hqZPdtSMi6F29O5aFxnB9MOo3ZvTSJznHRXdDPi olZsQWge8smi0iF/F2Sd9vWXcgNwUcjX2djhmITGmKqq7bwmvPdNn8o9yPWOVONDHNpHI2/gPUd skthF1J7sBqj4BD2O4REl9htiTyqyHA8SD+9D4KPktVvVYxQGYuriU3+lEu/1/YIGraS8P1WFpG DOQie4N0lvLBzwb8= X-Received: by 2002:a05:6808:211c:b0:3fb:174f:821d with SMTP id 5614622812f47-3fea18d164bmr3175578b6e.35.1742324717545; Tue, 18 Mar 2025 12:05:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0oPFytHnSwWiWEyE0i6Zq6g46JKWsbktjeJE5tWF7seB8gkd1dk4wmLOs9B2mofGvogFQdw== X-Received: by 2002:a05:6808:211c:b0:3fb:174f:821d with SMTP id 5614622812f47-3fea18d164bmr3175542b6e.35.1742324717114; Tue, 18 Mar 2025 12:05:17 -0700 (PDT) Received: from [192.168.86.65] (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3fcd403b065sm2264273b6e.4.2025.03.18.12.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 12:05:16 -0700 (PDT) From: Bjorn Andersson Date: Tue, 18 Mar 2025 14:05:06 -0500 Subject: [PATCH v5 6/7] usb: dwc3: qcom: Transition to flattened model Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-dwc3-refactor-v5-6-90ea6e5b3ba4@oss.qualcomm.com> References: <20250318-dwc3-refactor-v5-0-90ea6e5b3ba4@oss.qualcomm.com> In-Reply-To: <20250318-dwc3-refactor-v5-0-90ea6e5b3ba4@oss.qualcomm.com> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Felipe Balbi , Wesley Cheng , Saravana Kannan , Thinh Nguyen , Philipp Zabel , Bjorn Andersson , Konrad Dybcio , Frank Li Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=11907; i=bjorn.andersson@oss.qualcomm.com; h=from:subject:message-id; bh=eQkqYxpWSanYKxPhcGDRdC42rK/h4DBAcc6ryt80h+Q=; b=owEBgwJ8/ZANAwAIAQsfOT8Nma3FAcsmYgBn2cPkM9LBwJ0OMl5jBRqXpXuOP/YHLHmJTmOnf CWHXL21zOmJAkkEAAEIADMWIQQF3gPMXzXqTwlm1SULHzk/DZmtxQUCZ9nD5BUcYW5kZXJzc29u QGtlcm5lbC5vcmcACgkQCx85Pw2ZrcW0Rg/+LnBSuBQQG0u1ou9Yxw5vpTTiExzPmRVCQ1dcdJI BWZamNmWSd9Ecx/G/RDQ1ORbOrK/xdqPbmWzags4F2Apg9lVvvSiRzmLBMyOS/YRkv67033m+de nnzsLwdfaOPwVi6F/RDl9NHLQFTfwIg6nqbZYD3iq8KOmbHZIfs/M3+cTMGLExwKRqzBh0N4U1b AP+nGRsQ3FumxoZX2t7soCe20L/HCJ6r9lFoJRFGJfL00svKfxcmJv8kKIM0tKxu5IYjOHqpan9 p88ekMJK1v4Ux6NNhIfCkvLdFRomSefCA05IrK10oLgkoaSfBb/r1yRoGheJD8UAImdDyISiBhs 8kqp7pzcL3wSwoRALEl4nYyn2iINUmSwokGdyfcJ2cK4gCq6xPqN1DEuC7ODpLc8AjIM6p+xKOt 0UOh9m9eKZcQorO1Ouqccc2tNoBOrGLQzPrM+Iu67bdocqA5QQZI4nbM49yQmUYhAT2qxPnGVxZ c1Cq/UMqA0K1O1HVHxoHnewJpIivdxdYGYSFdR0CrcAgY5ve5ILMNgPSFAkH0XdTyc5fCjI0iUb aGbx253jM5YwwOGFX28K0lPqEW9/vXlYiPAMPC1IEdwZV5FaAf1gx5yuFeOzU0GXlncjjf3TiTa OhrmEJD9S1x2RCS9infPMMYUcYmvui7m6boGm1uNCNVc= X-Developer-Key: i=bjorn.andersson@oss.qualcomm.com; a=openpgp; fpr=05DE03CC5F35EA4F0966D5250B1F393F0D99ADC5 X-Authority-Analysis: v=2.4 cv=b+uy4sGx c=1 sm=1 tr=0 ts=67d9c3ee cx=c_pps a=WJcna6AvsNCxL/DJwPP1KA==:117 a=DaeiM5VmU20ml6RIjrOvYw==:17 a=IkcTkHD0fZMA:10 a=Vs1iUdzkB0EA:10 a=EUspDBNiAAAA:8 a=Rmjymn6LDx49BAQaV_MA:9 a=QEXdDO2ut3YA:10 a=_Y9Zt4tPzoBS9L09Snn2:22 X-Proofpoint-ORIG-GUID: 7HdWYFXGsA23JBLqfJ1a4ZDcDNTpWaAK X-Proofpoint-GUID: 7HdWYFXGsA23JBLqfJ1a4ZDcDNTpWaAK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1093,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-03-18_08,2025-03-17_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 adultscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2503180137 The USB IP-block found in most Qualcomm platforms is modelled in the Linux kernel as 3 different independent device drivers, but as shown by the already existing layering violations in the Qualcomm glue driver they can not be operated independently. With the current implementation, the glue driver registers the core and has no way to know when this is done. As a result, e.g. the suspend callbacks needs to guard against NULL pointer dereferences when trying to peek into the struct dwc3 found in the drvdata of the child. Even with these checks, there are no way to fully protect ourselves from the race conditions that occur if the DWC3 is unbound. Missing from the upstream Qualcomm USB support is handling of role switching, in which the glue needs to be notified upon DRD mode changes. Several attempts has been made through the years to register callbacks etc, but they always fall short when it comes to handling of the core's probe deferral on resources etc. Moving to a model where the DWC3 core is instantiated in a synchronous fashion avoids above described race conditions. It is however not feasible to do so without also flattening the DeviceTree binding, as assumptions are made in the DWC3 core and frameworks used that the device's associated of_node will the that of the core. Furthermore, the DeviceTree binding is a direct representation of the Linux driver model, and doesn't necessarily describe "the USB IP-block". The Qualcomm DWC3 glue driver is therefor transitioned to initialize and operate the DWC3 within the one device context, in synchronous fashion. To provide a limited time backwards compatibility, a snapshot of the driver is retained in a previous commit. As such no care is taken in the dwc3-qcom driver for the qcom,dwc3 backwards compatibility. Signed-off-by: Bjorn Andersson Acked-by: Thinh Nguyen --- drivers/usb/dwc3/dwc3-qcom.c | 143 ++++++++++++++++++++++-----------------= ---- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 9d04c2457433bd6bcd96c445f59d7f2a3c6fdf24..49ad3fc8df33a354c7ab7cb0fbc= 47e47419fe689 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -4,7 +4,6 @@ * Inspired by dwc3-of-simple.c */ =20 -#include #include #include #include @@ -14,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -23,6 +21,7 @@ #include #include #include "core.h" +#include "glue.h" =20 /* USB QSCRATCH Hardware registers */ #define QSCRATCH_HS_PHY_CTRL 0x10 @@ -73,7 +72,7 @@ struct dwc3_qcom_port { struct dwc3_qcom { struct device *dev; void __iomem *qscratch_base; - struct platform_device *dwc3; + struct dwc3 dwc; struct clk **clks; int num_clocks; struct reset_control *resets; @@ -92,6 +91,8 @@ struct dwc3_qcom { struct icc_path *icc_path_apps; }; =20 +#define to_dwc3_qcom(d) container_of((d), struct dwc3_qcom, dwc) + static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 v= al) { u32 reg; @@ -116,6 +117,11 @@ static inline void dwc3_qcom_clrbits(void __iomem *bas= e, u32 offset, u32 val) readl(base + offset); } =20 +/* + * TODO: Make the in-core role switching code invoke dwc3_qcom_vbus_overri= de_enable(), + * validate that the in-core extcon support is functional, and drop extcon + * handling from the glue + */ static void dwc3_qcom_vbus_override_enable(struct dwc3_qcom *qcom, bool en= able) { if (enable) { @@ -260,7 +266,7 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom= *qcom) goto put_path_ddr; } =20 - max_speed =3D usb_get_maximum_speed(&qcom->dwc3->dev); + max_speed =3D usb_get_maximum_speed(qcom->dwc.dev); if (max_speed >=3D USB_SPEED_SUPER || max_speed =3D=3D USB_SPEED_UNKNOWN)= { ret =3D icc_set_bw(qcom->icc_path_ddr, USB_MEMORY_AVG_SS_BW, USB_MEMORY_PEAK_SS_BW); @@ -303,25 +309,14 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_q= com *qcom) /* Only usable in contexts where the role can not change. */ static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom) { - struct dwc3 *dwc; - - /* - * FIXME: Fix this layering violation. - */ - dwc =3D platform_get_drvdata(qcom->dwc3); - - /* Core driver may not have probed yet. */ - if (!dwc) - return false; - - return dwc->xhci; + return qcom->dwc.xhci; } =20 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *q= com, int port_index) { - struct dwc3 *dwc =3D platform_get_drvdata(qcom->dwc3); struct usb_device *udev; struct usb_hcd __maybe_unused *hcd; + struct dwc3 *dwc =3D &qcom->dwc; =20 /* * FIXME: Fix this layering violation. @@ -498,7 +493,7 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, boo= l wakeup) static irqreturn_t qcom_dwc3_resume_irq(int irq, void *data) { struct dwc3_qcom *qcom =3D data; - struct dwc3 *dwc =3D platform_get_drvdata(qcom->dwc3); + struct dwc3 *dwc =3D &qcom->dwc; =20 /* If pm_suspended then let pm_resume take care of resuming h/w */ if (qcom->pm_suspended) @@ -700,40 +695,14 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom,= int count) return 0; } =20 -static int dwc3_qcom_of_register_core(struct dwc3_qcom *qcom, struct platf= orm_device *pdev) -{ - struct device_node *np =3D pdev->dev.of_node; - struct device *dev =3D &pdev->dev; - int ret; - - struct device_node *dwc3_np __free(device_node) =3D of_get_compatible_chi= ld(np, - "snps,dwc3"); - if (!dwc3_np) { - dev_err(dev, "failed to find dwc3 core child\n"); - return -ENODEV; - } - - ret =3D of_platform_populate(np, NULL, NULL, dev); - if (ret) { - dev_err(dev, "failed to register dwc3 core - %d\n", ret); - return ret; - } - - qcom->dwc3 =3D of_find_device_by_node(dwc3_np); - if (!qcom->dwc3) { - ret =3D -ENODEV; - dev_err(dev, "failed to get dwc3 platform device\n"); - of_platform_depopulate(dev); - } - - return ret; -} - static int dwc3_qcom_probe(struct platform_device *pdev) { + struct dwc3_probe_data probe_data =3D {}; struct device_node *np =3D pdev->dev.of_node; struct device *dev =3D &pdev->dev; struct dwc3_qcom *qcom; + struct resource res; + struct resource *r; int ret, i; bool ignore_pipe_clk; bool wakeup_source; @@ -742,7 +711,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (!qcom) return -ENOMEM; =20 - platform_set_drvdata(pdev, qcom); qcom->dev =3D &pdev->dev; =20 qcom->resets =3D devm_reset_control_array_get_optional_exclusive(dev); @@ -771,8 +739,15 @@ static int dwc3_qcom_probe(struct platform_device *pde= v) goto reset_assert; } =20 - qcom->qscratch_base =3D devm_platform_ioremap_resource(pdev, 0); + r =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!r) + goto clk_disable; + res =3D *r; + res.end =3D res.start + SDM845_QSCRATCH_BASE_OFFSET; + + qcom->qscratch_base =3D devm_ioremap(dev, res.end, SDM845_QSCRATCH_SIZE); if (IS_ERR(qcom->qscratch_base)) { + dev_err(dev, "failed to map qscratch region: %pe\n", qcom->qscratch_base= ); ret =3D PTR_ERR(qcom->qscratch_base); goto clk_disable; } @@ -792,17 +767,21 @@ static int dwc3_qcom_probe(struct platform_device *pd= ev) if (ignore_pipe_clk) dwc3_qcom_select_utmi_clk(qcom); =20 - ret =3D dwc3_qcom_of_register_core(qcom, pdev); - if (ret) { - dev_err(dev, "failed to register DWC3 Core, err=3D%d\n", ret); + qcom->dwc.dev =3D dev; + probe_data.dwc =3D &qcom->dwc; + probe_data.res =3D &res; + probe_data.ignore_clocks_and_resets =3D true; + ret =3D dwc3_core_probe(&probe_data); + if (ret) { + ret =3D dev_err_probe(dev, ret, "failed to register DWC3 Core\n"); goto clk_disable; } =20 ret =3D dwc3_qcom_interconnect_init(qcom); if (ret) - goto depopulate; + goto remove_core; =20 - qcom->mode =3D usb_get_dr_mode(&qcom->dwc3->dev); + qcom->mode =3D usb_get_dr_mode(dev); =20 /* enable vbus override for device mode */ if (qcom->mode !=3D USB_DR_MODE_HOST) @@ -815,20 +794,15 @@ static int dwc3_qcom_probe(struct platform_device *pd= ev) =20 wakeup_source =3D of_property_read_bool(dev->of_node, "wakeup-source"); device_init_wakeup(&pdev->dev, wakeup_source); - device_init_wakeup(&qcom->dwc3->dev, wakeup_source); =20 qcom->is_suspended =3D false; - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - pm_runtime_forbid(dev); =20 return 0; =20 interconnect_exit: dwc3_qcom_interconnect_exit(qcom); -depopulate: - of_platform_depopulate(&pdev->dev); - platform_device_put(qcom->dwc3); +remove_core: + dwc3_core_remove(&qcom->dwc); clk_disable: for (i =3D qcom->num_clocks - 1; i >=3D 0; i--) { clk_disable_unprepare(qcom->clks[i]); @@ -842,12 +816,12 @@ static int dwc3_qcom_probe(struct platform_device *pd= ev) =20 static void dwc3_qcom_remove(struct platform_device *pdev) { - struct dwc3_qcom *qcom =3D platform_get_drvdata(pdev); + struct dwc3 *dwc =3D platform_get_drvdata(pdev); + struct dwc3_qcom *qcom =3D to_dwc3_qcom(dwc); struct device *dev =3D &pdev->dev; int i; =20 - of_platform_depopulate(&pdev->dev); - platform_device_put(qcom->dwc3); + dwc3_core_remove(&qcom->dwc); =20 for (i =3D qcom->num_clocks - 1; i >=3D 0; i--) { clk_disable_unprepare(qcom->clks[i]); @@ -864,10 +838,15 @@ static void dwc3_qcom_remove(struct platform_device *= pdev) =20 static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev) { - struct dwc3_qcom *qcom =3D dev_get_drvdata(dev); + struct dwc3 *dwc =3D dev_get_drvdata(dev); + struct dwc3_qcom *qcom =3D to_dwc3_qcom(dwc); bool wakeup =3D device_may_wakeup(dev); int ret; =20 + ret =3D dwc3_pm_suspend(&qcom->dwc); + if (ret) + return ret; + ret =3D dwc3_qcom_suspend(qcom, wakeup); if (ret) return ret; @@ -879,7 +858,8 @@ static int __maybe_unused dwc3_qcom_pm_suspend(struct d= evice *dev) =20 static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev) { - struct dwc3_qcom *qcom =3D dev_get_drvdata(dev); + struct dwc3 *dwc =3D dev_get_drvdata(dev); + struct dwc3_qcom *qcom =3D to_dwc3_qcom(dwc); bool wakeup =3D device_may_wakeup(dev); int ret; =20 @@ -889,30 +869,55 @@ static int __maybe_unused dwc3_qcom_pm_resume(struct = device *dev) =20 qcom->pm_suspended =3D false; =20 + ret =3D dwc3_pm_resume(&qcom->dwc); + if (ret) + return ret; + return 0; } =20 static int __maybe_unused dwc3_qcom_runtime_suspend(struct device *dev) { - struct dwc3_qcom *qcom =3D dev_get_drvdata(dev); + struct dwc3 *dwc =3D dev_get_drvdata(dev); + struct dwc3_qcom *qcom =3D to_dwc3_qcom(dwc); + int ret; + + ret =3D dwc3_runtime_suspend(&qcom->dwc); + if (ret) + return ret; =20 return dwc3_qcom_suspend(qcom, true); } =20 +static void __maybe_unused dwc3_qcom_complete(struct device *dev) +{ + struct dwc3 *dwc =3D dev_get_drvdata(dev); + + dwc3_pm_complete(dwc); +} + static int __maybe_unused dwc3_qcom_runtime_resume(struct device *dev) { - struct dwc3_qcom *qcom =3D dev_get_drvdata(dev); + struct dwc3 *dwc =3D dev_get_drvdata(dev); + struct dwc3_qcom *qcom =3D to_dwc3_qcom(dwc); + int ret; + + ret =3D dwc3_qcom_resume(qcom, true); + if (ret) + return ret; =20 - return dwc3_qcom_resume(qcom, true); + return dwc3_runtime_resume(&qcom->dwc); } =20 static const struct dev_pm_ops dwc3_qcom_dev_pm_ops =3D { SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume) SET_RUNTIME_PM_OPS(dwc3_qcom_runtime_suspend, dwc3_qcom_runtime_resume, NULL) + .complete =3D dwc3_qcom_complete, }; =20 static const struct of_device_id dwc3_qcom_of_match[] =3D { + { .compatible =3D "qcom,snps-dwc3" }, { } }; MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match); --=20 2.48.1