* Re: [PATCH net v3 0/3] tg3: Bug fixes
2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
@ 2026-11-18 10:52 ` netdev-bot+sinfo
2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-11-18 10:52 UTC (permalink / raw)
To: Pavan Chebbi
Cc: michael.chan, kuba, andrew+netdev, andrew.gospodarek, davem,
edumazet, netdev, pabeni
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported
2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
2026-11-18 10:52 ` netdev-bot+sinfo
@ 2026-11-18 10:54 ` Pavan Chebbi
2026-11-18 10:54 ` [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready Pavan Chebbi
2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
3 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
To: michael.chan, kuba
Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
Pavan Chebbi, Rui Salvaterra
Commit 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for
BCM57766 chipsets") lowered the coherent DMA mask to 31 bits as a
workaround for a spurious address overflow error in the hardware.
The result of dma_set_coherent_mask() is fatal to probe, so on
platforms that cannot satisfy such a mask the device fails to probe:
tg3 0000:01:00.0: Unable to obtain 64 bit DMA for consistent allocations
tg3 0000:01:00.0: probe with driver tg3 failed with error -5
This was reported on a Mac mini (Macmini6,2, BCM57766) running a
kernel built without CONFIG_ZONE_DMA and with IOMMU passthrough as
the default. Without CONFIG_ZONE_DMA, dma_direct_supported() only
accepts a mask narrower than 32 bits if it covers the highest
physical memory address, so with direct mapping a 31-bit coherent
mask is rejected whenever memory extends above 2GB.
Treat the 31-bit mask as best effort. If it is refused, warn and fall
back to the mask used before 614f4d166eee, so that the device still
probes. Platforms that accept the mask are unaffected. Where it is
refused, 614f4d166eee never protected the device, it only stopped it
from probing, so this restores the behaviour of kernels before that
commit. Warn when a status block lands at an address matching the
pattern described in 614f4d166eee, so that a resulting TX timeout can
be identified.
Fixes: 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets")
Reported-by: Rui Salvaterra <rsalvaterra@gmail.com>
Link: https://lore.kernel.org/netdev/CALjTZvYKHWrD5m+RXimjxODvpFPw7Cq_EOEuzRi1PZT9_JxF+g@mail.gmail.com/
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 95827df4cf6a..2cf9d2ea069b 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8867,6 +8867,13 @@ static int tg3_alloc_consistent(struct tg3 *tp)
if (!tnapi->hw_status)
goto err_out;
+ if (tg3_asic_rev(tp) == ASIC_REV_57766 &&
+ (lower_32_bits(tnapi->status_mapping) & 0xffff0000) ==
+ 0xffff0000)
+ dev_warn(&tp->pdev->dev,
+ "Status block at DMA address %pad may cause TX timeouts on this device\n",
+ &tnapi->status_mapping);
+
sblk = tnapi->hw_status;
if (tg3_flag(tp, ENABLE_RSS)) {
@@ -17756,6 +17763,7 @@ static int tg3_init_one(struct pci_dev *pdev,
u64 dma_mask, persist_dma_mask;
netdev_features_t features = 0;
u8 addr[ETH_ALEN] __aligned(2);
+ u64 test_dma_mask = 0;
err = pci_enable_device(pdev);
if (err) {
@@ -17895,15 +17903,22 @@ static int tg3_init_one(struct pci_dev *pdev,
persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
if (tg3_asic_rev(tp) == ASIC_REV_57766)
- persist_dma_mask = DMA_BIT_MASK(31);
+ test_dma_mask = DMA_BIT_MASK(31);
/* Configure DMA attributes. */
if (dma_mask > DMA_BIT_MASK(32)) {
err = dma_set_mask(&pdev->dev, dma_mask);
if (!err) {
features |= NETIF_F_HIGHDMA;
- err = dma_set_coherent_mask(&pdev->dev,
- persist_dma_mask);
+ if (!test_dma_mask ||
+ dma_set_coherent_mask(&pdev->dev,
+ test_dma_mask)) {
+ if (test_dma_mask)
+ dev_warn(&pdev->dev,
+ "Unable to set 31 bit coherent DMA mask, workaround not applied\n");
+ err = dma_set_coherent_mask(&pdev->dev,
+ persist_dma_mask);
+ }
if (err < 0) {
dev_err(&pdev->dev, "Unable to obtain 64 bit "
"DMA for consistent allocations\n");
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready
2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
2026-11-18 10:52 ` netdev-bot+sinfo
2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
@ 2026-11-18 10:54 ` Pavan Chebbi
2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
3 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
To: michael.chan, kuba
Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
Pavan Chebbi
When the APE firmware is not present or not ready, for example when
the NCSI component is missing in the NVRAM, tg3_read_fw_ver() still
calls tg3_read_dash_ver() after tg3_probe_ncsi(). The signature and
ready checks that tg3_read_dash_ver() used to make were moved into
tg3_probe_ncsi(), which only sets the NCSI flag and does not stop the
caller. The driver then reads the APE firmware version register, which
holds no valid data in this state, and ethtool -i shows an invalid
"DASH" string with a garbage version.
Make tg3_probe_ncsi() return whether valid, ready APE firmware was
found, and read the version only in that case. Otherwise just report
the bootcode version.
This was seen by a user on BCM5719/BCM5720 with no NCSI component in
the NVRAM. With this change, ethtool -i displays only the bootcode
version.
Fixes: 165f4d1cb3d7 ("tg3: Fix the setting of the APE_HAS_NCSI flag")
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 2cf9d2ea069b..5a0e247a4c46 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -15997,20 +15997,26 @@ static void tg3_read_mgmtfw_ver(struct tg3 *tp)
}
}
-static void tg3_probe_ncsi(struct tg3 *tp)
+/* Returns true if valid, ready APE firmware is present, regardless of
+ * whether it advertises NCSI (it may be DASH or SMASH). Sets APE_HAS_NCSI
+ * if the NCSI feature is advertised.
+ */
+static bool tg3_probe_ncsi(struct tg3 *tp)
{
u32 apedata;
apedata = tg3_ape_read32(tp, TG3_APE_SEG_SIG);
if (apedata != APE_SEG_SIG_MAGIC)
- return;
+ return false;
apedata = tg3_ape_read32(tp, TG3_APE_FW_STATUS);
if (!(apedata & APE_FW_STATUS_READY))
- return;
+ return false;
if (tg3_ape_read32(tp, TG3_APE_FW_FEATURES) & TG3_APE_FW_FEATURE_NCSI)
tg3_flag_set(tp, APE_HAS_NCSI);
+
+ return true;
}
static void tg3_read_dash_ver(struct tg3 *tp)
@@ -16089,8 +16095,7 @@ static void tg3_read_fw_ver(struct tg3 *tp)
if (tg3_flag(tp, ENABLE_ASF)) {
if (tg3_flag(tp, ENABLE_APE)) {
- tg3_probe_ncsi(tp);
- if (!vpd_vers)
+ if (tg3_probe_ncsi(tp) && !vpd_vers)
tg3_read_dash_ver(tp);
} else if (!vpd_vers) {
tg3_read_mgmtfw_ver(tp);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path
2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
` (2 preceding siblings ...)
2026-11-18 10:54 ` [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready Pavan Chebbi
@ 2026-11-18 10:54 ` Pavan Chebbi
3 siblings, 0 replies; 5+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
To: michael.chan, kuba
Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
Shravya KN, Pavan Chebbi
From: Shravya KN <shravya.k-n@broadcom.com>
tg3_nvram_write_block_unbuffered() reads a whole NVRAM page into a
buffer of pagesize bytes, copies the caller's data into it at page_off,
and writes the page back. The copy size was clamped to pagesize rather
than to the room left in the page, pagesize - page_off, so a write at an
offset that is not page aligned, as ETHTOOL_SEEPROM allows, copies past
the end of the buffer and corrupts the kernel heap.
Clamp size to pagesize - page_off. Also advance buf by size on each
iteration. Without this, a write that spans more than one page
programmed every page after the first with the data of the first page,
and a write that did not start on a page boundary lost the tail of the
data without reporting an error.
Reject an nvram_pagesize that is smaller than 4 or not a power of two.
The page mask is pagesize - 1, which is only a valid mask for a power
of two. A page size of 0, which tg3_get_nvram_info() leaves unset for
an unhandled flash vendor, also made the loop issue erase commands at
address 0 forever with the rtnl and NVRAM locks held. ethtool -E now
fails with -EINVAL in these cases.
This was found by an AI code review scan. It has not been observed on
hardware, but it can be reached with ethtool -E on devices with
unbuffered flash.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Shravya KN <shravya.k-n@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 5a0e247a4c46..12f199355984 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -56,6 +56,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/crc32.h>
#include <linux/dmi.h>
+#include <linux/log2.h>
#include <net/checksum.h>
#include <net/gso.h>
@@ -3379,6 +3380,9 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
u32 nvram_cmd;
u8 *tmp;
+ if (pagesize < 4 || !is_power_of_2(pagesize))
+ return -EINVAL;
+
tmp = kmalloc(pagesize, GFP_KERNEL);
if (tmp == NULL)
return -ENOMEM;
@@ -3399,13 +3403,14 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
break;
page_off = offset & pagemask;
- size = pagesize;
+ size = pagesize - page_off;
if (len < size)
size = len;
len -= size;
memcpy(tmp + page_off, buf, size);
+ buf += size;
offset = offset + (pagesize - page_off);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread