Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1436866rdb; Fri, 16 Feb 2024 16:38:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBhitCc1xOHwinJ9wUODThch2nbnIf/B1tXsP6xfuTlMPtfjKqlmI6gg8FAOTO67WmXgaAH31iLLYkBgCJvxwmv37qvNyqCmtm6q0KzQ== X-Google-Smtp-Source: AGHT+IEuJQ9y2yIcn/Y9Fe9slENTyGaYEp3Pv/dhFLUl3kqhnGHFUvKMUfoW3SHXSKO2dwZSGxvX X-Received: by 2002:a17:902:eccb:b0:1d8:deb5:3390 with SMTP id a11-20020a170902eccb00b001d8deb53390mr8327905plh.42.1708130332457; Fri, 16 Feb 2024 16:38:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708130332; cv=pass; d=google.com; s=arc-20160816; b=08B0A+U6xqNFF7jmkgLQNLWPMwlb4lldooKx06UuG8St2uF125smVmIDABi2yUyzvx sHGtzBigqYyvNQWi0f5BB/MdW//IQpoYzrZkEa5xN0KJUlwPv1QzK9N5H72JQolUY+zn 4z+Det9JACOQq8MS7Tv3JtZLhdHLtOo4rI82e7QGSEG+xwP7WXZVKrtO9EsUkSmKnTI9 G96NXDA8ZAW6ydVmw2baYwZvBQAm2D10sfhT3/osr49x0QLbntoYOlsQ3d9fdSIaoxe7 da5y7LiK/fSvcvYK+s7IdvQC/jTHupzWIoKHtPZQMvca0sF3fgYQTjlMjpSIEoBGlgID lxJA== 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=cqTaKTUFscXB8XSt8ayCbJtdywCONdL1JGnM+W67clM=; fh=Dz/sGw+9lzNFrkoqVn+ZLx/Xi4dC8owgH35eQDavKgI=; b=kLyPL2gsn3e8X37/yMIN163EL/O8zBXb5dXoWvQHrg/gf71oX+cpVM0j/UwIISt6DF UwJUOhZxIjO+rp+jNt4D55V5T82O4DZTZ+dAEPAThB/kj0aOCiKuf68ahCpnIYDAaKr8 p28cKt3YmZMaaazkuqfgzTRSszsRlMCbrhzr7n7agSBQjxUZ0cgU/WUs3oXTpc9AnGCE RnI740RFy4OlKEWaXIsnNzl9lKu7OvdaBZS8K6CdSajPtkWjmhCDuYl88RzqkLid+6mv g8kCsbPnaGz7csgVx7e/w+QoFxrHFGD0LabkPmuvhhaIBKHkeaIT7rSINLC0BtMGt7fi 3/qA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kWuaJ+ib; 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-69554-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69554-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x7-20020a170902a38700b001da2a3e4b27si625667pla.294.2024.02.16.16.38.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:38:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69554-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=kWuaJ+ib; 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-69554-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69554-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 36F2CB27A84 for ; Sat, 17 Feb 2024 00:21:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B445279928; Sat, 17 Feb 2024 00:11:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="kWuaJ+ib" 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 888E050A62; Sat, 17 Feb 2024 00:11:00 +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=1708128663; cv=none; b=WIxqv1MDuftdNFN22/EzTjrGtlOUUC5LvS6AMX9dYGTZkulAKNikYfGjoHWezrLNy6k2c9E4DZmNYG1/fo99TSnqmv0GHZZW8InRsRnfCUxYF5lbtaSyCGoPbGCwPyHTdR7w54naWfVEmj1EytNQ3SE6btNJQTyashq3N7rYVLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128663; c=relaxed/simple; bh=P5mG2b1ed1qDhA71qq1qwIsqVAqNsGaiBcpzVmRr/Ms=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XOvQC3lwe0wzX6djJEOhgsWJfv+t0KW8NExXgnqv4anLeZzPAhI8uveTBo/rk1/vkNFb1EskMoiFDPdWYomOtTnhvFkvJoBSqU/XcSTyQwQo+63HC0lFA71agta5CkGBaxvqwlOltwE7ONxced8mA/7e353/WFofoNYDK72UmPg= 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=kWuaJ+ib; 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41GNQWXA016004; Sat, 17 Feb 2024 00:10:32 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=cqTaKTUFscXB8XSt8ayC bJtdywCONdL1JGnM+W67clM=; b=kWuaJ+ib80Ydy5D0Kefn/eMWQuvqxbvSzWNh djW3h9mw1ZMAoTzxnH/Q3CiKCnly8k5ASvlh7MHiRXWy9MLgtdiN3mK3ImIxY7uW 0LAVat9tGUmoapJgL2v1jQHsSgm+pLl6lPZnjiSUXG/yKkdHDfJ3D/bsCOtaIS4P fcAZYeCDRePd3xWcPiSXfFvvCAptW1sKcZTPIIhEpqm+RCUcV2OTdd9FZs8GVrMg +hkH0daz5RErAf66UJgiC7QUg4kb8dVMbOjr60z5ya0g53OdAA+NmhsSIc23aCaC +LBcrVSip5ZgOnOiGVJTKwUllk8Lvtzf07iJvrx8tUCkcPGppA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9qbc38xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:32 +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 41H0AVji012877 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:31 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; Fri, 16 Feb 2024 16:10:30 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v17 04/51] xhci: remove unnecessary event_ring_deq parameter from xhci_handle_event() Date: Fri, 16 Feb 2024 16:09:30 -0800 Message-ID: <20240217001017.29969-5-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240217001017.29969-1-quic_wcheng@quicinc.com> References: <20240217001017.29969-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: 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: xmkx-tP4nqUAymj5u3osL7dKv6XXPFrC X-Proofpoint-ORIG-GUID: xmkx-tP4nqUAymj5u3osL7dKv6XXPFrC 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_23,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 spamscore=0 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160189 From: Mathias Nyman The event_ring_deq parameter is used to check if the event ring dequeue position is updated while calling by xhci_handle_event(), meaning there was an actual event on the ring to handle. In this case the driver needs to inform hardware about the updated dequeue position. Basically event_ring_deq just stores the old event ring dequeue position before calling the event handler. Keeping track of software event dequeue updates this way is no longer useful as driver anyways reads the current hardware dequeue position within the handle event, and checks if it needs to be updated. The driver might anyway need to modify the EHB (event handler busy) bit in the same register as the dequeue pointer even if the actual dequeue position did not change. Signed-off-by: Mathias Nyman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-ring.c | 37 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 49f10dc25516..1136c6170b1a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3032,30 +3032,26 @@ static int xhci_handle_event(struct xhci_hcd *xhci, struct xhci_interrupter *ir) */ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, struct xhci_interrupter *ir, - union xhci_trb *event_ring_deq, bool clear_ehb) { u64 temp_64; dma_addr_t deq; temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); - /* If necessary, update the HW's version of the event ring deq ptr. */ - if (event_ring_deq != ir->event_ring->dequeue) { - deq = xhci_trb_virt_to_dma(ir->event_ring->deq_seg, - ir->event_ring->dequeue); - if (deq == 0) - xhci_warn(xhci, "WARN something wrong with SW event ring dequeue ptr\n"); - /* - * Per 4.9.4, Software writes to the ERDP register shall - * always advance the Event Ring Dequeue Pointer value. - */ - if ((temp_64 & ERST_PTR_MASK) == (deq & ERST_PTR_MASK)) - return; + deq = xhci_trb_virt_to_dma(ir->event_ring->deq_seg, + ir->event_ring->dequeue); + if (deq == 0) + xhci_warn(xhci, "WARN something wrong with SW event ring dequeue ptr\n"); + /* + * Per 4.9.4, Software writes to the ERDP register shall always advance + * the Event Ring Dequeue Pointer value. + */ + if ((temp_64 & ERST_PTR_MASK) == (deq & ERST_PTR_MASK) && !clear_ehb) + return; - /* Update HC event ring dequeue pointer */ - temp_64 = ir->event_ring->deq_seg->num & ERST_DESI_MASK; - temp_64 |= deq & ERST_PTR_MASK; - } + /* Update HC event ring dequeue pointer */ + temp_64 = ir->event_ring->deq_seg->num & ERST_DESI_MASK; + temp_64 |= deq & ERST_PTR_MASK; /* Clear the event handler busy flag (RW1C) */ if (clear_ehb) @@ -3084,7 +3080,6 @@ static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, irqreturn_t xhci_irq(struct usb_hcd *hcd) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - union xhci_trb *event_ring_deq; struct xhci_interrupter *ir; irqreturn_t ret = IRQ_NONE; u64 temp_64; @@ -3142,15 +3137,13 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) goto out; } - event_ring_deq = ir->event_ring->dequeue; /* FIXME this should be a delayed service routine * that clears the EHB. */ while (xhci_handle_event(xhci, ir) > 0) { if (event_loop++ < TRBS_PER_SEGMENT / 2) continue; - xhci_update_erst_dequeue(xhci, ir, event_ring_deq, false); - event_ring_deq = ir->event_ring->dequeue; + xhci_update_erst_dequeue(xhci, ir, false); /* ring is half-full, force isoc trbs to interrupt more often */ if (ir->isoc_bei_interval > AVOID_BEI_INTERVAL_MIN) @@ -3159,7 +3152,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) event_loop = 0; } - xhci_update_erst_dequeue(xhci, ir, event_ring_deq, true); + xhci_update_erst_dequeue(xhci, ir, true); ret = IRQ_HANDLED; out: