Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1365110lqe; Mon, 8 Apr 2024 07:04:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlwJgtJ6qaecc2ilryVgcb7BpZFh/qEsjLJ43wjElwAZ4fkPD/Ep+h3xuElbEc9kb5edXzgiwA/FEevbZosvrKKbrOQF5XsRJBS8tNXA== X-Google-Smtp-Source: AGHT+IEBt1VCzt3tYNPcNlEW5QoTgS1Z0qPr4ibB73WXrGn100L5PYfrn7hBID+VLuKd7l06R7et X-Received: by 2002:a17:90a:ac03:b0:2a0:4073:deda with SMTP id o3-20020a17090aac0300b002a04073dedamr6710114pjq.20.1712585077734; Mon, 08 Apr 2024 07:04:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712585077; cv=pass; d=google.com; s=arc-20160816; b=fNwF1RZnZQVqUWWbvtjqstWkcHQsx6Cih7UbNSTKRVY8PC2dFcPQmsEzytPF3T61hr 4qXyCd+64j/vzWhgayHJu3acF//9eh7g4k+ngFGxyxrI89QPW6HU2R/pLq3Q6ssePlYP C3V1y815XA03KEK6T8gy8dKPcsT1v9ptBOha6ib+UOWhhHT8qI2KvIa4SCff8qY8DumC c+EkJYpUzxapD0FVU+TRJqeVprz6eFAloLmAanSoM2OOppcYEHj2RMJTinB9FoUdbHIP hF7dk36o+Gg0stMu+QOYd2SBRF07EB5oPLJu/boIrnQMN74rekyZEBGNlAHBJGt5Qd8R QL2Q== 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=kHd+PKS+dfb5GSNH4hiQTzpHoG97BqNiGU31XOaYZUY=; fh=rCVsw0ADKhTADdWslfxGcKb2/OuP7S3j40Ot+ZbMR4o=; b=C+vOs2pKbcfK9l30U8dKxriAaELTfPGiQdZGHnr7XiwnNGRvIn+1z3e6a3hbHdxgWe AKYKFjs/l+UA7M+edilQ9kLjh/iCQIgG0loJ4NZ5viBiheqqWywTlWIq71fgX6CWHlvD WF3v6E3BMRzDIr7GaIxUIkNDIsVgGgTD9ty5nipoOrLGKniD0W6UmPkNnujX5Ac2BMhF K/be5uZVEpdYIU3VNEp7++Z0qnz7f974lBTil+UxGMuGa5RqFW3gWdEXgteugPqqE2yB 0jmjv6yHwSz8QJpIB9Uye3OECVgb8wFgeImU3wA7Sm4l9KXiAA/HfDobadU6Pxd97GWw JdIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jLQqsbAj; 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-135447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135447-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 h4-20020a17090acf0400b002a241249bf8si8664762pju.99.2024.04.08.07.04.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 07:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135447-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=jLQqsbAj; 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-135447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135447-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 D2182B26D28 for ; Mon, 8 Apr 2024 13:36:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52AAF12BEA5; Mon, 8 Apr 2024 13:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jLQqsbAj" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 EE399129E8C; Mon, 8 Apr 2024 13:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712583033; cv=none; b=i81VCrBWxpJ9v9rc/qCdsox03xjctIGdPSxWGN7L5ON1+EC5Xn/Ss7qGsy8/Cs5bDVAsYn5js67iTFdr0jhbBVj35VS7GdgTLiqIRWXuLaRawPpBnB0ZW/aw5GLFCsh6efYozck7fEwyBliF/A7X83y+E1fbvE/CdvXpFl+dWDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712583033; c=relaxed/simple; bh=LhoA2W59TIpKYINn8ySPE5KCAFKscDic5R/FKqYiTKM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BYa7qznxmRN8ZNWlDdoru5Km86l82YBLvsMZ+o71HyuVQr2VJ2jbQj87bkuW6d94dXaF5V4RMUhNKt01Fp9UabUs1gX2zDaOvGucQou/zeUha65RRxMTFASE8OoXBe3EzzdtSihQPSZ/SYEqwW1S6qe9dyip7ucaE2pYwz3l3mE= 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=jLQqsbAj; arc=none smtp.client-ip=205.220.180.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 (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4386cEKw022412; Mon, 8 Apr 2024 13:30:25 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=kHd+PKS+dfb5GSNH4hiQTzpHoG97BqNiGU31XOaYZUY=; b=jL QqsbAj+SgdfEqFGs2kuKhAuVT+2KkicHdusd+roPsBl+712uCm5EXDsjVhwvGDBK tv7gg90djyP13oWWROt6t/wPBgIRWgMtYSU4vyv6uJ2jhq7aosaCXALwgcogx2AV 3rtuK7bwt3JtcZJae+eyCHpPP+gytLrEHQNcPWylRJivb1MGdQMhK9enugoKfrLC TXzPw6JEtmN6aQ6myd03IlVOJavbno5ho9zIhUcczLWwiqPqkxQ9EDvx9biIEJrL yvSw8fptoF5rZtOWV3tKaEtEQKm37F1H81LN5f77q7ScKxuBEcGs0teeSG8YqAuO lQr1J7I0sgtShiB1xb6A== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xcbg2rvm2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Apr 2024 13:30:25 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 438DU2B5005057 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 8 Apr 2024 13:30:02 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; Mon, 8 Apr 2024 06:29:56 -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 v20 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Mon, 8 Apr 2024 18:59:19 +0530 Message-ID: <20240408132925.1880571-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240408132925.1880571-1-quic_kriskura@quicinc.com> References: <20240408132925.1880571-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-ORIG-GUID: MMjPRk6Re5HSBlHpa7PCq4il9gXc-9Em X-Proofpoint-GUID: MMjPRk6Re5HSBlHpa7PCq4il9gXc-9Em 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-08_11,2024-04-05_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404080104 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 ddab30531f8a..1a3d8a9beea8 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