Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp56668lqe; Wed, 3 Apr 2024 22:14:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUl+3tVkZnMOVX24S99nnrAzixKuuQRNmuCWY9MN7/FxzGvP3fmhjfnZT1YSXRDZae4Y5fAVZFGnVvn/Wb1/LGdd1SadZkQy+VhmxhQaw== X-Google-Smtp-Source: AGHT+IFpccAunsCjbJPwYVMD0OBwyQ7YL/MC9uWAJDfsl0Yy0MhLB/NDHwe17Mj5PirePs3OkFwx X-Received: by 2002:a17:906:4118:b0:a4a:859e:97b8 with SMTP id j24-20020a170906411800b00a4a859e97b8mr779241ejk.24.1712207663243; Wed, 03 Apr 2024 22:14:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712207663; cv=pass; d=google.com; s=arc-20160816; b=qk++1Nt1c8bURt3WrhvLHoot+npqUzF+l60i5XeHl6mPSqReVCmXnRxKoIzzldxMhv 2srQVP6peKYytZYHnE0Bc/IYZNqqKkeMl4TYgRt1RtvV32KETg2HeXE3DoExW2CKsuGJ Mgti+NxDD9Ad0KlXXtHlVQNI7Mmfd6v41QyEFWcctAXW3CCSodl5V9SBi2+tOBjRHDgq Vkk7XilOTXNYSUXSKanr61i46AnTA5eGrVDpI7AqrMAWJbE5On5qOmBN3YpLgAnOwBoV 3b8/RpH7b9j3+PG115lQKevl3hIeswt+XG19/+2FtOCeSylubNVzvstMPvFlDnrHh5G+ 3LQQ== 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=anjQ/gpaEqJMWRXFaf6E0+AwKkmGcIjau44pZz8PgIA=; fh=rCVsw0ADKhTADdWslfxGcKb2/OuP7S3j40Ot+ZbMR4o=; b=ywLnmDy9ZiJXE21229lKAfrt97lf4akHfgupZYw3EBq/OaLFdB4jSFtR2j96nwNZUX jRIh1xTXVnr5Gju0c8DYmimdUQc2jMMEA1PsN82u+ClYqdB30pgSUfxghsnXtl9A23+o P+PxXOUWy50Z18Tzr5sIDFJy7ooK4SWlb6JOTrndwxr2+ZZZvoAn1sEtSLKalZS+Ulpi s8gemo/rcFHSnfmMKTlKlhn1lZggdihtUK+eUKYRYsrANF2vqno0sux0DjOIWxiVlxho fL6Di0aIQ1lsTLzeKGrmI6xjcvgQsHSV3/kUTWIIv/qFtwyN6f/U91PUfCUlFNaC0Wl0 uQbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EtpGSRWb; 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-130902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130902-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hq16-20020a1709073f1000b00a4e30c8c0a1si6700549ejc.219.2024.04.03.22.14.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 22:14:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130902-linux.lists.archive=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=EtpGSRWb; 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-130902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130902-linux.lists.archive=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 69C4D1F250D5 for ; Thu, 4 Apr 2024 05:14:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B70A524B1; Thu, 4 Apr 2024 05:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EtpGSRWb" 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 C70AD4E1C1; Thu, 4 Apr 2024 05:13:09 +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=1712207591; cv=none; b=YkHvTW2W4pHkvoX5n51klPpbGWcZ+egl73hseOF8JBzBODDoHPdRsiEmvm/kfYiol6yTrsjE8H4A0BPhIprRutjlJDCMYTgiWSqS9F+JCrSNkisvdDVd7Ktut9llUWabYWXC6vpduIlXLYekFoh30wkHcmEDmQj7vK+cfWEcZF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712207591; c=relaxed/simple; bh=HZH5inmYE5fjRLo/hLuz/VXoCDBgOVlF+cz1uRFwrc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YgTkfS8vZkkPQZGFl6/x3Px7P3itIeojqGzvm4hL3SjHyWmvmgLxBzr7OmNUgxbF+30ofgL5qquI6AcEVDvBy+J/nZG/ZdpUGwYbd/m+BSXk7i792ph+XBcS6aTTak0ZT7/EFVr10B9e/TFsOdliQQUBDoBHiavTDmbP9VY6Xb0= 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=EtpGSRWb; 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 (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4345AwHo023538; Thu, 4 Apr 2024 05:13:04 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=anjQ/gpaEqJMWRXFaf6E0+AwKkmGcIjau44pZz8PgIA=; b=Et pGSRWbg+J2t78LEEuuetL/tXoKp/2m9rl0NDewQHugUtxS26Qu1KSJjqUsygDZYh rx+HNKN4FhjY41tWUdRsmNruHmnjrPVWWaqJYe8u405XdKjLzJPaerl3QG7x2Zlr JH7kUsACsZ+0B2BUTBj4nd6x3biwXlm4MUMDrkCTD0t0SgdjAUVQcDq4Tw3qZxG0 IX1ne1psSEjMwUkxIAPGx8sUOGu6dLvsqJvnbFANzpSIxwgmzs4dWJIDUH6ZDIPH Je3qqQcM3PW6sYVd9sSOAMh866emD+tEPQGSjld84jwdhYHM1nppuomHuldfSwLE b5hlpoVa2g6PfNv6rAIg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x9en70mej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Apr 2024 05:13:04 +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 4345D3bC007455 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 4 Apr 2024 05:13:03 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.1544.4; Wed, 3 Apr 2024 22:12:58 -0700 From: Krishna Kurapati To: Krzysztof Kozlowski , Rob Herring , Bjorn Andersson , Wesley Cheng , Konrad Dybcio , "Greg Kroah-Hartman" , Conor Dooley , Thinh Nguyen , Felipe Balbi , Johan Hovold CC: , , , , , , Krishna Kurapati , Johan Hovold Subject: [PATCH v19 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Thu, 4 Apr 2024 10:42:23 +0530 Message-ID: <20240404051229.3082902-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240404051229.3082902-1-quic_kriskura@quicinc.com> References: <20240404051229.3082902-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: X4hlumHhzb4kitnydfz8NojOC7glE6zU X-Proofpoint-ORIG-GUID: X4hlumHhzb4kitnydfz8NojOC7glE6zU 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-04-04_01,2024-04-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404040033 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 d4765d93693f..b023012b9321 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; -- 2.34.1