Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3227783lqp; Tue, 26 Mar 2024 03:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdeb9UIRepRRj63wcd6ikzxXeZKYiohvJC6I+ynTuj3eBGxQDmfjkQ4+3oinQ+2FF5EodlAIEp2tmd6yVVj8/hBiR0/CsCVPf1RuOcow== X-Google-Smtp-Source: AGHT+IHz3e9EWJYaABefaXlyc12DgtHhOvFcArwrzo05voP53Z93Hwm8L9HpBf+XTmRbiiZSaP+R X-Received: by 2002:a17:902:b495:b0:1de:faa5:552 with SMTP id y21-20020a170902b49500b001defaa50552mr9730009plr.56.1711448993706; Tue, 26 Mar 2024 03:29:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711448993; cv=pass; d=google.com; s=arc-20160816; b=ckG6ko1IBT5qNY+4BHeE3Ix47iOvaLLcJLeen93i2CcOldpTjYS+vQuv4hQSI0FeCu 81ag2GBYIGufTa87qCnYXqkd1R3K7c4TQ8IywqnBDavRfpCmQwZorOm12JMo+bgsWo+P 4ijs5rCzMyO7Uf5CuM9IUZdwgcM7mbYihnpAS7+FzSsZ/5adrT7Mc9Ts/yboQq/uxuKv ChN5BS7lZhvL+P78+aTM0ILGY5i8qTqB6z6bL1F8w+gvI8AZWlBDo0kcJSy0/DwEX7AW hcGSbgExOFl6mZ4cWmYTHISQfFmNQ2i1lGKZR0TdM99AL9tTgAaKn5Q7xmyDL2RlreSr 113A== 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=ixN29Lj+cZsbbQ5/nDYH1DqI8TvSw6+TBe8HkhyxOT0VAi44chp4aml0obtuE7hnrt wbD6ivKQgkC084Xe5hvdst1XxpcCXqZQK1NQfESjlgmsMBJflZ9UIyibLUADk2gLYLE/ 7q7hSxAgUYQqv2WhKuZkdfwHd8uB+938YMSdEzZBQirMQTMo+wGFKKaRtl1gSGbwF0zV ki4nGow4ZbGNU04tpuTX5u6RSz9p71oYKxGXjI7Pb7jnkW3r3Ni6Ff0FRWqRELOoLs6z eOliS2yE2znncv0gcEId928ugQP8yrlHYtiFIdVYWt8bKu2Fvu23J6QY+uV8HoMLGs2Y wUdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GVhJALy3; 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-118793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h18-20020a170902f55200b001e0f5034e8esi721762plf.253.2024.03.26.03.29.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 03:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=GVhJALy3; 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-118793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118793-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F2DC2E23E9 for ; Tue, 26 Mar 2024 10:29:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5569874414; Tue, 26 Mar 2024 10:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="GVhJALy3" 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 173977351F; Tue, 26 Mar 2024 10:28:52 +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=1711448934; cv=none; b=MR1ZxjuMxL1jQVLUOKQqKvsBOkTmGXGdsrOL4CMSc8aFPdetajRxPOiZczIlVzRwnefMMNB31K4yx9x6qXSKuK9ItWiBJ0uzNgRsYdoR8x2u4jKrqpV3ZXbgwPJNHUIcI0kFy1HwNFnM0PROegsiczbfqY8aeU/RukNai3coF1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711448934; c=relaxed/simple; bh=6J7JyUtPwBv60XXPJt4Q+1DO8Rjs0n8T6C74CuTTjnI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M4HiGa8EIjXF4B39BVrNJLJM03RmMFS8MGjg/elCxHmcHh8uW5eYUVywTYw1oiq5LBcm95khITOtnGhH6hGxEg34nK6fpzTKdgxhtHSOCcdP1dMvzzf35OJdeMXyntiRX8h8G1M1cxEJ6wdZZRjZt6bkuOPT+Ys1DqxYccGuirw= 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=GVhJALy3; 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 42Q5jobo010518; Tue, 26 Mar 2024 10:28:47 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=GV hJALy3P4wfxiGqQlX4eU2HsJvLxPC2JaLv345cKXpxb5B3NvRFVxUfGd7cnuZ7uP MGgCWmYWwSOXe8ZJormO52D8eTbYoKwfqP7aK+f94LS3fuja/VVDZrBtQdByLBFL WN3drRQt/+m9/z3PO5nlYFRqMVXnVBWczX1tkqOfdED1IhfkC/Ckbaf3yWUXYeM7 DDygH1VbtDGv11hmjbtQJVJaxv1MTA5+EKFDmjpjRb52Xo814vThPAeu0RhOsQN8 rVdSyA+HnFW1+YQSD40idNCFRq90VGHeDfGlyK0SRmv4ceu3MLjQQdYi2XAMdpB2 JM0YZAmdVMKHCFpqZC1A== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x3rghrrxr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 10:28:47 +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 42QASkB1018557 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Mar 2024 10:28:46 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 03:28:40 -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 v17 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Tue, 26 Mar 2024 15:58:03 +0530 Message-ID: <20240326102809.2940123-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240326102809.2940123-1-quic_kriskura@quicinc.com> References: <20240326102809.2940123-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: gwdON_u-1AH6UFa1rEWPXhE6Wz7yN3Ug X-Proofpoint-ORIG-GUID: gwdON_u-1AH6UFa1rEWPXhE6Wz7yN3Ug 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_04,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 clxscore=1015 phishscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403260071 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