From nobody Sat Jan 3 06:55:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4E9EE7C4E5 for ; Wed, 4 Oct 2023 17:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243583AbjJDRAF (ORCPT ); Wed, 4 Oct 2023 13:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243555AbjJDQ75 (ORCPT ); Wed, 4 Oct 2023 12:59:57 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFCCBD; Wed, 4 Oct 2023 09:59:53 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 394FFpCM002355; Wed, 4 Oct 2023 16:59:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=9ALIUoz1vkM6MhoUdR9nJ++NWyOo4YGcWioNI82djYU=; b=BHESrBFtrLR1GyZA4Q6wWxsFFcGwy5dv8haL4bg8L9EMu/2rVtyDyp7CjG8A4lB024Rn jBh3UE0AjYGS33bny1SOv4W/6pFGMyi5LKvUHF3uxHQlz0k73SpKzp3EDuMUqp/k/D6Z 9ME9X9M877z4lJfU7qDYNypcj1vSJJ+YIRWqwpyJCGFKfRdaS25EbQPmYDrz+fWH9bEy V2fd08Unlx5rpflrWYVLXcRQ3u6LeypLgJrKMmQ2MasXJmZ6MlZSx1nw/i7U94m4JAvo Wf8WuldyesEwKpRWDZpyvei1N38FR5Uf7DkvDiFlUdbGxAtLOBavBDAogFur4RT9+wuf 1g== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tghsjumxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 16:59:43 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 394Gxg43032102 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Oct 2023 16:59:42 GMT Received: from hu-kriskura-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 4 Oct 2023 09:59:38 -0700 From: Krishna Kurapati To: Thinh Nguyen , Greg Kroah-Hartman , Bjorn Andersson CC: , , , , , Krishna Kurapati , "Johan Hovold" Subject: [PATCH v12 2/3] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Wed, 4 Oct 2023 22:29:21 +0530 Message-ID: <20231004165922.25642-3-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231004165922.25642-1-quic_kriskura@quicinc.com> References: <20231004165922.25642-1-quic_kriskura@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: yGfWHI3jeTDEvFlGisQeJGni3rfGCBFv X-Proofpoint-ORIG-GUID: yGfWHI3jeTDEvFlGisQeJGni3rfGCBFv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_08,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 mlxlogscore=890 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1011 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040123 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On some SoC's like SA8295P where the tertiary controller is host-only capable, GEVTADDRHI/LO, GEVTSIZ, GEVTCOUNT registers are not accessible. Trying to access them leads to a crash. For DRD/Peripheral supported controllers, event buffer setup is done again in gadget_pullup. Skip setup or cleanup of event buffers if controller is host-only capable. Suggested-by: Johan Hovold Signed-off-by: Krishna Kurapati Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d7c5669ebd06..3e507e4cc542 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -486,6 +486,13 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned int length) { struct dwc3_event_buffer *evt; + unsigned int hw_mode; + + hw_mode =3D DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); + if (hw_mode =3D=3D DWC3_GHWPARAMS0_MODE_HOST) { + dwc->ev_buf =3D NULL; + return 0; + } =20 evt =3D dwc3_alloc_one_event_buffer(dwc, length); if (IS_ERR(evt)) { @@ -507,6 +514,9 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc) { struct dwc3_event_buffer *evt; =20 + if (!dwc->ev_buf) + return 0; + evt =3D dwc->ev_buf; evt->lpos =3D 0; dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), @@ -524,6 +534,9 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc) { struct dwc3_event_buffer *evt; =20 + if (!dwc->ev_buf) + return; + evt =3D dwc->ev_buf; =20 evt->lpos =3D 0; --=20 2.42.0