Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3262770lqp; Tue, 26 Mar 2024 04:39:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLs/9I+9lAk7PRz4bOlDoxdRI4Wqf8umqIj6w84oowyv/ISf8Fco9rbTG+TKdmaZPniM0KbIDo87epU/nmEIvG5bTOcB+FX0ve/HuEOw== X-Google-Smtp-Source: AGHT+IEl08qrGkZrapB5+1xbKDzzIeD88tD9KnOFeHAcubIC8KDGSHWpo+IIF0546Bu0p7NgH1X3 X-Received: by 2002:a05:6a20:2a1c:b0:1a3:50fb:4f7c with SMTP id e28-20020a056a202a1c00b001a350fb4f7cmr8688933pzh.29.1711453172334; Tue, 26 Mar 2024 04:39:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711453172; cv=pass; d=google.com; s=arc-20160816; b=Cb2SwvY96/eIc1Hmk/JfBKSfjcfJb+FdeU+iJLq3/kWA0M9QxNyJIAwRkgBK/Wp/KY mAa+vlfl1ZPVeJfydDBBz/V48SYzcl6EVyX6t+zNFCmxURpOEUjzyQmVPRV/uJuxB65V lwPSfXRCyoz9MDP2xAP1x9jYacysFbtKaIJGfzVNowC82WP704qqPcYmhcfC60fZwPaJ jLi7Y102ybnHw4gRt0+iduCcfU+NmP47/Mxd0bVe7rCLIePnbH/iKwLzsVxmjDLHyIjW jinKrGTwui3I6I8iBEfV7JoPEcCS/HByS1kJND87uOc376dNujhWbSQHkhbUISpZhHYP xxsg== 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=M4Jl6Zo4BYYFr3gf7bSbxkxvmjWVrby58WZEde7kV6M=; fh=rCVsw0ADKhTADdWslfxGcKb2/OuP7S3j40Ot+ZbMR4o=; b=CTIsOzDc6Ma5gr8E/aN1fo6ocqd6zs51vrdvZcblwfYM8gFoE+uBXX3hjQl/Eu87cB AJteTR2MKkKxGMXJqMrkEQ9XJ/D0mdcl+eqDMm2Eff8oNDu6L4eLQnwFdQYUVo3FsCNa tBdixw/PC8FtNS2q/cZu+s8jVz+aHAKXGm0io3/rIAW+kWoghpH+p34WP+m6d3OnVSBF K6un2bTeRtsk9t7MFKSe1gqtrbqNCTV/utvXhiewm83+9JbrRihcN+Usr6ljDA/Y/Zcb AYcE/wsNXFcN7tFpKSMBB0CZ5DPxm3BGNyFfH9kTfLEWp5f4NG5pSOJ/o0+6cOBQT44k QAhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Vb1m4ffR; 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-118892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118892-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a17-20020a631a51000000b005cdd9963f49si9542049pgm.863.2024.03.26.04.39.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 04:39:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Vb1m4ffR; 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-118892-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118892-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A0C86B22027 for ; Tue, 26 Mar 2024 11:34:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BCFB6EB7A; Tue, 26 Mar 2024 11:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Vb1m4ffR" 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 D45336BFD4; Tue, 26 Mar 2024 11:33:35 +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=1711452817; cv=none; b=Auj4/NdlxYHXEZipjK1DdELTOSMwF990Owvvja9jOIVZSmvX8kwY2OjZRy5UJ/zzp6SfgA65dEiuyhiYxopA36ihqCXXgXqManjnbiNzZ+Hp0Sz0H0Q+dwY5sJr0uhOCY34gU8uOeccBOB2J5Yb1owM6yWDm3GXkQzcnn4ZH6yE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711452817; c=relaxed/simple; bh=6J7JyUtPwBv60XXPJt4Q+1DO8Rjs0n8T6C74CuTTjnI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OjgmIg99rz13zmO8QLV2E1eXx+vtqoOexugHL57Fq3rK9bbPm0Jv/ImUa2g3pI+hAiIlcOlhyLjzOsXbZ+4yQQtiT7IEiKdq94hJ5j2ZR+2mIRlYiglaHp6ngnHWvJzBNfAHfs3biGYTVHwAZrcX95Jr5s7vYNtg8NvE0jGL+hE= 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=Vb1m4ffR; 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 42Q8TOQZ012337; Tue, 26 Mar 2024 11:33:30 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=M4Jl6Zo4BYYFr3gf7bSbxkxvmjWVrby58WZEde7kV6M=; b=Vb 1m4ffRUDYMenTVQXiRA+Fw+kGIyciDcjRbBbdwiAIAsWdtMpEA1DDOw4im17gmXM 1pMOyenlPLEPhWdCCIAuVMdOeEOUNz5b4dprP8mWfQuU1dZ7BPMoN1u+IwqDr5lL QL5QGxly3CnTUN2T5ft1paW2V3tZ349nd/PPvz27Xtuvxe3xILG0BuocBUnzV1Dc ACYrZeqgBfvcO5xkG18FNlsIgiQ4gv6EBcDJ+VBXULWoox1NDqeW0oTXohQYaaTu +6edKN2D+fqdFryixiGJW6QzEDN+A3jfsxghtlAt8ZHB34NlfIa0whgyIAAmRw59 7Kzuccrr5FQcdKiAvgzg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x3tvy8fvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 11:33:30 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42QBXTWa017970 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 11:33:29 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; Tue, 26 Mar 2024 04:33:23 -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 v18 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Tue, 26 Mar 2024 17:02:47 +0530 Message-ID: <20240326113253.3010447-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240326113253.3010447-1-quic_kriskura@quicinc.com> References: <20240326113253.3010447-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: 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: DiTuZjV15gari3N84SeN1OQ-o1dn3uMA X-Proofpoint-ORIG-GUID: DiTuZjV15gari3N84SeN1OQ-o1dn3uMA 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-03-26_05,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 adultscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403260079 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 fab7664c12c0..ba0bfa9f85b6 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