Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp606795rdb; Thu, 8 Feb 2024 15:55:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2DxyKkb0xAdhphu/nQqHV8XV/DVceLx0TPJofInQLy62nRqEiCXym6xzGLdpjAOszWLYo X-Received: by 2002:a17:90b:906:b0:290:2e08:74f1 with SMTP id bo6-20020a17090b090600b002902e0874f1mr920634pjb.21.1707436536808; Thu, 08 Feb 2024 15:55:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707436536; cv=pass; d=google.com; s=arc-20160816; b=nL9b41kvHDaesOQUS/t87nD32C33WEKH03dDPAnL3qnbbQLrS5+vESRuWnaYqdOOcx 7ssLMU0I0cz8SlGZ4L/J8Mvku9XyMndWoS5V+hblJ7btjhUKJ7cbUHwrnqD1oVDPmZ6I itcHpS8vBilRZ4rHEPCjU3CCkjYXlg9YJhdQH5+0kxd+S2aQnsAuUwBk5uX2wkXDMjCV kJxEQxSlT3FagtLxGII+KhBdkzkbdgbLEt4HTghz4jE/Wd44oElSoCK6f0J7GhBLZ1Gr VbSv4ctwERYQaDqUZ8CjoeHCnu0PzZP4QVllggAL6o9tF8Nt3kViv/nNUA57cAS4hDOf fuug== 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=N0RqZh5Uvj8HVwGdIx1CEYpeVB7x9RDT5JDDE9haTco=; b=Z06aLry/521hFq+CJ3dWxkPyGVMarUc9QPB6+uP/EYfFQko7J/0CWYlJvHbXpg8oYk Htj23mISbcl57SlkjHuqps++9O7MMvj6wHKhatx5cyMTmXFwgV2K6KTj8q5QWhpK7OhB yFdklNoFsM3knFjJBF+R8vEkr0fE3DjeH5Q9v846aFRGESwtdXXt8QeEQQIfO5/DrZju k0Jh5BwWiUYQymXuMembnBOGf9Mxj++LD27EdHxwsylijvpQOFQy48+gSYcpKSnRsPfn YwvXc5yLXolF0T0w5tOMPvWS3NdkyZFGOUs0Tjp9sky2251ta6aC3uRUN8upIBz9kFxP J69Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eRIdNiTm; 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-58833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCUJTrIylkCiYclmXpEekKte0T4v4W2QvFwjEbyWNXVopK5KhwwnchRUvCQfFpBGEQsiCCqUylgm6KqK9kD3Yppg6W/bRt2TXXsqaAHi8g== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lk16-20020a17090b33d000b002931f778063si590161pjb.67.2024.02.08.15.55.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58833-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=eRIdNiTm; 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-58833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58833-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 1A07DB2679C for ; Thu, 8 Feb 2024 23:27:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45CA0604DF; Thu, 8 Feb 2024 23:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="eRIdNiTm" 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 3EF345026B; Thu, 8 Feb 2024 23:14:42 +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=1707434086; cv=none; b=Sc5HlLA9deFZ1nclbBQl3AvV6VdXXmCV3yTyFGgaFLAMowohZNnRN2ZbD/PXER4CC7ri5P7CoQMFq//e9uycDhuaZZg8CcwwnOVxSyzdi/CGyFq5SPPKImKPT5YiikJKiWtKMd4Y2D6WdPLP2vvHenSIiKrjpHEC2rUcPJ2SWIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434086; c=relaxed/simple; bh=Jk0LMWaa/SpQYHxNARX1Jnkq4LIW4HOuymWLQdv26ls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fp913WSRaSY/blxhXeFN35CE7p0SgcXfUFLdKMENTvUcUehq1Vp9TzYwsJEfI78/cWQbqPSR3WGH6C0iMrcIWDEfgAEH9+Igu5ZOEpkbZM6KnUAkHgeCaUnfvq643PV6HMsU3CkdAjogRqc/ahQ0YCBW/Po13xkNXlvouk0XGec= 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=eRIdNiTm; 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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 418KFtpA005718; Thu, 8 Feb 2024 23:14:20 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=eRIdNiTmMl6+jbowa4xC8fs7fbsBMAPyjJ2Q 9/+UdM1KNgJ537SBDdDQpxgtuYWWXYFM2wu2Bdm86mg3SuWUv1MmuGER2Xr8GdPM o6sA0O9DhxAaXeP0b88hc7IW9bL+badHvp8z2FCw2jYwvHLUOopBHzoUfPjJKDXd RtKVs7Nn951/fwcNfqtKsSAn0y53Zgp7n2E2fqLFu0e5F+nDZWtwnQW/+pdUiT/t AiFJ5ft2nBhqSLb+AkrSEROcnk7IYDwzr56zXXZlIUiVKKILjnTNWNWe5fTYJFur a6mINJpToY53LJOWzz9emGub5sPsmWFbt9dhggP98Hrg+InJow== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4hhkbaj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 23:14:19 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 418NEIdp005532 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Feb 2024 23:14:18 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; Thu, 8 Feb 2024 15:14:18 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v14 10/53] xhci: Don't check if the event ring is valid before every event TRB Date: Thu, 8 Feb 2024 15:13:23 -0800 Message-ID: <20240208231406.27397-11-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240208231406.27397-1-quic_wcheng@quicinc.com> References: <20240208231406.27397-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 Content-Type: text/plain X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) 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: 93zJEfuOBtSwavi2uQlPONvU6kF3CJUY X-Proofpoint-GUID: 93zJEfuOBtSwavi2uQlPONvU6kF3CJUY 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-08_11,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=477 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402080131 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");