From patchwork Fri Feb 16 03:58: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: 201888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp287170dyb; Thu, 15 Feb 2024 20:12:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUX1J+zXElLzqnHavyBsIb0lrmrMyoFEHXnHOMLNvK6QKayn/8CWj4nhzpboVcEh6gdPUuiB6rNNZ+K64Of7bRWi2qiBw== X-Google-Smtp-Source: AGHT+IHzZpgtnvZgR8SWNjFE0/t1cqiaLEdUAZsfGwbDzIH2PhbGyqTA4qRoURopiIRdELNp9rtr X-Received: by 2002:ac8:5e52:0:b0:42d:bf79:52f with SMTP id i18-20020ac85e52000000b0042dbf79052fmr5731347qtx.48.1708056766364; Thu, 15 Feb 2024 20:12:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708056766; cv=pass; d=google.com; s=arc-20160816; b=O2VZFoj0stV+Y5C63gQOQHc7CtvcCyCRRLVSRTLfTe3GsOy36LtxVd0PI6iIA/fctp 67J/MqgR++5/+RsS5641gVB+Gs8yxKerm+38wkdE05qmKRZtJ6HQB6pEf1ck7y/SKup6 Wok4gTTpS6kZXqDYROYfqI0XmQgS3Uc+DxfRIRIYolfbYfN0VAwtm8cWCV9AeqwvGuVc EYeysYCI0fZ1juSQHXVBCcnJvgBVh76lCHgc6VTL1d5V2+kDp65KJ1cflKj495YN3gv6 /4NX9Bwyi8o9rc9PEQvTUvuH0I+kB2g2XaA+w8rzo6bOhdqqVYsQmfSGdYsSfAT1oxQd txsA== 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=J6PqM7y/z1h8FCZqkEAQKxaiOCjo8iRGi6WtYbn5R9E=; fh=Dz/sGw+9lzNFrkoqVn+ZLx/Xi4dC8owgH35eQDavKgI=; b=Ecm9eY2AqlyaefZPcsxcI3/G26jL5x7nBc5cbE3XbvAA2kGPa8sE6P87Cm+v5icCE3 RgZ8XvQGuKXpWQ3YkUtDX4+xmA6to7OwASdqwKkDJ1wuMLmIVFZnLntFJszwVFw5zhw6 Q4gMoj3DQqTi90jotp1DRnyxB6hutqvFCIMAzYPnl48tvQjql/uZNU93OrlDxjS8uWwH UFyPGbyghwvdXvx0GpM0O/fyJDzFMUd00jwCcQ+F8sKXz5nFwlNp70n1K89nwScCKBbQ KQfsgFQfDssJ7P+XzrARqv24Kq7LONXVu1neHuIpN/bnUhGnY1VKeEWZREwKQ/SzbOzT jGlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=k09hN7aq; 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-68020-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68020-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 o13-20020a05622a138d00b0042c28da72e2si3292917qtk.341.2024.02.15.20.12.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:12:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68020-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=k09hN7aq; 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-68020-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68020-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 24D9A1C22486 for ; Fri, 16 Feb 2024 04:12:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 448064CE02; Fri, 16 Feb 2024 04:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="k09hN7aq" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 B043A14A99; Fri, 16 Feb 2024 03:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056003; cv=none; b=qD/QB7PQTLK/m528AI88C9hZlD2jAil38TDuZieDkXr4wVpD2RgrS+FMpj7JgW7+V0TQJQJEVHsd4xIAm3jqb72P6leCUcjRA+NmRl++bz5ewBBFTuKwVXXbkNqBO+JWO672wBaigKj7cmzaaqM7xS5fbQdMkD4m415C0gtMXHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708056003; c=relaxed/simple; bh=rGBI8/1xyEocU+KperBTW20R1SZDCmNOw8fTHGOWAOo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q6JE2JT1Szp43LRAId1rl/2kaHi1wk/Lvq+tdnP3W4zMt2TfqftHcZqdYR5VTikbUD5jScXkAwkv/wRVUyKDvSCW1aUEnbFGbbWoOjKdhxNG78FCQpCC4v1DsknbnPHPkn77vCooy0mH+XwnjunwX2sngWF/XA48tAGDHRTFSTE= 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=k09hN7aq; arc=none smtp.client-ip=205.220.168.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 (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41G3qVgo013853; Fri, 16 Feb 2024 03:59: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=J6PqM7y/z1h8FCZqkEAQ KxaiOCjo8iRGi6WtYbn5R9E=; b=k09hN7aqd3jeqQciEIpXcuRWjb0tmQ+ubApe Ohria9N39d/BAZMEvWxZR0DN1bLO1fyFgrvCWkoVo5NhMUFYB+YTi9mGbrzcjpAV kIFOj7DMqp6Ji2hlVKRVVpYh3tqSyUjRD4jsemVsFbGY5gyzNoSnk/N3W5ZWjqui oSJYAl76PQm5xZKKqBwaByOU3ycv8Dq2KZmbzcv8eRSBXaWd1hn58iHZ1SxgQEiX KkPbzOGzkCTM7WboFQi/XLZ9JW/MY1cbaHk4C2j11wZ3ftLrWZspHWGdfnlsx4aj sDQ8fk2pyP9do2QH7Orhj/y6zAY7SD2AXB/weugPPePEygn1gA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9e4h2p19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:35 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41G3xZgD014647 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59: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; Thu, 15 Feb 2024 19:59:34 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v16 07/50] xhci: add helper that checks for unhandled events on a event ring Date: Thu, 15 Feb 2024 19:58:40 -0800 Message-ID: <20240216035923.23392-8-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240216035923.23392-1-quic_wcheng@quicinc.com> References: <20240216035923.23392-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: nalasex01a.na.qualcomm.com (10.47.209.196) 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-GUID: oN3VWIRrsr5aN2obPndp3NIzUOQjTBCr X-Proofpoint-ORIG-GUID: oN3VWIRrsr5aN2obPndp3NIzUOQjTBCr 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-16_03,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 impostorscore=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160031 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791027331568872335 X-GMAIL-MSGID: 1791027331568872335 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. Change-Id: I0d60c9155bad0a72bcb0c7f33f95013e3b1db709 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 ad008a5abc81..275164dc449d 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; @@ -2973,9 +2979,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);