From patchwork Tue Feb 13 00:53:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 200133 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp270142dyb; Mon, 12 Feb 2024 17:32:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/mG/bcM+Nl2tR+hvy/003HukpCGlimd1wCk1Flf3MGnbiMc5Q7yLgwgcOK6jPrx48dLl9EAhUtm0w9gm/5QLtJF0BhA== X-Google-Smtp-Source: AGHT+IECOB4x0SoaxUahhuK/+N0TelomXPnFIwnRtBROO6on2uHr8DdodYZXkyPsatQRU34R2LiT X-Received: by 2002:ac8:7c8b:0:b0:42c:72af:d9ce with SMTP id y11-20020ac87c8b000000b0042c72afd9cemr5229257qtv.64.1707787959133; Mon, 12 Feb 2024 17:32:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707787959; cv=pass; d=google.com; s=arc-20160816; b=0D0Qawrxxt001BR1FDcF7d9zDkkEl/zZBiQFcO6NqkoOdsGJPdseLilO3Sm/J3rVF3 bFx2DYoJViY92SWV5VjvpR3n0YvM6TyIX1drJjwa31jaLS2k6pHvNaS++nT0XjxidRj8 hO2QWqLzdLQBPTomYFw2ywROAhKIfsAMrJ5YrVrCWUmfqbEgvVV3lMjyNzteCT1T8ena 17xtXXzuM3PmdtHpw9O4VCmdE7pesKLu97n5DIIN8wy8+ap4PwPOalfCe1P82CT9oPVi EBPzv0seJU2Ax20tDB2hcYdMttc7nIEFvkBMU7OVZQMt8XBytOd1x1NEoCiWCjZdeKQ7 6BLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KLjeKKCPmPfKQrXevx6PEsBCLzPg435el7fcR46yWyc=; fh=ED3m9srEc/nrNxUQJK+hdad/O8pOBXb6dK3nJNYrYLw=; b=DZ6b7IxOAaNN2liRGJld/UjHSk0c9xPQxcVTg8CH/Ig4CbY7DzfnoEQjeh/1TxEdMd kv+nesOQdaq6eEKhdW/iHNdnNjgvyvpa2XvZpfm75QyaQFuv3aLatnuXk6wTSsq5Jb89 W9chlBHjRxazosW7YsSgoNv4c4HNmN65/oXzTe4WAcaRO8qjxcr7Ts0+62NGqIl/PNx9 8U7a3/qCnL+xUd06Ht01BkvrStK0mZqoPXNUg2H+y3OxSlwh3mWayfznY+hrXhlJlOfF agIINM31nYCOwVAvoJRWRmVyGYLasFbR0/AlZmw9cL4h5Y1x01BWG/LQALq3YCaJxnFK Z9kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DoBqXamO; 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-62797-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62797-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCVAMW5lgfDEFZS9OSECYxQbv9o4t0jRfFXziDXbN1zjk9zQ4VgFYAzaavJCxc5NLd7Sd4yiIFfUPJTvUkvqbB0NJaShxQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z17-20020ac87f91000000b0042c8093f2d8si1829137qtj.583.2024.02.12.17.32.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:32:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62797-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DoBqXamO; 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-62797-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62797-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 E858C1C23121 for ; Tue, 13 Feb 2024 01:32:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07FBF60BBF; Tue, 13 Feb 2024 00:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DoBqXamO" 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 F02C6374C5; Tue, 13 Feb 2024 00:54:57 +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=1707785700; cv=none; b=u0G04cc8sBG4BkKRerdtXqd+6FpSMpCHPBf3sNVGajjPY8e9wn3JPJMCBsdgs/m8Qxdpmbc1SeEUxwV+qWu3+tNtKLB/gUuqhOn/QyACb7ibvgbz6NEJd8uudvoG7bvIaLfU1IIJN1kxOHpiwn6Rz5bfD2T0t5P3BLULyHnFPpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785700; c=relaxed/simple; bh=Jk0LMWaa/SpQYHxNARX1Jnkq4LIW4HOuymWLQdv26ls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PzeJNzKeuIp1SF1qtMmY/SUULGF98aXEjR4TWWLPh+f2ahyjlqeYS2zDIMk01VLSpU7+R4GbCQeIOA4bgSpl4h7BCgyoiHMW5QdayM1HlT2u0CaKcT5D6hSs4U2+ndvRAJA0mgwz2kcbsQJPQ6nnq27HAkPTB7PsISuy3EhagiU= 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=DoBqXamO; 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 (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41D0sa51001435; Tue, 13 Feb 2024 00:54:36 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-type; s=qcppdkim1; bh=KLjeKKCPmPfKQrXevx6P EsBCLzPg435el7fcR46yWyc=; b=DoBqXamOhXervrR6deZ/k9rCaIFCIg92Xl6p gCVoBxWVXzoTQ7YuJQcVA98jQ/edMRm8CPCIt0VMG8nc5rtEP2ak/rBupifsUgJZ 1a5ck0QYeaADbl44D5N8QaRqrhWhyiCA6yQmpX2vVCp5Vq+Fx3KyJmSDEGYt59b2 3gj6Tx7N1UMtlTXgaLMcatSc6ttE7KBl5AiI+rqE5hGAwf1eroSB6HQydVx/mjbR g3Gyrd58CKfRodlC/6M1zMyTl1057igQZFB1k3WqSLGyUhRQq6aOWbUEaqoBRR+b Hsl6eOXzlG/txfOedMmNVNT+DviRGr9S9yiNbqhTQTKW9KHibg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w7s390kbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:36 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41D0sZmb031075 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:35 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 12 Feb 2024 16:54:34 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v15 08/50] xhci: Don't check if the event ring is valid before every event TRB Date: Mon, 12 Feb 2024 16:53:40 -0800 Message-ID: <20240213005422.3121-9-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240213005422.3121-1-quic_wcheng@quicinc.com> References: <20240213005422.3121-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: yprBD-P_vUWcNNinZbNpqAwESbsCnXXu X-Proofpoint-GUID: yprBD-P_vUWcNNinZbNpqAwESbsCnXXu 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-12_20,2024-02-12_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 spamscore=0 bulkscore=0 phishscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=476 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402130005 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790745467124389463 X-GMAIL-MSGID: 1790745467124389463 From: Mathias Nyman Check if the event ring exists and is valid once when the event handler is called, not before every individual event TRB. At this point the interrupter is valid, so no need to check that. Signed-off-by: Mathias Nyman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-ring.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 48388bc16b24..293239d8fab0 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2922,12 +2922,6 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir) union xhci_trb *event; u32 trb_type; - /* Event ring hasn't been allocated yet. */ - if (!ir || !ir->event_ring || !ir->event_ring->dequeue) { - xhci_err(xhci, "ERROR interrupter not ready\n"); - return -ENOMEM; - } - event = ir->event_ring->dequeue; if (!unhandled_event_trb(ir->event_ring)) @@ -3031,6 +3025,12 @@ static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir xhci_clear_interrupt_pending(xhci, ir); + /* Event ring hasn't been allocated yet. */ + if (!ir->event_ring || !ir->event_ring->dequeue) { + xhci_err(xhci, "ERROR interrupter event ring not ready\n"); + return -ENOMEM; + } + if (xhci->xhc_state & XHCI_STATE_DYING || xhci->xhc_state & XHCI_STATE_HALTED) { xhci_dbg(xhci, "xHCI dying, ignoring interrupt. Shouldn't IRQs be disabled?\n");