Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1054347lqt; Fri, 19 Apr 2024 21:50:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKVtGOQl5OIHnIVMJClqPzzG9xOI6mBMCgA21xUWV9tnWF3JIgUXvLN1btrdN/8rU/VcAF8lMGuSrBv9eTrtMZLuTxTL1hCuhYe115nQ== X-Google-Smtp-Source: AGHT+IFGA01Im3s1RuOA9ywS1st56Ogil5XiGh3Mn/99746ezF+G56evEwiMsFWbNw0lcjwh7g77 X-Received: by 2002:ad4:4e2d:0:b0:6a0:7403:2a69 with SMTP id dm13-20020ad44e2d000000b006a074032a69mr70907qvb.4.1713588618728; Fri, 19 Apr 2024 21:50:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713588618; cv=pass; d=google.com; s=arc-20160816; b=TMuOZNQxJhrD/vg0/6TQDBaGQ+BRVKOETkqnbfq1DtVC2dA45y3/lOwtUL4xsOYbJF EgpQWo0XPVfwOeYu0H4EHhQ8jwH4trQmy+e0Y/kO6z0w/ljd+QL1tnBTSVW9cvl45+nj 3CPQi4Y4vQ7+E1zmZk560VTMvrclmvaUcoqCUIxYaNCkbDk09GDo2DF9OunqaI+cwr/3 BtQwyk1lEFTIAjsARKRj/HLofzyfR36hTbzbzv4cmfs0Wb8Aj2hhM5hoOujlcvI/Fo0S gjLpQUkiVVK1qIBdJY2UaCUwnBJBiHRFPDc+4fqPQ/FUBK/mRtSxMc1dAOR5XeoWUwD7 wbIQ== 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=Bd0VDm6aPjELcAIzAGGlQtjaKL/VOLWILqfqI56n4GM=; fh=rCVsw0ADKhTADdWslfxGcKb2/OuP7S3j40Ot+ZbMR4o=; b=bq3mbIrdkFG9KUreQXdXVck4EmoDsHe7d0te8ochshEVuMBXniT2rM+LJWrCI33v8R NS/55xP1qT3vLa6shAU+dSxfE0h2RDdn4ab3ONBBlbiTCrm9uK7P4v/ArEfC4wYqp96y wbUGIclm/KmZjlPKCAX6vtlLme8Hx0+XDDOT/9B66Z4oGVBxe6mDlBzq8Zu0VkHs0DF+ mScASKPsYBW33KYPziqJ8tGLYR0wujM99D210DdOzyC8vl/4lJWYzgTmwggSObEB/sbn f5/j5Gv1jmm/m1w/iZ3bbfz1L9YKoX+38ePjV2ECu/ajU+s+kOHuCCMzuZ5/Iy/zDxqe tFDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oh0c89bb; 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-152131-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152131-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iu5-20020ad45cc5000000b006993bf4b013si5629487qvb.73.2024.04.19.21.50.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 21:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152131-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oh0c89bb; 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-152131-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152131-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 743041C2096B for ; Sat, 20 Apr 2024 04:50:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3074413FFC; Sat, 20 Apr 2024 04:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="oh0c89bb" 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 AF0FA883D; Sat, 20 Apr 2024 04:49:47 +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=1713588590; cv=none; b=nk17ATLZDxVitKIhOuyu/MBDxOZ+vV1TBmnK8xPoHeA200MlSBDYk12sNBI58gzTfFJEkHz5u0wZuZV/A5I+J9PvnKWSD9Tnpu2Q1dWVZ5udRte7KmZKDK7rnI6w9qDXbWRr6FdyKjEB7EYZai9hw9RqzmjInLQ3F2yr3zjFeP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713588590; c=relaxed/simple; bh=EjG6EKNShBqtlue7UesBWGotWOisLY2wJkCcyrWVazk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gkw98gASZN4WJAsjQzUgfEEDb9DHNQq7SAbxxSwG7nlCTKKxD+OOlkAhqm5INwyJ1QW3P27DpZhqQ/2W5JdopStijz+UJuLFw5oJumhG+uAPuDHNsca1IdQ+3HM7jbdcS3PmqGExmz0SGpQIZbELTgnomUNrB/XxIrcYiYwfHD4= 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=oh0c89bb; 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 (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43K4ncjI004636; Sat, 20 Apr 2024 04:49:38 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=Bd0VDm6aPjELcAIzAGGlQtjaKL/VOLWILqfqI56n4GM=; b=oh 0c89bbGRWxvB1oIyrkvJ8Gc/82U6TR5j/C5qzoMt4KyF4tQNQYJse7JiVV/EjyMR i+kTgcqtQmZiVWpSmKoolZoZ5EDUZjJx0Mb0Y+TWZuqHU/54jdHf8ZBwUvQDmBrL KNcDXrkFRFjv2LYhFddRPrS8PCHc2wgeFqUPAgvBgRPE3JRK6ztmHLtdgddYwYyZ fmjgJ00tHOIPQq/QeEPK1dIUfWMg16d8OFiQRTDGmBDC42XiNCDgZVHLwtwCqSOn KeZzD6SpKAAEuH5qQfl5hX6f1vXujhK23xB4qAER/V/2Je8KlnEJd7yn5IK8LNtY qmxjDhZAxgfGYWmIVEjw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xm6vr80ak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Apr 2024 04:49:38 +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 43K4nbkC020456 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 20 Apr 2024 04:49:37 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.9; Fri, 19 Apr 2024 21:49:31 -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 v21 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Sat, 20 Apr 2024 10:18:55 +0530 Message-ID: <20240420044901.884098-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240420044901.884098-1-quic_kriskura@quicinc.com> References: <20240420044901.884098-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: keIw5jsvQXsoLdGzzA1SJd_q2QKc0Njk X-Proofpoint-ORIG-GUID: keIw5jsvQXsoLdGzzA1SJd_q2QKc0Njk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-20_03,2024-04-19_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 clxscore=1011 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404200032 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 38fcf530332f..733b1e24af54 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