From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796317291; b=0i1q+pwObuySWiFoubB068HW3HjbY6lkZTorb2reKK6lJ0/ONf/Gcm+pxTH5JWDoEMSk 1bEcT9jM/jA9X2sT+YB10hLAjz7uyyNlfcZWGswO8wb6rzSibyKcFnl4vAmHbCbXSaF99 /1h7evuyQko5U23UH/KPhCJNVZNIXqFls+lbZq+8p2DaV6MZvyEKC3UZ80KPVgl3QUp70 VxiQvNOMNzihe+rT/WVguAU+azZPnePFTl4McZDa2f2QKXQ6bfXJNrqMHhH7Z+zvdbCyA EreEzgdBAtlQcnr4FzkSSUZvf8uwOKGKsEYuaMLdJv9JRFx6LGAnL0UgdDsZJhZeI1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796317291; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=8O7YznjW1BPBa7nUf7xNb7NeDXGXD45/3bNtFT7c/RY=; b=M9A+PKgUpgxFzADFW6OM1Qa9KyWf0s+DvZGN2bG9F29ClQ1cGAns0spYfUpzha2peXv7 669+eDaJWEMKLFTYCld3z9GszVJpF/gdMXxF0JX5k49LmLmnqMKmqzKi30nxsnwXtzk5W tijwH8nHXHONiRLYYFm7f7MrwaJ57SXgfmJsS7wYkAOUs/GVevfpQYnjJckJ3ol4R6ceE Gyk/ubn4O13iR/4KSZPkeaI8QwtNtTN1UNUWx379Pth6rwsZDfbC201yS4aQWkrvMDe0i a/Ef5du1AcLQCFYO8k3sa6usYa9W97cU8plqWUo6L190oYGx0LBP7i+ftTr+KuwtgwA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=jT3bmbu3; arc=none smtp.remote-ip=74.125.82.200 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1D83606A32C for ; Thu, 3 Dec 2026 17:01:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B1D83606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=jT3bmbu3 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-341eff9e381so21758972eec.1 for ; Thu, 03 Dec 2026 09:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796317290; x=1796922090; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8O7YznjW1BPBa7nUf7xNb7NeDXGXD45/3bNtFT7c/RY=; b=jT3bmbu3wmdlePpsdXG80nIcdlQY7yaqgftJKBfVXMjLEYbGPrOmLtw+Q7mOXqPhiV cuuOBQ0arxalrH+GsFbcTqkgblUsVzb7+Pc1OyxKZgXVvygJYs4OOdhmjfM7hdmH+sUs DjgyuGovesmsyENeOdBiIOTuFVDOFLLlExUGF/WIs4BSpiALVHjyH+rdnVhj/Yzs0EIC 3gb3MVqUcj9rzTuqlJh+XaF0rLW04auTeNIvlR8D+XZE5GxvC82JcsI1s7xnFraGb5SE mYnlHq2FHBjtC0L+O9kOPprku4ZSUHbuRivZpLpNDRwa821/sDUyat746ngjl6TIa3mC I83A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796317290; x=1796922090; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8O7YznjW1BPBa7nUf7xNb7NeDXGXD45/3bNtFT7c/RY=; b=TRxOgv8+qBzLUE1KP+AEDD6PuwNv/Y9YtJmhGH0QPJJq+WcBTs4mjDqLAhHFrTRRLG 0lTdzkfNw+d9e9xUgwxhg4I23BkWcMAJsMjgRVCA1sN1BFZ4FeQRDy9AnrA8oTvyDMTb QlDI6hwctvK/Q098QFmdQ35svlW8rBtthFu9vnAhOLi/DGJOyFVCVIb5Kv7F2vxdm2Ar fYjZVFlx2Ci6x9kE+ggTp+O2OueJ4Wg2VTdZZ5OxA1P4IWc/h5LZtino5e6jsGXwUxpq sYk1MILGm9Nl7luL8mwq9sJCJAVv3lCMTn5ZRvjddRYGaf38idktBlPyYSfqzaOfwDo6 q6RA== X-Forwarded-Encrypted: i=1; AL+hErEMRW1IBjN5NR8MvtWhqlxYuG/i05pREHhx/6OzmBtVFalNtvseQfNTtXPyCfXs+jLUYHz6lZk=@vger.kernel.org X-Gm-Message-State: APuU4Z9yiObfoFhfhUMEGSMHfuJeA18alBXXLRtJX5Zxsukpf0ZNvGTX O/j5ITNZgMPvSPm5LHNp5/VmuGch3Z4smtAO3tFx51ac50FVqTWHifabjYS2GO5LJr6Wlnfa8kz SXE0tKMUaOQ== X-Received: from dybpj8.prod.google.com ([2002:a05:7301:4248:b0:36c:a092:ca28]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:83cf:10b0:386:b526:24d1 with SMTP id 5a478bee46e88-386b52638e1mr36191274eec.9.1796317289241; Thu, 03 Dec 2026 09:01:29 -0800 (PST) Date: Thu, 3 Dec 2026 09:01:26 -0800 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261203170126.408134-1-irogers@google.com> Subject: [PATCH net v2] eth: funeth: Include FEC stats in fun_free_stats_area() DMA free size From: Ian Rogers To: Dimitris Michailidis , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Daniel Machon , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Elkin Cruz , Ian Rogers Content-Type: text/plain; charset="UTF-8" fun_init_stats_area() allocates coherent DMA memory for (PORT_MAC_RX_STATS_MAX + PORT_MAC_TX_STATS_MAX + PORT_MAC_FEC_STATS_MAX) 64-bit counters (632 bytes), whereas fun_free_stats_area() omits PORT_MAC_FEC_STATS_MAX and passes 616 bytes to dma_free_coherent(), triggering a CONFIG_DMA_API_DEBUG size-mismatch warning on teardown. Define a shared FUN_PORT_NSTATS macro (casting the first enum constant to unsigned int to avoid cross-enum arithmetic) and use it in both fun_init_stats_area() and fun_free_stats_area(). Found with Clang's -Wenum-enum-conversion on an x86_64 allyesconfig build and confirmed by reading both functions; Gemini helped triage the warning and draft the patch and commit message. The issue was not triggered at runtime and the fix is compile-tested only (LLVM=1 W=1 -Werror and -Wenum-enum-conversion) because Fungible Ethernet hardware is not available. Fixes: ee6373ddf3a9 ("net/funeth: probing and netdev ops") Suggested-by: Daniel Machon Signed-off-by: Ian Rogers --- Notes: v2: - Replace the fun_stats_area_size() helper with a compile-time FUN_PORT_NSTATS macro (Daniel Machon, Paolo Abeni). v1: https://lore.kernel.org/r/20261119170613.1519353-1-irogers@google.com .../net/ethernet/fungible/funeth/funeth_main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/fungible/funeth/funeth_main.c b/drivers/net/ethernet/fungible/funeth/funeth_main.c index bad8276d26b0..39cfe4f694d2 100644 --- a/drivers/net/ethernet/fungible/funeth/funeth_main.c +++ b/drivers/net/ethernet/fungible/funeth/funeth_main.c @@ -1457,17 +1457,16 @@ void fun_set_ring_count(struct net_device *netdev, unsigned int ntx, } } +#define FUN_PORT_NSTATS ((unsigned int)PORT_MAC_RX_STATS_MAX + \ + PORT_MAC_TX_STATS_MAX + PORT_MAC_FEC_STATS_MAX) + static int fun_init_stats_area(struct funeth_priv *fp) { - unsigned int nstats; - if (!(fp->port_caps & FUN_PORT_CAP_STATS)) return 0; - nstats = PORT_MAC_RX_STATS_MAX + PORT_MAC_TX_STATS_MAX + - PORT_MAC_FEC_STATS_MAX; - - fp->stats = dma_alloc_coherent(&fp->pdev->dev, nstats * sizeof(u64), + fp->stats = dma_alloc_coherent(&fp->pdev->dev, + FUN_PORT_NSTATS * sizeof(u64), &fp->stats_dma_addr, GFP_KERNEL); if (!fp->stats) return -ENOMEM; @@ -1476,11 +1475,9 @@ static int fun_init_stats_area(struct funeth_priv *fp) static void fun_free_stats_area(struct funeth_priv *fp) { - unsigned int nstats; - if (fp->stats) { - nstats = PORT_MAC_RX_STATS_MAX + PORT_MAC_TX_STATS_MAX; - dma_free_coherent(&fp->pdev->dev, nstats * sizeof(u64), + dma_free_coherent(&fp->pdev->dev, + FUN_PORT_NSTATS * sizeof(u64), fp->stats, fp->stats_dma_addr); fp->stats = NULL; } -- 2.56.1.911.g883d8bcb20-goog