From patchwork Fri Feb 16 00:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krishna Kurapati X-Patchwork-Id: 201859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp223487dyb; Thu, 15 Feb 2024 17:04:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXIr8eTK7Uaamm9MK5xBzJhi223uwb9JVdNBXc3USULCw2pnhzpUIWh2Lc9U86BymdlQGU5egOHXdEtv7Gj4mN/Yd/iog== X-Google-Smtp-Source: AGHT+IF1WOkpU3B6JibAJVN6oNf5f/BcfUVU+XL4hvtDFNwZjTwO2Ae8LybEFrIBkWKTMI2Q2s/L X-Received: by 2002:ae9:e415:0:b0:787:3597:f7f1 with SMTP id q21-20020ae9e415000000b007873597f7f1mr3543281qkc.8.1708045480448; Thu, 15 Feb 2024 17:04:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708045480; cv=pass; d=google.com; s=arc-20160816; b=WwZG//zIkpq02is+LHB9j8lPw0lL+ki0RySi4Bs6QANBdLyhNR2YLzfxV6M1+LE056 CyyjmpmA00i1cAgKlCpTdN9C6YAB6U4Jp/T9y/RO/N8DzZYEcEgLlbHZTE+OSLZpccYg h0GrN44v8fVEbQ2j75XS3ExnX1VERMAVrMLf7YawM2FrHOuQNdDCdJkls3fH9j4amykj DKxbV8jNNRTOjRPOSuc0kbwR/z1A4IKOCM6vi77n9uu2ZL8mh1IDTLR3VuDY2PVBxUHD stlXADRo9sLWKm4WhQFgYz69lH3WE1vHXwJAPxm2SXydfgpO4ZkrCMmpvzMde3o1077A gwVQ== 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=klQ0e5yd37YolVhl5A0HVZyQxyg020LgvEn0rWDlci8=; fh=3z8MJZ0gcLl6Gv/MTgV5Y56yRgI3zFu1i9ViDV47Ve4=; b=nJoQAjbX4We69DLLJ8rK87PL5HtlCbd6ivyLshik1EjamhJr1HLVy/AdpQEQi0cVXE 7UjM9okKoLUUdXp7ZRCJB0kYip+yileOqznK4eMqWYbwrlfnblJUD+5a6Qvc0frnm2Cx shGb3ga+TmqxU590/3QVjVBfqe2Pt+KWCeyr3tjA7YkAhhl0PxZ+ITx9RmwHwvou+N5x 7PqQiQ8LfAL7Si69tQV3BPPa+qP7Ubsp9KPHHDMH7LDV6b4+3i89rNP1asVMFMK0Wo8T +FelA9GTrBH9sJ/PzoS2a/pAUdf4DApnIBiE1GlCCSaiOtD0bm1py3YbdwO4wp/8KecW eCBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lRZnoth0; 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-67922-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67922-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t12-20020a05620a450c00b007871d3bfd7bsi3168992qkp.507.2024.02.15.17.04.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 17:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67922-ouuuleilei=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=lRZnoth0; 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-67922-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67922-ouuuleilei=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 2EF541C203BF for ; Fri, 16 Feb 2024 01:04:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3C4D17BA6; Fri, 16 Feb 2024 00:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lRZnoth0" 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 9073F14AB0; Fri, 16 Feb 2024 00:58:50 +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=1708045132; cv=none; b=giyk+ylBzkYHjx7bXdtgOkH9jgnJyjlCfxPck0uw8ZFmjOCx3W3oLLwDwj388WRZbAkPVSl/+Zdv3krSAV02qC4y9A5V66PHLzhhHjpZoGD/kvpEOAeTBMoh0F2EwPm5yUiTBdw4bu9f2aNv3cP5bDOhh9MpSWPPVaMyIXM62DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708045132; c=relaxed/simple; bh=YLem1hOPjiqPuildLMItrfLCmdfkUWy0HKaxpIG+JAg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NAw9C44cHFDo96UrV4UKJK1N/eC1FVo51Io/Pntb0Nosn7Cd+1gub5IMujQxFB6KAvRudhh05fzdxGz2phTZm2GKfB4D9EjC/DL8H39mh4PiyfQ8BefrbdSSeGhXZZMT36trBWpLYJurx+7Lk62y/JwDIjBQk2dpswbWmFi2vPY= 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=lRZnoth0; 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 (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41FLhM76029346; Fri, 16 Feb 2024 00:58:44 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=klQ0e5yd37YolVhl5A0HVZyQxyg020LgvEn0rWDlci8=; b=lR Znoth0Zm8FCDvlAOt6DgmcANGax/4pnG7xhkZ2pObzsfqg0RZkZ8ffDNTZ3L7wnY WkAYbZkYjRhJeoXWCN4UQvlygp49JjO8MQfduxIReq0m4FjouMIMJOJAUoTQOkep Wc/ArPWpHkopDMh1poyCnQZmoRxDAmP7/DineYv/n1aQYkGtRzPjZO/OfLkedQ/C aC5o6d+O5pu6ppEIw7AX+8X/B+6jFf80/SmjGRpvUpp9gBlrMFr3BLYHfEQC6ev6 tBuoWJ1qaS9p0ygAkzPRE0ObNHSoW+L7FvJzOQPpWL/LJjP7YOj8aS9DY03cJKVD vUe+M09iL6TZ2vLkgboA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9435umgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 00:58:44 +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 41G0wVdC029162 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 00:58:31 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; Thu, 15 Feb 2024 16:58:26 -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 v15 3/9] usb: dwc3: core: Skip setting event buffers for host only controllers Date: Fri, 16 Feb 2024 06:27:50 +0530 Message-ID: <20240216005756.762712-4-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216005756.762712-1-quic_kriskura@quicinc.com> References: <20240216005756.762712-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 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: VBUlPRW4X_nUCMmItRi0c-Baib01axC2 X-Proofpoint-ORIG-GUID: VBUlPRW4X_nUCMmItRi0c-Baib01axC2 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-02-15_24,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160006 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791015497536526235 X-GMAIL-MSGID: 1791015497536526235 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 965eaad195fb..c47fec10b231 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;