From patchwork Wed Sep 14 01:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12975478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D310ECAAD8 for ; Wed, 14 Sep 2022 01:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tOGU5cxbKde4VC5PjO/BIO9g5FSxxDw36kiz/Fe1GBw=; b=zhz2lp6i93Duig cmyqtOUkr1b2s6fZoU2GL5H5slbWvHKwTgCR9XAwb7C7VF1aq2NPkhwZRZKSwBDNIkbBRUx8LVXvb 0v017W881fmJgI2Ch3MDCgsiaWOZx33VaTZvYLDXK4FiV+mOfSPSXzzdO/FSzX4wwKJ19xkgr4lfG CG4GOpaxx9mGY9uLJZMcfaIdb+i7Eu0PlE7ABqhlWQw5HcIvUsGGAIi7OTyExcJSz/eJAEqN3Y4Q3 jz6OonmtKfAJ4mMraM5lmPg/Vi+v6fErpHt98X69JRdktZXExZ5YK0GhPm0XwON8BeCjwmWAXWLy1 HH5fydZJu3m2qdlvlwrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYHZ0-003ugr-F9; Wed, 14 Sep 2022 01:51:42 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYHYx-003uWS-3F for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 01:51:40 +0000 Received: by mail-pl1-x62f.google.com with SMTP id w20so1572833ply.12 for ; Tue, 13 Sep 2022 18:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=/WIYwNyx5Wu29EYSy/2Jrb2UOMIrmP6W19HsWBdfXxc=; b=WM5xtV3vceALBvE0lUoU4kpxV8MOOlvjjYHEozJeuKfrKLcGJIGIGrhYO6B+iq3K+n x6QkfRYxmfdZrtYOSmMPpGzsCcBCGHr8n++n8U7T1MHAeR5oJVoQjeOqQM1HcvKcixII rOXmZEna7jDPMbtcrMfH8Q+rAW+sV1MEm2kzzB9J3k4ivxtYV1GZh2plWT1IhL2q7REL B0KpMEFLtGeHeeg7k9A3P6lVaRyWqAPTuNXBrlRLbYdWi8K4A7g2iberUhz81cT4m68V xd/RxAIMb7vu0S9rj34yNNUL+3ZHXSn3HmTJcl1E9SB4/bA10zWlW7pHuSKiPD/Sj2sz 06VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=/WIYwNyx5Wu29EYSy/2Jrb2UOMIrmP6W19HsWBdfXxc=; b=3NRTuwy/f1G68NKbCfpcZfvyVOLA/Y9ynrCbab3JpYwhCrwPGIvqyaJxzO/jmSPHHm VRe4xEQ6HMrRaJo6ajQXPpjE2nwCt2+NNbaK+mCuGVRIaS+ARCLXI7uZgvi//IY24VzE 6O20Os8VMFveswvKwh3JWks0BI/zJyQKLS5jAk5zEyJtVfauzSOVGrGgAn1At/gBIClc 3Rnjx4I6BGFj+HeCmLv/Gmbep/fA2OZhw8X1NX/ebktTStaQZvebZjQQ05fYFFw2gKYD tmlu8SQ5VI7kHtF4BTYmm7pzP2Gpwb4mAjv94jfbaanQEayAQBpd3Tmvpmp2W7Dime3e eLgg== X-Gm-Message-State: ACrzQf1jAJzipgHmJTfVGlyuKz2GPbFfgZU8PKuL+I1DaJnv5ijbhJeC f347KL/j3c6uvV7N7rGe5UA= X-Google-Smtp-Source: AMsMyM6g9yibw5BiATdzD4iYp2v8oqxw78nq7VZQH9hmv1lrA3BS03K/DL+KgFbpjre+EkNd3aVGrQ== X-Received: by 2002:a17:90b:3c8a:b0:200:b874:804 with SMTP id pv10-20020a17090b3c8a00b00200b8740804mr2201323pjb.151.1663120296643; Tue, 13 Sep 2022 18:51:36 -0700 (PDT) Received: from localhost.localdomain ([104.28.240.137]) by smtp.gmail.com with ESMTPSA id s129-20020a625e87000000b00537b1aa9191sm8778989pfb.178.2022.09.13.18.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 18:51:36 -0700 (PDT) From: Qingfang DENG To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Ong Boon Leong , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: stmmac: fix invalid usage of irq_set_affinity_hint Date: Wed, 14 Sep 2022 09:51:20 +0800 Message-Id: <20220914015120.3023123-1-dqfext@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_185139_212020_7676C48F X-CRM114-Status: GOOD ( 13.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The cpumask should not be a local variable, since its pointer is saved to irq_desc and may be accessed from procfs. To fix it, store cpumask to the heap. Fixes: 8deec94c6040 ("net: stmmac: set IRQ affinity hint for multi MSI vectors") Signed-off-by: Qingfang DENG --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index bdbf86cb102a..720e9f2a40d8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -77,6 +77,7 @@ struct stmmac_tx_queue { dma_addr_t dma_tx_phy; dma_addr_t tx_tail_addr; u32 mss; + cpumask_t cpu_mask; }; struct stmmac_rx_buffer { @@ -114,6 +115,7 @@ struct stmmac_rx_queue { unsigned int len; unsigned int error; } state; + cpumask_t cpu_mask; }; struct stmmac_channel { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8418e795cc21..7b1c1be998e3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3469,7 +3469,6 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); enum request_irq_err irq_err; - cpumask_t cpu_mask; int irq_idx = 0; char *int_name; int ret; @@ -3580,9 +3579,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) irq_idx = i; goto irq_error; } - cpumask_clear(&cpu_mask); - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); - irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), + &priv->dma_conf.rx_queue[i].cpu_mask); + irq_set_affinity_hint(priv->rx_irq[i], + &priv->dma_conf.rx_queue[i].cpu_mask); } /* Request Tx MSI irq */ @@ -3605,9 +3605,10 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev) irq_idx = i; goto irq_error; } - cpumask_clear(&cpu_mask); - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); - irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), + &priv->dma_conf.tx_queue[i].cpu_mask); + irq_set_affinity_hint(priv->tx_irq[i], + &priv->dma_conf.tx_queue[i].cpu_mask); } return 0;