From mboxrd@z Thu Jan 1 00:00:00 1970 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 B67D22C3261 for ; Thu, 21 May 2026 01:09:55 +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=1779325798; cv=none; b=OtU92cxot1Bu4CHBWA/8nEp+dDLdoqvKutFTUpjMdCFYS3Xpxqr8LQ3JByjruex9mkINk7obsvxrgbwKzjMYzvXvFMSivkqQxNFUVRG2BlC42gKUf7gfWDVfyRsj8ceX5IH5Cx8sPqvtq2fIZQcd/A3dTurdbbZNoqU+m0pAh6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779325798; c=relaxed/simple; bh=uQLvCLyLKewaPBfOITpkJUe/bRH5dqsoapo9fOu8YkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nBAdvchZeeir9sJkESykvL7yhxhILSCBN1iHn4gNN4UiDVKAV1GHZkADt1D0FUFuje/uQi6fhSrgXfpzX0DJOI6v2rABWBcSjoDYaY7MKUoKVOAHGqsHoz5ezPQimSaju5p7vcf2bmdf1I3VsJaaVOc9y3d832MAkxWBdpv4au4= 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=YuaSAZeb; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CBN0ZsZM; 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="YuaSAZeb"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CBN0ZsZM" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KLEGKc1798618 for ; Thu, 21 May 2026 01:09:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=u+V9cVsKTNh VN5JgnurmHUqaFwybS+3Yl850UmViNVU=; b=YuaSAZeby1ujciVFSKjkfjOJWEB /BNSvVWFrwpINlIANgENFA1odq8X/Fk9+OiW1fJ7Sjg5FJoE8biY4I+VqKNVl0pk 2Hdqi0qmyrmabO/eE3Oe1lNFwCPIwLWXe3VGzxX8/eaLa9O03Qqo755nOszwbbvI b+fxf49nYLNkZ/ehFqCfJdUh2a5Os06zS2YuW1wvICTJZOvjmuVLBij2/QhHdJ9s r7jjQmvgqrS5T+GeQO+ozFSS/aGCzp5zSrC28BHBQd+d/wz56wF+7vU4mPrlZXxh O2cLYh1Uje2ILgsP007rvxtXkxr7cyryszM1T+pR7hl3shmZ1o8hDL8p0hg== Received: from mail-yx1-f71.google.com (mail-yx1-f71.google.com [74.125.224.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e9dxu2f86-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 21 May 2026 01:09:54 +0000 (GMT) Received: by mail-yx1-f71.google.com with SMTP id 956f58d0204a3-651cc9f2261so11194988d50.3 for ; Wed, 20 May 2026 18:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779325794; x=1779930594; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u+V9cVsKTNhVN5JgnurmHUqaFwybS+3Yl850UmViNVU=; b=CBN0ZsZMkGloV1S/5i/E8jBx/yhCpWZRxKrMyOHDW6Hbq8Salz5HCuzhC/bUC4w9pJ J1GI0KclwXmEt8XQNBY/G5aoSSN4STrWkaAM889XpmtcBRn9nfrFqJVl1SHLSEDH4W/t 4IMrKZoeMoOu3sQX2ziKLtinOF/X3xFtVVi4ysMPbpfrID1ZTJfAgP/qzpV4Vahy1Gxb +cy/RjU5BXJNsPHlv5ETp/eZK74Wcakho57JxSgjTuA9TIZ3pl22UAPlko8K8Nx/5hS6 ywteEOPWlpOseq1kxMe+HOCd4hYwT6cUiFcF6Mdh0VDAH+W5uDA+KoFK9+cRncm00kXn Rg5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779325794; x=1779930594; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u+V9cVsKTNhVN5JgnurmHUqaFwybS+3Yl850UmViNVU=; b=GCdyzzEn9AggIDLG/RzUSSDvwTKSH7E8ZGjuH70P4TvUJ8sxKKga9UkDi2Zlc6QlnD FBhcvqM6ad6Fsjclold+p9lPfzZQzpnr6JuyBA8WUoVBZMOof55GvXZG7ae+VmLJxU/5 i7kNF70rSd7QPrqRLTM8dITYtlsOqo49Mcg0+Kyw7vWrR6A5mHueH9MBWJPgOzvBikia yD9HeJEwWL6CijO1GPm/RXMbK3tiLRaYUQPSfk5Yspf/sWUXQd9vdOALPUXzoIKP0EkL B60pLx0IZOLYCpb6jDJnqhq0BGDPf+uUCqGCBBUfcS4N+ZsqoBi/T889ieyHQaKrPtFE 9NNg== X-Forwarded-Encrypted: i=1; AFNElJ/+VIwPWLLS3ykkRi+RWGxvOq9qYS/48R9tIolq9iPJURvQ72if1Svh3EtVLXgkdej1omJCB5HVHaL9gY0=@vger.kernel.org X-Gm-Message-State: AOJu0YwX3jFbc/afJ9IkBqg4eYh16inA/L1h8OcKfXQUyWRMxj3Mz8S2 F8/PnutLQiQ9ng5oUkLmqc6kDDK6ED76YH1fvc9zEwJbD7rmZ6+i8NpELYViHjp50KcV4h4R8W6 OvR+IcrffaPPi6rfkCKaINY4KwP2oaQ86EeyvMkIo0+CV0ijvMq36uh4ptnI5Sg/UkMk= X-Gm-Gg: Acq92OGHgIW4fbq/tzh+n6TCGpqAZMHtM4sOVzYIiMnO4i0q13pR1hnxL3z2seXDFbA 0eY4nUF9DLxyPaVJAYTDiioNtuWAfT+AxTV28DnJya4q0fHZNEDVpnKCFoa2l/UBs+iy3ySwAbF z/KCPgZsSj+S3sF41Le0irbN4wFIk8Yai3A278RfKLNlCTDW7IDkkiCSVUEfj5a4xES+bQaKoU4 CqRKeM3Nai2PnHEr1Di5GOPAwAvWfpOn5e6TFxzlDEF6KNSK3p3yjrfse4gurw7KM3A4IO14dlw BGcqLJl/BfjYuKQxmJX60BoNJp1GozCToIDiQdsvemWhxSMOWo/hjA1GdDaEt6sgUvRbnWa03tW UkRRThAus6fkkDl0mvCzF8qVvKQ7/XxFShUU1UzfDsiLqp2K4MU5hLIiYI9LuDBW1s3Fftg2YH8 WJTmsY680OacUlPR4= X-Received: by 2002:a05:690c:6387:b0:7b2:136d:240a with SMTP id 00721157ae682-7d20aa9cb6fmr9421997b3.9.1779325794024; Wed, 20 May 2026 18:09:54 -0700 (PDT) X-Received: by 2002:a05:690c:6387:b0:7b2:136d:240a with SMTP id 00721157ae682-7d20aa9cb6fmr9421707b3.9.1779325793555; Wed, 20 May 2026 18:09:53 -0700 (PDT) Received: from scottml-Latitude-7455 (107-198-5-8.lightspeed.irvnca.sbcglobal.net. [107.198.5.8]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7cc991c98d9sm60851307b3.10.2026.05.20.18.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 18:09:52 -0700 (PDT) From: Michael Scott To: linux-arm-msm@vger.kernel.org Cc: vkoul@kernel.org, neil.armstrong@linaro.org, dmitry.baryshkov@oss.qualcomm.com, wesley.cheng@oss.qualcomm.com, abelvesa@kernel.org, faisal.hassan@oss.qualcomm.com, linux-phy@lists.infradead.org, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, val@packett.cool, bryan.odonoghue@linaro.org, laurentiu.tudor1@dell.com, alex.vinarskis@gmail.com, linux-kernel@vger.kernel.org, Michael Scott Subject: [PATCH v2 1/4] phy: qcom: qmp-combo: skip USB power_off/exit after device teardown Date: Wed, 20 May 2026 18:09:32 -0700 Message-ID: <20260521010935.1333494-2-mike.scott@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260521010935.1333494-1-mike.scott@oss.qualcomm.com> References: <20260521010935.1333494-1-mike.scott@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDAwOCBTYWx0ZWRfX+Z9oviI0F8rZ /As88yICunuH5gnmv6r/i3L8IMON1L2IjoFkcNRtrKQEtrR0m9p3iUz+lE0yoMwKlR5fVAAAnBz HvdAneGNz3lrPiD/5rqYlF/5D5qZmYPll4UDhVup7SSYHkuODdD73NbxpEi6VPMs6VEAl7CvSST fQx18wWephdtoUIJO8XP5cXEyXWmKOiFZ99YulShpGXfPi4q7/UseTJQNYQBN+PlZXvAJqAkiM+ cpZmn3tlVDb3agEdbBSz6KiYDk2f3kzD6snbhCniWw0MQU0dmw33AqJ/AQ56T0Nfe6mgr94GNF2 ibloMxc9znETxi5SarFr2vR23/JySX+QUtvBsdHvBpAGJHTsRqEvyiTvuufX0xonU974nDpSlff zlQbHrG80teOmNsL8CKUSzsU1Kqyo8kqdnZSOH77+2yn1l6e7d4U4I0hysocQjTzSRVTg2V3Dvb 5oFfa4jY8kn/OgAdc5A== X-Authority-Analysis: v=2.4 cv=Zckt8MVA c=1 sm=1 tr=0 ts=6a0e5b62 cx=c_pps a=ngMg22mHWrP7m7pwYf9JkA==:117 a=cdagev08qavQYXHyx3V8vg==:17 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=EvQFHbMspfJCUfrvVzMA:9 a=yHXA93iunegOHmWoMUFd:22 X-Proofpoint-GUID: MLFoamu8LxZnvEBfYdVcyg5egScNjmok X-Proofpoint-ORIG-GUID: MLFoamu8LxZnvEBfYdVcyg5egScNjmok X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210008 qmp_combo_usb_power_off() is reachable from an external consumer (notably dwc3 via phy_exit() during driver unbind) after this device's backing resources have already been released along a separate teardown chain. The dereference of qmp->pcs (whose ioremap mapping has been freed by devm cleanup) then takes a level-3 translation fault and oopses. Easily reproducible during testing of USB-C role-switch enablement on Dell Latitude 7455 (X1E80100), by writing "none" to a USB-C DWC3's usb_role_switch role attribute, e.g. echo none > /sys/class/usb_role/a800000.usb-role-switch/role which triggers the chain: Unable to handle kernel paging request at virtual address ffff8000876c5400 pc : qmp_combo_usb_power_off.isra.0+0x58/0x470 [phy_qcom_qmp_combo] Call trace: qmp_combo_usb_power_off+0x58/0x470 [phy_qcom_qmp_combo] qmp_combo_usb_exit+0x38/0x90 [phy_qcom_qmp_combo] phy_exit dwc3_phy_exit [dwc3] dwc3_core_remove [dwc3] dwc3_remove [dwc3] platform_remove device_release_driver_internal device_driver_detach unbind_store sysfs_kf_write vfs_write ksys_write __arm64_sys_write el0_svc Two WARNs precede the oops from the same teardown chain, confirming the resource ordering: WARNING: drivers/clk/clk.c:4494 at clk_nodrv_disable_unprepare+0x8/0x18 WARNING: drivers/regulator/core.c:2657 at _regulator_put+0x84/0x98 i.e. the pipe clock provider has been unregistered and the regulators released before qmp_combo_usb_power_off() runs. The proper long-term fix is a teardown-ordering rework so the QMP PHY's backing resources outlive any consumer that may still call its phy_ops. Pending that, guard the power_off/exit paths with the existing usb_init_count balance so re-entry after teardown does not oops. usb_init_count tracks the balance of usb_power_on/off; if it is zero we have either never powered on or have already powered off, and there is nothing to do. The same guard is added to qmp_combo_usb_exit() since it is the entry point used by external consumers via phy_exit(). Signed-off-by: Michael Scott --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index cdcfad2e86b1..0db200292642 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -3926,6 +3926,17 @@ static int qmp_combo_usb_power_off(struct phy *phy) struct qmp_combo *qmp = phy_get_drvdata(phy); const struct qmp_phy_cfg *cfg = qmp->cfg; + /* + * Reachable as ->exit from external consumers (notably dwc3) after + * this device's backing resources have already been released along + * a teardown chain. Refuse to touch registers in that case. + */ + if (!qmp->usb_init_count) { + dev_dbg(qmp->dev, "%s: PHY not powered on, skipping\n", + __func__); + return 0; + } + /* PHY reset */ qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); @@ -3968,6 +3979,17 @@ static int qmp_combo_usb_exit(struct phy *phy) struct qmp_combo *qmp = phy_get_drvdata(phy); int ret; + /* + * See qmp_combo_usb_power_off(): an external consumer may call + * phy_exit() after the QMP device's resources have been torn + * down. usb_init_count tracks usb_init/usb_exit balance. + */ + if (!qmp->usb_init_count) { + dev_dbg(qmp->dev, "%s: PHY not initialised, skipping\n", + __func__); + return 0; + } + mutex_lock(&qmp->phy_mutex); ret = qmp_combo_usb_power_off(phy); if (ret) -- 2.53.0