From patchwork Wed Dec 18 11:51:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13913552 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 D1B5D19FA92; Wed, 18 Dec 2024 11:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522694; cv=none; b=uuPoLkb98iCX5aXVwRnLxnMLIySsEJH/i4V0m2w9uZ+BCWhD/0X4ZyDBg/dpLW/dRRFO9CLv6bwGDh3JTx8wQLksb5jfw+089NrsohCzGBdpHNgcjlNTRJWqTPA7TETl5vK653OI6V7Ke29QU0jYRPd+wF13aKBf3zvsohFja/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522694; c=relaxed/simple; bh=NZhaB+UEmMnKLHiJAumVCq88FfI0Rm+jiZaefdkg2QA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XFAP1Ggl2KrkVd3xHxKJkBlke+CsN6+hOPO6Lhlf27pC2+KtrrdFtLPZLPucG8LZPKrUCXJxuEjTye5cvP8ldSP5CoZA888tPFUN7jsluipI4+SZXd7NQ0lyZgDeMLfsgLe2sl2cNNL+VzPD8VLuyHQmBW/MQqT9fYnHll/pGTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=J+P2eELO; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="J+P2eELO" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BI9vMJU030754; Wed, 18 Dec 2024 03:51:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=n av91Ly0/uh9EQJD8b4swuC8q8IinqPy5JzxZcEOL7Y=; b=J+P2eELOvtWwDkoE6 h1nEqI47i330RuGPVy6m1maM2/aBJbv2oD2oFA70RRBJd/WcVGGsDxEVY+RAHxrO bzT5UQtJ9jETMxl5enV/Ysa5sXUaTYFgHrtMMH2KWR08EggCSwQ5WAU4NtLJzDdN 80f5CCzjC5tVUY5/ztYU9rJP+iKr9BbEBIcqCxja/JRKH/cY8RHJeJMGM9IIPDg/ WXBxVGX/Sx3V8NPaJLI2EW1qyuBcaKCvv9+fniO08g6neAPN6CF4g376OrkiQvFD 0TiP1CT+7zJQ3qyHZWteomFNGDZWiwBSAbvVzHxkG8VUsoF0gpCuCLtaExBEgbVj xThHw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 43kv6pg5x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Dec 2024 03:51:17 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 18 Dec 2024 03:51:16 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 18 Dec 2024 03:51:16 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id A0C5D3F7075; Wed, 18 Dec 2024 03:51:15 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Satananda Burla , "Abhijit Ayarekar" Subject: [PATCH net v3 1/4] octeon_ep: fix race conditions in ndo_get_stats64 Date: Wed, 18 Dec 2024 03:51:08 -0800 Message-ID: <20241218115111.2407958-2-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241218115111.2407958-1-srasheed@marvell.com> References: <20241218115111.2407958-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: CXm-UsbWJ_JCSJAKCmGii_6d0FZbrb5n X-Proofpoint-GUID: CXm-UsbWJ_JCSJAKCmGii_6d0FZbrb5n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org ndo_get_stats64() can race with ndo_stop(), which frees input and output queue resources. Call synchronize_net() to avoid such races. Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V3: - No changes V2: https://lore.kernel.org/all/20241216075842.2394606-2-srasheed@marvell.com/ - Changed sync mechanism to fix race conditions from using an atomic set_bit ops to a much simpler synchronize_net() V1: https://lore.kernel.org/all/20241203072130.2316913-2-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 549436efc204..941bbaaa67b5 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -757,6 +757,7 @@ static int octep_stop(struct net_device *netdev) { struct octep_device *oct = netdev_priv(netdev); + synchronize_net(); netdev_info(netdev, "Stopping the device ...\n"); octep_ctrl_net_set_link_status(oct, OCTEP_CTRL_NET_INVALID_VFID, false, From patchwork Wed Dec 18 11:51:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13913553 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 2EE1619FA8D; Wed, 18 Dec 2024 11:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522695; cv=none; b=FuzYxCGYqNH3NB5Qy4gX91Gi0gRDb0SSjfwwPlgAWuwxx6UBp1x0Y5hGKlSaELVJhwFhZycSxThFVVMutDXjvXefpsjC2OTv9Hp+/dQUxnXMRal6c8+Tm0vYMo+1uT7j6TuxeBuuCxyAkXOB5irUI6aQKwAFAqwFpaDXA9TiKDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522695; c=relaxed/simple; bh=gBFXaEu1ThW5Cas4fgAeB72ZKmA5jOrIeQzEv3zWsgs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xzy2A2ysFaeAm5nSB67ixKb6DoN5NaxD+DZJmSO4C0QoIZIu/KhAO+f9hMxtleV2Bi8FR99CC0f0g4dNaIGwNjYCjbi8nEXWTKjuVAK4cz1TfxUBsAQMiX5+oY8StBeh2iv3h3TaO52D1KfAoqIf1CFvCcGbvhVlV0C90K56geI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=LnFkmCUI; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="LnFkmCUI" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BIB6ccC029620; Wed, 18 Dec 2024 03:51:20 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=c lN7ixwELwrk2WPht65jIJTQB6HXPVk6pdDNcoTO1oM=; b=LnFkmCUIcaI/GCnCJ xE+5EOhGzb+7qbFszSg54T+FlwdOjTXYo/j5ZSDsmeasR5EMFbL/bRF5giXIR1O7 0ISwv7QBlblcNf/hfTe9nsGNyka9OFl+SxlTci+kLiDU4bES6IFoDiG0mqElQyQK k4KHyUoBmm6CIyWO10NrglCO9PHqgZ72Vi1l22UKGTlcTMvqY4pr4x9yyyx8z9lY jNMqLSpp0HG8muXID8WYmt99ML+SAgzAtBdS2ImBecBXKQdnBCZSYjQ8jLgS48Lu AKiwy86fPgF+wap8BBqlZ3RjEpGXu9hQpx5aC23upsqdAa79v3yHmrwVizqKlDRB JJLZA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43kw7ur27y-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Dec 2024 03:51:19 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 18 Dec 2024 03:51:18 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 18 Dec 2024 03:51:18 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id EC8975C68EB; Wed, 18 Dec 2024 03:51:17 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Abhijit Ayarekar , Satananda Burla Subject: [PATCH net v3 2/4] octeon_ep: remove firmware stats fetch in ndo_get_stats64 Date: Wed, 18 Dec 2024 03:51:09 -0800 Message-ID: <20241218115111.2407958-3-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241218115111.2407958-1-srasheed@marvell.com> References: <20241218115111.2407958-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 6mg-P_VJ1ZRobHgnhjFFHqfytpXU72OQ X-Proofpoint-ORIG-GUID: 6mg-P_VJ1ZRobHgnhjFFHqfytpXU72OQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org The per queue stats are available already and are retrieved from register reads during ndo_get_stats64. The firmware stats fetch call that happens in ndo_get_stats64() is currently not required The warn log is given below: [ 123.316837] ------------[ cut here ]------------ [ 123.316840] Voluntary context switch within RCU read-side critical section! [ 123.316917] pc : rcu_note_context_switch+0x2e4/0x300 [ 123.316919] lr : rcu_note_context_switch+0x2e4/0x300 [ 123.316947] Call trace: [ 123.316949] rcu_note_context_switch+0x2e4/0x300 [ 123.316952] __schedule+0x84/0x584 [ 123.316955] schedule+0x38/0x90 [ 123.316956] schedule_timeout+0xa0/0x1d4 [ 123.316959] octep_send_mbox_req+0x190/0x230 [octeon_ep] [ 123.316966] octep_ctrl_net_get_if_stats+0x78/0x100 [octeon_ep] [ 123.316970] octep_get_stats64+0xd4/0xf0 [octeon_ep] [ 123.316975] dev_get_stats+0x4c/0x114 [ 123.316977] dev_seq_printf_stats+0x3c/0x11c [ 123.316980] dev_seq_show+0x1c/0x40 [ 123.316982] seq_read_iter+0x3cc/0x4e0 [ 123.316985] seq_read+0xc8/0x110 [ 123.316987] proc_reg_read+0x9c/0xec [ 123.316990] vfs_read+0xc8/0x2ec [ 123.316993] ksys_read+0x70/0x100 [ 123.316995] __arm64_sys_read+0x20/0x30 [ 123.316997] invoke_syscall.constprop.0+0x7c/0xd0 [ 123.317000] do_el0_svc+0xb4/0xd0 [ 123.317002] el0_svc+0xe8/0x1f4 [ 123.317005] el0t_64_sync_handler+0x134/0x150 [ 123.317006] el0t_64_sync+0x17c/0x180 [ 123.317008] ---[ end trace 63399811432ab69b ]--- Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V3: - Added warn log that happened due to rcu_read_lock in commit message V2: https://lore.kernel.org/all/20241216075842.2394606-3-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20241203072130.2316913-3-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 941bbaaa67b5..6400d6008097 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -996,12 +996,6 @@ static void octep_get_stats64(struct net_device *netdev, struct octep_device *oct = netdev_priv(netdev); int q; - if (netif_running(netdev)) - octep_ctrl_net_get_if_stats(oct, - OCTEP_CTRL_NET_INVALID_VFID, - &oct->iface_rx_stats, - &oct->iface_tx_stats); - tx_packets = 0; tx_bytes = 0; rx_packets = 0; @@ -1019,10 +1013,6 @@ static void octep_get_stats64(struct net_device *netdev, stats->tx_bytes = tx_bytes; stats->rx_packets = rx_packets; stats->rx_bytes = rx_bytes; - stats->multicast = oct->iface_rx_stats.mcast_pkts; - stats->rx_errors = oct->iface_rx_stats.err_pkts; - stats->collisions = oct->iface_tx_stats.xscol; - stats->tx_fifo_errors = oct->iface_tx_stats.undflw; } /** From patchwork Wed Dec 18 11:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13913554 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (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 D8BC61A3029; Wed, 18 Dec 2024 11:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522696; cv=none; b=OCWiA5xfJvG4JN2fP9YtCoFkMqmEsXOWqPoua7OFO042+wbR39JOgYruax/SIaQToJGAb0IejUj1AzRbNa6iJu6vcGj0Y4K6G+XwoNHOTPL+2SUMruvviMj40aau5kSd1uqzHxct0Soj8b8KzQ0Gx/yopTjTHKdF2jd46A7gXRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522696; c=relaxed/simple; bh=PiJEX1bR7cTuzgYfpY/U90WDRAQZvKUHN+RkZtUuppo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J6f207T0TR/nhDyCZbUOruO39XaK5krEwORk3nGb5pbvAsPcQ2j9TIuhnxZl2nEMI4kirWOOU9XYNQlWCXtd4m81yNDimc4FCiumhyDF3WM6+hyzEjZmRocvcJN/X21bva4dUH6w6sT9yeDch3A3UpENuGeY0lsVLeLj5sjGEJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=MJDTXqjI; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="MJDTXqjI" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BIB2SFn010379; Wed, 18 Dec 2024 03:51:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=3 ZZwW3OWYx+MQZ6OVJXbTXQeMbvyRrGaRYXTXIj3Ia8=; b=MJDTXqjI5mjVSoFiy 4/nRl3zc1Qd64IwGheHnvdBRyB1v1IhBFKS/MwE56rM0lpk+ppOWPCwAydvpVCW+ 36P7oNwsuoMfCdbt7UscvjBv0ZMws17GxGSyyubGtypdPerXr7ydHYaUH+JKid0b aLSRmahI/cfo1ZzFgYY/4wIkx+EMQsrJLI11tMc6P3Oa8adY8yr7KOx4INU1Q5cG HZ005ALHU3gOOhxIsoP9KGFDcsHR/ebNCfWBMPEus6js2CneldX2jgO8U57kgg8i r5agKIv0tlhWoNdFP1KLUxgFX5sCout8nYmTPrrcKYI5RfFNWrr5VOhWQfFK09WE zsYUA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 43kw5p02ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Dec 2024 03:51:22 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 18 Dec 2024 03:51:20 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 18 Dec 2024 03:51:20 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 30CCF5C68EB; Wed, 18 Dec 2024 03:51:20 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 3/4] octeon_ep_vf: fix race conditions in ndo_get_stats64 Date: Wed, 18 Dec 2024 03:51:10 -0800 Message-ID: <20241218115111.2407958-4-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241218115111.2407958-1-srasheed@marvell.com> References: <20241218115111.2407958-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: xsLL0AY3ne1njMWbvObywLb1MDPsnBzY X-Proofpoint-ORIG-GUID: xsLL0AY3ne1njMWbvObywLb1MDPsnBzY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org ndo_get_stats64() can race with ndo_stop(), which frees input and output queue resources. Call synchornize_net() in ndo_stop() to avoid such races. Fixes: c3fad23cdc06 ("octeon_ep_vf: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V3: - No changes V2: https://lore.kernel.org/all/20241216075842.2394606-4-srasheed@marvell.com/ - Changed sync mechanism to fix race conditions from using an atomic set_bit ops to a much simpler synchronize_net() V1: https://lore.kernel.org/all/20241203072130.2316913-4-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 7e6771c9cdbb..e6253f85b623 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -523,6 +523,7 @@ static int octep_vf_stop(struct net_device *netdev) { struct octep_vf_device *oct = netdev_priv(netdev); + synchronize_rcu(); netdev_info(netdev, "Stopping the device ...\n"); /* Stop Tx from stack */ From patchwork Wed Dec 18 11:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13913555 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 222A31A2396; Wed, 18 Dec 2024 11:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522704; cv=none; b=MRw1+7w43GQXqwcHcf1s5Oy/d7P/SMsQzeGCeDeJy6hT4oJgO3Y/zCUcmlcNipi9zurGf4GY7Fqa0yTkzVeLiXUZKcvPM0qTfqGa/OOPHszk2Fo/8bPc9Z02jpWfs5vrW4Z+YCkMHf0JHn/HZJ5Lo8tuEPRTx/7k824Mw1NSk/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734522704; c=relaxed/simple; bh=ZPjwKF14+rWlR5d+TGWlLYgioHcW+JlqPJprVfdsPis=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E11VJ/6ntowWtaQtzwmLAUsGIHLNHXvstLQ+2lqNpXmFE9Yrwyg9uvrBEoRidAs8XQqcZBRJtLTjHVTh45MyTRP8nlUlbpub7IoQV6cIbB9eGyRwOAGPzymvoBqrHiocCs0gIr/xBdtDyjs9LQNHE4yVDhOQFoUILYeDBqK/LhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=Ke8jwy3U; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Ke8jwy3U" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BIAHSvc012776; Wed, 18 Dec 2024 03:51:24 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=i hC4ok/dwsisZqXaQNIlsz/9j5ntvdyV0p89AtJl++U=; b=Ke8jwy3U19E94SllL MEKsN/35Lz3WFl5V7VfvB3OIo6jPfFVDotgxlc7XvvCtLdJctaEVvZiS5/3Fd+U5 XOncxb6kuXWXjDt67Ls8XS555/4QhcyoKzEHzB+FS362Pld9sPsGStIkxZBajCkz g1nh16+Bz+z0Shh+vrEBCtIpm0bZyASKVaHyihX0GK88c+fPksBXIoHhx4u58wHY Dn93eJ2J20VZJr+bTncmTJv34V9Gp3sSCNAOJ4+jLjo3+8IBL7jPQzz90TNsutdj V2LMnxxRyg5sijCTcWJQOM7gWbZEjDTtehob9tRCAtA5kWjaaJJrVHLqA3IJ3S8B w0zYQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 43kvgvr505-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Dec 2024 03:51:23 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 18 Dec 2024 03:51:23 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 18 Dec 2024 03:51:23 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 8A63C3F706B; Wed, 18 Dec 2024 03:51:22 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , "Shinas Rasheed" , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 4/4] octeon_ep_vf: remove firmware stats fetch in ndo_get_stats64 Date: Wed, 18 Dec 2024 03:51:11 -0800 Message-ID: <20241218115111.2407958-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241218115111.2407958-1-srasheed@marvell.com> References: <20241218115111.2407958-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 3uwPDK3mVs22R-hvh3sAWT-3_Dx4aWRC X-Proofpoint-ORIG-GUID: 3uwPDK3mVs22R-hvh3sAWT-3_Dx4aWRC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org The per queue stats are available already and are retrieved from register reads during ndo_get_stats64. The firmware stats fetch call that happens in ndo_get_stats64() is currently not required The warn log is given below: [ 123.316837] ------------[ cut here ]------------ [ 123.316840] Voluntary context switch within RCU read-side critical section! [ 123.316917] pc : rcu_note_context_switch+0x2e4/0x300 [ 123.316919] lr : rcu_note_context_switch+0x2e4/0x300 [ 123.316947] Call trace: [ 123.316949] rcu_note_context_switch+0x2e4/0x300 [ 123.316952] __schedule+0x84/0x584 [ 123.316955] schedule+0x38/0x90 [ 123.316956] schedule_timeout+0xa0/0x1d4 [ 123.316959] octep_send_mbox_req+0x190/0x230 [octeon_ep] [ 123.316966] octep_ctrl_net_get_if_stats+0x78/0x100 [octeon_ep] [ 123.316970] octep_get_stats64+0xd4/0xf0 [octeon_ep] [ 123.316975] dev_get_stats+0x4c/0x114 [ 123.316977] dev_seq_printf_stats+0x3c/0x11c [ 123.316980] dev_seq_show+0x1c/0x40 [ 123.316982] seq_read_iter+0x3cc/0x4e0 [ 123.316985] seq_read+0xc8/0x110 [ 123.316987] proc_reg_read+0x9c/0xec [ 123.316990] vfs_read+0xc8/0x2ec [ 123.316993] ksys_read+0x70/0x100 [ 123.316995] __arm64_sys_read+0x20/0x30 [ 123.316997] invoke_syscall.constprop.0+0x7c/0xd0 [ 123.317000] do_el0_svc+0xb4/0xd0 [ 123.317002] el0_svc+0xe8/0x1f4 [ 123.317005] el0t_64_sync_handler+0x134/0x150 [ 123.317006] el0t_64_sync+0x17c/0x180 [ 123.317008] ---[ end trace 63399811432ab69b ]--- Fixes: c3fad23cdc06 ("octeon_ep_vf: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V3: - Added warn log that happened due to rcu_read_lock in commit message V2: https://lore.kernel.org/all/20241216075842.2394606-5-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20241203072130.2316913-5-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index e6253f85b623..75dd3bd2b9ba 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -800,14 +800,6 @@ static void octep_vf_get_stats64(struct net_device *netdev, stats->tx_bytes = tx_bytes; stats->rx_packets = rx_packets; stats->rx_bytes = rx_bytes; - if (!octep_vf_get_if_stats(oct)) { - stats->multicast = oct->iface_rx_stats.mcast_pkts; - stats->rx_errors = oct->iface_rx_stats.err_pkts; - stats->rx_dropped = oct->iface_rx_stats.dropped_pkts_fifo_full + - oct->iface_rx_stats.err_pkts; - stats->rx_missed_errors = oct->iface_rx_stats.dropped_pkts_fifo_full; - stats->tx_dropped = oct->iface_tx_stats.dropped; - } } /**