Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1209544rdb; Fri, 2 Feb 2024 18:54:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8x786Irnb063Z1Ry1yT/GH9q3ZgJ3Ct38XAXJmL5bAOwo1oyH6KJnyDAUw7Eh9Jl3fqZu X-Received: by 2002:a17:90a:d707:b0:296:12df:a93a with SMTP id y7-20020a17090ad70700b0029612dfa93amr3925186pju.46.1706928854760; Fri, 02 Feb 2024 18:54:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706928854; cv=pass; d=google.com; s=arc-20160816; b=IWenJzSYhZynYgPbqvGStvWwm8qTB58X0SE9NJCQIHedFakFF/9phoBPoyAj82qrRN pynYk4H4J/RVKGy6ARKVzC5vcERzdBZDAykFwxO/tiBjPtf0z3Ov8WSTJXMcZT5wqNrp RqtMskq1GCNvjzqG/hCJWWfVzj8b65/TPsO0+MiqG+mgSfLtNeBLbEnm6h4yilqVaVpb 2qJ0y4iq1Sv/2fH+aHJhR0az567/FCPbZnBCj1ycHQ9F8iHr5tEJEJzeT/QMA5zrZYZ6 c7Qx8fpnpfraA5seE0SIDhqTnlgqGabcRkFhKxc2OaLevpYN+fWj7iV34K7zfiMb2a4v B9gA== 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=N1alWV4PWu2ZQmDggZ7zsuZUodSQzl50W127f+/3e+0=; fh=b+sh2udc2Z/xo5hhy44A6ap7DJfGuTHCOH/5+9Ig9cA=; b=d/Xq7egRY/9K1lFlYLy1pNmC87p+W8trqQvGfSrrdrjVzhlpZY+BowFMvhN1obQBDL HCrBTm1/eTuiTCk49C6yiToGMEvU01xLYjpVtE4F61ygGCzgaw03mibxiEj8xPIMhCqA 2vax6rZ8pULp+u1a8cgH+d3n1XmoiNMZk3mVhVQO/RKgg4QezTicfNYMleV7ZPdaEdtj kd/57QSNmVsigyppNZZ9nxAqfheC6ZwA1xTdkGlLvdI5UgDZyoCS09CgtvrZFLgIfrFI F4JdtrOEUbaEz1Gm6rCXzapkGvevuwX+4rD/wWov35J3TwRHm3Tzmy+MALPlOBgyqa1x J3Wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uc79986w; 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-50870-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50870-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCVEePinpKNu3S41exh6a12Ss4WEDiFixwggjxme63R8hUO7uwddPAVxRMq46Ps5kd9zjZZs9Rf1SsWuOQiDQ0pw8Xg2awxjkJhtbRc7aA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x16-20020a17090a8a9000b00295c11a9575si863169pjn.170.2024.02.02.18.54.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 18:54:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50870-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uc79986w; 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-50870-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50870-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 71A78283180 for ; Sat, 3 Feb 2024 02:54:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD41457303; Sat, 3 Feb 2024 02:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Uc79986w" 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 3C10E495DB; Sat, 3 Feb 2024 02:38:04 +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=1706927887; cv=none; b=dDmLn6pg1s66S5DUu2f9DR33wJwffAoKsTzW3GjDlrLed1K78NaheCmT/OASamS15bqAhMZxHhMQODNEZDruvLwIcUKCOzWK68OhpWHjxLQxKSNha9L48LTtl6nf01KWQYwF7gCzPFssUXK25YyK7qzwv3sfAYaz+c9HDNFYdSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706927887; c=relaxed/simple; bh=kBRKQewBFwebBlSfn7sxo02gwubgl581TIfyTJo/ozk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YZ8DUVD5Vg+ki96uRkVNkjgz5pIRy5adcxNC3786Z9PAi0QB0VbJ9VwDpaypJhasyctUsL1I8j8+fsmzuzHdhg723vsLYztYW1GcOXOKhMxSj+yiBb6CEur0/sA6qhOuvIF+Tt0Xh/pGWQF8lDmK5TCj3cqGy1EJmwXHfy9S9rU= 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=Uc79986w; 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 4132Z1tA015813; Sat, 3 Feb 2024 02:37:48 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=N1alWV4PWu2ZQmDggZ7z suZUodSQzl50W127f+/3e+0=; b=Uc79986wdiSMq8zhN9dv5olmooLVvczDmIzS DFESmwqumpGcPNO2LNhsysB0ATnankOArVhJS7leb4Wx/csplOKFWenIhJ2wYe3f CTPHfkt3m6xvgHE4hSw/dr+TEe6ZNCz4MtYUmnXBYRK5dCvQzMXO+enmX0uhcKdO 4DAZEtlz4vX28BiX8y9HrJph75zzA905wLlr1OS3wUmQtchmNCRta/mRIxjtTbxY cELuFFRQQBlFAo5hXjLxubyRER87MWg4bk5lG+B6ulvS9NecsAyRiJVdR5BuYJps +vDRO2L6Vr46k+SX9qYOBJrUlPX0Mfg0xwStctkI4B4e4BPuNA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w1ctq003a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 03 Feb 2024 02:37:47 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4132bJWd004215 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Feb 2024 02:37: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; Fri, 2 Feb 2024 18:37:18 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v13 06/53] xhci: remove unnecessary event_ring_deq parameter from xhci_handle_event() Date: Fri, 2 Feb 2024 18:35:58 -0800 Message-ID: <20240203023645.31105-7-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240203023645.31105-1-quic_wcheng@quicinc.com> References: <20240203023645.31105-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: nalasex01b.na.qualcomm.com (10.47.209.197) 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: havHPyCI2yOrvJNsKJocuu63du7Ignmg X-Proofpoint-GUID: havHPyCI2yOrvJNsKJocuu63du7Ignmg 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-02_16,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 mlxlogscore=992 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402030015 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 1b619a290446..a9d2e876d62b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2982,30 +2982,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) @@ -3034,7 +3030,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; @@ -3092,15 +3087,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) @@ -3109,7 +3102,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: