From patchwork Fri Feb 16 03:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 201878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp286021dyb; Thu, 15 Feb 2024 20:08:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXvvIQH5w0JYurBpfKmKOnAQwR+S3Twu1XIdaRg/KM0zQoJGaFfHOCjf5YbPW13jHCoruRNadps/XGsWzNPQA5V+iEykw== X-Google-Smtp-Source: AGHT+IEIyoL/jN/kB46XJhmgjMyIWYkHIRFLoEAZuPRSWo9zfrCdqUWkGa71ykNfPmmt6t3CGMEW X-Received: by 2002:a2e:8e93:0:b0:2d0:af2a:63c8 with SMTP id z19-20020a2e8e93000000b002d0af2a63c8mr2702893ljk.40.1708056533505; Thu, 15 Feb 2024 20:08:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708056533; cv=pass; d=google.com; s=arc-20160816; b=aB1glaoB2A7DK34ZrMQT2Q9bqolXlCPcahZ4K2Y+BbMDlxleanRqWT0gq0bVBLkeDg pi3H99rVuNwQHH5f0W2Lb6ejbWoMM8rU71RpLqdGvQHhNCj7b53nwoA1kiaEsYRHnF75 wYIb9XyvtFyzIFClA4ETB83blW+T0rD7VBT9KpUzjEjPyOdtOiRrdHw6QwpezXr8V8SU eYm6PA9ostyvVHbKxFT3IO2ZYFDP7gxM5WK9g0OwQyHeKrvlE0toVEyqBfpTCAal/5y5 8B+O6lHFWjRkIk2+ye+jvstBX6qtWY821ve4JCU5ru2LfWLmtuV19ZOGdqUa2qfk7cH6 YnZg== 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=vmf1cZXxABjiR/1HcLIkvsjwqfLe94Nw6IqAgIOtkyo=; fh=Dz/sGw+9lzNFrkoqVn+ZLx/Xi4dC8owgH35eQDavKgI=; b=DXLh6JjmC28F16jJELxoSf5MIcMKw2GAqvhDj4RiW0DT784GuNCwPVtMcDBcQzLEdA 5c1o2Y3hQPM7ZMjObec8oX/tYPV6zoIYyKxR4UJirog0+ldoyE3lDezAr/7sxlQKpT/d fo0iWjXkvcVQ7Hh0LEwH9hhM5IMCxh3qei+hVi85YzZrK1itUReB1kDd/zGbHTZ50Pg7 qEfyHIrjB2jgcndkc/KB0h4ySr+0jRKlb2GuCZj+L79q0c1UnkFkF0zd3rlIp2vdpdv9 FC6mC2r2NkgBdwafxc0GtzHCslUaJX1wr6vO1Oc/4YcSv3WGzOlPgT1l+kD9MDN9N7Xy 1JMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DWoskuX9; 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-67999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67999-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f8-20020a50a6c8000000b00560bf985b13si1254969edc.135.2024.02.15.20.08.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 20:08:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DWoskuX9; 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-67999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67999-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 1D7591F221DF for ; Fri, 16 Feb 2024 04:08:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E53B33CF67; Fri, 16 Feb 2024 04:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DWoskuX9" 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 53D88FC0B; Fri, 16 Feb 2024 03:59:57 +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=1708055999; cv=none; b=Ibjt0Zeg42KsVtTte9NIEAGD/4GPcz3pVrWuZFLTAcxLimSems7xRTytyCWm5rd4Wr9K6nwH0HnaqIMF/G31eU1X4g8sHsrNuP9dDt4rJyJGAs+tOksf9kgjygt2CCTXsTL2AfNentQK99kyAlU/msp2muSMxOXD9Lt8+Z5Y154= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708055999; c=relaxed/simple; bh=SP1tDT+ZcI4HMbOwwegDpk1cEkI9cNbmVOWO+1TEhlI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u+71FOCznwZK5iaPWAIEgkxwrJypUpfpP0i7UVCzhmWQeAIF+beXb1SWv/2bo4Ajf9SQyXyQvUy54v8HBulNvmoGwvwJ9T3wM8CipK7SofuYj7KNGCeBDvQVZA2E5qbjMo5t1n6D4HFAtwn/yFCEbR713Q/iUiBi/y7ctm4Z348= 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=DWoskuX9; 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 41G3ePVG031287; Fri, 16 Feb 2024 03:59:35 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=vmf1cZXxABjiR/1HcLIk vsjwqfLe94Nw6IqAgIOtkyo=; b=DWoskuX9RTmG4Q62/l2UnFdm5mPMjmV2y8jL lKSkNfgiK5qUjDGf45kuhm4a459F7KoBg6dhmaFcGFS58eLpZS4Vagoe5XUPF7PI eonDJpwrcB8/t+LU+5QW2ktm9ig/O2TzjDp9Znz2b1SaYxnR9g6vLGI11i+UxIXe H0ihLizrlRNpRbw2QFDbrCIuOO0ZYAbssBsEaDZWXa6YH2V3s5Asij1Bl4Z7pOPF N9ihvoejqSRPu0IcHaN04jaEtqGUVxAaCjsY7da+uAA5vJMNmHegK4Ina6MqlIN2 6zunykdtF6PdY5xL99TUCVQN7w0gU5ZeFMeUrZap+U88XTMZCA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9435uvcd-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 NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41G3xY41024879 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 03:59:34 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:33 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v16 04/50] xhci: remove unnecessary event_ring_deq parameter from xhci_handle_event() Date: Thu, 15 Feb 2024 19:58:37 -0800 Message-ID: <20240216035923.23392-5-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: LtG3tAf8r-sCFBYVdIgam2nQghlR91Jt X-Proofpoint-ORIG-GUID: LtG3tAf8r-sCFBYVdIgam2nQghlR91Jt 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_02,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160030 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791027087647152152 X-GMAIL-MSGID: 1791027087647152152 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. Change-Id: I7ece833f9f52f16a40d4fc2c10530cdd4c94497e 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: