Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp368951lqi; Wed, 6 Mar 2024 22:22:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUznAozTElim2mzFBdSlR38JHh0W7dKTw17wi8oJFsbOhdG1jQGhC9PkkNMlAsGfJ5urAXSNIXeO9PCXzLt7v+cpx7xTT4ex2DIzrGw1w== X-Google-Smtp-Source: AGHT+IFJcwRk77ivx8KERHY4feR9HWXAt4aA9ow6ctIe0u+o7IZ+uajEkUuYmCh5n7uuF4wqvHz+ X-Received: by 2002:a17:906:5953:b0:a44:b90b:3262 with SMTP id g19-20020a170906595300b00a44b90b3262mr11548778ejr.5.1709792547344; Wed, 06 Mar 2024 22:22:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709792547; cv=pass; d=google.com; s=arc-20160816; b=W+fpDMCp7xFYiuzjDpb6MAMSjHHWa6AkobQ6oi9D/IPhLIPCdOD2/UnZmqXRkic0Gf LDJJ7Stnq68V5D2Kt/cIOVwaJm4XiLZCXVSnv9RCt677tki1Ykx+0fSjY/FSDTkm5uYU Xdk2aURw+t4dHMj/Iy7zVBKf0nsxRfViwUzZJsFxqJ+DEk0d09NSAlI/Fc2PtRj6MTIA 8Av0SfwqG4uHfh+AEks/0QV7X+Omz7I3d1i7+SUVlbDGPwgcHLazXkAyylNRXUOWv2/K lyTB3RPnMHRcDitcXT4ci6jv4KZy4rT57miPsPODqUtPRKiDmmBizjenPlFH8Q9QJbna fGdg== 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=VFniaZJsurmNWvNTt9+wS/qIPu1TPr0Jxyl6U/2PmvM=; fh=3z8MJZ0gcLl6Gv/MTgV5Y56yRgI3zFu1i9ViDV47Ve4=; b=g7z5EgWQMI0fqhCt8ddMvqSvEpvi6M0ynW1N49ELPGIi+p+rexoyMhZTEhzBAK066a 75poQKfZGhQGu5p4vppfXGbt47mjPgw9n+oVmII4VwBRH6IYHQt345bXuUhFPe6R9us4 fC95emEQYt5BECm2NBPfuH4xWHB2zno+WeP7riF6WiaoKrJRNO1EjEiZu7VhuwSK5OHn RW+LtcPRPYOhbBUARAhZps/pJ3LPKcc8lORlBg2kPIeQ6rXybekzLa7M2c1bpLzTo6h2 GIqZB+SDCUcZvE0/boI6yWaPD7gBaRsmGj87nf23JQcyRYkyCw5ZT5Sa6r9nCompwD48 1PMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="LkX7/ARh"; 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-95005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95005-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 s5-20020a170906bc4500b00a44d19c4051si4800416ejv.409.2024.03.06.22.22.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 22:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95005-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="LkX7/ARh"; 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-95005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95005-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 16B7F1F214A0 for ; Thu, 7 Mar 2024 06:22:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5CBB1F61D; Thu, 7 Mar 2024 06:21:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LkX7/ARh" 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 9E1F91F17B; Thu, 7 Mar 2024 06:21:36 +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=1709792498; cv=none; b=PNYN+2glj1HgWfQ73f9sOOhNjH80IhfuSdyck+D4tn4iEKFN+0rjsg70wB8x6bJefFRk3sQjL02hnBgOegOC5y2paRD6tt5JBjjQE9bpewGL2MDomYGNmhHv0J/t1ppkX/iLPYRzCSi9SvOaun7Mg/8gA4VGsFH88ObKIUuCKNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709792498; c=relaxed/simple; bh=sQQjudi+y8MTXg6xWA/a5ImPp/1Fd+KAz+dSp2HG6lg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kPLMP/eG4Jg6azgGQb9VKzU2vgz7EyO/ORUVfEk2PqgzRZWNR7IeVRyDddOiU16jlosjiPlqBcVTw8iic1c90qgmv8CpirVojX9HjQHX2OnejvyqGkMtwSPrI0hWJC+Nl+lAcXLmqQRVnYHLIyjxBFFaACUApPKR2Emn+mh8WqY= 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=LkX7/ARh; 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42742WPb020617; Thu, 7 Mar 2024 06:21: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=VFniaZJsurmNWvNTt9+wS/qIPu1TPr0Jxyl6U/2PmvM=; b=Lk X7/ARhcH5H4j5c8aAI51GfJ90fe5dwdysvMWZjObkoUlpEYECNeie0wpcCJSJ4Av 7YjxM/dsFMTOR/mRZv8mmofgs7ZVrXGD2tWDWZX35Ryl16VY6eOiLuls7pAAD8T4 1pwWlY2oHV851H/KoqGFROiqc38azY5hCRO0yzpoLvsCwJ8KqsvPglS2RUKSqKBA IQcr/HGtmtlo5+bjTd9dv3MbKZl3E0UyIR0E0feOKYlKRqvQLqNYncsP6TMztD59 JC+unIx06eCiEgvMM3/auUYF+C/AFZihnKsQF7UmmQAdQ9fcv1zbSdMsh21xiqjx SRt29l3CJAfFsDoHMo4Q== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wq01urvt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Mar 2024 06:21: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 4276LTNu014407 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 7 Mar 2024 06:21: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; Wed, 6 Mar 2024 22:21:24 -0800 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 v16 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Thu, 7 Mar 2024 11:50:46 +0530 Message-ID: <20240307062052.2319851-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307062052.2319851-1-quic_kriskura@quicinc.com> References: <20240307062052.2319851-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: 5tqMSD6Af3Fjlb4ReP111DyOZGofjizn X-Proofpoint-ORIG-GUID: 5tqMSD6Af3Fjlb4ReP111DyOZGofjizn 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-07_02,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 clxscore=1011 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403070044 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 02edafb4c2e3..e30105ccb059 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