Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2793988rdb; Mon, 12 Feb 2024 17:51:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGs45MzIHlI7kJ3dUelmpA0kuRTvGsT3nDVd7WxiRlAmSfs65VeJFS5tcq77YwGnTlWKowU X-Received: by 2002:a05:6a20:7b1b:b0:19e:99c0:c1eb with SMTP id s27-20020a056a207b1b00b0019e99c0c1ebmr7023118pzh.51.1707789064174; Mon, 12 Feb 2024 17:51:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707789064; cv=pass; d=google.com; s=arc-20160816; b=XmJaka2xJNGpBO5gSRzTWBDC7vRnWTrTvzgfdMNaV4Kx6oA2NQ6Q4+atJQwpQ3e+eZ uqm5DVJd9qxcOrr41nQkePKkvxQsMc2PC7Owu/lSarVBR06ImIJefNpg48akVKtcTn03 y4wJLrxMtNY/gB0bWGnBBH6oT6izXlkAD8FqOmKCLJ0+PBnookYC5UWSRFHHs8dpLevU BmTk5drVKPtQuyxtO59SYCPtqkPXbo7PQ6DBuC3dnGy+aledPDZMNG69ochG93lnWpNS wQ17g9NWWpy3RIvL7wfx5lg623ERecMqYVeqTxVMInDqUHwc/2nNNjWjv8k/ye/gyAwz L5Kg== 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=X/e3FiBfDN1EWv75PPeHiH4D2XoUUWYrFku5SlBC73g=; b=kxvr38e2QoB7InpggtLCw2OlCdm5YbxSEwr4TnZh6821D3nVmb5ys6YbV0KEgafzVF J1TraZ2ZFTXF1gkDXUb8sn85fk2Q1qaOnMUiWQmZSTPmAKSepeDa419OTwakxt3j4g4B W10MqZ70gnJ+F+9A8dOQBB2K0jaoJWaFHVEjmYlkJXpc+t+CYMLHC+6Xmqf7OtnUBpfA yaFRK3RjwxCR/X4kvNHEBAUkPwjoxsRCj37ger7hU2cvMeQFql0r8niazqgQWIg3e+G/ eS+vsr/yUnN8cA7q3/LecbuzrYWVpQamlhkNMLHM4FMevXzclYNnbmxew6TZd9FekLoj xxxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NppvrRQD; 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-62796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCXxaA1KHehOOkfYTax2WuU6C476U5J6TmMB3OgxVu9DzjM4q9GZZ2O8lyVTKC8qNzTg9zMpTzHPnKk2pBjAS3nqJLBg2MzHG+2KepUekw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w16-20020a17090ad61000b00296041acecfsi1198080pju.1.2024.02.12.17.51.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NppvrRQD; 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-62796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62796-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 87E50B21AFA for ; Tue, 13 Feb 2024 01:29:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2D345FF13; Tue, 13 Feb 2024 00:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="NppvrRQD" 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 A92E0224F9; 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=1707785700; cv=none; b=ovc6Gf1mv5drePp39QEvd8cjxDw2vUqGVWDd8sTygwGQiohDQZfzZy0EQbmYTvnSzpcTCO3VfCffARfgkKMJpcV+00CXVqQOvGO0zF0x6kYLAXZz7aqT6Qh+S+nM7QiRwCDpMTMSCh9WJhB1+BddTnEiUhrKXphnRwE+kPuVLXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785700; c=relaxed/simple; bh=u1nuq17zD0xhgBZbYsuMjFfbINv/RaVLoPTPOjJ2BuQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YcDD4TbHIQ/rsSbkFy7rtYHnizd5LThe+2Ch4N1AHqxgfuzYqdL5tuQInVH9tYz4l2DRDCll9H6K45qiCsWpePqamWnfAKKTbhTJuOOU+y4SRFHTMlFPJBrcMDso1DwlkNWaDUgg/fsp9XvWRLzB3yg1yg2Hh30snD1Eepa2m0o= 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=NppvrRQD; 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 41D0Yi9x014733; Tue, 13 Feb 2024 00:54: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=cPeqWAOHiC/DRr2Pu2t5 FImj3arw3vFei7pmew6OZTU=; b=NppvrRQD2phZJS7TY2FZRvpHWhFOc94LaI2N dWiD0h5zOebSlWBh80zbXHMgHnOcz5ao7xLaucTnWL5qL2vweyS2B0G/5gNWX7G7 toW+taGqNXXacgb81uGPN7zGG+LgYzcdA+hba+Ap7wEH1UyNYWsJPEyoQ9Bxmmap uFdnHTgzFqOomtmMiBCV/27D1ELQ+nz1NoUI268TV8GAmRKzrDTTgudBjE7FF5CL DLWIN6jSZQnU1i3hL+7ShVXOlvMzbdU315VidiohfM3U6rLibSuVpQhXJdkq3tYd DBHbsca7U3bhCCwB9fTcRVpPs950xLT9/aIbm2oUOS3aAyfjXg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w7ww5r1a4-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 NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41D0sXDp031061 (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:33 -0800 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Mathias Nyman , Wesley Cheng Subject: [PATCH v15 02/50] xhci: Add helper to set an interrupters interrupt moderation interval Date: Mon, 12 Feb 2024 16:53:34 -0800 Message-ID: <20240213005422.3121-3-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 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-GUID: 18AqyCUdRgCwt8ip7-4XEaq9JR8JgQFp X-Proofpoint-ORIG-GUID: 18AqyCUdRgCwt8ip7-4XEaq9JR8JgQFp 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 priorityscore=1501 impostorscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402130005 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;