From patchwork Thu Feb 8 23:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 198655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp515883dyd; Thu, 8 Feb 2024 15:29:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVrw3eKIO7VhbQPV3NNmDhhkYz/4kAql6fNS/RFDax/QEUk6XGb8gVx4+ifbbp5aZxX/aHdlmkK9zzLkOEPfrE7hKgMXA== X-Google-Smtp-Source: AGHT+IE7wp1MK7zZbJw1ZqLbD45S6vsrnLgIh/vnkG82NmO4e2zi9Dzqd+nufO+nmJYx3SvqWgwO X-Received: by 2002:a05:6830:1458:b0:6dd:e1a4:17fb with SMTP id w24-20020a056830145800b006dde1a417fbmr1073345otp.38.1707434996254; Thu, 08 Feb 2024 15:29:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707434996; cv=pass; d=google.com; s=arc-20160816; b=yEg2InXQFxDvx23lxa+t8uXykF9/HU0cwDCyx/39V+5j1+xtd4iWZ4r9VKep+j07e9 Fz1MYuWa5XzqJWM3a3wGVmfkLshKH8+zDuGTba3Gr6P1LakvIgWwm4QRd4NEgOfZgkWe DcVQS/Lio+NiKLpMQgZqaEMbnye2QWXvcSQWT1f0OqwvM7zjlzLtBp/ydnqjuVqnyoz7 n8S8pv40/yDn+0DQkxEBoV2JAJhd5rLz9MXmc1e4gL3Ih2yajkWtEVDCLc4jzKehQwuk iN5jgC1vax5jgy6Tr2lK99mzIkjUXptK8zuvBDDfpHbZ/4rn065ILdEuXxL4m8EVjsZC 0tmQ== 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=v2ItLrNtk2j1QY1c2ABM7WgcR1ha0sOr3zVlmeNNouY=; fh=Fi0pWKvTIysr+rZVwpRfl9u+xx38ztf+vUsMWQHJyBY=; b=PCYFsUiAvocHYr5WzqG+Kk8mpWV/i7vJAfH7XUxiKVExTco9mPdjWqoIpbMtkBVupy I6ljUWsr1+TdPu13iv3GTpAfoqlZZbWuyAHPMJQjdMFSHlfLOZAhmJcvk4dsb1rzz9lg xSXg5nIAey2MFon7n4rfyelVzAWxNLyN/GWDX+LQeMyUnD4GfxJE27v7lKrCK9cw835z lvTwYpMOVGpoS3OE5IzPEsnHR9feK06ZqJJHT3bQnrW177slHTcxhJFaZS5mIHQRs42E /DE+uhMDsQkSCzk2dmVJ3P3t35zdMMc/hFo/B/ddlBmTB9JWab4k+13pbi3Z4Lp3uPMA xmcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=e24GPRU1; 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-58838-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58838-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCWCGvTDxWWU09UP4yT8HCsRI6wGibdy/XRbFq7vwSIcByFfINyUxmPAVTeb2JUMEzPfXNUFvU6ODTgHCgqpmHzCYIRlOQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 19-20020ac85713000000b0042c4a985c46si603032qtw.35.2024.02.08.15.29.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58838-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=e24GPRU1; 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-58838-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58838-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 08AAF1C21C23 for ; Thu, 8 Feb 2024 23:29:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27480612C4; Thu, 8 Feb 2024 23:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="e24GPRU1" 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 95F00535A1; Thu, 8 Feb 2024 23:14:46 +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=1707434090; cv=none; b=a+mfmy7H8C+yiz748NbgdLxAi9zXQP6bfS+PS5pqmpOfZ7+U8dmh2cyOL8RIfavt6/rxSPCU2iluy2dnfsV05hzBEybSwAlM5FwPfD7tmxaDPJQ6lq5vrTwfSJnja9k8RnZrTY6BLwo4AF0yA2Jl41jA61+jAuYICYRSH1Tdg5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434090; c=relaxed/simple; bh=httnPJJML5QlmnUl6L9g9SMmpTEhPWJw3rWiUQwkot4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aax8PThlSzFUvNWz9sBajgdpm9gKrPtZKUZHMdnnUx+Fpkr7WI20yJvsLrzIp9A+iIJXFlt0SIHSKP6+y//90ITayJqRLUaebvK5SSeZOoO012qwj5/2IakUe9GR6PSHvobkAuV0jmoafhV7B+2szmDbxaMsBQ8XjkD+Xbic2G8= 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=e24GPRU1; 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 418MlA5J031470; Thu, 8 Feb 2024 23:14:19 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=v2ItLrNtk2j1QY1c2ABM 7WgcR1ha0sOr3zVlmeNNouY=; b=e24GPRU1V4U6QFgGWVVKhW8vy3TgUPj0vLdR pelgFWziJfpruK8ipMubFs8eHrEgwFQTDUsM4gExPm/+mWBIKFdbxMBpmz0hThsa jH6X4v+0GkZAI4DpgI2fw25n3LyD6iVAnlca7O1owa2AjulBOkGUWC5ZQyRj+mNL k49iHOQ+t8Fb/V25LqxeJEuq2M0GEYz2Iy6sSvKRVhOgJFI+QwGJbWZx42JStH6r +C/OEZRmGox6MkmikYLERxqSiC0mwDj6Q0uDq5j9bIGJ5GnPm7inSPJNQEJNO8Aj VIgxe69+60s8Tpo7tJl6FaFUDQE5TuBIsBqOkZJE8/WHOk2bpA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4sns2aaq-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 NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 418NEI3o012202 (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 09/53] xhci: add helper that checks for unhandled events on a event ring Date: Thu, 8 Feb 2024 15:13:22 -0800 Message-ID: <20240208231406.27397-10-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 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: 2LjOZDT6qoQD_SNop_3nA5mBVBIiiktS X-Proofpoint-GUID: 2LjOZDT6qoQD_SNop_3nA5mBVBIiiktS 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 mlxscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 clxscore=1015 suspectscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402080131 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790375359046583069 X-GMAIL-MSGID: 1790375359046583069 From: Mathias Nyman Add unhandled_event_trb() that returns true in case xHC hardware has written new event trbs to the event ring that driver has not yet handled. Signed-off-by: Mathias Nyman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-ring.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 338b6fddedc3..48388bc16b24 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -113,6 +113,12 @@ static bool last_td_in_urb(struct xhci_td *td) return urb_priv->num_tds_done == urb_priv->num_tds; } +static bool unhandled_event_trb(struct xhci_ring *ring) +{ + return ((le32_to_cpu(ring->dequeue->event_cmd.flags) & TRB_CYCLE) == + ring->cycle_state); +} + static void inc_td_cnt(struct urb *urb) { struct urb_priv *urb_priv = urb->hcpriv; @@ -2923,9 +2929,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir) } event = ir->event_ring->dequeue; - /* Does the HC or OS own the TRB? */ - if ((le32_to_cpu(event->event_cmd.flags) & TRB_CYCLE) != - ir->event_ring->cycle_state) + + if (!unhandled_event_trb(ir->event_ring)) return 0; trace_xhci_handle_event(ir->event_ring, &event->generic);