From patchwork Thu Feb 8 23:13:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 198699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp526082dyd; Thu, 8 Feb 2024 15:55:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuZg7VRgCWcSGhGpjeqUWM3FErFymD3300jX47z4IcpifVnFaERvQ5hW0r0UE9cqibqJkf/8KUwQRPaOVDbnPQEchkKw== X-Google-Smtp-Source: AGHT+IFSxSMcXT4rGxWqfxUe3v8DFOFWKpvUqvXc7tB4U7mScCNCRC04jMZPSwqEHEDKsJZpOMlD X-Received: by 2002:a17:90b:1d82:b0:296:5c1a:f681 with SMTP id pf2-20020a17090b1d8200b002965c1af681mr440242pjb.5.1707436506901; Thu, 08 Feb 2024 15:55:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707436506; cv=pass; d=google.com; s=arc-20160816; b=kCJlCrIAh61GhzSauFJZkzP3sWLptKr/Qv0L6REXF/qNKUowwy930e/gL6wQlvQNk2 stKzejOR13SZtI/8+XlqFGs8yIh/1W1ZTxwtDhI0SMjblHkioj9Se6IGWdVhZPTCgksV xK+o9Bojjj3H8aaqhTMkCmXykYG0A54Ay1KUvRolBhoTk7IgLrqyqruMC5cnfpy5u50P /I64h0/9hrWk9npoUD3/tRVWQB+l25Lt9poMa41yHKxP0EqSToHzamakseI44WI8YJSS kms8zyGlRKEjhI5kiAM8RuY4BYqKvOTGvlbjUUvVofZ5ye5D6NzWrlK7vx+K8GNLCTxZ w8Og== 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=xzOBrfDY1od+4Hb15JRtAcSYTxJyZa8TNxYwb0Lo8t0=; fh=HgBqiG/70YChkBG8xhlsoVblfECXWSo3di5On+x9HHw=; b=YSueTwhTu2c988ealdsVZIX7dXbD7dJDwDKtJm4V8b8LtRk/pVLWgn2iNIiojCPreT /RVcBVx98xRkOUCVxlWa/E054dHlgew2WVdMKZEEeKfXhbRmuOYhslyxth3PEQhXisR8 NgNKKZzwv4QTrt9nuqanRelyCNUPYSxWuc7g8gdaTVh8S6GlfrTGBJJyF7mhEwzfIoYu Yx82xcGElY+ORgopaUe/ev2HJh12EPdRqWVQdoaKUyoKL/wKyD3IDPLFLkXpFOP/BJp5 weu7QniJGZaATYJHBx59n12TzHgSL9ZFJPL19noZ164StZghjkNBTh6ME8DLNVzCkGeb ICRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EVKI0Bra; 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-58825-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58825-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCWuTZTwpAStA42gyGR4JemD+zv9x61C2/K6gTXF/z35e97RbD1GbeCONBejcSoDRsxdvf58ae/zrv6C07MY8yw7O91s6w== 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.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:55:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58825-ouuuleilei=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=EVKI0Bra; 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-58825-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58825-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B1393B2D188 for ; Thu, 8 Feb 2024 23:29:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14A7660DFB; Thu, 8 Feb 2024 23:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EVKI0Bra" 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 7C53850A8F; Thu, 8 Feb 2024 23:14:38 +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=1707434082; cv=none; b=eM2eUFrkoW+rwp74cRF8UGS5SNukzGs5NEf1XJBLWuH8/GpkS5556Ug2eaJMraroHWmZkAkYCcWIt1b46B9GoSkxNfCl25a99Z4XC2a1XPs7rjTZ8isQ3saCfDHhENn+WwgUzAXUXygva5DLkSTksaof0JmE0CTEEvyAXF9fQb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434082; c=relaxed/simple; bh=4wdCwc+iVxrd0/Vexs840M3pCv76BsAs/d8m7vV44Kw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WiobqOVGMp4kUOKEOq1L4lrfYvSyYb8Tz+EOU4RewHySV3KTSziLN1Wrh+LzV+ZNTdaahkQE3YlN5Jy0+MsqmdVrpO25tXNnNmpG8ylPYn80HIaJiab0yNcPj6yeq2l/M9+ae94y89Vf9n4pygzpL5EPH1EdDAldKqRUCXMA8Tg= 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=EVKI0Bra; 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 418K2eGA004633; Thu, 8 Feb 2024 23:14:21 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=xzOBrfDY1od+4Hb15JRt AcSYTxJyZa8TNxYwb0Lo8t0=; b=EVKI0BrasVNYMX1TKA1W/yRoE93YVVFbSQ3/ nVFcMPi427e/3Vw5F+d+g7SW1HOCAiDTpVZs+6Lcu9RJeT1m4RhTFpl1/+1yfcnF 4NH256cviux1kihofe3dQwnJr2S9tUdjszzosTR13Lu4sCWkXiBZ/AapkMbOX7Am i55bm1a+VAJZbreWYYcrqWXLM8jlp/2d2MqXbammCERCG+vmIv29WnSiHCsS2hb5 YsLgb2LKJQnjj1NreKTk86cGXIVMbIs93302qafVFETsKa84C9f3ywUvPCve2vK2 M4U141nQKFYdpsUQmPgL57dv8i5XhRp9aBEn6uB1PnOk+zVDYw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4frwujtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 23:14:20 +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 418NEJsL009175 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Feb 2024 23:14:19 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:19 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v14 14/53] usb: host: xhci: Repurpose event handler for skipping interrupter events Date: Thu, 8 Feb 2024 15:13:27 -0800 Message-ID: <20240208231406.27397-15-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: AC6ddKv74oJRJjEdwF54M0Zcdw4LlBzb X-Proofpoint-GUID: AC6ddKv74oJRJjEdwF54M0Zcdw4LlBzb 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 impostorscore=0 malwarescore=0 spamscore=0 suspectscore=0 bulkscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=762 adultscore=0 priorityscore=1501 mlxscore=0 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: 1790376942757999700 X-GMAIL-MSGID: 1790376942757999700 Depending on the interrupter use case, the OS may only be used to handle the interrupter event ring clean up. In these scenarios, event TRBs don't need to be handled by the OS, so introduce an xhci interrupter flag to tag if the events from an interrupter needs to be handled or not. Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-ring.c | 17 +++++++++++++---- drivers/usb/host/xhci.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 6ef95f67970a..958d6fd6d156 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2912,14 +2912,22 @@ static int handle_tx_event(struct xhci_hcd *xhci, } /* - * This function handles one OS-owned event on the event ring. It may drop - * xhci->lock between event processing (e.g. to pass up port status changes). + * This function handles one OS-owned event on the event ring, or ignores one event + * on interrupters which are non-OS owned. It may drop xhci->lock between event + * processing (e.g. to pass up port status changes). */ static int xhci_handle_event_trb(struct xhci_hcd *xhci, struct xhci_interrupter *ir, union xhci_trb *event) { u32 trb_type; + /* + * Some interrupters do not need to handle event TRBs, as they may be + * managed by another entity, but rely on the OS to clean up. + */ + if (ir->skip_events) + return 0; + trace_xhci_handle_event(ir->event_ring, &event->generic); /* @@ -3008,8 +3016,9 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, } /* - * Handle all OS-owned events on an interrupter event ring. It may drop - * and reaquire xhci->lock between event processing. + * Handle all OS-owned events on an interrupter event ring, or skip pending events + * for non OS owned interrupter event ring. It may drop and reaquire xhci->lock + * between event processing. */ static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir) { diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 7c2481838f79..ad9d93c645ad 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1432,6 +1432,7 @@ struct xhci_interrupter { struct xhci_intr_reg __iomem *ir_set; unsigned int intr_num; bool ip_autoclear; + bool skip_events; u32 isoc_bei_interval; /* For interrupter registers save and restore over suspend/resume */ u32 s3_irq_pending;