From patchwork Tue Feb 13 00:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 200126 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp268776dyb; Mon, 12 Feb 2024 17:28:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUogRlZt+fsZKA6npJU6ykNMIh/fDzAiSHr7OWY+L+czF+xFB1mcDJgmUZIOhsKEYtVODCOh20BZMnYgyc1wXTqZVZ1VA== X-Google-Smtp-Source: AGHT+IFoK8i/hRQfNQpECgu+9EH4xbG2auAcKlXCYyxWnKN24py/Ol6eGy15Wmox8qZQzAOUf+jK X-Received: by 2002:a05:620a:21c4:b0:783:63bc:3eb9 with SMTP id h4-20020a05620a21c400b0078363bc3eb9mr9605617qka.20.1707787712863; Mon, 12 Feb 2024 17:28:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707787712; cv=pass; d=google.com; s=arc-20160816; b=HgZE/p8WWPbrCofe2xq/Cce3NH9oXH+K3dSJRshDROODfRJaWsUKi1dSrhcd+HK5hg 6VzEnUnmfZMY1laJ6OjKqmLBUzi69uZf6fNvg07rIRV/OBx7b7ZjXE+fR7XOUDu0RQy4 uB3FYFghLRWJERfKO9yrZxWnKqImjOTmTX2VQsfQDNdE9xM5o4I6TL/EZlFx7HpBaZOE SMt7je24fUpw/fNxaxFCd6Akv5Isfb/huw/Y1qeRl2E32ZU++1qaQ9ENPcdrJlVtcF6X uB/5aZGpjoP7d1ppVPvO45he+wLjx6Xi21Ita5ezGBaGf5Y8njMqZ88Y2o5ut8HoekPf XMRw== 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=CAxjiLONN0FsfVJGEMs1T7t8zj114/9U4ixQ4PoMPaY=; fh=umT4iWQ4Ub9xmWhd1TFyPCMDcTKJen/9mhgu00IY92g=; b=D7Y5YTfIttm/jLK2fUZE5R2CkQ13WePCIZM6JFVQktIPtJImYFWGMns5uofKNwXy/v hfd+G1+Jb8ADGnVpG+kqcAnWoPwJ8naNgmRozN+FRYeCVJvtlA63jvOm4MvTiwfI04M8 hMbym/SpLjpOZ+xKH3SsvICackzfmXKakfdiPo/N9SnK5qN+vUNj2xoy55wPIj+3ODzw XV1fnnWk1t/dkuEGZeI48rIvcgSqrRUOvPz11HlmwZ2W6c92ValbDiLAo0c+cKEv6HCv g5rZUvXLgg8/pKb5NbOI5CC2vRF0/ZMVn1CKahXy1Cb4eBorGM4dQHWxGm2wu9o5jWU0 C4TQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T7NZ8y+e; 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-62787-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62787-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCUkYHpOhp43OOyo3ZaPzzNOq47xZFE8yrUq9A9lo6B3IVBbOzxmGZJcfLLMuhhy+iBVZb9w/AkR5sKcomM1zRLyTAz99w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g24-20020a05620a219800b00785d52d1bd0si3687122qka.785.2024.02.12.17.28.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:28:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62787-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T7NZ8y+e; 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-62787-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62787-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 97CFD1C248B8 for ; Tue, 13 Feb 2024 01:28:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BAAD5F850; Tue, 13 Feb 2024 00:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="T7NZ8y+e" 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 9927F224EE; Tue, 13 Feb 2024 00:54:56 +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=1707785699; cv=none; b=eGi2CdphXcjaAPdP68WaI8RtP2w2lgXopfzRLA3F7Qhg0al7d0qHVFa2ej3AUiFgFmRtp6YdPg9YPbe/T+6F3aWfANPxb4fvVuMGDqahdopUmBPlcPWA1VhEsnRFVgRXIaoHLTscPuFeFgm+3gPsVEs7f9JpaW4z2mFqRzwFDmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785699; c=relaxed/simple; bh=+Lw1+4MAX2LtZpd2jn62R4vA+ALFex1PxyuYDKU/fN0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cr4vqFclcvu3PVp/KRz3JOJbx3FHpwUw9fytOfYdbbo3ci/rp095fsRM4E87I3aufSQc836T0Zd0qJuwdoLZZ9VY5daa+ikhOHSQ0zJyQLUx5NR6F0x5t22l4hubPSjfcuVfzzhN82/AT6uENBR+ShBOVgLG7t0dhudcZ9ZOBA4= 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=T7NZ8y+e; 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 (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41D0NBRo009799; Tue, 13 Feb 2024 00:54:34 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=CAxjiLONN0FsfVJGEMs1 T7t8zj114/9U4ixQ4PoMPaY=; b=T7NZ8y+e5oI8U/bskqs1KNlL7pdIOVCYCVLn QNpBbh308/HgouJjD5Hgiq9PkYx68NKX/81KXjneaazT84mJSYmzuS90g/PZkfKC eIRCgGXtWIi1d75UzZ59xfxJQGX4hp95TrhEmVZQvIAZ7ouv+sVpLMoIerUDLD4T FjRm7YSDz8ROm2QO+Upy3R6ofKL+FGVWmRBXfxKThgxp4W5zaY1HqLtVZUBbmgo2 j70k76jGBZCnw5Tagr1MTUwT75JcWgkOCEgMOeWX12OmsodGTj6ptDfCVKDRIBEY b0tkT2YHd2upkO/15SawIv18akJh0Ejqne66//UvdSdW4ZIwOg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w62kt4ty6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:34 +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 41D0sX6M029942 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Feb 2024 00:54:33 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; Mon, 12 Feb 2024 16:54:32 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v15 01/50] xhci: Add interrupt pending autoclear flag to each interrupter Date: Mon, 12 Feb 2024 16:53:33 -0800 Message-ID: <20240213005422.3121-2-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240213005422.3121-1-quic_wcheng@quicinc.com> References: <20240213005422.3121-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: 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-GUID: xYYz8C5f7TWID6_kRTK0hGUGGVnPikRk X-Proofpoint-ORIG-GUID: xYYz8C5f7TWID6_kRTK0hGUGGVnPikRk 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-12_20,2024-02-12_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=747 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402130005 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790745208906550586 X-GMAIL-MSGID: 1790745208906550586 From: Mathias Nyman Each interrupter has an interrupt pending (IP) bit that should be cleared in the interrupt handler. This is done automatically for systems using MSI/MSI-X interrupts. Secondary interrupters used by audio offload may not actually trigger MSI/MSI-X messages, so driver may need to clear the IP bit manually for these, even if the primary interrupter IP is cleared automatically. Add an ip_autoclear flag to each interrupter that driver can configure when requesting an interrupt for that xHC interrupter, and move the interrupt pending clearing code to its own helper function. Use this ip_autoclear flag instead of the current hcd->msi_enabled to check if IP flag is cleared by software. [Moved ip_autoclear into xhci and set based on msi_enabled -wcheng] Signed-off-by: Mathias Nyman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-ring.c | 21 +++++++++++++++------ drivers/usb/host/xhci.c | 3 +++ drivers/usb/host/xhci.h | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 33806ae966f9..f8e78068c36f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3013,6 +3013,19 @@ static void xhci_update_erst_dequeue(struct xhci_hcd *xhci, xhci_write_64(xhci, temp_64, &ir->ir_set->erst_dequeue); } +/* Clear the interrupt pending bit for a specific interrupter. */ +static void xhci_clear_interrupt_pending(struct xhci_hcd *xhci, + struct xhci_interrupter *ir) +{ + if (!ir->ip_autoclear) { + u32 irq_pending; + + irq_pending = readl(&ir->ir_set->irq_pending); + irq_pending |= IMAN_IP; + writel(irq_pending, &ir->ir_set->irq_pending); + } +} + /* * xHCI spec says we can get an interrupt, and if the HC has an error condition, * we might get bad data out of the event ring. Section 4.10.2.7 has a list of @@ -3062,12 +3075,8 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) /* This is the handler of the primary interrupter */ ir = xhci->interrupters[0]; - if (!hcd->msi_enabled) { - u32 irq_pending; - irq_pending = readl(&ir->ir_set->irq_pending); - irq_pending |= IMAN_IP; - writel(irq_pending, &ir->ir_set->irq_pending); - } + + xhci_clear_interrupt_pending(xhci, ir); if (xhci->xhc_state & XHCI_STATE_DYING || xhci->xhc_state & XHCI_STATE_HALTED) { diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c057c42c36f4..0886829d53e5 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -538,6 +538,9 @@ int xhci_run(struct usb_hcd *hcd) */ hcd->uses_new_polling = 1; + if (hcd->msi_enabled) + ir->ip_autoclear = true; + if (!usb_hcd_is_primary_hcd(hcd)) return xhci_run_finished(xhci); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index c6349e7e1e95..daee202cd369 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1431,6 +1431,7 @@ struct xhci_interrupter { struct xhci_erst erst; struct xhci_intr_reg __iomem *ir_set; unsigned int intr_num; + bool ip_autoclear; /* For interrupter registers save and restore over suspend/resume */ u32 s3_irq_pending; u32 s3_irq_control;