Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1431385rdb; Fri, 16 Feb 2024 16:22:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKSKUqVypFyDItp6Uy14RUmoyxqJVIieZBMd1KWL+IQ4c37fc1bnYDs+jDGd7b6uKh9eL2Ok2INvZi54mqqtvqeC2cBJYi42TsCD2c6g== X-Google-Smtp-Source: AGHT+IF4DYOLm6hm473aORV+rnffgC5pKIS7nLEc17yl6tLqbRKa1sU3y0hhfJP/vpYmr0DxuJkQ X-Received: by 2002:a05:6830:a58:b0:6e2:f0f5:e118 with SMTP id g24-20020a0568300a5800b006e2f0f5e118mr6707249otu.16.1708129362906; Fri, 16 Feb 2024 16:22:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708129362; cv=pass; d=google.com; s=arc-20160816; b=QoRgafN8dhMqZMHKPg3Ua5ZCySz+jZfbIpNIEhpWjO2T2arYd9zyZMzLsahTIYu7Sd ZLbJl28XRfWffZnajTrFNzSo1qytq1YlbLVX/BcwBT6ZY54YAMZ1rPU4PmSqHHezzuBk 3rd5teHFc1yts7KQGjsfJQKu/LOIj4oJiApumVIF6bENQC3SrOZtjB9F7OHzX4uyIb7p dWKsk76QGj5eFweh9lXO7wO1w6/2pFddNxIcuIUGHVErQSG2gB4UwnNuV0r7FpWCMW8q +EtW/7IwGd467iWRoR697hph7JyPJ4AGridDCngL82Wd9EzCLZYrx+EhIL7w5RgWw3B8 al6w== 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=cPeqWAOHiC/DRr2Pu2t5FImj3arw3vFei7pmew6OZTU=; fh=Dz/sGw+9lzNFrkoqVn+ZLx/Xi4dC8owgH35eQDavKgI=; b=YeXVZrYHZqqFMQz4FQWyjqY8jRPxqf5FK6fnIWpoZP9uOM6viLg85IyUbpi858lWwF KGskZDakyicDnAE6fDpbGPfw7yRrO4FT0pJrpdjRyn6UBnLKBxMRkg5V/hyFoSHAQvAT jxZZeIjux/r97sW+fJz4qSinNZPYGJ1n6naxTdy87OgVjrf/K0j/+mCJ4wvNX3wQn9R7 vdBZWngOHXdJV6ewjFb83LVS7VWkWZJEqOoz6veiu3lAZU9MVELOHjf3w8ivDjSwamUG x/M5ujANqkmweFaISh18NBer1uc0wMaK7SSHNJ26wnH4JyoxGqn21LSIdrP/+M5iRimh aNUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="a/dAGA8C"; 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-69557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69557-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s4-20020ac87584000000b0042bec0c07a4si935295qtq.413.2024.02.16.16.22.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:22:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="a/dAGA8C"; 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-69557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69557-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BD7031C23EC5 for ; Sat, 17 Feb 2024 00:22:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 510AF7A73F; Sat, 17 Feb 2024 00:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="a/dAGA8C" 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 4A76E46AF; 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=h3TVWGmIHq4e1+7PWLotRqf3n9QUFU00tF4LBLvUiPi1JXQUFAw/tbzjA4GyhpgFzcAjI77tH0FJi030XYFR9GmgBtquMgwcsmTD0/L+D4yalKUDU40/CwP3zsXvDGHueo21yzdupAx3Ub5Mhgobl+3LLEd28HKd9nl4ttar63U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708128663; c=relaxed/simple; bh=u1nuq17zD0xhgBZbYsuMjFfbINv/RaVLoPTPOjJ2BuQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sZKfJ1EoZpQ4QOKZZkg6LJfvMVE4JGah1f5Ei5cRL92Ef4U2M6kqRWy/0WbQ89IOVzbpGfBfcWors8JCGh62g/rcWCrh/mQ0iAFFwD55jiN5UBjvDZXCg5+5qS+ySDXtgL1VB9TbplbGDmdR3ic7wgNg5mFxydtrdoTui0x1/Vc= 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=a/dAGA8C; 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 (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41GNRSE7012486; Sat, 17 Feb 2024 00:10:31 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=cPeqWAOHiC/DRr2Pu2t5 FImj3arw3vFei7pmew6OZTU=; b=a/dAGA8Cl6+05XOz8YGOGpByzLT1QDdT3CSR 0OJjuJmzv0TKRCaKmmrWZ6Gmk8ujy1bqtnvlqvCdbFQ8GmiFS6GwrkSn0fveLgkY fU67QSaMs+8Y6slypT4hIFp1TOv5o6FQd6JNuiwkfLXWQ0g6LA+VW9GwQEDW4ddk yQw/EebciP/L5BbOn//L9Js6gegAwwVV6temau3+9tNSviHnDCyTYPECjTLLQzf8 eaP0Y2vNqktp0HDVyKINCtrRCpkCv6sg9+5u0nDckK2bnmakEJSFRmrkmRxB2yb9 jxUW1YFj5nLCCk5whkhIk2wNLIuxjK6hJcYKYb9sjXwryVGkWA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wa61nhek0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:31 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41H0AUE8017196 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 00:10:30 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 02/51] xhci: Add helper to set an interrupters interrupt moderation interval Date: Fri, 16 Feb 2024 16:09:28 -0800 Message-ID: <20240217001017.29969-3-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: gdIcMei1LT9tAKqEBMIekUwgF8QMAxEj X-Proofpoint-ORIG-GUID: gdIcMei1LT9tAKqEBMIekUwgF8QMAxEj 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 impostorscore=0 mlxscore=0 clxscore=1015 bulkscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402160189 From: Mathias Nyman Add a helper to set the interrupt moderation interval for an interrupter. Each interrupter can have its own moderation value. Hardware has a 16bit register for the moderation value, each step is 250ns. Helper function imod_interval argument is in nanoseconds. Values from 0 to 16383750 (250 x 0xffff) are accepted. 0 means no interrupt throttling. Signed-off-by: Mathias Nyman Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0886829d53e5..b405b8236134 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -346,6 +346,23 @@ static int xhci_disable_interrupter(struct xhci_interrupter *ir) return 0; } +/* interrupt moderation interval imod_interval in nanoseconds */ +static int xhci_set_interrupter_moderation(struct xhci_interrupter *ir, + u32 imod_interval) +{ + u32 imod; + + if (!ir || !ir->ir_set || imod_interval > U16_MAX * 250) + return -EINVAL; + + imod = readl(&ir->ir_set->irq_control); + imod &= ~ER_IRQ_INTERVAL_MASK; + imod |= (imod_interval / 250) & ER_IRQ_INTERVAL_MASK; + writel(imod, &ir->ir_set->irq_control); + + return 0; +} + static void compliance_mode_recovery(struct timer_list *t) { struct xhci_hcd *xhci; @@ -528,7 +545,6 @@ static int xhci_run_finished(struct xhci_hcd *xhci) */ int xhci_run(struct usb_hcd *hcd) { - u32 temp; u64 temp_64; int ret; struct xhci_hcd *xhci = hcd_to_xhci(hcd); @@ -551,12 +567,7 @@ int xhci_run(struct usb_hcd *hcd) xhci_dbg_trace(xhci, trace_xhci_dbg_init, "ERST deq = 64'h%0lx", (long unsigned int) temp_64); - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "// Set the interrupt modulation register"); - temp = readl(&ir->ir_set->irq_control); - temp &= ~ER_IRQ_INTERVAL_MASK; - temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK; - writel(temp, &ir->ir_set->irq_control); + xhci_set_interrupter_moderation(ir, xhci->imod_interval); if (xhci->quirks & XHCI_NEC_HOST) { struct xhci_command *command;