From patchwork Sun Feb 18 19:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 202867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp915248dyc; Sun, 18 Feb 2024 11:07:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgCmgMgO/s6KigFy708SGujuHRDV04Q9+zd/FhO0leela56GxI5FDn/+dDJb2ywtXYBerMFLU33mYwn87zZxuA5nglUQ== X-Google-Smtp-Source: AGHT+IEoUSpz3dCfWmE1mXMC5tW0+vUDtNL3Q3MO56kbdfovmu7H5NWZPdWbsOM06EA83FJIC3dc X-Received: by 2002:a17:902:c942:b0:1db:d13e:26fb with SMTP id i2-20020a170902c94200b001dbd13e26fbmr3658990pla.5.1708283226142; Sun, 18 Feb 2024 11:07:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708283226; cv=pass; d=google.com; s=arc-20160816; b=pHmCeIO/33ExIn/FvOvbTYGSTxkAWFoLT0T8iAxuhYGNjpn6+eHxRGUBIcMWVHUV3E Fp24vKk25bFbgsohGARVDx3ID0v3xk2LaVm/DB29U11HUMv1iXtVA6C8CtlAwbjn0RgC Oih0zxwRY6k8mJZDxt13dv9Vm7+DZ7KxRNyqRLmVwTaeEh1xljQP98qPuX7iILtCYSCw Oc9c+pwfgvPdUx3hY241V+8k1/cbExCsFNDkFBizv5eojZDbBhJbBdSJ+g56VmvNyH2I qdwLN/bJsiAGDpc2uD0VjN25cliUuNzFoMk3GspwXUdAWG6vyMwfOk7h8ONC/5N/yAQ1 owbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Pkl65YWoZqBRy7PXp9WalSTMwRYxXFsGyTDBtpnT5Zg=; fh=CcwBWppwIOFVs4Mqz5tGu256xta/OELTqej5gcz5/5M=; b=Xw136oYi/JU7JcOYQHaGZTubSe0jrJPAFJd3qXWtFDTa5Xnx6XuqvWM8+LRiAt7NS/ ulWz8HTeC2OFcNsOsdR8eIuQrLdiXjoTbFKBInKOtUyITODuAecCBTjDl6OMFDsFq0PN wc+XUDJJbvteXWKQkrsIZx5x5apbdUPaecqZcIkrAeTYLsf3Bch3UEP1AmNRuohtyX1X RWRqmKndMF0pHf++Dns5ZZFhEOl/N+nlTVh3j+MiKWXJlhATgO5zEOhKHc5zhr8eJqgo Vqtx/AsIbL6jw4Ua4XXbmShb1SB+6POei+zDtbk54wh3P5HSQ+ooG6ja3nSMAwasZwKT gLSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kKpsh04U; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-70535-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70535-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id hk3-20020a17090b224300b00298980e9292si3366471pjb.118.2024.02.18.11.07.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:07:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70535-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kKpsh04U; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-70535-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70535-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EF3C62812E9 for ; Sun, 18 Feb 2024 19:07:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BF5574E3F; Sun, 18 Feb 2024 19:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kKpsh04U" Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CE79745F6 for ; Sun, 18 Feb 2024 19:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708283097; cv=none; b=a5lDq5T1OHf0KrnfLn/A0Nr83KYf6uCIQgJVcyRA9CxDuDSJU/9Fe+Jz37mOG8TN4G6Qcwh7zq/yrBdJjGdcK4osqDgpg4bQVy1Jkxo0dT59EZH/I0wCgzvMD8Am3ZMzLP00LCjxIiTD1icBjEwKEh35hBnTFcnTSQlFPAn9QII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708283097; c=relaxed/simple; bh=EiHEARKfsSch8CWg3qSOqrgsBmJrYMqzousU6JGvsio=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=LeXbL7BX7Oo8tnuRknSEDUsS2k9BTE1+OKcoDMD8yIq7PpBq9ualIbapO4T7EyJpJ5Jc1N2z6sSv22hsi0SbEqOUXnF/QNuNlALJGylvtTKUsAAhoxHimaPPL50EZgpOMizPFrEP+69boniXHub5OHXYQI9U87fHGJbxRtPKFZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kKpsh04U; arc=none smtp.client-ip=209.85.166.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-7c48e13e0d7so134543039f.1 for ; Sun, 18 Feb 2024 11:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708283095; x=1708887895; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Pkl65YWoZqBRy7PXp9WalSTMwRYxXFsGyTDBtpnT5Zg=; b=kKpsh04U8AChJFNvvcK2Ypa5nxuU1bHtMcF3zIopO7rd6k+gU7sTHPQVGhUBe7T3+/ SyR88IB/HfQO76TU76Qi/Bv2kL2/HE75Rm7MCB1NtwEgoI481MOHedeDZUuFJgKmnGpy UWqak5GMtrBPCuEXrcwWrwfxNmyoONtxhmcuQzizK9BVjciqoWsLGs5ONKx7pfFtYxq+ gOKS6HCsrsjVscKeIcMPpEJGZ3eme7QK4dBssRzt2vRUrpusHhwV4wJXm6K14Wi/FDX6 m1syRbF5wEQK7jQWIuZo03St9ZILsJqSfI71uFvDI99WKA0W0qumTaUhewBWPqICLBXC 9b4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708283095; x=1708887895; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pkl65YWoZqBRy7PXp9WalSTMwRYxXFsGyTDBtpnT5Zg=; b=IxpyTdHFMddsHSDi+nzmbyeeUIntuwiroxcsh4F/MporlJExV0YpKF2HKeTOIEOXvD 195NxCq/3f3rEpx9a9EZT4QH3ZeIJsq/KIivhLEwRpHY9bRuOduca7ASDBMRde10Aufi gUXja9dgJeFy8QP6RS2JJ3xz78LxOIhIjBLycQ09dl2e1awlV78QU0X60tYmjxVY9iRO hJRVs5ujVYSENnWJFC4GOBhkWDlFCEEkIKvuml9HVzKmpibXqc3Lv7Z75xrxAQY7RPOW wIN8miqdF7QewXrEZk1WVRxilt3vRxEfx0b9JnGmhxw20FrsYBx+AaBEdd0jYm7s6OUd 9gMw== X-Forwarded-Encrypted: i=1; AJvYcCXLj7DyUC4lf4JBFciTSC/yrHDiv3GMf+obPxSzakaxlJVEZn+4b0o9oHk4Iiji5JmplMAT5s/YVcyvRWyOCRG3HfhfkSNHSF92Vp0M X-Gm-Message-State: AOJu0Yzk1f15fdvBh6+Vi8iiyNSv+bYZN2AGoI5HR4RGyof0KuPy3iRG GAVHFhSj2IlflgC+/tFfFafxRiJSUaT9aJ0iJCUzvYOCo3N6AR2XLUtA+zN4V7w= X-Received: by 2002:a6b:6113:0:b0:7c3:ec35:8df7 with SMTP id v19-20020a6b6113000000b007c3ec358df7mr12455709iob.3.1708283095387; Sun, 18 Feb 2024 11:04:55 -0800 (PST) Received: from localhost.localdomain (c-98-61-227-136.hsd1.mn.comcast.net. [98.61.227.136]) by smtp.gmail.com with ESMTPSA id t125-20020a6bc383000000b007c4926ebed8sm1300105iof.40.2024.02.18.11.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:04:54 -0800 (PST) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, andersson@kernel.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: ipa: don't overrun IPA suspend interrupt registers Date: Sun, 18 Feb 2024 13:04:50 -0600 Message-Id: <20240218190450.331390-1-elder@linaro.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791264792351918263 X-GMAIL-MSGID: 1791264792351918263 In newer hardware, IPA supports more than 32 endpoints. Some registers--such as IPA interrupt registers--represent endpoints as bits in a 4-byte register, and such registers are repeated as needed to represent endpoints beyond the first 32. In ipa_interrupt_suspend_clear_all(), we clear all pending IPA suspend interrupts by reading all status register(s) and writing corresponding registers to clear interrupt conditions. Unfortunately the number of registers to read/write is calculated incorrectly, and as a result we access *many* more registers than intended. This bug occurs only when the IPA hardware signals a SUSPEND interrupt, which happens when a packet is received for an endpoint (or its underlying GSI channel) that is suspended. This situation is difficult to reproduce, but possible. Fix this by correctly computing the number of interrupt registers to read and write. This is the only place in the code where registers that map endpoints or channels this way perform this calculation. Fixes: f298ba785e2d ("net: ipa: add a parameter to suspend registers") Signed-off-by: Alex Elder Reviewed-by: Simon Horman --- drivers/net/ipa/ipa_interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c index 4bc05948f772d..a78c692f2d3c5 100644 --- a/drivers/net/ipa/ipa_interrupt.c +++ b/drivers/net/ipa/ipa_interrupt.c @@ -212,7 +212,7 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt) u32 unit_count; u32 unit; - unit_count = roundup(ipa->endpoint_count, 32); + unit_count = DIV_ROUND_UP(ipa->endpoint_count, 32); for (unit = 0; unit < unit_count; unit++) { const struct reg *reg; u32 val;