Thread (7 messages) 7 messages, 2 authors, 6d ago

Re: [PATCH net-next] tg3: normalize inherited M3000 register byte order

flat view

From: Magnus Lindholm <linmag7@gmail.com>
Date: 2026-10-09 06:29:04
Also in: lkml, sparclinux

Hi Andrew,

On Fri, Oct 9, 2026 at 3:13 AM Andrew Lunn [off-list ref] wrote:
On Fri, Oct 09, 2026 at 12:04:03AM +0200, Magnus Lindholm wrote:
quoted
M3000 firmware can leave BCM5718 vendor registers byte-swapped while
standard PCI fields retain normal byte order. Match the Fujitsu 10cf:165a
subsystem, IKKAKU model and swapped revision/product signature before
restoring host control; reject failed PCI accesses or register readbacks.

Keep this in probe so failures can abort initialization; SPARC firmware
enumeration skips PCI_FIXUP_EARLY. Normal rebinds and other platforms
retain their existing path.

Use tg3.h's MISC_HOST_CTRL_BYTE_SWAP and TG3PCI_GEN2_PRODID_ASICREV;
the inherited state was observed on M3000 hardware.

Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
quoted
+/* M3000 firmware can leave the on-board BCM5718 registers byte-swapped. */
+static bool tg3_is_m3000(struct pci_dev *pdev)
+{
+     struct device_node *root;
+     const char *model;
+     bool match;
+
+     if (pdev->vendor != PCI_VENDOR_ID_BROADCOM ||
+         pdev->device != TG3PCI_DEVICE_TIGON3_5718 ||
+         pdev->subsystem_vendor != 0x10cf ||
+         pdev->subsystem_device != 0x165a)
+             return false;
+
+     root = of_find_node_by_path("/");
+     match = !of_property_read_string(root, "model", &model) &&
+             !strcmp(model, "IKKAKU");
The DT Maintainers generally don't like this.

Is there a legitimate reason you would want the bytes are swapped?

Can you not just probe the registers, and if they are swapped undo it?
Does it really need to be conditional on the machine?
Thanks for the suggestion. I've tested a revised approach without
the machine-model or subsystem checks. It checks the BCM5718 register
state, leaving a normal revision signature untouched and requiring
the swapped revision, byte-swap bit and product ID before correcting
the byte order. Both register readbacks are checked afterward.

On the M3000, all four ports normalized at boot, with no additional
normalization on driver rebind. Link cycling and bidirectional
file-transfer checks also passed.

I'll send v2 shortly.

Thanks,
Magnus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help