From patchwork Wed Oct 4 16:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Kurapati X-Patchwork-Id: 148427 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp274268vqb; Wed, 4 Oct 2023 10:01:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmR//fChryctIF9Q+825BCdMMnc4CXWxJuee2UMaB+7YNIT9GsnQPac1psgKakL+IrQyok X-Received: by 2002:a05:6a21:614:b0:15d:684d:f518 with SMTP id ll20-20020a056a21061400b0015d684df518mr2680533pzb.26.1696438892951; Wed, 04 Oct 2023 10:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696438892; cv=none; d=google.com; s=arc-20160816; b=vLySFKFIiVbCVqmZkHa6U2959+/Mi4jGo4rdctJAgiR3aAbZIVGlkKuHvGFFg90Azs aSjHYRJfjNXMicNYSX4GCSAjG9v6kuymXL3XknEoX0XTv/QrQWBQl1kXwa9siZkeCXy4 c8SlMDLZ2imu0cuP8Bflt+HuT+664dIL/7muv/7ao5fvjO8SUj1BXvC6seY5B9vUz0wv a9l10QwbrtI2R6jvLwN/p/EZ71C7oM9gwAmIv1GJLNJYjupf3w68mF3WN1F7DYeL6Z0a 58C73jLsCyfWHXfiCwAA+UGKCRfSUNMYWAsvY03QN9z7IJgmyLhF9vIPdzE16mufrohB 2A5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9ALIUoz1vkM6MhoUdR9nJ++NWyOo4YGcWioNI82djYU=; fh=2no/LIScGOHq97r8tJeznZi4QNCPpbTntaTYBU0/+fs=; b=ax09dqU17quoTumwFZwNzP2/gChgdbyB+3j2XIwn7tc1UqriYFQMZlvhL7kh7GClyJ pJpSlnIem7MSRynSBtePEvt6XDyS1Ok3JIJuZyx5fb9ZAmUdckxZEb8dRFJgwGLPzW28 s8FtyepS0L/uTktriiCSLJEQ6opcjuTwYKw4mP9X9iQa7swfgD6X9Hm1eIBMm/2TSZvo SCliFA1ZDfqaYhmpvvD/h4Kziu6T91UoYeYUABYlBAqEP4NcaADFaQy9q6WdhsqqGISm J/WtmcAMws+ZltFUxrntyR7ShLtWgji9bXrXSqDH/rMgQPryaly5eCpUjQimy+kvdtzg uyXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BHESrBFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id d11-20020a056a00198b00b0068fe8cac913si4127869pfl.324.2023.10.04.10.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 10:01:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BHESrBFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6852580845A9; Wed, 4 Oct 2023 10:00:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243564AbjJDRAE (ORCPT + 19 others); Wed, 4 Oct 2023 13:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243555AbjJDQ75 (ORCPT ); Wed, 4 Oct 2023 12:59:57 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFCCBD; Wed, 4 Oct 2023 09:59:53 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 394FFpCM002355; Wed, 4 Oct 2023 16:59:43 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=9ALIUoz1vkM6MhoUdR9nJ++NWyOo4YGcWioNI82djYU=; b=BHESrBFtrLR1GyZA4Q6wWxsFFcGwy5dv8haL4bg8L9EMu/2rVtyDyp7CjG8A4lB024Rn jBh3UE0AjYGS33bny1SOv4W/6pFGMyi5LKvUHF3uxHQlz0k73SpKzp3EDuMUqp/k/D6Z 9ME9X9M877z4lJfU7qDYNypcj1vSJJ+YIRWqwpyJCGFKfRdaS25EbQPmYDrz+fWH9bEy V2fd08Unlx5rpflrWYVLXcRQ3u6LeypLgJrKMmQ2MasXJmZ6MlZSx1nw/i7U94m4JAvo Wf8WuldyesEwKpRWDZpyvei1N38FR5Uf7DkvDiFlUdbGxAtLOBavBDAogFur4RT9+wuf 1g== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tghsjumxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 16:59:43 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 394Gxg43032102 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Oct 2023 16:59:42 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.36; Wed, 4 Oct 2023 09:59:38 -0700 From: Krishna Kurapati To: Thinh Nguyen , Greg Kroah-Hartman , Bjorn Andersson CC: , , , , , Krishna Kurapati , "Johan Hovold" Subject: [PATCH v12 2/3] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Wed, 4 Oct 2023 22:29:21 +0530 Message-ID: <20231004165922.25642-3-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231004165922.25642-1-quic_kriskura@quicinc.com> References: <20231004165922.25642-1-quic_kriskura@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: yGfWHI3jeTDEvFlGisQeJGni3rfGCBFv X-Proofpoint-ORIG-GUID: yGfWHI3jeTDEvFlGisQeJGni3rfGCBFv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_08,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 mlxlogscore=890 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1011 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040123 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 10:00:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778845108299859359 X-GMAIL-MSGID: 1778845108299859359 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 --- 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 d7c5669ebd06..3e507e4cc542 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;