From patchwork Thu Feb 8 23:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 198656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp515968dyd; Thu, 8 Feb 2024 15:30:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUxvjuhpIiXL+FNFimPESchHq0O2239g4rI3Ltyq5Ndts5Vl3Jg1n/PEzx9YR7GV7JEmicpxYGSHpiS2G+gzMm7EXw29w== X-Google-Smtp-Source: AGHT+IFRzTjGDuHUg736f9Z7L77EO9WnVw41lBI6Dxdqejcx3VzJeLJr9YNE3HtpxbkMjYW5pb1Z X-Received: by 2002:a05:6402:28cb:b0:560:5c7b:ba5 with SMTP id ef11-20020a05640228cb00b005605c7b0ba5mr150713edb.19.1707435006004; Thu, 08 Feb 2024 15:30:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707435005; cv=pass; d=google.com; s=arc-20160816; b=KaDrZF0yxC10oEaVUjgQMv91lXxe0aThO+vNiG03rh2mv6QINKOAefg8IYWKq1bfqE qg9jY8MSnJRcjEx8/HkbhmGOFd7AOR1DClEEwQT7NLanS9mDInSAw9600kw0WqV/7Yuy aY+ErMmFpRp9TyvyU4Zu+Qt1dSivJvckiGqJ3j/iKX3b9EQSw+uXns2lQWgCJlr6r0vf ijZ7dBM22DL9j2H3c4UdRTKmQbBceLwio6FmhRmZ0s8fI3dgm7pkP2xa4ZJrlw0XD4Xp s/9HCmmajZmTH7sI3yduCv85tvG0VieaXhTZXrAaKs0J9wtp+FlibnrAtO/h6m1m5guc Fyag== 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=TM9p2GGFRl8zcSOqMJpYsb08/gDsOLC0iZtHVRFM14c=; b=KME2Lx7GE795/CaE8ZrKa4otGnavbQdhaVRIXKhOg+oduLFsPhOwL6/MDB/IBizoHu CHVrP6Sp11BKry3G0COw7vTxhRxDjvjyjJqpVjRU0lPUFPylUi4uJ/eRVaiaZji2WE22 ouxkeEf4lGEGWLcAl3/DBrJ2dU+UgJufSMtuGBydFb9+gTbZDx8gqFfJGsCmq2ihIMeF 0zIh7FsnnwWF5Q85qw4wiMjeuhVR5xKR17YR6lYu6E1RjDZHBK9OhGfgVAF6/neRC6bo dekooML8DI0UINaE2S0rQbLwJJfd41IclkYPSKLrTnr6nhd1SZeT6wBq1454/xEdTaXG 8BQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UJNCcHgl; 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-58827-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58827-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCW7+xF8NTuIccHtDNYhKJEcwwiNTBYjMBa167zmR+4x67SWYpcS3a2du/47pAYt9GaB6/qAjyB6mASv1VtOeXm9ZSqT4Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bo8-20020a0564020b2800b0056035dce894si210777edb.145.2024.02.08.15.30.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:30:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58827-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UJNCcHgl; 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-58827-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58827-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 667C71F20846 for ; Thu, 8 Feb 2024 23:30:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5763160EE4; 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="UJNCcHgl" 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 3C1A65025F; 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=1707434083; cv=none; b=eAg/vcaFB7IrqboNuROJqxHjbZ6IO7Kvi7G3/J9Cl68tNVjUSbvOBMYNdoZDyVkDEvlBEFXWWPIfxB1TaM5mQY7sYgWN+nz5Uc2XU2+ciRnZBJWAIRYQMhZplaccr4wASMftrFwyqPyqrUQPqQGo4F4MyYHCs1ecS1GplHXmILM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434083; c=relaxed/simple; bh=kBRKQewBFwebBlSfn7sxo02gwubgl581TIfyTJo/ozk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RbssGXU8ngQlD2MZFDH+GoVuMivrtwWWKgpY2TVFkMaF2naDaoY/ZgYKxJGKpSE9gQEH5duZdPrpSIqSt5F4MRDTih9uh7RZQiUdTcg3d3YguDwz93xtNrDxQOKXDtGtMNnHFjGXbVOeiImXCYt81IVgpTYXF75iVGTxrybrnt0= 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=UJNCcHgl; 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 (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 418NEJIJ030158; 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=N1alWV4PWu2ZQmDggZ7z suZUodSQzl50W127f+/3e+0=; b=UJNCcHglAQSC7sPmuN8UH7Yp70IYmtGoyRco egrrZgif8heTA2+N7+SOwMI05AMG7aW+eYR7YNLIdZTVPBq3ZtNNl4paL/rqahx5 FU7IykElolrja82xmD4oSKhbHwm0Gqwv/oiC0+vt8b1sYnlT15CKqXDMICNXhVHd 4VXbfXOyMSd0AO1DyCmeP0PBDfThTyIIwtVtqJoUd/d8QlG2O63kpVsfMKIfUy1E Ka1y4LjgKawbbx5fOdwt2H/P/pwhKDt5d9XgZKAreFmT/jV86Rlr8wlS/s0ySn7O BAv3Q2YyC0fcd8pZQP2m99L8PSP884nnPHLB+wGox3F64a4hfw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4hhkbaj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 23:14:18 +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 418NEHHX013086 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Feb 2024 23:14:17 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:17 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v14 06/53] xhci: remove unnecessary event_ring_deq parameter from xhci_handle_event() Date: Thu, 8 Feb 2024 15:13:19 -0800 Message-ID: <20240208231406.27397-7-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: 7GjNYeHCyostH8ZVGYTA7NnMP9VQNmHq X-Proofpoint-GUID: 7GjNYeHCyostH8ZVGYTA7NnMP9VQNmHq 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 mlxlogscore=994 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 bulkscore=0 suspectscore=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: 1790375368925056283 X-GMAIL-MSGID: 1790375368925056283 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: