From patchwork Tue Feb 6 05:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Kurapati X-Patchwork-Id: 197189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1331515dyb; Mon, 5 Feb 2024 21:20:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyrd21YuKrRmHbCCk8ApnpxyzQuyHfn5YdvMilPnQbaYSsAOQ0ldglPqXtMVlHeLIcIKsV X-Received: by 2002:a05:6402:713:b0:560:885e:8bf1 with SMTP id w19-20020a056402071300b00560885e8bf1mr663260edx.25.1707196820704; Mon, 05 Feb 2024 21:20:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707196820; cv=pass; d=google.com; s=arc-20160816; b=yBeNGGoRUSHPzF56cUSM9t7uhEsDjfMR3j2nDGGHVX2ddNPnRkTieFM32xz92ppIrf b7JhbP2q/n8H9Pm7cxhq4Fgv7ld/iF5U9HWpSOW24rkPlgqkcStPPMjL7kH+3VNoVx7y PoiovWV3yyaOGE9p0FDNnT68+ZQwmIANzJrw+ZNS+/SSbZ/JdwlOGXY6KGSoWfExpUWx k9nFGXdgshn485P+uHaBgGZ7F8+KXjEm6p4hrMlqyEkog2ygh8wpZX1bLUQQo0KIscMR SZ9o74kyTifqZFW34vPj7AAnfivSTfzs3rMjqNeU49YoJ3QCTChWE7bzjNQF9CycKSd8 YWdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+y0cDrTLtTyYxuXcifRN7tNYkgbdfiJfM2ekZ4zgrFI=; fh=vaWFzbyaxTWHK6dRREV4uJwD6NmUBHSg3jUKUGsKiyg=; b=hdC6G4+7F1Y8VxLBXvdq1DEfX8oAHX3I6r6sTrT+9pGzPCK5IqXGOi2OUgiiF2KG7N tI0hCwvYQqSz02kOGDqd8jglDBHJzgKja0IgtrpBVH1IlSHFzlAZ06aegZ3ZV5Cy/dCP OiTPTDn1KQmRjcR4qm59GQ+IP1Qmv3C8W8gl62/arn35f3uwCsflSdO/ihBDFzt+hWdO QTtvX6BOuoljO2BREkx0irO7IOkuqUPlENCu2cjMwP6KE/GShtI+wZPS4xTXrOnhjPpH njO6/oQOw605lJxaDIw6OhOS78uktiE5B0zfiwGanDNlBGjmhsuiE4fRppTkRwkO7W2K vp2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WlAS455d; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-54344-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54344-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCWkWs/Pp70/+BloBA7mFz9h5K8NRNt6F+ufn/FAsZUGqJp5/PGHTmZllR4qWMtWZiYbig5qUJoFSqq2BmpJv9Mkc++2eQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h7-20020aa7c607000000b005601bd4cc81si690879edq.467.2024.02.05.21.20.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 21:20:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54344-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WlAS455d; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-54344-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54344-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 514AB1F250EF for ; Tue, 6 Feb 2024 05:20:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A502080023; Tue, 6 Feb 2024 05:19:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="WlAS455d" 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 728B67FBB2; Tue, 6 Feb 2024 05:19:05 +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=1707196746; cv=none; b=m2AQ3OOMbx3FnYpR8kk1SijUVcs2ech1sse053OJIsFYmOaDqDyd00lThwLoPOz3xTf1uMh6lPNK2ImdrCadZtV0IcdZb8TXyRQlJhufOkUhgSvbStGVv1L4ufTTC/yRFDzJezbae+DdF8phDOVNWNx9MQCIrAqBaRGtXrffULo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707196746; c=relaxed/simple; bh=genjBk3uvlsaAJU2yoYHfO+ITR5u2b7rhyQVgSXjeaI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IdDczZERg7fkUoKWKsCfZrh140hR8rPuKbuYTRTBJ7/olJUW66Qt+xNuPEOV0Wf83rP9ndNYB2mxlzS+w3ogqjMiE0XsO/+/cDkk1j7KazGGRkvwGTxOJr27aqTh6zVyooxyqJ8LoXmXLJe48HCNHorjdzz7b1SDdaR8dPB8x1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=WlAS455d; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4164xaI5031651; Tue, 6 Feb 2024 05:18:59 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=+y0cDrTLtTyYxuXcifRN7tNYkgbdfiJfM2ekZ4zgrFI=; b=Wl AS455dnBkV/zhE4I8p8MDy22DEJ2qUhHsw6gjhGyJ1brBIBDKs8DYSpa0L+miLIl me3755BZ74+lW3pZAGYhhTTUk5s7sfuKwKcAG70CWqJ3Z9HK1ASfsrbqQ4SsKpVR G5ilZ63ISemNgm8ruTcIeJZhdW/gYVisx/4kezWOkfd4RWQ9c/NSPg489QOLCM7m kCbE9PYladxN3BX8iDHrg7mFbJg11az1ryClR0K57/xTNv+yiBXMXLoN/PxS33Ls lltypJTvVKm4qtK/slRT3BS9RCyM1kS57rq2x1+x3spbtIXdbNSYHk7sjaa0WExy Z3jfQmQPxXq9sJ8ztn9w== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w3e7g0125-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Feb 2024 05:18:59 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4165Iwfg026025 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Feb 2024 05:18:58 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.40; Mon, 5 Feb 2024 21:18:53 -0800 From: Krishna Kurapati To: Krzysztof Kozlowski , Rob Herring , Bjorn Andersson , Wesley Cheng , Konrad Dybcio , "Greg Kroah-Hartman" , Conor Dooley , Thinh Nguyen , Felipe Balbi CC: , , , , , , Krishna Kurapati , Johan Hovold , Johan Hovold Subject: [PATCH v14 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Tue, 6 Feb 2024 10:48:19 +0530 Message-ID: <20240206051825.1038685-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206051825.1038685-1-quic_kriskura@quicinc.com> References: <20240206051825.1038685-1-quic_kriskura@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: CUgJNCvzaQBnG66iT1RDAKlIF5FiX3w8 X-Proofpoint-ORIG-GUID: CUgJNCvzaQBnG66iT1RDAKlIF5FiX3w8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_18,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 adultscore=0 mlxscore=0 mlxlogscore=894 lowpriorityscore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402060035 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790125613622803744 X-GMAIL-MSGID: 1790125613622803744 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 Reviewed-by: Johan Hovold Reviewed-by: Bjorn Andersson --- 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 965eaad195fb..c47fec10b231 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 = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); + if (hw_mode == DWC3_GHWPARAMS0_MODE_HOST) { + dwc->ev_buf = NULL; + return 0; + } evt = 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; + if (!dwc->ev_buf) + return 0; + evt = dwc->ev_buf; evt->lpos = 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; + if (!dwc->ev_buf) + return; + evt = dwc->ev_buf; evt->lpos = 0;