From patchwork Tue Feb 13 00:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 200178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp277053dyb; Mon, 12 Feb 2024 17:54:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHf5gT1VNk1pzix/lRq2QMroLAWlCfsaRl+V73BDvErrRwe3T4o6Blw1Z1YlLgeX12Z0PTN X-Received: by 2002:a05:6a20:9e4e:b0:19e:367a:2ca9 with SMTP id mt14-20020a056a209e4e00b0019e367a2ca9mr11409739pzb.8.1707789279552; Mon, 12 Feb 2024 17:54:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707789279; cv=pass; d=google.com; s=arc-20160816; b=hfD2NrBs8EpWypmI5eyn0YVkz7E/c8CSfTYJo+mVX26PWcrryP91/jeB60j0/9b1S5 c/y3jo25jgV6TUaJx3qaC8STDMEFaamL2j4Xx9WjXVS3Lw1Kfkays96X4T3YnQJ8K/nF luKHtXzW0+4FrPk8ffRHDDMzjr696JaMtpqhDZlxrEwU4+duq+7TW2vMYjUNyby9TGZO V/AcQm9TpSxmAxghuyO4XYvGrJ+oIKrpqcf8mbjt1RZFg34mFm7j1j0dNeAYWR48/Wq/ TMHzhnl7bgmXR9LQOJnZmbMwjeivjQK+ro11XfdWUoiXiTNz5o+HgtHzXy835Z4oo9yt kY1Q== 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=L5e2ULvIZaD524FhcpT0/RDh9V8JluyXzl2FSwsFj0Y=; b=Osc+P8Tk1iscgKqZw8RtFrICCTo3IrQOQkmEjK0xtVcYt8T6240CE+Rjbia8Yt5tCc W/HiCrGv+yzwjNaRqm9ey3ScabgOOrCpq+1JNmyIkd2EJVEevJSUjFQ+49j5TYzkaDUW PrDl0BIuDNjpA0yA7zijCJBxOIUEypH7I53ohfITFgDd/HfKnGSNlJgQxsFiuRpy7UI6 jr6CDemve/IGv1UjHeo7wmFSOkBk3ao+SvZZx7sqHM9s5UOzEXg2c5P2aAS6AAmQ96rK 7hwHtBzbMjNk5DXSraQP1Bo0pUNqLzI9EtmR/5XfYNKq8Ur4w4LRUTzbEUxvr00AVWly WoNA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62796-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCW6xt0mnLZw6JHNFEJkWa5fgTeHZgdAJb60pQY/WIqzQBUlXc/mdSD89NUTH9wCDyvldbs54xOF2c0I+ab9OEzaakpqmw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jd4-20020a170903260400b001da31b60e3csi1105195plb.571.2024.02.12.17.54.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:54:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62796-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62796-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0742FB285E1 for ; Tue, 13 Feb 2024 01:32:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CC1860DC2; Tue, 13 Feb 2024 00:55:18 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790746851779767655 X-GMAIL-MSGID: 1790746851779767655 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;