AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/11 18:16 flow patch-triage
4m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patched file (drivers/net/ethernet/cortina/gemini.c) is a platform driver for the Cortina Systems Gemini (StorLink SL351x) Ethernet controller, which is an ARM-specific SoC peripheral. This hardware is not emulated in standard QEMU/GCE virtualization environments and is structurally unreachable on the target architecture (amd64).",
  "WorthFuzzing": false
}

1/1 2026/10/11 18:16 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 66b204a3384cfce65a08505180cf66059d607408\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sun Oct 11 18:16:50 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c\nindex 2fe7fd0202d26..9f7946876d585 100644\n--- a/drivers/net/ethernet/cortina/gemini.c\n+++ b/drivers/net/ethernet/cortina/gemini.c\n@@ -14,7 +14,9 @@\n  * Gary Chen \u0026 Ch Hsu Storlink Semiconductor\n  */\n #include \u003clinux/kernel.h\u003e\n+#include \u003clinux/bitmap.h\u003e\n #include \u003clinux/init.h\u003e\n+#include \u003clinux/mm.h\u003e\n #include \u003clinux/module.h\u003e\n #include \u003clinux/net.h\u003e\n #include \u003clinux/platform_device.h\u003e\n@@ -25,6 +27,7 @@\n #include \u003clinux/interrupt.h\u003e\n #include \u003clinux/reset.h\u003e\n #include \u003clinux/clk.h\u003e\n+#include \u003clinux/rtnetlink.h\u003e\n #include \u003clinux/of.h\u003e\n #include \u003clinux/of_mdio.h\u003e\n #include \u003clinux/of_net.h\u003e\n@@ -34,9 +37,11 @@\n #include \u003clinux/skbuff.h\u003e\n #include \u003clinux/phy.h\u003e\n #include \u003clinux/crc32.h\u003e\n+#include \u003clinux/sizes.h\u003e\n #include \u003clinux/ethtool.h\u003e\n #include \u003clinux/tcp.h\u003e\n #include \u003clinux/u64_stats_sync.h\u003e\n+#include \u003clinux/xarray.h\u003e\n \n #include \u003clinux/in.h\u003e\n #include \u003clinux/ip.h\u003e\n@@ -87,11 +92,13 @@ MODULE_PARM_DESC(debug, \"Debug level (0=none,...,16=all)\");\n /**\n  * struct gmac_queue_page - page buffer per-page info\n  * @page: the page struct\n- * @mapping: the dma address handle\n+ * @mapping: DMA address of the first fragment\n+ * @fragments: number of fragments not yet claimed from the hardware\n  */\n struct gmac_queue_page {\n \tstruct page *page;\n \tdma_addr_t mapping;\n+\tunsigned int fragments;\n };\n \n struct gmac_txq {\n@@ -155,6 +162,7 @@ struct gemini_ethernet_port {\n struct gemini_ethernet {\n \tstruct device *dev;\n \tvoid __iomem *base;\n+\t/* Protected by RTNL. */\n \tstruct gemini_ethernet_port *port0;\n \tstruct gemini_ethernet_port *port1;\n \tbool initialized;\n@@ -165,7 +173,12 @@ struct gemini_ethernet {\n \tstruct gmac_rxdesc *freeq_ring;\n \tdma_addr_t\tfreeq_dma_base;\n \tstruct gmac_queue_page\t*freeq_pages;\n+\tstruct xarray\tfreeq_mappings;\n \tunsigned int\tnum_freeq_pages;\n+\tunsigned long\t*freeq_page_bitmap;\n+\tunsigned long\t*freeq_recycle_bitmap;\n+\tunsigned int\tfreeq_page_cursor;\n+\tunsigned int\tfreeq_recycle_pending;\n \tspinlock_t\tfreeq_lock; /* Locks queue from reentrance */\n };\n \n@@ -463,6 +476,17 @@ static int gmac_pick_rx_max_len(unsigned int max_l3_len)\n \treturn -1;\n }\n \n+static unsigned int gmac_pick_rxq_order(void)\n+{\n+\tif (totalram_pages() \u003c= (SZ_32M \u003e\u003e PAGE_SHIFT))\n+\t\treturn DEFAULT_GMAC_RXQ_ORDER - 2;\n+\n+\tif (totalram_pages() \u003c= (SZ_64M \u003e\u003e PAGE_SHIFT))\n+\t\treturn DEFAULT_GMAC_RXQ_ORDER - 1;\n+\n+\treturn DEFAULT_GMAC_RXQ_ORDER;\n+}\n+\n static int gmac_init(struct net_device *netdev)\n {\n \tstruct gemini_ethernet_port *port = netdev_priv(netdev);\n@@ -531,7 +555,7 @@ static int gmac_init(struct net_device *netdev)\n \twritel(sw_weigh.bits32,\n \t       port-\u003edma_base + GMAC_TX_WEIGHTING_CTRL_1_REG);\n \n-\tport-\u003erxq_order = DEFAULT_GMAC_RXQ_ORDER;\n+\tport-\u003erxq_order = gmac_pick_rxq_order();\n \tport-\u003etxq_order = DEFAULT_GMAC_TXQ_ORDER;\n \tport-\u003erx_coalesce_nsecs = DEFAULT_RX_COALESCE_NSECS;\n \n@@ -724,31 +748,109 @@ static int gmac_setup_rxq(struct net_device *netdev)\n \treturn 0;\n }\n \n-static struct gmac_queue_page *\n-gmac_get_queue_page(struct gemini_ethernet *geth,\n-\t\t    struct gemini_ethernet_port *port,\n-\t\t    dma_addr_t addr)\n+static unsigned long\n+geth_freeq_mapping_index(const struct gemini_ethernet *geth,\n+\t\t\t dma_addr_t mapping)\n {\n-\tstruct gmac_queue_page *gpage;\n-\tdma_addr_t mapping;\n-\tint i;\n+\treturn (unsigned long)(mapping \u003e\u003e geth-\u003efreeq_frag_order);\n+}\n \n-\t/* Only look for even pages */\n-\tmapping = addr \u0026 PAGE_MASK;\n+static int geth_freeq_alloc_slot(struct gemini_ethernet *geth)\n+{\n+\tunsigned int slot;\n \n-\tif (!geth-\u003efreeq_pages) {\n-\t\tdev_err_ratelimited(geth-\u003edev,\n-\t\t\t\t    \"try to get page with no page list\\n\");\n-\t\treturn NULL;\n+\tlockdep_assert_held(\u0026geth-\u003efreeq_lock);\n+\n+\tslot = find_next_zero_bit(geth-\u003efreeq_page_bitmap,\n+\t\t\t\t  geth-\u003enum_freeq_pages,\n+\t\t\t\t  geth-\u003efreeq_page_cursor);\n+\tif (slot == geth-\u003enum_freeq_pages) {\n+\t\tslot = find_first_zero_bit(geth-\u003efreeq_page_bitmap,\n+\t\t\t\t\t   geth-\u003efreeq_page_cursor);\n+\t\tif (slot == geth-\u003efreeq_page_cursor)\n+\t\t\treturn -ENOSPC;\n+\t}\n+\n+\t__set_bit(slot, geth-\u003efreeq_page_bitmap);\n+\tgeth-\u003efreeq_page_cursor = slot + 1;\n+\tif (geth-\u003efreeq_page_cursor == geth-\u003enum_freeq_pages)\n+\t\tgeth-\u003efreeq_page_cursor = 0;\n+\n+\treturn slot;\n+}\n+\n+static int geth_freeq_recycle_slot(struct gemini_ethernet *geth)\n+{\n+\tunsigned int slot = geth-\u003efreeq_page_cursor;\n+\n+\tlockdep_assert_held(\u0026geth-\u003efreeq_lock);\n+\n+\tif (!geth-\u003efreeq_recycle_pending)\n+\t\treturn -ENOSPC;\n+\n+\tslot = find_next_bit(geth-\u003efreeq_recycle_bitmap,\n+\t\t\t     geth-\u003enum_freeq_pages,\n+\t\t\t     geth-\u003efreeq_page_cursor);\n+\tif (slot == geth-\u003enum_freeq_pages) {\n+\t\tslot = find_first_bit(geth-\u003efreeq_recycle_bitmap,\n+\t\t\t\t      geth-\u003efreeq_page_cursor);\n+\t\tif (slot == geth-\u003efreeq_page_cursor)\n+\t\t\treturn -ENOSPC;\n \t}\n \n-\t/* Look up a ring buffer page from virtual mapping */\n-\tfor (i = 0; i \u003c geth-\u003enum_freeq_pages; i++) {\n-\t\tgpage = \u0026geth-\u003efreeq_pages[i];\n-\t\tif (gpage-\u003emapping == mapping)\n-\t\t\treturn gpage;\n+\t__clear_bit(slot, geth-\u003efreeq_recycle_bitmap);\n+\tgeth-\u003efreeq_page_cursor = slot + 1;\n+\tif (geth-\u003efreeq_page_cursor == geth-\u003enum_freeq_pages)\n+\t\tgeth-\u003efreeq_page_cursor = 0;\n+\tgeth-\u003efreeq_recycle_pending--;\n+\n+\treturn slot;\n+}\n+\n+static struct page *geth_freeq_claim(struct gemini_ethernet *geth,\n+\t\t\t\t     dma_addr_t mapping,\n+\t\t\t\t     unsigned int *page_offs)\n+{\n+\tunsigned int frag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order;\n+\tstruct gmac_queue_page *gpage;\n+\tunsigned long index;\n+\tunsigned long flags;\n+\tdma_addr_t page_mapping;\n+\tstruct page *page;\n+\tunsigned int slot;\n+\tbool valid;\n+\n+\tindex = geth_freeq_mapping_index(geth, mapping);\n+\n+\tspin_lock_irqsave(\u0026geth-\u003efreeq_lock, flags);\n+\tgpage = xa_load(\u0026geth-\u003efreeq_mappings, index);\n+\tif (!gpage || !gpage-\u003epage || !gpage-\u003efragments)\n+\t\tgoto err_unlock;\n+\n+\tpage = gpage-\u003epage;\n+\tpage_mapping = gpage-\u003emapping;\n+\tvalid = mapping \u003e= page_mapping \u0026\u0026\n+\t\tmapping - page_mapping \u003c= PAGE_SIZE - frag_len \u0026\u0026\n+\t\t!((mapping - page_mapping) \u0026 (frag_len - 1));\n+\tif (!valid)\n+\t\tgoto err_unlock;\n+\n+\tdma_sync_single_range_for_cpu(geth-\u003edev, page_mapping,\n+\t\t\t\t      mapping - page_mapping, frag_len,\n+\t\t\t\t      DMA_FROM_DEVICE);\n+\txa_erase(\u0026geth-\u003efreeq_mappings, index);\n+\tif (!--gpage-\u003efragments) {\n+\t\tslot = gpage - geth-\u003efreeq_pages;\n+\t\t__set_bit(slot, geth-\u003efreeq_recycle_bitmap);\n+\t\tgeth-\u003efreeq_recycle_pending++;\n \t}\n \n+\t*page_offs = mapping - page_mapping;\n+\tspin_unlock_irqrestore(\u0026geth-\u003efreeq_lock, flags);\n+\treturn page;\n+\n+err_unlock:\n+\tspin_unlock_irqrestore(\u0026geth-\u003efreeq_lock, flags);\n \treturn NULL;\n }\n \n@@ -757,11 +859,12 @@ static void gmac_cleanup_rxq(struct net_device *netdev)\n \tstruct gemini_ethernet_port *port = netdev_priv(netdev);\n \tstruct gemini_ethernet *geth = port-\u003egeth;\n \tstruct gmac_rxdesc *rxd = port-\u003erxq_ring;\n-\tstatic struct gmac_queue_page *gpage;\n \tstruct nontoe_qhdr __iomem *qhdr;\n \tvoid __iomem *dma_reg;\n \tvoid __iomem *ptr_reg;\n+\tunsigned int page_offs;\n \tdma_addr_t mapping;\n+\tstruct page *page;\n \tunion dma_rwptr rw;\n \tunsigned int r, w;\n \n@@ -788,42 +891,65 @@ static void gmac_cleanup_rxq(struct net_device *netdev)\n \t\tif (!mapping)\n \t\t\tcontinue;\n \n-\t\t/* Freeq pointers are one page off */\n-\t\tgpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE);\n-\t\tif (!gpage) {\n+\t\tpage = geth_freeq_claim(geth, mapping, \u0026page_offs);\n+\t\tif (!page) {\n \t\t\tdev_err(geth-\u003edev, \"could not find page\\n\");\n \t\t\tcontinue;\n \t\t}\n \t\t/* Release the RX queue reference to the page */\n-\t\tput_page(gpage-\u003epage);\n+\t\tput_page(page);\n \t}\n \n \tdma_free_coherent(geth-\u003edev, sizeof(*port-\u003erxq_ring) \u003c\u003c port-\u003erxq_order,\n \t\t\t  port-\u003erxq_ring, port-\u003erxq_dma_base);\n }\n \n-static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,\n-\t\t\t\t\t      int pn)\n+static int geth_freeq_map_page(struct gemini_ethernet *geth,\n+\t\t\t       struct page **pagep,\n+\t\t\t       dma_addr_t *page_mappingp)\n {\n-\tstruct gmac_rxdesc *freeq_entry;\n-\tstruct gmac_queue_page *gpage;\n-\tunsigned int fpp_order;\n-\tunsigned int frag_len;\n-\tdma_addr_t mapping;\n+\tdma_addr_t page_mapping;\n \tstruct page *page;\n-\tint i;\n \n-\t/* First allocate and DMA map a single page */\n \tpage = alloc_page(GFP_ATOMIC);\n \tif (!page)\n-\t\treturn NULL;\n+\t\treturn -ENOMEM;\n \n-\tmapping = dma_map_single(geth-\u003edev, page_address(page),\n-\t\t\t\t PAGE_SIZE, DMA_FROM_DEVICE);\n-\tif (dma_mapping_error(geth-\u003edev, mapping)) {\n+\tpage_mapping = dma_map_single(geth-\u003edev, page_address(page),\n+\t\t\t\t      PAGE_SIZE, DMA_FROM_DEVICE);\n+\tif (dma_mapping_error(geth-\u003edev, page_mapping)) {\n \t\tput_page(page);\n-\t\treturn NULL;\n+\t\treturn -ENOMEM;\n \t}\n+\tif (page_mapping \u003e U32_MAX - (PAGE_SIZE - 1)) {\n+\t\tdev_err_ratelimited(geth-\u003edev,\n+\t\t\t\t    \"freeq DMA mapping exceeds 32 bits\\n\");\n+\t\tdma_unmap_single(geth-\u003edev, page_mapping, PAGE_SIZE,\n+\t\t\t\t DMA_FROM_DEVICE);\n+\t\tput_page(page);\n+\t\treturn -EOVERFLOW;\n+\t}\n+\n+\t*pagep = page;\n+\t*page_mappingp = page_mapping;\n+\n+\treturn 0;\n+}\n+\n+static int geth_freeq_post_page(struct gemini_ethernet *geth, unsigned int pn,\n+\t\t\t\tstruct gmac_queue_page *gpage, bool recycle)\n+{\n+\tstruct gmac_rxdesc *freeq_entry;\n+\tunsigned int fpp_order;\n+\tunsigned int fragments;\n+\tunsigned int frag_len;\n+\tdma_addr_t page_mapping = gpage-\u003emapping;\n+\tdma_addr_t mapping;\n+\tstruct page *page = gpage-\u003epage;\n+\tint ret;\n+\tint i;\n+\n+\tlockdep_assert_held(\u0026geth-\u003efreeq_lock);\n \n \t/* The assign the page mapping (physical address) to the buffer address\n \t * in the hardware queue. PAGE_SHIFT on ARM is 12 (1 page is 4096 bytes,\n@@ -833,43 +959,115 @@ static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,\n \t */\n \tfrag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order; /* Usually 2048 */\n \tfpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n+\tfragments = 1 \u003c\u003c fpp_order;\n+\n+\tfor (i = 0; i \u003c fragments; i++) {\n+\t\tmapping = page_mapping + i * frag_len;\n+\t\tret = xa_insert(\u0026geth-\u003efreeq_mappings,\n+\t\t\t\tgeth_freeq_mapping_index(geth, mapping),\n+\t\t\t\tgpage, GFP_ATOMIC);\n+\t\tif (ret)\n+\t\t\tgoto err_mappings;\n+\t}\n+\tif (recycle)\n+\t\tdma_sync_single_for_device(geth-\u003edev, page_mapping, PAGE_SIZE,\n+\t\t\t\t\t   DMA_FROM_DEVICE);\n+\tgpage-\u003efragments = fragments;\n+\tpage_ref_add(page, fragments);\n+\n \tfreeq_entry = geth-\u003efreeq_ring + (pn \u003c\u003c fpp_order);\n-\tdev_dbg(geth-\u003edev, \"allocate page %d fragment length %d fragments per page %d, freeq entry %p\\n\",\n-\t\t pn, frag_len, (1 \u003c\u003c fpp_order), freeq_entry);\n+\tdev_dbg(geth-\u003edev, \"post page %d fragment length %d fragments per page %d, freeq entry %p\\n\",\n+\t\tpn, frag_len, (1 \u003c\u003c fpp_order), freeq_entry);\n+\tmapping = page_mapping;\n \tfor (i = (1 \u003c\u003c fpp_order); i \u003e 0; i--) {\n \t\tfreeq_entry-\u003eword2.buf_adr = mapping;\n \t\tfreeq_entry++;\n \t\tmapping += frag_len;\n \t}\n+\tdev_dbg(geth-\u003edev, \"page %d, DMA addr: %pad, page %p\\n\",\n+\t\tpn, \u0026page_mapping, page);\n \n-\t/* If the freeq entry already has a page mapped, then unmap it. */\n-\tgpage = \u0026geth-\u003efreeq_pages[pn];\n-\tif (gpage-\u003epage) {\n-\t\tmapping = geth-\u003efreeq_ring[pn \u003c\u003c fpp_order].word2.buf_adr;\n-\t\tdma_unmap_single(geth-\u003edev, mapping, frag_len, DMA_FROM_DEVICE);\n-\t\t/* This should be the last reference to the page so it gets\n-\t\t * released\n-\t\t */\n-\t\tput_page(gpage-\u003epage);\n+\treturn 0;\n+\n+err_mappings:\n+\twhile (i--) {\n+\t\tmapping = page_mapping + i * frag_len;\n+\t\txa_erase(\u0026geth-\u003efreeq_mappings,\n+\t\t\t geth_freeq_mapping_index(geth, mapping));\n \t}\n+\treturn ret;\n+}\n \n-\t/* Then put our new mapping into the page table */\n-\tdev_dbg(geth-\u003edev, \"page %d, DMA addr: %08x, page %p\\n\",\n-\t\tpn, (unsigned int)mapping, page);\n-\tgpage-\u003emapping = mapping;\n+static int geth_freeq_add_page(struct gemini_ethernet *geth, unsigned int pn,\n+\t\t\t       struct page *page, dma_addr_t page_mapping)\n+{\n+\tstruct gmac_queue_page *gpage;\n+\tint ret;\n+\tint slot;\n+\n+\tlockdep_assert_held(\u0026geth-\u003efreeq_lock);\n+\n+\tslot = geth_freeq_alloc_slot(geth);\n+\tif (slot \u003c 0)\n+\t\treturn slot;\n+\n+\tgpage = \u0026geth-\u003efreeq_pages[slot];\n \tgpage-\u003epage = page;\n+\tgpage-\u003emapping = page_mapping;\n+\tret = geth_freeq_post_page(geth, pn, gpage, false);\n+\tif (ret) {\n+\t\tgpage-\u003epage = NULL;\n+\t\tgpage-\u003emapping = 0;\n+\t\t__clear_bit(slot, geth-\u003efreeq_page_bitmap);\n+\t}\n \n-\treturn page;\n+\treturn ret;\n+}\n+\n+static int geth_freeq_recycle_page(struct gemini_ethernet *geth,\n+\t\t\t\t   unsigned int pn)\n+{\n+\tstruct gmac_queue_page *gpage;\n+\tstruct page *page;\n+\tint ret;\n+\tint slot;\n+\n+\tlockdep_assert_held(\u0026geth-\u003efreeq_lock);\n+\n+\tslot = geth_freeq_recycle_slot(geth);\n+\tif (slot \u003c 0)\n+\t\treturn slot;\n+\n+\tgpage = \u0026geth-\u003efreeq_pages[slot];\n+\tif (page_ref_count(gpage-\u003epage) \u003e 1) {\n+\t\tpage = gpage-\u003epage;\n+\t\tdma_unmap_single_attrs(geth-\u003edev, gpage-\u003emapping, PAGE_SIZE,\n+\t\t\t\t       DMA_FROM_DEVICE,\n+\t\t\t\t       DMA_ATTR_SKIP_CPU_SYNC);\n+\t\tgpage-\u003epage = NULL;\n+\t\tgpage-\u003emapping = 0;\n+\t\t__clear_bit(slot, geth-\u003efreeq_page_bitmap);\n+\t\tput_page(page);\n+\t\treturn -EAGAIN;\n+\t}\n+\n+\tret = geth_freeq_post_page(geth, pn, gpage, true);\n+\tif (ret) {\n+\t\t__set_bit(slot, geth-\u003efreeq_recycle_bitmap);\n+\t\tgeth-\u003efreeq_recycle_pending++;\n+\t}\n+\n+\treturn ret;\n }\n \n /**\n  * geth_fill_freeq() - Fill the freeq with empty fragments to use\n  * @geth: the ethernet adapter\n- * @refill: whether to reset the queue by filling in all freeq entries or\n- * just refill it, usually the interrupt to refill the queue happens when\n- * the queue is half empty.\n+ *\n+ * Usually the interrupt to refill the queue happens when the queue is half\n+ * empty.\n  */\n-static unsigned int geth_fill_freeq(struct gemini_ethernet *geth, bool refill)\n+static unsigned int geth_fill_freeq(struct gemini_ethernet *geth)\n {\n \tunsigned int fpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n \tunsigned int count = 0;\n@@ -877,63 +1075,145 @@ static unsigned int geth_fill_freeq(struct gemini_ethernet *geth, bool refill)\n \tunsigned long flags;\n \tunion dma_rwptr rw;\n \tunsigned int m_pn;\n+\tbool recycle = true;\n \n \t/* Mask for page */\n \tm_pn = (1 \u003c\u003c (geth-\u003efreeq_order - fpp_order)) - 1;\n \n-\tspin_lock_irqsave(\u0026geth-\u003efreeq_lock, flags);\n-\n-\trw.bits32 = readl(geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG);\n-\tpn = (refill ? rw.bits.wptr : rw.bits.rptr) \u003e\u003e fpp_order;\n-\tepn = (rw.bits.rptr \u003e\u003e fpp_order) - 1;\n-\tepn \u0026= m_pn;\n-\n \t/* Loop over the freeq ring buffer entries */\n-\twhile (pn != epn) {\n-\t\tstruct gmac_queue_page *gpage;\n+\tfor (;;) {\n+\t\tdma_addr_t page_mapping;\n \t\tstruct page *page;\n+\t\tint ret;\n+\n+\t\tspin_lock_irqsave(\u0026geth-\u003efreeq_lock, flags);\n+\t\trw.bits32 = readl(geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG);\n+\t\tpn = (rw.bits.wptr \u003e\u003e fpp_order) \u0026 m_pn;\n+\t\tepn = (rw.bits.rptr \u003e\u003e fpp_order) - 1;\n+\t\tepn \u0026= m_pn;\n+\t\tret = -ENOSPC;\n+\t\tif (pn != epn \u0026\u0026 recycle) {\n+\t\t\tret = geth_freeq_recycle_page(geth, pn);\n+\t\t\tif (!ret) {\n+\t\t\t\tcount += 1 \u003c\u003c fpp_order;\n+\t\t\t\tpn++;\n+\t\t\t\tpn \u0026= m_pn;\n+\t\t\t\twritew(pn \u003c\u003c fpp_order,\n+\t\t\t\t       geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG + 2);\n+\t\t\t}\n+\t\t\tif (ret == -ENOSPC)\n+\t\t\t\trecycle = false;\n+\t\t}\n+\t\tspin_unlock_irqrestore(\u0026geth-\u003efreeq_lock, flags);\n+\t\tif (pn == epn)\n+\t\t\tbreak;\n+\t\tif (!ret)\n+\t\t\tcontinue;\n+\t\tif (ret != -ENOSPC \u0026\u0026 ret != -EAGAIN)\n+\t\t\tbreak;\n \n-\t\tgpage = \u0026geth-\u003efreeq_pages[pn];\n-\t\tpage = gpage-\u003epage;\n+\t\tret = geth_freeq_map_page(geth, \u0026page, \u0026page_mapping);\n+\t\tif (ret)\n+\t\t\tbreak;\n \n-\t\tdev_dbg(geth-\u003edev, \"fill entry %d page ref count %d add %d refs\\n\",\n-\t\t\tpn, page_ref_count(page), 1 \u003c\u003c fpp_order);\n+\t\tspin_lock_irqsave(\u0026geth-\u003efreeq_lock, flags);\n \n-\t\tif (page_ref_count(page) \u003e 1) {\n-\t\t\tunsigned int fl = (pn - epn) \u0026 m_pn;\n+\t\trw.bits32 = readl(geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG);\n+\t\tpn = (rw.bits.wptr \u003e\u003e fpp_order) \u0026 m_pn;\n+\t\tepn = (rw.bits.rptr \u003e\u003e fpp_order) - 1;\n+\t\tepn \u0026= m_pn;\n+\t\tif (pn == epn) {\n+\t\t\tret = -ENOSPC;\n+\t\t} else {\n+\t\t\tret = geth_freeq_add_page(geth, pn, page,\n+\t\t\t\t\t\t  page_mapping);\n+\t\t\tif (!ret) {\n+\t\t\t\tcount += 1 \u003c\u003c fpp_order;\n+\t\t\t\tpn++;\n+\t\t\t\tpn \u0026= m_pn;\n+\t\t\t\twritew(pn \u003c\u003c fpp_order,\n+\t\t\t\t       geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG + 2);\n+\t\t\t}\n+\t\t}\n \n-\t\t\tif (fl \u003e 64 \u003e\u003e fpp_order)\n-\t\t\t\tbreak;\n+\t\tspin_unlock_irqrestore(\u0026geth-\u003efreeq_lock, flags);\n \n-\t\t\tpage = geth_freeq_alloc_map_page(geth, pn);\n-\t\t\tif (!page)\n-\t\t\t\tbreak;\n+\t\tif (ret) {\n+\t\t\tdma_unmap_single(geth-\u003edev, page_mapping, PAGE_SIZE,\n+\t\t\t\t\t DMA_FROM_DEVICE);\n+\t\t\tput_page(page);\n+\t\t\tbreak;\n \t\t}\n+\t}\n \n-\t\t/* Add one reference per fragment in the page */\n-\t\tpage_ref_add(page, 1 \u003c\u003c fpp_order);\n-\t\tcount += 1 \u003c\u003c fpp_order;\n-\t\tpn++;\n-\t\tpn \u0026= m_pn;\n+\treturn count;\n+}\n+\n+static void geth_freeq_release_pages(struct gemini_ethernet *geth)\n+{\n+\tunsigned int fpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n+\tunsigned int frag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order;\n+\tunsigned int pn;\n+\n+\tfor (pn = 0; pn \u003c geth-\u003enum_freeq_pages; pn++) {\n+\t\tstruct gmac_queue_page *gpage;\n+\t\tdma_addr_t mapping;\n+\t\tstruct page *page;\n+\t\tunsigned int i;\n+\n+\t\tgpage = \u0026geth-\u003efreeq_pages[pn];\n+\t\tif (!gpage-\u003epage)\n+\t\t\tcontinue;\n+\n+\t\tpage = gpage-\u003epage;\n+\t\tfor (i = 0; i \u003c (1 \u003c\u003c fpp_order); i++) {\n+\t\t\tmapping = gpage-\u003emapping + i * frag_len;\n+\t\t\tif (xa_load(\u0026geth-\u003efreeq_mappings,\n+\t\t\t\t    geth_freeq_mapping_index(geth, mapping)) != gpage)\n+\t\t\t\tcontinue;\n+\n+\t\t\tdma_sync_single_range_for_cpu(geth-\u003edev, gpage-\u003emapping,\n+\t\t\t\t\t\t      i * frag_len, frag_len,\n+\t\t\t\t\t\t      DMA_FROM_DEVICE);\n+\t\t}\n+\t\tdma_unmap_single_attrs(geth-\u003edev, gpage-\u003emapping, PAGE_SIZE,\n+\t\t\t\t       DMA_FROM_DEVICE,\n+\t\t\t\t       DMA_ATTR_SKIP_CPU_SYNC);\n+\t\twhile (gpage-\u003efragments) {\n+\t\t\tput_page(page);\n+\t\t\tgpage-\u003efragments--;\n+\t\t}\n+\t\tput_page(page);\n \t}\n+\txa_destroy(\u0026geth-\u003efreeq_mappings);\n+\tgeth-\u003efreeq_recycle_pending = 0;\n+}\n \n-\twritew(pn \u003c\u003c fpp_order, geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG + 2);\n+static unsigned int\n+geth_freeq_page_slots(struct gemini_ethernet *geth, unsigned int order)\n+{\n+\tunsigned int fpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n+\tunsigned int slots = 1 \u003c\u003c (order - fpp_order);\n \n-\tspin_unlock_irqrestore(\u0026geth-\u003efreeq_lock, flags);\n+\tif (geth-\u003eport0 \u0026\u0026 geth-\u003eport0-\u003enetdev)\n+\t\tslots += 1 \u003c\u003c geth-\u003eport0-\u003erxq_order;\n+\tif (geth-\u003eport1 \u0026\u0026 geth-\u003eport1-\u003enetdev)\n+\t\tslots += 1 \u003c\u003c geth-\u003eport1-\u003erxq_order;\n \n-\treturn count;\n+\treturn slots;\n }\n \n static int geth_setup_freeq(struct gemini_ethernet *geth)\n {\n \tunsigned int fpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n-\tunsigned int frag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order;\n \tunsigned int len = 1 \u003c\u003c geth-\u003efreeq_order;\n-\tunsigned int pages = len \u003e\u003e fpp_order;\n+\tunsigned int page_slots;\n+\tunsigned int expected;\n \tunion queue_threshold qt;\n \tunion dma_skb_size skbsz;\n \tunsigned int filled;\n-\tunsigned int pn;\n+\n+\tpage_slots = geth_freeq_page_slots(geth, geth-\u003efreeq_order);\n \n \tgeth-\u003efreeq_ring = dma_alloc_coherent(geth-\u003edev,\n \t\tsizeof(*geth-\u003efreeq_ring) \u003c\u003c geth-\u003efreeq_order,\n@@ -945,20 +1225,26 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)\n \t\tgoto err_freeq;\n \t}\n \n-\t/* Allocate a mapping to page look-up index */\n-\tgeth-\u003efreeq_pages = kzalloc_objs(*geth-\u003efreeq_pages, pages);\n+\t/* Allocate page metadata referenced by the mapping index */\n+\tgeth-\u003efreeq_pages = kzalloc_objs(*geth-\u003efreeq_pages, page_slots);\n \tif (!geth-\u003efreeq_pages)\n \t\tgoto err_freeq;\n-\tgeth-\u003enum_freeq_pages = pages;\n-\n-\tdev_info(geth-\u003edev, \"allocate %d pages for queue\\n\", pages);\n-\tfor (pn = 0; pn \u003c pages; pn++)\n-\t\tif (!geth_freeq_alloc_map_page(geth, pn))\n-\t\t\tgoto err_freeq_alloc;\n+\tgeth-\u003efreeq_page_bitmap = bitmap_zalloc(page_slots, GFP_KERNEL);\n+\tif (!geth-\u003efreeq_page_bitmap)\n+\t\tgoto err_freeq_pages;\n+\tgeth-\u003efreeq_recycle_bitmap = bitmap_zalloc(page_slots, GFP_KERNEL);\n+\tif (!geth-\u003efreeq_recycle_bitmap)\n+\t\tgoto err_freeq_page_bitmap;\n+\tgeth-\u003enum_freeq_pages = page_slots;\n+\tgeth-\u003efreeq_page_cursor = 0;\n+\n+\t/* Discard pointer state belonging to the previous queue geometry. */\n+\twritel(0, geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG);\n \n-\tfilled = geth_fill_freeq(geth, false);\n-\tif (!filled)\n-\t\tgoto err_freeq_alloc;\n+\texpected = len - (1 \u003c\u003c fpp_order);\n+\tfilled = geth_fill_freeq(geth);\n+\tif (filled != expected)\n+\t\tgoto err_freeq_bitmap;\n \n \tqt.bits32 = readl(geth-\u003ebase + GLOBAL_QUEUE_THRESHOLD_REG);\n \tqt.bits.swfq_empty = 32;\n@@ -971,19 +1257,20 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)\n \n \treturn 0;\n \n-err_freeq_alloc:\n-\twhile (pn \u003e 0) {\n-\t\tstruct gmac_queue_page *gpage;\n-\t\tdma_addr_t mapping;\n-\n-\t\t--pn;\n-\t\tmapping = geth-\u003efreeq_ring[pn \u003c\u003c fpp_order].word2.buf_adr;\n-\t\tdma_unmap_single(geth-\u003edev, mapping, frag_len, DMA_FROM_DEVICE);\n-\t\tgpage = \u0026geth-\u003efreeq_pages[pn];\n-\t\tput_page(gpage-\u003epage);\n-\t}\n-\n+err_freeq_bitmap:\n+\twritew(readw(geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG),\n+\t       geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG + 2);\n+\tgeth_freeq_release_pages(geth);\n+\tbitmap_free(geth-\u003efreeq_recycle_bitmap);\n+\tgeth-\u003efreeq_recycle_bitmap = NULL;\n+err_freeq_page_bitmap:\n+\tbitmap_free(geth-\u003efreeq_page_bitmap);\n+\tgeth-\u003efreeq_page_bitmap = NULL;\n+err_freeq_pages:\n \tkfree(geth-\u003efreeq_pages);\n+\tgeth-\u003efreeq_pages = NULL;\n+\tgeth-\u003enum_freeq_pages = 0;\n+\tgeth-\u003efreeq_page_cursor = 0;\n err_freeq:\n \tdma_free_coherent(geth-\u003edev,\n \t\t\t  sizeof(*geth-\u003efreeq_ring) \u003c\u003c geth-\u003efreeq_order,\n@@ -998,43 +1285,52 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)\n  */\n static void geth_cleanup_freeq(struct gemini_ethernet *geth)\n {\n-\tunsigned int fpp_order = PAGE_SHIFT - geth-\u003efreeq_frag_order;\n-\tunsigned int frag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order;\n-\tunsigned int len = 1 \u003c\u003c geth-\u003efreeq_order;\n-\tunsigned int pages = len \u003e\u003e fpp_order;\n-\tunsigned int pn;\n+\tif (!geth-\u003efreeq_ring)\n+\t\treturn;\n \n \twritew(readw(geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG),\n \t       geth-\u003ebase + GLOBAL_SWFQ_RWPTR_REG + 2);\n \twritel(0, geth-\u003ebase + GLOBAL_SW_FREEQ_BASE_SIZE_REG);\n \n-\tfor (pn = 0; pn \u003c pages; pn++) {\n-\t\tstruct gmac_queue_page *gpage;\n-\t\tdma_addr_t mapping;\n-\n-\t\tmapping = geth-\u003efreeq_ring[pn \u003c\u003c fpp_order].word2.buf_adr;\n-\t\tdma_unmap_single(geth-\u003edev, mapping, frag_len, DMA_FROM_DEVICE);\n-\n-\t\tgpage = \u0026geth-\u003efreeq_pages[pn];\n-\t\twhile (page_ref_count(gpage-\u003epage) \u003e 0)\n-\t\t\tput_page(gpage-\u003epage);\n-\t}\n+\tgeth_freeq_release_pages(geth);\n \n+\tbitmap_free(geth-\u003efreeq_recycle_bitmap);\n+\tgeth-\u003efreeq_recycle_bitmap = NULL;\n+\tbitmap_free(geth-\u003efreeq_page_bitmap);\n+\tgeth-\u003efreeq_page_bitmap = NULL;\n \tkfree(geth-\u003efreeq_pages);\n+\tgeth-\u003efreeq_pages = NULL;\n+\tgeth-\u003enum_freeq_pages = 0;\n+\tgeth-\u003efreeq_page_cursor = 0;\n \n \tdma_free_coherent(geth-\u003edev,\n \t\t\t  sizeof(*geth-\u003efreeq_ring) \u003c\u003c geth-\u003efreeq_order,\n \t\t\t  geth-\u003efreeq_ring, geth-\u003efreeq_dma_base);\n+\tgeth-\u003efreeq_ring = NULL;\n+}\n+\n+static void geth_set_freeq_irq(struct gemini_ethernet *geth, bool enable)\n+{\n+\tunsigned long flags;\n+\tu32 val;\n+\n+\tspin_lock_irqsave(\u0026geth-\u003eirq_lock, flags);\n+\tval = readl(geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n+\tif (enable)\n+\t\tval |= SWFQ_EMPTY_INT_BIT;\n+\telse\n+\t\tval \u0026= ~SWFQ_EMPTY_INT_BIT;\n+\twritel(val, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n+\tspin_unlock_irqrestore(\u0026geth-\u003eirq_lock, flags);\n }\n \n /**\n  * geth_resize_freeq() - resize the software queue depth\n  * @port: the port requesting the change\n  *\n- * This gets called at least once during probe() so the device queue gets\n- * \"resized\" from the hardware defaults. Since both ports/net devices share\n- * the same hardware queue, some synchronization between the ports is\n- * needed.\n+ * This is called when a port is opened or its RX ring size changes. Since\n+ * both ports/net devices share the same hardware queue, some synchronization\n+ * between the ports is needed.\n  */\n static int geth_resize_freeq(struct gemini_ethernet_port *port)\n {\n@@ -1042,19 +1338,24 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)\n \tstruct net_device *netdev = port-\u003enetdev;\n \tstruct gemini_ethernet_port *other_port;\n \tstruct net_device *other_netdev;\n+\tbool other_running;\n \tunsigned int new_size = 0;\n+\tunsigned int page_slots;\n \tunsigned int new_order;\n-\tunsigned long flags;\n-\tu32 en;\n \tint ret;\n \n+\tASSERT_RTNL();\n+\n+\t/* The software free queue interrupt is routed through port 1. */\n+\tif (!geth-\u003einitialized || !geth-\u003eport0 || !geth-\u003eport1)\n+\t\treturn -ENODEV;\n+\n \tif (netdev-\u003edev_id == 0)\n-\t\tother_netdev = geth-\u003eport1-\u003enetdev;\n+\t\tother_port = geth-\u003eport1;\n \telse\n-\t\tother_netdev = geth-\u003eport0-\u003enetdev;\n-\n-\tif (other_netdev \u0026\u0026 netif_running(other_netdev))\n-\t\treturn -EBUSY;\n+\t\tother_port = geth-\u003eport0;\n+\tother_netdev = other_port ? other_port-\u003enetdev : NULL;\n+\tother_running = other_netdev \u0026\u0026 netif_running(other_netdev);\n \n \tnew_size = 1 \u003c\u003c (port-\u003erxq_order + 1);\n \tnetdev_dbg(netdev, \"port %d size: %d order %d\\n\",\n@@ -1062,7 +1363,6 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)\n \t\t   new_size,\n \t\t   port-\u003erxq_order);\n \tif (other_netdev) {\n-\t\tother_port = netdev_priv(other_netdev);\n \t\tnew_size += 1 \u003c\u003c (other_port-\u003erxq_order + 1);\n \t\tnetdev_dbg(other_netdev, \"port %d size: %d order %d\\n\",\n \t\t\t   other_netdev-\u003edev_id,\n@@ -1073,16 +1373,22 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)\n \tnew_order = min(15, ilog2(new_size - 1) + 1);\n \tdev_dbg(geth-\u003edev, \"set shared queue to size %d order %d\\n\",\n \t\tnew_size, new_order);\n-\tif (geth-\u003efreeq_order == new_order)\n-\t\treturn 0;\n+\tif (new_order \u003c= PAGE_SHIFT - geth-\u003efreeq_frag_order)\n+\t\treturn -EINVAL;\n \n-\tspin_lock_irqsave(\u0026geth-\u003eirq_lock, flags);\n+\tif (geth-\u003efreeq_ring) {\n+\t\tpage_slots = geth_freeq_page_slots(geth, geth-\u003efreeq_order);\n+\t\tif (geth-\u003enum_freeq_pages \u003e= page_slots \u0026\u0026\n+\t\t    (geth-\u003efreeq_order == new_order ||\n+\t\t     (other_running \u0026\u0026 geth-\u003efreeq_order \u003e new_order)))\n+\t\t\treturn 0;\n+\t}\n \n-\t/* Disable the software queue IRQs */\n-\ten = readl(geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n-\ten \u0026= ~SWFQ_EMPTY_INT_BIT;\n-\twritel(en, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n-\tspin_unlock_irqrestore(\u0026geth-\u003eirq_lock, flags);\n+\tif (other_running)\n+\t\treturn -EBUSY;\n+\n+\tdisable_irq(geth-\u003eport1-\u003eirq);\n+\tgeth_set_freeq_irq(geth, false);\n \n \t/* Drop the old queue */\n \tif (geth-\u003efreeq_ring)\n@@ -1092,14 +1398,10 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)\n \tgeth-\u003efreeq_order = new_order;\n \tret = geth_setup_freeq(geth);\n \n-\t/* Restart the interrupts - NOTE if this is the first resize\n-\t * after probe(), this is where the interrupts get turned on\n-\t * in the first place.\n-\t */\n-\tspin_lock_irqsave(\u0026geth-\u003eirq_lock, flags);\n-\ten |= SWFQ_EMPTY_INT_BIT;\n-\twritel(en, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n-\tspin_unlock_irqrestore(\u0026geth-\u003eirq_lock, flags);\n+\t/* Enable the queue interrupt only after successful setup. */\n+\tif (!ret)\n+\t\tgeth_set_freeq_irq(geth, true);\n+\tenable_irq(geth-\u003eport1-\u003eirq);\n \n \treturn ret;\n }\n@@ -1410,12 +1712,12 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,\n \tunsigned int rx_status = word0.bits.status;\n \tstruct sk_buff *skb = NULL;\n \n-\tport-\u003erx_stats[rx_status]++;\n-\tport-\u003erx_csum_stats[rx_csum]++;\n-\n \tif (word0.bits.derr || word0.bits.perr ||\n \t    rx_status || frame_len \u003c ETH_ZLEN ||\n \t    rx_csum \u003e= RX_CHKSUM_IP_ERR_UNKNOWN) {\n+\t\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n+\t\tport-\u003erx_stats[rx_status]++;\n+\t\tport-\u003erx_csum_stats[rx_csum]++;\n \t\tport-\u003estats.rx_errors++;\n \n \t\tif (frame_len \u003c ETH_ZLEN || RX_ERROR_LENGTH(rx_status))\n@@ -1426,6 +1728,7 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,\n \t\t\tport-\u003estats.rx_crc_errors++;\n \t\tif (RX_ERROR_FRAME(rx_status))\n \t\t\tport-\u003estats.rx_frame_errors++;\n+\t\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n \t\treturn NULL;\n \t}\n \n@@ -1437,8 +1740,12 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,\n \t\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n \n update_exit:\n+\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n+\tport-\u003erx_stats[rx_status]++;\n+\tport-\u003erx_csum_stats[rx_csum]++;\n \tport-\u003estats.rx_bytes += frame_len;\n \tport-\u003estats.rx_packets++;\n+\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n \treturn skb;\n }\n \n@@ -1448,6 +1755,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \tstruct gemini_ethernet_port *port = netdev_priv(netdev);\n \tunsigned short m = (1 \u003c\u003c port-\u003erxq_order) - 1;\n \tstruct gemini_ethernet *geth = port-\u003egeth;\n+\tunsigned int freeq_frag_len = 1 \u003c\u003c geth-\u003efreeq_frag_order;\n \tvoid __iomem *ptr_reg = port-\u003erxq_rwptr;\n \tunsigned int frag_nr = port-\u003erx_frag_nr;\n \tstruct sk_buff *skb = port-\u003erx_skb;\n@@ -1456,7 +1764,6 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \tunsigned int consumed = 0;\n \tunsigned int frame_len, frag_len;\n \tstruct gmac_rxdesc *rx = NULL;\n-\tstruct gmac_queue_page *gpage;\n \tunsigned int received = 0;\n \tbool dropping = port-\u003erx_dropping;\n \tunion gmac_rxdesc_0 word0;\n@@ -1493,12 +1800,12 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \n \t\tfrag_len = word0.bits.buffer_size;\n \t\tframe_len = word1.bits.byte_count;\n-\t\tpage_offs = mapping \u0026 ~PAGE_MASK;\n-\n \t\tif (word3.bits32 \u0026 SOF_BIT) {\n \t\t\tif (skb) {\n \t\t\t\tnapi_free_frags(\u0026port-\u003enapi);\n+\t\t\t\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n \t\t\t\tport-\u003estats.rx_dropped++;\n+\t\t\t\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n \t\t\t\tskb = NULL;\n \t\t\t\tfrag_nr = 0;\n \t\t\t}\n@@ -1513,20 +1820,21 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \t\t\tgoto err_drop;\n \t\t}\n \n-\t\t/* Freeq pointers are one page off */\n-\t\tgpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE);\n-\t\tif (!gpage) {\n+\t\tpage = geth_freeq_claim(geth, mapping, \u0026page_offs);\n+\t\tif (!page) {\n \t\t\tdev_err_ratelimited(geth-\u003edev,\n \t\t\t\t\t    \"could not find mapping\\n\");\n \t\t\tgoto err_drop;\n \t\t}\n-\t\tpage = gpage-\u003epage;\n \n \t\tif (word3.bits32 \u0026 SOF_BIT) {\n \t\t\tskb = gmac_skb_if_good_frame(port, word0, frame_len);\n \t\t\tif (!skb)\n \t\t\t\tgoto err_drop;\n \n+\t\t\tif (frag_len \u003c NET_IP_ALIGN)\n+\t\t\t\tgoto err_drop;\n+\n \t\t\tpage_offs += NET_IP_ALIGN;\n \t\t\tfrag_len -= NET_IP_ALIGN;\n \t\t\tfrag_nr = 0;\n@@ -1535,20 +1843,33 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \t\t\tgoto err_drop;\n \t\t}\n \n-\t\tif (word3.bits32 \u0026 EOF_BIT)\n+\t\tif (word3.bits32 \u0026 EOF_BIT) {\n+\t\t\tif (frame_len \u003c ETH_ZLEN ||\n+\t\t\t    frame_len \u003c skb-\u003elen ||\n+\t\t\t    frame_len - skb-\u003elen \u003e frag_len)\n+\t\t\t\tgoto err_drop;\n \t\t\tfrag_len = frame_len - skb-\u003elen;\n+\t\t}\n \n \t\t/* append page frag to skb */\n \t\tif (frag_nr == MAX_SKB_FRAGS)\n \t\t\tgoto err_drop;\n+\t\tif (frag_len \u003e freeq_frag_len -\n+\t\t\t       (page_offs \u0026 (freeq_frag_len - 1)) ||\n+\t\t    frag_len \u003e PAGE_SIZE - page_offs)\n+\t\t\tgoto err_drop;\n \n-\t\tif (frag_len == 0 \u0026\u0026 net_ratelimit())\n-\t\t\tnetdev_err(netdev, \"Received fragment with len = 0\\n\");\n+\t\tif (!frag_len) {\n+\t\t\tif (net_ratelimit())\n+\t\t\t\tnetdev_err(netdev,\n+\t\t\t\t\t   \"Received fragment with len = 0\\n\");\n+\t\t\tgoto err_drop;\n+\t\t}\n \n \t\tskb_fill_page_desc(skb, frag_nr, page, page_offs, frag_len);\n \t\tskb-\u003elen += frag_len;\n \t\tskb-\u003edata_len += frag_len;\n-\t\tskb-\u003etruesize += frag_len;\n+\t\tskb-\u003etruesize += freeq_frag_len;\n \t\tfrag_nr++;\n \n \t\tif (word3.bits32 \u0026 EOF_BIT) {\n@@ -1569,7 +1890,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,\n \t\t\tput_page(page);\n \n \t\tif (!dropping) {\n+\t\t\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n \t\t\tport-\u003estats.rx_dropped++;\n+\t\t\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n \t\t\tdropping = true;\n \t\t}\n \n@@ -1601,18 +1924,18 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)\n \tbool reschedule;\n \n \tfreeq_threshold = 1 \u003c\u003c (geth-\u003efreeq_order - 1);\n-\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n \n \treceived = gmac_rx(napi-\u003edev, budget, \u0026freeq_consumed, \u0026reschedule);\n-\tif (!reschedule \u0026\u0026 received \u003c budget)\n+\tif (!reschedule \u0026\u0026 received \u003c budget) {\n+\t\tu64_stats_update_begin(\u0026port-\u003erx_stats_syncp);\n \t\t++port-\u003erx_napi_exits;\n-\n-\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n+\t\tu64_stats_update_end(\u0026port-\u003erx_stats_syncp);\n+\t}\n \n \tport-\u003efreeq_refill += freeq_consumed;\n \tif (port-\u003efreeq_refill \u003e freeq_threshold) {\n \t\tport-\u003efreeq_refill -= freeq_threshold;\n-\t\tgeth_fill_freeq(geth, true);\n+\t\tgeth_fill_freeq(geth);\n \t}\n \n \tif (!reschedule \u0026\u0026 received \u003c budget \u0026\u0026\n@@ -1867,10 +2190,7 @@ static int gmac_open(struct net_device *netdev)\n \tphy_start(netdev-\u003ephydev);\n \n \terr = geth_resize_freeq(port);\n-\t/* It's fine if it's just busy, the other port has set up\n-\t * the freeq in that case.\n-\t */\n-\tif (err \u0026\u0026 (err != -EBUSY)) {\n+\tif (err) {\n \t\tnetdev_err(netdev, \"could not resize freeq\\n\");\n \t\tgoto err_stop_phy;\n \t}\n@@ -1911,12 +2231,19 @@ static int gmac_open(struct net_device *netdev)\n static int gmac_stop(struct net_device *netdev)\n {\n \tstruct gemini_ethernet_port *port = netdev_priv(netdev);\n+\tunsigned long flags;\n \n \thrtimer_cancel(\u0026port-\u003erx_coalesce_timer);\n \tnetif_tx_stop_all_queues(netdev);\n \tgmac_disable_tx_rx(netdev);\n \tgmac_stop_dma(port);\n \tnapi_disable(\u0026port-\u003enapi);\n+\tif (port-\u003erx_skb) {\n+\t\tnapi_free_frags(\u0026port-\u003enapi);\n+\t\tflags = u64_stats_update_begin_irqsave(\u0026port-\u003erx_stats_syncp);\n+\t\tport-\u003estats.rx_dropped++;\n+\t\tu64_stats_update_end_irqrestore(\u0026port-\u003erx_stats_syncp, flags);\n+\t}\n \tport-\u003erx_skb = NULL;\n \tport-\u003erx_frag_nr = 0;\n \tport-\u003erx_dropping = false;\n@@ -2229,14 +2556,20 @@ static int gmac_set_ringparam(struct net_device *netdev,\n \t\t\t      struct netlink_ext_ack *extack)\n {\n \tstruct gemini_ethernet_port *port = netdev_priv(netdev);\n+\tunsigned int old_rxq_order;\n \tint err = 0;\n \n \tif (netif_running(netdev))\n \t\treturn -EBUSY;\n \n \tif (rp-\u003erx_pending) {\n+\t\told_rxq_order = port-\u003erxq_order;\n \t\tport-\u003erxq_order = min(15, ilog2(rp-\u003erx_pending - 1) + 1);\n \t\terr = geth_resize_freeq(port);\n+\t\tif (err) {\n+\t\t\tport-\u003erxq_order = old_rxq_order;\n+\t\t\treturn err;\n+\t\t}\n \t}\n \tif (rp-\u003etx_pending) {\n \t\tport-\u003etxq_order = min(15, ilog2(rp-\u003etx_pending - 1) + 1);\n@@ -2342,7 +2675,7 @@ static irqreturn_t gemini_port_irq_thread(int irq, void *data)\n \n \tgeth = port-\u003egeth;\n \t/* The queue is half empty so refill it */\n-\tgeth_fill_freeq(geth, true);\n+\tgeth_fill_freeq(geth);\n \n \tspin_lock_irqsave(\u0026geth-\u003eirq_lock, flags);\n \t/* ACK queue interrupt */\n@@ -2362,6 +2695,9 @@ static irqreturn_t gemini_port_irq(int irq, void *data)\n \tirqreturn_t ret = IRQ_NONE;\n \tu32 val, en;\n \n+\tif (!port-\u003eid)\n+\t\treturn IRQ_NONE;\n+\n \tgeth = port-\u003egeth;\n \tspin_lock(\u0026geth-\u003eirq_lock);\n \n@@ -2384,24 +2720,43 @@ static irqreturn_t gemini_port_irq(int irq, void *data)\n \treturn ret;\n }\n \n+static void gemini_port_clear(struct gemini_ethernet_port *port)\n+{\n+\tstruct gemini_ethernet *geth = port-\u003egeth;\n+\n+\tASSERT_RTNL();\n+\n+\tif (!port-\u003eid \u0026\u0026 geth-\u003eport0 == port)\n+\t\tgeth-\u003eport0 = NULL;\n+\telse if (port-\u003eid \u0026\u0026 geth-\u003eport1 == port)\n+\t\tgeth-\u003eport1 = NULL;\n+\telse\n+\t\treturn;\n+\n+\tgeth-\u003einitialized = false;\n+}\n+\n static void gemini_port_remove(struct gemini_ethernet_port *port)\n {\n+\trtnl_lock();\n+\tgemini_port_clear(port);\n+\trtnl_unlock();\n+\n \tif (port-\u003enetdev) {\n-\t\tphy_disconnect(port-\u003enetdev-\u003ephydev);\n \t\tunregister_netdev(port-\u003enetdev);\n+\t\tphy_disconnect(port-\u003enetdev-\u003ephydev);\n \t}\n \tclk_disable_unprepare(port-\u003epclk);\n-\tgeth_cleanup_freeq(port-\u003egeth);\n }\n \n static void gemini_ethernet_init(struct gemini_ethernet *geth)\n {\n+\tASSERT_RTNL();\n+\n \t/* Only do this once both ports are online */\n \tif (geth-\u003einitialized)\n \t\treturn;\n-\tif (geth-\u003eport0 \u0026\u0026 geth-\u003eport1)\n-\t\tgeth-\u003einitialized = true;\n-\telse\n+\tif (!geth-\u003eport0 || !geth-\u003eport1)\n \t\treturn;\n \n \twritel(0, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_0_REG);\n@@ -2440,10 +2795,20 @@ static void gemini_ethernet_init(struct gemini_ethernet *geth)\n \twritel(0, geth-\u003ebase + GLOBAL_HWFQ_RWPTR_REG);\n \n \tgeth-\u003efreeq_frag_order = DEFAULT_RX_BUF_ORDER;\n-\t/* This makes the queue resize on probe() so that we\n-\t * set up and enable the queue IRQ. FIXME: fragile.\n-\t */\n-\tgeth-\u003efreeq_order = 1;\n+\tgeth-\u003einitialized = true;\n+}\n+\n+static void gemini_port_publish(struct gemini_ethernet_port *port)\n+{\n+\tstruct gemini_ethernet *geth = port-\u003egeth;\n+\n+\tASSERT_RTNL();\n+\n+\tif (!port-\u003eid)\n+\t\tgeth-\u003eport0 = port;\n+\telse\n+\t\tgeth-\u003eport1 = port;\n+\tgemini_ethernet_init(geth);\n }\n \n static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)\n@@ -2539,15 +2904,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)\n \treset_control_reset(port-\u003ereset);\n \tusleep_range(100, 500);\n \n-\t/* Assign pointer in the main state container */\n-\tif (!id)\n-\t\tgeth-\u003eport0 = port;\n-\telse\n-\t\tgeth-\u003eport1 = port;\n-\n-\t/* This will just be done once both ports are up and reset */\n-\tgemini_ethernet_init(geth);\n-\n \tplatform_set_drvdata(pdev, port);\n \n \t/* Set up and register the netdev */\n@@ -2598,6 +2954,16 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)\n \tif (ret)\n \t\tgoto unprepare;\n \n+\tif (!of_property_present(np, \"phy-handle\") \u0026\u0026\n+\t    !of_phy_is_fixed_link(np)) {\n+\t\tdev_info(dev, \"no PHY, keeping port for shared IRQ\\n\");\n+\t\tport-\u003enetdev = NULL;\n+\t\trtnl_lock();\n+\t\tgemini_port_publish(port);\n+\t\trtnl_unlock();\n+\t\treturn 0;\n+\t}\n+\n \tret = gmac_setup_phy(netdev);\n \tif (ret) {\n \t\tnetdev_err(netdev,\n@@ -2605,9 +2971,15 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)\n \t\tgoto unprepare;\n \t}\n \n-\tret = register_netdev(netdev);\n-\tif (ret)\n+\trtnl_lock();\n+\tret = register_netdevice(netdev);\n+\tif (!ret)\n+\t\tgemini_port_publish(port);\n+\trtnl_unlock();\n+\tif (ret) {\n+\t\tphy_disconnect(netdev-\u003ephydev);\n \t\tgoto unprepare;\n+\t}\n \n \treturn 0;\n \n@@ -2635,6 +3007,7 @@ static struct platform_driver gemini_ethernet_port_driver = {\n \t.driver = {\n \t\t.name = \"gemini-ethernet-port\",\n \t\t.of_match_table = gemini_ethernet_port_of_match,\n+\t\t.suppress_bind_attrs = true,\n \t},\n \t.probe = gemini_ethernet_port_probe,\n \t.remove = gemini_ethernet_port_remove,\n@@ -2671,6 +3044,7 @@ static int gemini_ethernet_probe(struct platform_device *pdev)\n \n \tspin_lock_init(\u0026geth-\u003eirq_lock);\n \tspin_lock_init(\u0026geth-\u003efreeq_lock);\n+\txa_init(\u0026geth-\u003efreeq_mappings);\n \n \t/* The children will use this */\n \tplatform_set_drvdata(pdev, geth);\n@@ -2683,8 +3057,13 @@ static void gemini_ethernet_remove(struct platform_device *pdev)\n {\n \tstruct gemini_ethernet *geth = platform_get_drvdata(pdev);\n \n-\tgeth_cleanup_freeq(geth);\n+\trtnl_lock();\n \tgeth-\u003einitialized = false;\n+\trtnl_unlock();\n+\n+\tdevm_of_platform_depopulate(\u0026pdev-\u003edev);\n+\twritel(0, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n+\tgeth_cleanup_freeq(geth);\n }\n \n static const struct of_device_id gemini_ethernet_of_match[] = {\n"
}

2/1 2026/10/11 18:16 agent patch-evaluator
4m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patched file (drivers/net/ethernet/cortina/gemini.c) is a platform driver for the Cortina Systems Gemini (StorLink SL351x) Ethernet controller, which is an ARM-specific SoC peripheral. This hardware is not emulated in standard QEMU/GCE virtualization environments and is structurally unreachable on the target architecture (amd64).",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 66b204a3384cfce65a08505180cf66059d607408
Author: syz-cluster <triage@syzkaller.com>
Date:   Sun Oct 11 18:16:50 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 2fe7fd0202d26..9f7946876d585 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -14,7 +14,9 @@
  * Gary Chen & Ch Hsu Storlink Semiconductor
  */
 #include <linux/kernel.h>
+#include <linux/bitmap.h>
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/net.h>
 #include <linux/platform_device.h>
@@ -25,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/reset.h>
 #include <linux/clk.h>
+#include <linux/rtnetlink.h>
 #include <linux/of.h>
 #include <linux/of_mdio.h>
 #include <linux/of_net.h>
@@ -34,9 +37,11 @@
 #include <linux/skbuff.h>
 #include <linux/phy.h>
 #include <linux/crc32.h>
+#include <linux/sizes.h>
 #include <linux/ethtool.h>
 #include <linux/tcp.h>
 #include <linux/u64_stats_sync.h>
+#include <linux/xarray.h>
 
 #include <linux/in.h>
 #include <linux/ip.h>
@@ -87,11 +92,13 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 /**
  * struct gmac_queue_page - page buffer per-page info
  * @page: the page struct
- * @mapping: the dma address handle
+ * @mapping: DMA address of the first fragment
+ * @fragments: number of fragments not yet claimed from the hardware
  */
 struct gmac_queue_page {
 	struct page *page;
 	dma_addr_t mapping;
+	unsigned int fragments;
 };
 
 struct gmac_txq {
@@ -155,6 +162,7 @@ struct gemini_ethernet_port {
 struct gemini_ethernet {
 	struct device *dev;
 	void __iomem *base;
+	/* Protected by RTNL. */
 	struct gemini_ethernet_port *port0;
 	struct gemini_ethernet_port *port1;
 	bool initialized;
@@ -165,7 +173,12 @@ struct gemini_ethernet {
 	struct gmac_rxdesc *freeq_ring;
 	dma_addr_t	freeq_dma_base;
 	struct gmac_queue_page	*freeq_pages;
+	struct xarray	freeq_mappings;
 	unsigned int	num_freeq_pages;
+	unsigned long	*freeq_page_bitmap;
+	unsigned long	*freeq_recycle_bitmap;
+	unsigned int	freeq_page_cursor;
+	unsigned int	freeq_recycle_pending;
 	spinlock_t	freeq_lock; /* Locks queue from reentrance */
 };
 
@@ -463,6 +476,17 @@ static int gmac_pick_rx_max_len(unsigned int max_l3_len)
 	return -1;
 }
 
+static unsigned int gmac_pick_rxq_order(void)
+{
+	if (totalram_pages() <= (SZ_32M >> PAGE_SHIFT))
+		return DEFAULT_GMAC_RXQ_ORDER - 2;
+
+	if (totalram_pages() <= (SZ_64M >> PAGE_SHIFT))
+		return DEFAULT_GMAC_RXQ_ORDER - 1;
+
+	return DEFAULT_GMAC_RXQ_ORDER;
+}
+
 static int gmac_init(struct net_device *netdev)
 {
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
@@ -531,7 +555,7 @@ static int gmac_init(struct net_device *netdev)
 	writel(sw_weigh.bits32,
 	       port->dma_base + GMAC_TX_WEIGHTING_CTRL_1_REG);
 
-	port->rxq_order = DEFAULT_GMAC_RXQ_ORDER;
+	port->rxq_order = gmac_pick_rxq_order();
 	port->txq_order = DEFAULT_GMAC_TXQ_ORDER;
 	port->rx_coalesce_nsecs = DEFAULT_RX_COALESCE_NSECS;
 
@@ -724,31 +748,109 @@ static int gmac_setup_rxq(struct net_device *netdev)
 	return 0;
 }
 
-static struct gmac_queue_page *
-gmac_get_queue_page(struct gemini_ethernet *geth,
-		    struct gemini_ethernet_port *port,
-		    dma_addr_t addr)
+static unsigned long
+geth_freeq_mapping_index(const struct gemini_ethernet *geth,
+			 dma_addr_t mapping)
 {
-	struct gmac_queue_page *gpage;
-	dma_addr_t mapping;
-	int i;
+	return (unsigned long)(mapping >> geth->freeq_frag_order);
+}
 
-	/* Only look for even pages */
-	mapping = addr & PAGE_MASK;
+static int geth_freeq_alloc_slot(struct gemini_ethernet *geth)
+{
+	unsigned int slot;
 
-	if (!geth->freeq_pages) {
-		dev_err_ratelimited(geth->dev,
-				    "try to get page with no page list\n");
-		return NULL;
+	lockdep_assert_held(&geth->freeq_lock);
+
+	slot = find_next_zero_bit(geth->freeq_page_bitmap,
+				  geth->num_freeq_pages,
+				  geth->freeq_page_cursor);
+	if (slot == geth->num_freeq_pages) {
+		slot = find_first_zero_bit(geth->freeq_page_bitmap,
+					   geth->freeq_page_cursor);
+		if (slot == geth->freeq_page_cursor)
+			return -ENOSPC;
+	}
+
+	__set_bit(slot, geth->freeq_page_bitmap);
+	geth->freeq_page_cursor = slot + 1;
+	if (geth->freeq_page_cursor == geth->num_freeq_pages)
+		geth->freeq_page_cursor = 0;
+
+	return slot;
+}
+
+static int geth_freeq_recycle_slot(struct gemini_ethernet *geth)
+{
+	unsigned int slot = geth->freeq_page_cursor;
+
+	lockdep_assert_held(&geth->freeq_lock);
+
+	if (!geth->freeq_recycle_pending)
+		return -ENOSPC;
+
+	slot = find_next_bit(geth->freeq_recycle_bitmap,
+			     geth->num_freeq_pages,
+			     geth->freeq_page_cursor);
+	if (slot == geth->num_freeq_pages) {
+		slot = find_first_bit(geth->freeq_recycle_bitmap,
+				      geth->freeq_page_cursor);
+		if (slot == geth->freeq_page_cursor)
+			return -ENOSPC;
 	}
 
-	/* Look up a ring buffer page from virtual mapping */
-	for (i = 0; i < geth->num_freeq_pages; i++) {
-		gpage = &geth->freeq_pages[i];
-		if (gpage->mapping == mapping)
-			return gpage;
+	__clear_bit(slot, geth->freeq_recycle_bitmap);
+	geth->freeq_page_cursor = slot + 1;
+	if (geth->freeq_page_cursor == geth->num_freeq_pages)
+		geth->freeq_page_cursor = 0;
+	geth->freeq_recycle_pending--;
+
+	return slot;
+}
+
+static struct page *geth_freeq_claim(struct gemini_ethernet *geth,
+				     dma_addr_t mapping,
+				     unsigned int *page_offs)
+{
+	unsigned int frag_len = 1 << geth->freeq_frag_order;
+	struct gmac_queue_page *gpage;
+	unsigned long index;
+	unsigned long flags;
+	dma_addr_t page_mapping;
+	struct page *page;
+	unsigned int slot;
+	bool valid;
+
+	index = geth_freeq_mapping_index(geth, mapping);
+
+	spin_lock_irqsave(&geth->freeq_lock, flags);
+	gpage = xa_load(&geth->freeq_mappings, index);
+	if (!gpage || !gpage->page || !gpage->fragments)
+		goto err_unlock;
+
+	page = gpage->page;
+	page_mapping = gpage->mapping;
+	valid = mapping >= page_mapping &&
+		mapping - page_mapping <= PAGE_SIZE - frag_len &&
+		!((mapping - page_mapping) & (frag_len - 1));
+	if (!valid)
+		goto err_unlock;
+
+	dma_sync_single_range_for_cpu(geth->dev, page_mapping,
+				      mapping - page_mapping, frag_len,
+				      DMA_FROM_DEVICE);
+	xa_erase(&geth->freeq_mappings, index);
+	if (!--gpage->fragments) {
+		slot = gpage - geth->freeq_pages;
+		__set_bit(slot, geth->freeq_recycle_bitmap);
+		geth->freeq_recycle_pending++;
 	}
 
+	*page_offs = mapping - page_mapping;
+	spin_unlock_irqrestore(&geth->freeq_lock, flags);
+	return page;
+
+err_unlock:
+	spin_unlock_irqrestore(&geth->freeq_lock, flags);
 	return NULL;
 }
 
@@ -757,11 +859,12 @@ static void gmac_cleanup_rxq(struct net_device *netdev)
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
 	struct gemini_ethernet *geth = port->geth;
 	struct gmac_rxdesc *rxd = port->rxq_ring;
-	static struct gmac_queue_page *gpage;
 	struct nontoe_qhdr __iomem *qhdr;
 	void __iomem *dma_reg;
 	void __iomem *ptr_reg;
+	unsigned int page_offs;
 	dma_addr_t mapping;
+	struct page *page;
 	union dma_rwptr rw;
 	unsigned int r, w;
 
@@ -788,42 +891,65 @@ static void gmac_cleanup_rxq(struct net_device *netdev)
 		if (!mapping)
 			continue;
 
-		/* Freeq pointers are one page off */
-		gpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE);
-		if (!gpage) {
+		page = geth_freeq_claim(geth, mapping, &page_offs);
+		if (!page) {
 			dev_err(geth->dev, "could not find page\n");
 			continue;
 		}
 		/* Release the RX queue reference to the page */
-		put_page(gpage->page);
+		put_page(page);
 	}
 
 	dma_free_coherent(geth->dev, sizeof(*port->rxq_ring) << port->rxq_order,
 			  port->rxq_ring, port->rxq_dma_base);
 }
 
-static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,
-					      int pn)
+static int geth_freeq_map_page(struct gemini_ethernet *geth,
+			       struct page **pagep,
+			       dma_addr_t *page_mappingp)
 {
-	struct gmac_rxdesc *freeq_entry;
-	struct gmac_queue_page *gpage;
-	unsigned int fpp_order;
-	unsigned int frag_len;
-	dma_addr_t mapping;
+	dma_addr_t page_mapping;
 	struct page *page;
-	int i;
 
-	/* First allocate and DMA map a single page */
 	page = alloc_page(GFP_ATOMIC);
 	if (!page)
-		return NULL;
+		return -ENOMEM;
 
-	mapping = dma_map_single(geth->dev, page_address(page),
-				 PAGE_SIZE, DMA_FROM_DEVICE);
-	if (dma_mapping_error(geth->dev, mapping)) {
+	page_mapping = dma_map_single(geth->dev, page_address(page),
+				      PAGE_SIZE, DMA_FROM_DEVICE);
+	if (dma_mapping_error(geth->dev, page_mapping)) {
 		put_page(page);
-		return NULL;
+		return -ENOMEM;
 	}
+	if (page_mapping > U32_MAX - (PAGE_SIZE - 1)) {
+		dev_err_ratelimited(geth->dev,
+				    "freeq DMA mapping exceeds 32 bits\n");
+		dma_unmap_single(geth->dev, page_mapping, PAGE_SIZE,
+				 DMA_FROM_DEVICE);
+		put_page(page);
+		return -EOVERFLOW;
+	}
+
+	*pagep = page;
+	*page_mappingp = page_mapping;
+
+	return 0;
+}
+
+static int geth_freeq_post_page(struct gemini_ethernet *geth, unsigned int pn,
+				struct gmac_queue_page *gpage, bool recycle)
+{
+	struct gmac_rxdesc *freeq_entry;
+	unsigned int fpp_order;
+	unsigned int fragments;
+	unsigned int frag_len;
+	dma_addr_t page_mapping = gpage->mapping;
+	dma_addr_t mapping;
+	struct page *page = gpage->page;
+	int ret;
+	int i;
+
+	lockdep_assert_held(&geth->freeq_lock);
 
 	/* The assign the page mapping (physical address) to the buffer address
 	 * in the hardware queue. PAGE_SHIFT on ARM is 12 (1 page is 4096 bytes,
@@ -833,43 +959,115 @@ static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,
 	 */
 	frag_len = 1 << geth->freeq_frag_order; /* Usually 2048 */
 	fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
+	fragments = 1 << fpp_order;
+
+	for (i = 0; i < fragments; i++) {
+		mapping = page_mapping + i * frag_len;
+		ret = xa_insert(&geth->freeq_mappings,
+				geth_freeq_mapping_index(geth, mapping),
+				gpage, GFP_ATOMIC);
+		if (ret)
+			goto err_mappings;
+	}
+	if (recycle)
+		dma_sync_single_for_device(geth->dev, page_mapping, PAGE_SIZE,
+					   DMA_FROM_DEVICE);
+	gpage->fragments = fragments;
+	page_ref_add(page, fragments);
+
 	freeq_entry = geth->freeq_ring + (pn << fpp_order);
-	dev_dbg(geth->dev, "allocate page %d fragment length %d fragments per page %d, freeq entry %p\n",
-		 pn, frag_len, (1 << fpp_order), freeq_entry);
+	dev_dbg(geth->dev, "post page %d fragment length %d fragments per page %d, freeq entry %p\n",
+		pn, frag_len, (1 << fpp_order), freeq_entry);
+	mapping = page_mapping;
 	for (i = (1 << fpp_order); i > 0; i--) {
 		freeq_entry->word2.buf_adr = mapping;
 		freeq_entry++;
 		mapping += frag_len;
 	}
+	dev_dbg(geth->dev, "page %d, DMA addr: %pad, page %p\n",
+		pn, &page_mapping, page);
 
-	/* If the freeq entry already has a page mapped, then unmap it. */
-	gpage = &geth->freeq_pages[pn];
-	if (gpage->page) {
-		mapping = geth->freeq_ring[pn << fpp_order].word2.buf_adr;
-		dma_unmap_single(geth->dev, mapping, frag_len, DMA_FROM_DEVICE);
-		/* This should be the last reference to the page so it gets
-		 * released
-		 */
-		put_page(gpage->page);
+	return 0;
+
+err_mappings:
+	while (i--) {
+		mapping = page_mapping + i * frag_len;
+		xa_erase(&geth->freeq_mappings,
+			 geth_freeq_mapping_index(geth, mapping));
 	}
+	return ret;
+}
 
-	/* Then put our new mapping into the page table */
-	dev_dbg(geth->dev, "page %d, DMA addr: %08x, page %p\n",
-		pn, (unsigned int)mapping, page);
-	gpage->mapping = mapping;
+static int geth_freeq_add_page(struct gemini_ethernet *geth, unsigned int pn,
+			       struct page *page, dma_addr_t page_mapping)
+{
+	struct gmac_queue_page *gpage;
+	int ret;
+	int slot;
+
+	lockdep_assert_held(&geth->freeq_lock);
+
+	slot = geth_freeq_alloc_slot(geth);
+	if (slot < 0)
+		return slot;
+
+	gpage = &geth->freeq_pages[slot];
 	gpage->page = page;
+	gpage->mapping = page_mapping;
+	ret = geth_freeq_post_page(geth, pn, gpage, false);
+	if (ret) {
+		gpage->page = NULL;
+		gpage->mapping = 0;
+		__clear_bit(slot, geth->freeq_page_bitmap);
+	}
 
-	return page;
+	return ret;
+}
+
+static int geth_freeq_recycle_page(struct gemini_ethernet *geth,
+				   unsigned int pn)
+{
+	struct gmac_queue_page *gpage;
+	struct page *page;
+	int ret;
+	int slot;
+
+	lockdep_assert_held(&geth->freeq_lock);
+
+	slot = geth_freeq_recycle_slot(geth);
+	if (slot < 0)
+		return slot;
+
+	gpage = &geth->freeq_pages[slot];
+	if (page_ref_count(gpage->page) > 1) {
+		page = gpage->page;
+		dma_unmap_single_attrs(geth->dev, gpage->mapping, PAGE_SIZE,
+				       DMA_FROM_DEVICE,
+				       DMA_ATTR_SKIP_CPU_SYNC);
+		gpage->page = NULL;
+		gpage->mapping = 0;
+		__clear_bit(slot, geth->freeq_page_bitmap);
+		put_page(page);
+		return -EAGAIN;
+	}
+
+	ret = geth_freeq_post_page(geth, pn, gpage, true);
+	if (ret) {
+		__set_bit(slot, geth->freeq_recycle_bitmap);
+		geth->freeq_recycle_pending++;
+	}
+
+	return ret;
 }
 
 /**
  * geth_fill_freeq() - Fill the freeq with empty fragments to use
  * @geth: the ethernet adapter
- * @refill: whether to reset the queue by filling in all freeq entries or
- * just refill it, usually the interrupt to refill the queue happens when
- * the queue is half empty.
+ *
+ * Usually the interrupt to refill the queue happens when the queue is half
+ * empty.
  */
-static unsigned int geth_fill_freeq(struct gemini_ethernet *geth, bool refill)
+static unsigned int geth_fill_freeq(struct gemini_ethernet *geth)
 {
 	unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
 	unsigned int count = 0;
@@ -877,63 +1075,145 @@ static unsigned int geth_fill_freeq(struct gemini_ethernet *geth, bool refill)
 	unsigned long flags;
 	union dma_rwptr rw;
 	unsigned int m_pn;
+	bool recycle = true;
 
 	/* Mask for page */
 	m_pn = (1 << (geth->freeq_order - fpp_order)) - 1;
 
-	spin_lock_irqsave(&geth->freeq_lock, flags);
-
-	rw.bits32 = readl(geth->base + GLOBAL_SWFQ_RWPTR_REG);
-	pn = (refill ? rw.bits.wptr : rw.bits.rptr) >> fpp_order;
-	epn = (rw.bits.rptr >> fpp_order) - 1;
-	epn &= m_pn;
-
 	/* Loop over the freeq ring buffer entries */
-	while (pn != epn) {
-		struct gmac_queue_page *gpage;
+	for (;;) {
+		dma_addr_t page_mapping;
 		struct page *page;
+		int ret;
+
+		spin_lock_irqsave(&geth->freeq_lock, flags);
+		rw.bits32 = readl(geth->base + GLOBAL_SWFQ_RWPTR_REG);
+		pn = (rw.bits.wptr >> fpp_order) & m_pn;
+		epn = (rw.bits.rptr >> fpp_order) - 1;
+		epn &= m_pn;
+		ret = -ENOSPC;
+		if (pn != epn && recycle) {
+			ret = geth_freeq_recycle_page(geth, pn);
+			if (!ret) {
+				count += 1 << fpp_order;
+				pn++;
+				pn &= m_pn;
+				writew(pn << fpp_order,
+				       geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
+			}
+			if (ret == -ENOSPC)
+				recycle = false;
+		}
+		spin_unlock_irqrestore(&geth->freeq_lock, flags);
+		if (pn == epn)
+			break;
+		if (!ret)
+			continue;
+		if (ret != -ENOSPC && ret != -EAGAIN)
+			break;
 
-		gpage = &geth->freeq_pages[pn];
-		page = gpage->page;
+		ret = geth_freeq_map_page(geth, &page, &page_mapping);
+		if (ret)
+			break;
 
-		dev_dbg(geth->dev, "fill entry %d page ref count %d add %d refs\n",
-			pn, page_ref_count(page), 1 << fpp_order);
+		spin_lock_irqsave(&geth->freeq_lock, flags);
 
-		if (page_ref_count(page) > 1) {
-			unsigned int fl = (pn - epn) & m_pn;
+		rw.bits32 = readl(geth->base + GLOBAL_SWFQ_RWPTR_REG);
+		pn = (rw.bits.wptr >> fpp_order) & m_pn;
+		epn = (rw.bits.rptr >> fpp_order) - 1;
+		epn &= m_pn;
+		if (pn == epn) {
+			ret = -ENOSPC;
+		} else {
+			ret = geth_freeq_add_page(geth, pn, page,
+						  page_mapping);
+			if (!ret) {
+				count += 1 << fpp_order;
+				pn++;
+				pn &= m_pn;
+				writew(pn << fpp_order,
+				       geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
+			}
+		}
 
-			if (fl > 64 >> fpp_order)
-				break;
+		spin_unlock_irqrestore(&geth->freeq_lock, flags);
 
-			page = geth_freeq_alloc_map_page(geth, pn);
-			if (!page)
-				break;
+		if (ret) {
+			dma_unmap_single(geth->dev, page_mapping, PAGE_SIZE,
+					 DMA_FROM_DEVICE);
+			put_page(page);
+			break;
 		}
+	}
 
-		/* Add one reference per fragment in the page */
-		page_ref_add(page, 1 << fpp_order);
-		count += 1 << fpp_order;
-		pn++;
-		pn &= m_pn;
+	return count;
+}
+
+static void geth_freeq_release_pages(struct gemini_ethernet *geth)
+{
+	unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
+	unsigned int frag_len = 1 << geth->freeq_frag_order;
+	unsigned int pn;
+
+	for (pn = 0; pn < geth->num_freeq_pages; pn++) {
+		struct gmac_queue_page *gpage;
+		dma_addr_t mapping;
+		struct page *page;
+		unsigned int i;
+
+		gpage = &geth->freeq_pages[pn];
+		if (!gpage->page)
+			continue;
+
+		page = gpage->page;
+		for (i = 0; i < (1 << fpp_order); i++) {
+			mapping = gpage->mapping + i * frag_len;
+			if (xa_load(&geth->freeq_mappings,
+				    geth_freeq_mapping_index(geth, mapping)) != gpage)
+				continue;
+
+			dma_sync_single_range_for_cpu(geth->dev, gpage->mapping,
+						      i * frag_len, frag_len,
+						      DMA_FROM_DEVICE);
+		}
+		dma_unmap_single_attrs(geth->dev, gpage->mapping, PAGE_SIZE,
+				       DMA_FROM_DEVICE,
+				       DMA_ATTR_SKIP_CPU_SYNC);
+		while (gpage->fragments) {
+			put_page(page);
+			gpage->fragments--;
+		}
+		put_page(page);
 	}
+	xa_destroy(&geth->freeq_mappings);
+	geth->freeq_recycle_pending = 0;
+}
 
-	writew(pn << fpp_order, geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
+static unsigned int
+geth_freeq_page_slots(struct gemini_ethernet *geth, unsigned int order)
+{
+	unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
+	unsigned int slots = 1 << (order - fpp_order);
 
-	spin_unlock_irqrestore(&geth->freeq_lock, flags);
+	if (geth->port0 && geth->port0->netdev)
+		slots += 1 << geth->port0->rxq_order;
+	if (geth->port1 && geth->port1->netdev)
+		slots += 1 << geth->port1->rxq_order;
 
-	return count;
+	return slots;
 }
 
 static int geth_setup_freeq(struct gemini_ethernet *geth)
 {
 	unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
-	unsigned int frag_len = 1 << geth->freeq_frag_order;
 	unsigned int len = 1 << geth->freeq_order;
-	unsigned int pages = len >> fpp_order;
+	unsigned int page_slots;
+	unsigned int expected;
 	union queue_threshold qt;
 	union dma_skb_size skbsz;
 	unsigned int filled;
-	unsigned int pn;
+
+	page_slots = geth_freeq_page_slots(geth, geth->freeq_order);
 
 	geth->freeq_ring = dma_alloc_coherent(geth->dev,
 		sizeof(*geth->freeq_ring) << geth->freeq_order,
@@ -945,20 +1225,26 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
 		goto err_freeq;
 	}
 
-	/* Allocate a mapping to page look-up index */
-	geth->freeq_pages = kzalloc_objs(*geth->freeq_pages, pages);
+	/* Allocate page metadata referenced by the mapping index */
+	geth->freeq_pages = kzalloc_objs(*geth->freeq_pages, page_slots);
 	if (!geth->freeq_pages)
 		goto err_freeq;
-	geth->num_freeq_pages = pages;
-
-	dev_info(geth->dev, "allocate %d pages for queue\n", pages);
-	for (pn = 0; pn < pages; pn++)
-		if (!geth_freeq_alloc_map_page(geth, pn))
-			goto err_freeq_alloc;
+	geth->freeq_page_bitmap = bitmap_zalloc(page_slots, GFP_KERNEL);
+	if (!geth->freeq_page_bitmap)
+		goto err_freeq_pages;
+	geth->freeq_recycle_bitmap = bitmap_zalloc(page_slots, GFP_KERNEL);
+	if (!geth->freeq_recycle_bitmap)
+		goto err_freeq_page_bitmap;
+	geth->num_freeq_pages = page_slots;
+	geth->freeq_page_cursor = 0;
+
+	/* Discard pointer state belonging to the previous queue geometry. */
+	writel(0, geth->base + GLOBAL_SWFQ_RWPTR_REG);
 
-	filled = geth_fill_freeq(geth, false);
-	if (!filled)
-		goto err_freeq_alloc;
+	expected = len - (1 << fpp_order);
+	filled = geth_fill_freeq(geth);
+	if (filled != expected)
+		goto err_freeq_bitmap;
 
 	qt.bits32 = readl(geth->base + GLOBAL_QUEUE_THRESHOLD_REG);
 	qt.bits.swfq_empty = 32;
@@ -971,19 +1257,20 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
 
 	return 0;
 
-err_freeq_alloc:
-	while (pn > 0) {
-		struct gmac_queue_page *gpage;
-		dma_addr_t mapping;
-
-		--pn;
-		mapping = geth->freeq_ring[pn << fpp_order].word2.buf_adr;
-		dma_unmap_single(geth->dev, mapping, frag_len, DMA_FROM_DEVICE);
-		gpage = &geth->freeq_pages[pn];
-		put_page(gpage->page);
-	}
-
+err_freeq_bitmap:
+	writew(readw(geth->base + GLOBAL_SWFQ_RWPTR_REG),
+	       geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
+	geth_freeq_release_pages(geth);
+	bitmap_free(geth->freeq_recycle_bitmap);
+	geth->freeq_recycle_bitmap = NULL;
+err_freeq_page_bitmap:
+	bitmap_free(geth->freeq_page_bitmap);
+	geth->freeq_page_bitmap = NULL;
+err_freeq_pages:
 	kfree(geth->freeq_pages);
+	geth->freeq_pages = NULL;
+	geth->num_freeq_pages = 0;
+	geth->freeq_page_cursor = 0;
 err_freeq:
 	dma_free_coherent(geth->dev,
 			  sizeof(*geth->freeq_ring) << geth->freeq_order,
@@ -998,43 +1285,52 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
  */
 static void geth_cleanup_freeq(struct gemini_ethernet *geth)
 {
-	unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
-	unsigned int frag_len = 1 << geth->freeq_frag_order;
-	unsigned int len = 1 << geth->freeq_order;
-	unsigned int pages = len >> fpp_order;
-	unsigned int pn;
+	if (!geth->freeq_ring)
+		return;
 
 	writew(readw(geth->base + GLOBAL_SWFQ_RWPTR_REG),
 	       geth->base + GLOBAL_SWFQ_RWPTR_REG + 2);
 	writel(0, geth->base + GLOBAL_SW_FREEQ_BASE_SIZE_REG);
 
-	for (pn = 0; pn < pages; pn++) {
-		struct gmac_queue_page *gpage;
-		dma_addr_t mapping;
-
-		mapping = geth->freeq_ring[pn << fpp_order].word2.buf_adr;
-		dma_unmap_single(geth->dev, mapping, frag_len, DMA_FROM_DEVICE);
-
-		gpage = &geth->freeq_pages[pn];
-		while (page_ref_count(gpage->page) > 0)
-			put_page(gpage->page);
-	}
+	geth_freeq_release_pages(geth);
 
+	bitmap_free(geth->freeq_recycle_bitmap);
+	geth->freeq_recycle_bitmap = NULL;
+	bitmap_free(geth->freeq_page_bitmap);
+	geth->freeq_page_bitmap = NULL;
 	kfree(geth->freeq_pages);
+	geth->freeq_pages = NULL;
+	geth->num_freeq_pages = 0;
+	geth->freeq_page_cursor = 0;
 
 	dma_free_coherent(geth->dev,
 			  sizeof(*geth->freeq_ring) << geth->freeq_order,
 			  geth->freeq_ring, geth->freeq_dma_base);
+	geth->freeq_ring = NULL;
+}
+
+static void geth_set_freeq_irq(struct gemini_ethernet *geth, bool enable)
+{
+	unsigned long flags;
+	u32 val;
+
+	spin_lock_irqsave(&geth->irq_lock, flags);
+	val = readl(geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
+	if (enable)
+		val |= SWFQ_EMPTY_INT_BIT;
+	else
+		val &= ~SWFQ_EMPTY_INT_BIT;
+	writel(val, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
+	spin_unlock_irqrestore(&geth->irq_lock, flags);
 }
 
 /**
  * geth_resize_freeq() - resize the software queue depth
  * @port: the port requesting the change
  *
- * This gets called at least once during probe() so the device queue gets
- * "resized" from the hardware defaults. Since both ports/net devices share
- * the same hardware queue, some synchronization between the ports is
- * needed.
+ * This is called when a port is opened or its RX ring size changes. Since
+ * both ports/net devices share the same hardware queue, some synchronization
+ * between the ports is needed.
  */
 static int geth_resize_freeq(struct gemini_ethernet_port *port)
 {
@@ -1042,19 +1338,24 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
 	struct net_device *netdev = port->netdev;
 	struct gemini_ethernet_port *other_port;
 	struct net_device *other_netdev;
+	bool other_running;
 	unsigned int new_size = 0;
+	unsigned int page_slots;
 	unsigned int new_order;
-	unsigned long flags;
-	u32 en;
 	int ret;
 
+	ASSERT_RTNL();
+
+	/* The software free queue interrupt is routed through port 1. */
+	if (!geth->initialized || !geth->port0 || !geth->port1)
+		return -ENODEV;
+
 	if (netdev->dev_id == 0)
-		other_netdev = geth->port1->netdev;
+		other_port = geth->port1;
 	else
-		other_netdev = geth->port0->netdev;
-
-	if (other_netdev && netif_running(other_netdev))
-		return -EBUSY;
+		other_port = geth->port0;
+	other_netdev = other_port ? other_port->netdev : NULL;
+	other_running = other_netdev && netif_running(other_netdev);
 
 	new_size = 1 << (port->rxq_order + 1);
 	netdev_dbg(netdev, "port %d size: %d order %d\n",
@@ -1062,7 +1363,6 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
 		   new_size,
 		   port->rxq_order);
 	if (other_netdev) {
-		other_port = netdev_priv(other_netdev);
 		new_size += 1 << (other_port->rxq_order + 1);
 		netdev_dbg(other_netdev, "port %d size: %d order %d\n",
 			   other_netdev->dev_id,
@@ -1073,16 +1373,22 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
 	new_order = min(15, ilog2(new_size - 1) + 1);
 	dev_dbg(geth->dev, "set shared queue to size %d order %d\n",
 		new_size, new_order);
-	if (geth->freeq_order == new_order)
-		return 0;
+	if (new_order <= PAGE_SHIFT - geth->freeq_frag_order)
+		return -EINVAL;
 
-	spin_lock_irqsave(&geth->irq_lock, flags);
+	if (geth->freeq_ring) {
+		page_slots = geth_freeq_page_slots(geth, geth->freeq_order);
+		if (geth->num_freeq_pages >= page_slots &&
+		    (geth->freeq_order == new_order ||
+		     (other_running && geth->freeq_order > new_order)))
+			return 0;
+	}
 
-	/* Disable the software queue IRQs */
-	en = readl(geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
-	en &= ~SWFQ_EMPTY_INT_BIT;
-	writel(en, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
-	spin_unlock_irqrestore(&geth->irq_lock, flags);
+	if (other_running)
+		return -EBUSY;
+
+	disable_irq(geth->port1->irq);
+	geth_set_freeq_irq(geth, false);
 
 	/* Drop the old queue */
 	if (geth->freeq_ring)
@@ -1092,14 +1398,10 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
 	geth->freeq_order = new_order;
 	ret = geth_setup_freeq(geth);
 
-	/* Restart the interrupts - NOTE if this is the first resize
-	 * after probe(), this is where the interrupts get turned on
-	 * in the first place.
-	 */
-	spin_lock_irqsave(&geth->irq_lock, flags);
-	en |= SWFQ_EMPTY_INT_BIT;
-	writel(en, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
-	spin_unlock_irqrestore(&geth->irq_lock, flags);
+	/* Enable the queue interrupt only after successful setup. */
+	if (!ret)
+		geth_set_freeq_irq(geth, true);
+	enable_irq(geth->port1->irq);
 
 	return ret;
 }
@@ -1410,12 +1712,12 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,
 	unsigned int rx_status = word0.bits.status;
 	struct sk_buff *skb = NULL;
 
-	port->rx_stats[rx_status]++;
-	port->rx_csum_stats[rx_csum]++;
-
 	if (word0.bits.derr || word0.bits.perr ||
 	    rx_status || frame_len < ETH_ZLEN ||
 	    rx_csum >= RX_CHKSUM_IP_ERR_UNKNOWN) {
+		u64_stats_update_begin(&port->rx_stats_syncp);
+		port->rx_stats[rx_status]++;
+		port->rx_csum_stats[rx_csum]++;
 		port->stats.rx_errors++;
 
 		if (frame_len < ETH_ZLEN || RX_ERROR_LENGTH(rx_status))
@@ -1426,6 +1728,7 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,
 			port->stats.rx_crc_errors++;
 		if (RX_ERROR_FRAME(rx_status))
 			port->stats.rx_frame_errors++;
+		u64_stats_update_end(&port->rx_stats_syncp);
 		return NULL;
 	}
 
@@ -1437,8 +1740,12 @@ static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 update_exit:
+	u64_stats_update_begin(&port->rx_stats_syncp);
+	port->rx_stats[rx_status]++;
+	port->rx_csum_stats[rx_csum]++;
 	port->stats.rx_bytes += frame_len;
 	port->stats.rx_packets++;
+	u64_stats_update_end(&port->rx_stats_syncp);
 	return skb;
 }
 
@@ -1448,6 +1755,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
 	unsigned short m = (1 << port->rxq_order) - 1;
 	struct gemini_ethernet *geth = port->geth;
+	unsigned int freeq_frag_len = 1 << geth->freeq_frag_order;
 	void __iomem *ptr_reg = port->rxq_rwptr;
 	unsigned int frag_nr = port->rx_frag_nr;
 	struct sk_buff *skb = port->rx_skb;
@@ -1456,7 +1764,6 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 	unsigned int consumed = 0;
 	unsigned int frame_len, frag_len;
 	struct gmac_rxdesc *rx = NULL;
-	struct gmac_queue_page *gpage;
 	unsigned int received = 0;
 	bool dropping = port->rx_dropping;
 	union gmac_rxdesc_0 word0;
@@ -1493,12 +1800,12 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 
 		frag_len = word0.bits.buffer_size;
 		frame_len = word1.bits.byte_count;
-		page_offs = mapping & ~PAGE_MASK;
-
 		if (word3.bits32 & SOF_BIT) {
 			if (skb) {
 				napi_free_frags(&port->napi);
+				u64_stats_update_begin(&port->rx_stats_syncp);
 				port->stats.rx_dropped++;
+				u64_stats_update_end(&port->rx_stats_syncp);
 				skb = NULL;
 				frag_nr = 0;
 			}
@@ -1513,20 +1820,21 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 			goto err_drop;
 		}
 
-		/* Freeq pointers are one page off */
-		gpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE);
-		if (!gpage) {
+		page = geth_freeq_claim(geth, mapping, &page_offs);
+		if (!page) {
 			dev_err_ratelimited(geth->dev,
 					    "could not find mapping\n");
 			goto err_drop;
 		}
-		page = gpage->page;
 
 		if (word3.bits32 & SOF_BIT) {
 			skb = gmac_skb_if_good_frame(port, word0, frame_len);
 			if (!skb)
 				goto err_drop;
 
+			if (frag_len < NET_IP_ALIGN)
+				goto err_drop;
+
 			page_offs += NET_IP_ALIGN;
 			frag_len -= NET_IP_ALIGN;
 			frag_nr = 0;
@@ -1535,20 +1843,33 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 			goto err_drop;
 		}
 
-		if (word3.bits32 & EOF_BIT)
+		if (word3.bits32 & EOF_BIT) {
+			if (frame_len < ETH_ZLEN ||
+			    frame_len < skb->len ||
+			    frame_len - skb->len > frag_len)
+				goto err_drop;
 			frag_len = frame_len - skb->len;
+		}
 
 		/* append page frag to skb */
 		if (frag_nr == MAX_SKB_FRAGS)
 			goto err_drop;
+		if (frag_len > freeq_frag_len -
+			       (page_offs & (freeq_frag_len - 1)) ||
+		    frag_len > PAGE_SIZE - page_offs)
+			goto err_drop;
 
-		if (frag_len == 0 && net_ratelimit())
-			netdev_err(netdev, "Received fragment with len = 0\n");
+		if (!frag_len) {
+			if (net_ratelimit())
+				netdev_err(netdev,
+					   "Received fragment with len = 0\n");
+			goto err_drop;
+		}
 
 		skb_fill_page_desc(skb, frag_nr, page, page_offs, frag_len);
 		skb->len += frag_len;
 		skb->data_len += frag_len;
-		skb->truesize += frag_len;
+		skb->truesize += freeq_frag_len;
 		frag_nr++;
 
 		if (word3.bits32 & EOF_BIT) {
@@ -1569,7 +1890,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
 			put_page(page);
 
 		if (!dropping) {
+			u64_stats_update_begin(&port->rx_stats_syncp);
 			port->stats.rx_dropped++;
+			u64_stats_update_end(&port->rx_stats_syncp);
 			dropping = true;
 		}
 
@@ -1601,18 +1924,18 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)
 	bool reschedule;
 
 	freeq_threshold = 1 << (geth->freeq_order - 1);
-	u64_stats_update_begin(&port->rx_stats_syncp);
 
 	received = gmac_rx(napi->dev, budget, &freeq_consumed, &reschedule);
-	if (!reschedule && received < budget)
+	if (!reschedule && received < budget) {
+		u64_stats_update_begin(&port->rx_stats_syncp);
 		++port->rx_napi_exits;
-
-	u64_stats_update_end(&port->rx_stats_syncp);
+		u64_stats_update_end(&port->rx_stats_syncp);
+	}
 
 	port->freeq_refill += freeq_consumed;
 	if (port->freeq_refill > freeq_threshold) {
 		port->freeq_refill -= freeq_threshold;
-		geth_fill_freeq(geth, true);
+		geth_fill_freeq(geth);
 	}
 
 	if (!reschedule && received < budget &&
@@ -1867,10 +2190,7 @@ static int gmac_open(struct net_device *netdev)
 	phy_start(netdev->phydev);
 
 	err = geth_resize_freeq(port);
-	/* It's fine if it's just busy, the other port has set up
-	 * the freeq in that case.
-	 */
-	if (err && (err != -EBUSY)) {
+	if (err) {
 		netdev_err(netdev, "could not resize freeq\n");
 		goto err_stop_phy;
 	}
@@ -1911,12 +2231,19 @@ static int gmac_open(struct net_device *netdev)
 static int gmac_stop(struct net_device *netdev)
 {
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
+	unsigned long flags;
 
 	hrtimer_cancel(&port->rx_coalesce_timer);
 	netif_tx_stop_all_queues(netdev);
 	gmac_disable_tx_rx(netdev);
 	gmac_stop_dma(port);
 	napi_disable(&port->napi);
+	if (port->rx_skb) {
+		napi_free_frags(&port->napi);
+		flags = u64_stats_update_begin_irqsave(&port->rx_stats_syncp);
+		port->stats.rx_dropped++;
+		u64_stats_update_end_irqrestore(&port->rx_stats_syncp, flags);
+	}
 	port->rx_skb = NULL;
 	port->rx_frag_nr = 0;
 	port->rx_dropping = false;
@@ -2229,14 +2556,20 @@ static int gmac_set_ringparam(struct net_device *netdev,
 			      struct netlink_ext_ack *extack)
 {
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
+	unsigned int old_rxq_order;
 	int err = 0;
 
 	if (netif_running(netdev))
 		return -EBUSY;
 
 	if (rp->rx_pending) {
+		old_rxq_order = port->rxq_order;
 		port->rxq_order = min(15, ilog2(rp->rx_pending - 1) + 1);
 		err = geth_resize_freeq(port);
+		if (err) {
+			port->rxq_order = old_rxq_order;
+			return err;
+		}
 	}
 	if (rp->tx_pending) {
 		port->txq_order = min(15, ilog2(rp->tx_pending - 1) + 1);
@@ -2342,7 +2675,7 @@ static irqreturn_t gemini_port_irq_thread(int irq, void *data)
 
 	geth = port->geth;
 	/* The queue is half empty so refill it */
-	geth_fill_freeq(geth, true);
+	geth_fill_freeq(geth);
 
 	spin_lock_irqsave(&geth->irq_lock, flags);
 	/* ACK queue interrupt */
@@ -2362,6 +2695,9 @@ static irqreturn_t gemini_port_irq(int irq, void *data)
 	irqreturn_t ret = IRQ_NONE;
 	u32 val, en;
 
+	if (!port->id)
+		return IRQ_NONE;
+
 	geth = port->geth;
 	spin_lock(&geth->irq_lock);
 
@@ -2384,24 +2720,43 @@ static irqreturn_t gemini_port_irq(int irq, void *data)
 	return ret;
 }
 
+static void gemini_port_clear(struct gemini_ethernet_port *port)
+{
+	struct gemini_ethernet *geth = port->geth;
+
+	ASSERT_RTNL();
+
+	if (!port->id && geth->port0 == port)
+		geth->port0 = NULL;
+	else if (port->id && geth->port1 == port)
+		geth->port1 = NULL;
+	else
+		return;
+
+	geth->initialized = false;
+}
+
 static void gemini_port_remove(struct gemini_ethernet_port *port)
 {
+	rtnl_lock();
+	gemini_port_clear(port);
+	rtnl_unlock();
+
 	if (port->netdev) {
-		phy_disconnect(port->netdev->phydev);
 		unregister_netdev(port->netdev);
+		phy_disconnect(port->netdev->phydev);
 	}
 	clk_disable_unprepare(port->pclk);
-	geth_cleanup_freeq(port->geth);
 }
 
 static void gemini_ethernet_init(struct gemini_ethernet *geth)
 {
+	ASSERT_RTNL();
+
 	/* Only do this once both ports are online */
 	if (geth->initialized)
 		return;
-	if (geth->port0 && geth->port1)
-		geth->initialized = true;
-	else
+	if (!geth->port0 || !geth->port1)
 		return;
 
 	writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_0_REG);
@@ -2440,10 +2795,20 @@ static void gemini_ethernet_init(struct gemini_ethernet *geth)
 	writel(0, geth->base + GLOBAL_HWFQ_RWPTR_REG);
 
 	geth->freeq_frag_order = DEFAULT_RX_BUF_ORDER;
-	/* This makes the queue resize on probe() so that we
-	 * set up and enable the queue IRQ. FIXME: fragile.
-	 */
-	geth->freeq_order = 1;
+	geth->initialized = true;
+}
+
+static void gemini_port_publish(struct gemini_ethernet_port *port)
+{
+	struct gemini_ethernet *geth = port->geth;
+
+	ASSERT_RTNL();
+
+	if (!port->id)
+		geth->port0 = port;
+	else
+		geth->port1 = port;
+	gemini_ethernet_init(geth);
 }
 
 static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
@@ -2539,15 +2904,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	reset_control_reset(port->reset);
 	usleep_range(100, 500);
 
-	/* Assign pointer in the main state container */
-	if (!id)
-		geth->port0 = port;
-	else
-		geth->port1 = port;
-
-	/* This will just be done once both ports are up and reset */
-	gemini_ethernet_init(geth);
-
 	platform_set_drvdata(pdev, port);
 
 	/* Set up and register the netdev */
@@ -2598,6 +2954,16 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	if (ret)
 		goto unprepare;
 
+	if (!of_property_present(np, "phy-handle") &&
+	    !of_phy_is_fixed_link(np)) {
+		dev_info(dev, "no PHY, keeping port for shared IRQ\n");
+		port->netdev = NULL;
+		rtnl_lock();
+		gemini_port_publish(port);
+		rtnl_unlock();
+		return 0;
+	}
+
 	ret = gmac_setup_phy(netdev);
 	if (ret) {
 		netdev_err(netdev,
@@ -2605,9 +2971,15 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 		goto unprepare;
 	}
 
-	ret = register_netdev(netdev);
-	if (ret)
+	rtnl_lock();
+	ret = register_netdevice(netdev);
+	if (!ret)
+		gemini_port_publish(port);
+	rtnl_unlock();
+	if (ret) {
+		phy_disconnect(netdev->phydev);
 		goto unprepare;
+	}
 
 	return 0;
 
@@ -2635,6 +3007,7 @@ static struct platform_driver gemini_ethernet_port_driver = {
 	.driver = {
 		.name = "gemini-ethernet-port",
 		.of_match_table = gemini_ethernet_port_of_match,
+		.suppress_bind_attrs = true,
 	},
 	.probe = gemini_ethernet_port_probe,
 	.remove = gemini_ethernet_port_remove,
@@ -2671,6 +3044,7 @@ static int gemini_ethernet_probe(struct platform_device *pdev)
 
 	spin_lock_init(&geth->irq_lock);
 	spin_lock_init(&geth->freeq_lock);
+	xa_init(&geth->freeq_mappings);
 
 	/* The children will use this */
 	platform_set_drvdata(pdev, geth);
@@ -2683,8 +3057,13 @@ static void gemini_ethernet_remove(struct platform_device *pdev)
 {
 	struct gemini_ethernet *geth = platform_get_drvdata(pdev);
 
-	geth_cleanup_freeq(geth);
+	rtnl_lock();
 	geth->initialized = false;
+	rtnl_unlock();
+
+	devm_of_platform_depopulate(&pdev->dev);
+	writel(0, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
+	geth_cleanup_freeq(geth);
 }
 
 static const struct of_device_id gemini_ethernet_of_match[] = {

3/2 2026/10/11 18:16 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 18790
							output: 42
							thoughts: 108
						

Thoughts:
**Evaluating the Gemini Driver Patch**

Alright, let's get down to it. They want me to take a look at a patch series for the `cortina/gemini.c` driver in the Linux kernel, specifically targeting the amd64 architecture. My first instinct is to dive into the patch itself, but before that, I need to understand *what* exactly we're dealing with here.

So, the logical first step is to establish what kind of driver `cortina/gemini.c` is. Is it a NIC driver? MAC controller? A PHY? Based on the path, it looks like an Ethernet driver, but I need to confirm. And then, I need to know the bigger picture. To get a better understanding of the scope, I will search the Kconfig file for `gemini.c`. That will tell me which platform or architecture it's tied to, any dependencies it might have, and if there are any specific configurations I need to be aware of before even starting the detailed code review. That gives me the context I need to evaluate this patch.



4/2 2026/10/11 18:17 tool grepper
0m Args:
{
  "Expression": "CORTINA_GEMINI|GEMINI_ETHERNET",
  "PathPrefixes": [
    "drivers/net/ethernet/cortina"
  ]
}

Results:
{
  "Output": "drivers/net/ethernet/cortina/Kconfig=12=if NET_VENDOR_CORTINA\ndrivers/net/ethernet/cortina/Kconfig-13-\ndrivers/net/ethernet/cortina/Kconfig:14:config GEMINI_ETHERNET\ndrivers/net/ethernet/cortina/Kconfig-15-\ttristate \"Gemini Gigabit Ethernet support\"\n--\ndrivers/net/ethernet/cortina/Makefile-3-\ndrivers/net/ethernet/cortina/Makefile:4:obj-$(CONFIG_GEMINI_ETHERNET) += gemini.o\n--\ndrivers/net/ethernet/cortina/gemini.h-8- */\ndrivers/net/ethernet/cortina/gemini.h:9:#ifndef _GEMINI_ETHERNET_H\ndrivers/net/ethernet/cortina/gemini.h:10:#define _GEMINI_ETHERNET_H\ndrivers/net/ethernet/cortina/gemini.h-11-\n--\ndrivers/net/ethernet/cortina/gemini.h=953=struct nontoe_qhdr {\n--\ndrivers/net/ethernet/cortina/gemini.h-957-\ndrivers/net/ethernet/cortina/gemini.h:958:#endif /* _GEMINI_ETHERNET_H */\n"
}

5/2 2026/10/11 18:17 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 19497
							output: 38
							thoughts: 26
						

Thoughts:
Here's my thought process, summarized as you requested:

**Investigating Network Driver Configuration**

Okay, time to dig into the network driver configuration. I need to understand the specifics of the Cortina Ethernet driver. The best starting point is likely the `Kconfig` file within the `drivers/net/ethernet/cortina/` directory. That's where all the build-time configuration options are defined. I can probably find it using `read-file` in the project or even better, if there's a good grepping utility, I'll leverage that. Either tool should allow me to examine the contents and see what variables are available and how they're structured. This initial check will give me a solid foundation for further analysis or any modifications I might need to make. Let's see what's in there.



6/2 2026/10/11 18:17 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/cortina/Kconfig",
  "FirstLine": 1,
  "LineCount": 40
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0\n   2:\t# Cortina ethernet devices\n   3:\t\n   4:\tconfig NET_VENDOR_CORTINA\n   5:\t\tbool \"Cortina Gemini devices\"\n   6:\t\tdefault y\n   7:\t\thelp\n   8:\t\t  If you have a network (Ethernet) card belonging to this class, say Y\n   9:\t\t  and read the Ethernet-HOWTO, available from\n  10:\t\t  \u003chttps://www.tldp.org/docs.html#howto\u003e.\n  11:\t\n  12:\tif NET_VENDOR_CORTINA\n  13:\t\n  14:\tconfig GEMINI_ETHERNET\n  15:\t\ttristate \"Gemini Gigabit Ethernet support\"\n  16:\t\tdepends on OF\n  17:\t\tdepends on HAS_IOMEM\n  18:\t\tselect PHYLIB\n  19:\t\tselect CRC32\n  20:\t\thelp\n  21:\t\t  This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet.\n  22:\t\n  23:\tendif # NET_VENDOR_CORTINA\n"
}

7/2 2026/10/11 18:17 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20030
							output: 34
							thoughts: 51
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the Gemini Ethernet Controller**

Right, so `GEMINI_ETHERNET`... that's obviously for the StorLink SL351x, or "Gemini" as it's often called, dual Gigabit Ethernet controller. My immediate question is, what's the underlying System-on-a-Chip (SoC) for this Gemini silicon? I need to figure out the architectural context. Let me start digging around in the kernel source, specifically looking in places like `arch/arm/mach-gemini/` or any directory paths that follow a similar pattern, to get the lay of the land and understand the hardware specifics. I need to get a handle on the SoC to understand the device's interaction with the rest of the system.



8/2 2026/10/11 18:17 tool grepper
0m Args:
{
  "Expression": "cortina.*gemini|gemini.*ethernet",
  "PathPrefixes": [
    "arch/"
  ]
}

Results:
{
  "Output": "arch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts=10=/ {\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts-11-\tmodel = \"D-Link DIR-685 Xtreme N Storage Router\";\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts:12:\tcompatible = \"dlink,dir-685\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts-13-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts=424=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts:425:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts:426:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-dlink-dir-685.dts-427-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts=12=/ {\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-13-\tmodel = \"D-Link DNS-313 1-Bay Network Storage Enclosure\";\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts:14:\tcompatible = \"dlink,dns-313\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-15-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts=168=\t\tflash@30000000 {\n--\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-172-\t\t\t */\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts:173:\t\t\tcompatible = \"cortina,gemini-flash\", \"jedec-flash\";\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-174-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts=282=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-283-\t\t\t/* The ROM uses this muxmode */\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts:284:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts:285:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-dlink-dns-313.dts-286-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-nas4210b.dts=12=/ {\narch/arm/boot/dts/gemini/gemini-nas4210b.dts-13-\tmodel = \"Raidsonic NAS IB-4210-B\";\narch/arm/boot/dts/gemini/gemini-nas4210b.dts:14:\tcompatible = \"raidsonic,ib-4210-b\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-nas4210b.dts-15-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-nas4210b.dts=161=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-nas4210b.dts:162:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-nas4210b.dts:163:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-nas4210b.dts-164-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-nas4220b.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-nas4220b.dts-12-\tmodel = \"Raidsonic NAS IB-4220-B\";\narch/arm/boot/dts/gemini/gemini-nas4220b.dts:13:\tcompatible = \"raidsonic,ib-4220-b\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-nas4220b.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-nas4220b.dts=151=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-nas4220b.dts:152:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-nas4220b.dts:153:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-nas4220b.dts-154-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-ns2502.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-ns2502.dts-12-\tmodel = \"Edimax NS-2502\";\narch/arm/boot/dts/gemini/gemini-ns2502.dts:13:\tcompatible = \"edimax,ns-2502\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-ns2502.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-ns2502.dts=83=\u0026sata {\narch/arm/boot/dts/gemini/gemini-ns2502.dts:84:\tcortina,gemini-ata-muxmode = \u003c3\u003e;\narch/arm/boot/dts/gemini/gemini-ns2502.dts:85:\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-ns2502.dts-86-\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-rut1xx.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-rut1xx.dts-12-\tmodel = \"Teltonika RUT1xx\";\narch/arm/boot/dts/gemini/gemini-rut1xx.dts:13:\tcompatible = \"teltonika,rut1xx\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-rut1xx.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-sl93512r.dts=14=/ {\narch/arm/boot/dts/gemini/gemini-sl93512r.dts-15-\tmodel = \"Storlink Semiconductor Gemini324 EV-Board / Storm Semiconductor SL93512R_BRD\";\narch/arm/boot/dts/gemini/gemini-sl93512r.dts:16:\tcompatible = \"storlink,gemini324\", \"storm,sl93512r\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-sl93512r.dts-17-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-sl93512r.dts=241=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-sl93512r.dts:242:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-sl93512r.dts:243:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-sl93512r.dts-244-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-sq201.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-sq201.dts-12-\tmodel = \"ITian Square One SQ201\";\narch/arm/boot/dts/gemini/gemini-sq201.dts:13:\tcompatible = \"itian,sq201\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-sq201.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-sq201.dts=237=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-sq201.dts:238:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-sq201.dts:239:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-sq201.dts-240-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-ssi1328.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-ssi1328.dts-12-\tmodel = \"SSI 1328\";\narch/arm/boot/dts/gemini/gemini-ssi1328.dts:13:\tcompatible = \"ssi,1328\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-ssi1328.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-ssi1328.dts=93=\u0026sata {\narch/arm/boot/dts/gemini/gemini-ssi1328.dts:94:\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-ssi1328.dts:95:\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-ssi1328.dts-96-\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts=13=/ {\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts-14-\tmodel = \"Verbatim Gigabit Ethernet Hard Drive S08V1901-D1\";\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts:15:\tcompatible = \"verbatim,s08v1901-d1\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts-16-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts=175=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts:176:\t\t\tcortina,gemini-ata-muxmode = \u003c0\u003e;\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts:177:\t\t\tcortina,gemini-enable-sata-bridge;\narch/arm/boot/dts/gemini/gemini-verbatim-s08v1901-d1.dts-178-\t\t\tstatus = \"okay\";\n--\narch/arm/boot/dts/gemini/gemini-wbd111.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-wbd111.dts-12-\tmodel = \"Wiliboard WBD-111\";\narch/arm/boot/dts/gemini/gemini-wbd111.dts:13:\tcompatible = \"wiligear,wiliboard-wbd111\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-wbd111.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini-wbd222.dts=11=/ {\narch/arm/boot/dts/gemini/gemini-wbd222.dts-12-\tmodel = \"Wiliboard WBD-222\";\narch/arm/boot/dts/gemini/gemini-wbd222.dts:13:\tcompatible = \"wiligear,wiliboard-wbd222\", \"cortina,gemini\";\narch/arm/boot/dts/gemini/gemini-wbd222.dts-14-\t#address-cells = \u003c1\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi-6-#include \u003cdt-bindings/interrupt-controller/irq.h\u003e\narch/arm/boot/dts/gemini/gemini.dtsi:7:#include \u003cdt-bindings/clock/cortina,gemini-clock.h\u003e\narch/arm/boot/dts/gemini/gemini.dtsi:8:#include \u003cdt-bindings/reset/cortina,gemini-reset.h\u003e\narch/arm/boot/dts/gemini/gemini.dtsi-9-#include \u003cdt-bindings/gpio/gpio.h\u003e\n--\narch/arm/boot/dts/gemini/gemini.dtsi=19=\t\tflash: flash@30000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:20:\t\t\tcompatible = \"cortina,gemini-flash\", \"cfi-flash\";\narch/arm/boot/dts/gemini/gemini.dtsi-21-\t\t\tsyscon = \u003c\u0026syscon\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=28=\t\tsyscon: syscon@40000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:29:\t\t\tcompatible = \"cortina,gemini-syscon\",\narch/arm/boot/dts/gemini/gemini.dtsi-30-\t\t\t\t     \"syscon\", \"simple-mfd\";\n--\narch/arm/boot/dts/gemini/gemini.dtsi=44=\t\t\tpinctrl {\narch/arm/boot/dts/gemini/gemini.dtsi:45:\t\t\t\tcompatible = \"cortina,gemini-pinctrl\";\narch/arm/boot/dts/gemini/gemini.dtsi-46-\t\t\t\tregmap = \u003c\u0026syscon\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=163=\t\twatchdog@41000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:164:\t\t\tcompatible = \"cortina,gemini-watchdog\", \"faraday,ftwdt010\";\narch/arm/boot/dts/gemini/gemini.dtsi-165-\t\t\treg = \u003c0x41000000 0x1000\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=197=\t\trtc@45000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:198:\t\t\tcompatible = \"cortina,gemini-rtc\", \"faraday,ftrtc010\";\narch/arm/boot/dts/gemini/gemini.dtsi-199-\t\t\treg = \u003c0x45000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=208=\t\tsata: sata@46000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:209:\t\t\tcompatible = \"cortina,gemini-sata-bridge\";\narch/arm/boot/dts/gemini/gemini.dtsi-210-\t\t\treg = \u003c0x46000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=248=\t\tpower-controller@4b000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:249:\t\t\tcompatible = \"cortina,gemini-power-controller\";\narch/arm/boot/dts/gemini/gemini.dtsi-250-\t\t\treg = \u003c0x4b000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=256=\t\tgpio0: gpio@4d000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:257:\t\t\tcompatible = \"cortina,gemini-gpio\", \"faraday,ftgpio010\";\narch/arm/boot/dts/gemini/gemini.dtsi-258-\t\t\treg = \u003c0x4d000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=268=\t\tgpio1: gpio@4e000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:269:\t\t\tcompatible = \"cortina,gemini-gpio\", \"faraday,ftgpio010\";\narch/arm/boot/dts/gemini/gemini.dtsi-270-\t\t\treg = \u003c0x4e000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=280=\t\tgpio2: gpio@4f000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:281:\t\t\tcompatible = \"cortina,gemini-gpio\", \"faraday,ftgpio010\";\narch/arm/boot/dts/gemini/gemini.dtsi-282-\t\t\treg = \u003c0x4f000000 0x100\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=292=\t\tpci@50000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:293:\t\t\tcompatible = \"cortina,gemini-pci\", \"faraday,ftpci100\";\narch/arm/boot/dts/gemini/gemini.dtsi-294-\t\t\t/*\n--\narch/arm/boot/dts/gemini/gemini.dtsi=359=\t\tethernet: ethernet@60000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:360:\t\t\tcompatible = \"cortina,gemini-ethernet\";\narch/arm/boot/dts/gemini/gemini.dtsi-361-\t\t\treg = \u003c0x60000000 0x4000\u003e, /* Global registers, queue */\n--\narch/arm/boot/dts/gemini/gemini.dtsi=371=\t\t\tgmac0: ethernet-port@0 {\narch/arm/boot/dts/gemini/gemini.dtsi:372:\t\t\t\tcompatible = \"cortina,gemini-ethernet-port\";\narch/arm/boot/dts/gemini/gemini.dtsi-373-\t\t\t\treg = \u003c0x60008000 0x2000\u003e, /* Port 0 DMA/TOE */\n--\narch/arm/boot/dts/gemini/gemini.dtsi=382=\t\t\tgmac1: ethernet-port@1 {\narch/arm/boot/dts/gemini/gemini.dtsi:383:\t\t\t\tcompatible = \"cortina,gemini-ethernet-port\";\narch/arm/boot/dts/gemini/gemini.dtsi-384-\t\t\t\treg = \u003c0x6000c000 0x2000\u003e, /* Port 1 DMA/TOE */\n--\narch/arm/boot/dts/gemini/gemini.dtsi=402=\t\tide0: ide@63000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:403:\t\t\tcompatible = \"cortina,gemini-pata\", \"faraday,ftide010\";\narch/arm/boot/dts/gemini/gemini.dtsi-404-\t\t\treg = \u003c0x63000000 0x1000\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=415=\t\tide1: ide@63400000 {\narch/arm/boot/dts/gemini/gemini.dtsi:416:\t\t\tcompatible = \"cortina,gemini-pata\", \"faraday,ftide010\";\narch/arm/boot/dts/gemini/gemini.dtsi-417-\t\t\treg = \u003c0x63400000 0x1000\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=445=\t\tdisplay-controller@6a000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:446:\t\t\tcompatible = \"cortina,gemini-tvc\", \"faraday,tve200\";\narch/arm/boot/dts/gemini/gemini.dtsi-447-\t\t\treg = \u003c0x6a000000 0x1000\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=458=\t\tusb0: usb@68000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:459:\t\t\tcompatible = \"cortina,gemini-usb\", \"faraday,fotg200\";\narch/arm/boot/dts/gemini/gemini.dtsi-460-\t\t\treg = \u003c0x68000000 0x1000\u003e;\n--\narch/arm/boot/dts/gemini/gemini.dtsi=481=\t\tusb1: usb@69000000 {\narch/arm/boot/dts/gemini/gemini.dtsi:482:\t\t\tcompatible = \"cortina,gemini-usb\", \"faraday,fotg200\";\narch/arm/boot/dts/gemini/gemini.dtsi-483-\t\t\treg = \u003c0x69000000 0x1000\u003e;\n--\narch/arm/mach-gemini/board-dt.c=55=static const char *gemini_board_compat[] = {\narch/arm/mach-gemini/board-dt.c:56:\t\"cortina,gemini\",\narch/arm/mach-gemini/board-dt.c-57-\tNULL,\n"
}

9/2 2026/10/11 18:17 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26673
							output: 31
							thoughts: 218
						

Thoughts:
**Analyzing the Gemini Ethernet Driver**

Okay, so I'm looking at `drivers/net/ethernet/cortina/gemini.c`, a driver for the Cortina Systems Gemini (StorLink SL351x) SoC. Specifically, it's designed for the ARM architecture (`arch/arm/mach-gemini`). But wait a minute... the prompt mentioned the target architecture is `amd64`. That's a red flag!

Can this driver even *run* on amd64? This seems unlikely. It's a platform device driver using Device Tree ("cortina,gemini-ethernet"), so I need to figure out if it can be probed and executed in a standard virtualized environment like QEMU or GCE on x86-64.

First, I need to know if the driver even compiles on x86_64. Let's see... it depends on `OF` and `HAS_IOMEM`. Can I even enable `OF` on x86_64? I need to check the kernel configuration. It looks like `CONFIG_OF` can be enabled if `CONFIG_OF_UNITTEST` or `ARCH` has it. Or, in recent kernels, it's selectable with certain test options. So, let's dive into the Kconfig files and find out what's what regarding `OF` on x86.



10/2 2026/10/11 18:17 tool grepper
0m Args:
{
  "Expression": "config OF\\b",
  "PathPrefixes": [
    "drivers/of/Kconfig"
  ]
}

Results:
{
  "Output": "drivers/of/Kconfig=8=config BUILTIN_DTB_ALL\n--\ndrivers/of/Kconfig-10-\ndrivers/of/Kconfig:11:menuconfig OF\ndrivers/of/Kconfig-12-\tbool \"Device Tree and Open Firmware support\"\n"
}

11/2 2026/10/11 18:17 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27299
							output: 32
							thoughts: 16
						

Thoughts:
Okay, here's my attempt at summarizing that thought process, tailored for an expert audience:

**Diving into Kconfig: A Targeted Approach**

Right, let's zero in on the `drivers/of/Kconfig` file, specifically around line 11. I'm assuming there's something specific there I need to investigate. Could be a dependency issue, a potential configuration problem, or perhaps a new option that's just been introduced. More context would be useful, but line 11 is where my immediate focus will be. No need for general Kconfig overview, let's get right to the point.



12/2 2026/10/11 18:17 tool read-file
0m Args:
{
  "File": "drivers/of/Kconfig",
  "FirstLine": 1,
  "LineCount": 40
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0\n   2:\tconfig DTC\n   3:\t\tbool\n   4:\t\n   5:\tconfig GENERIC_BUILTIN_DTB\n   6:\t\tbool\n   7:\t\n   8:\tconfig BUILTIN_DTB_ALL\n   9:\t\tbool\n  10:\t\n  11:\tmenuconfig OF\n  12:\t\tbool \"Device Tree and Open Firmware support\"\n  13:\t\thelp\n  14:\t\t  This option enables the device tree infrastructure.\n  15:\t\t  It is automatically selected by platforms that need it or can\n  16:\t\t  be enabled manually for unittests, overlays or\n  17:\t\t  compile-coverage.\n  18:\t\n  19:\tif OF\n  20:\t\n  21:\tconfig OF_UNITTEST\n  22:\t\tbool \"Device Tree runtime unit tests\"\n  23:\t\tdepends on OF_EARLY_FLATTREE\n  24:\t\tselect IRQ_DOMAIN\n  25:\t\tselect OF_RESOLVE\n  26:\t\thelp\n  27:\t\t  This option builds in test cases for the device tree infrastructure\n  28:\t\t  that are executed once at boot time, and the results dumped to the\n  29:\t\t  console.\n  30:\t\n  31:\t\t  This option should only be enabled for a development kernel. The tests\n  32:\t\t  will taint the kernel with TAINT_TEST. The tests will cause ERROR and\n  33:\t\t  WARNING messages to print on the console. The tests will cause stack\n  34:\t\t  traces to print on the console.  It is possible that the tests will\n  35:\t\t  leave the devicetree in a corrupted state.\n  36:\t\n  37:\t\t  The unittest output will be verbose.  Copy the output to a file\n  38:\t\t  via capturing the console output or via the dmesg command.  Process\n  39:\t\t  this file with scripts/dtc/of_unittest_expect to reduce the\n  40:\t\t  verbosity, test whether expected output is present, and to\n"
}

13/2 2026/10/11 18:17 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28009
							output: 42
							thoughts: 97
						

Thoughts:
Here's my thought process, as if I were analyzing this code myself:

**Investigating Gemini Ethernet Driver Instantiation on AMD64 in QEMU**

Hold on a second! Even if the `CONFIG_OF` configuration option is enabled, I'm stuck, how could the `gemini_ethernet` driver possibly probe and instantiate itself correctly on an AMD64 architecture within a QEMU environment? This doesn't seem to make sense, given what I know about the typical hardware setup.

Okay, let's trace through this carefully. I need to understand the fundamental probe mechanism of this driver. My instinct is to dive into the code. I'll start by examining the core driver file, `drivers/net/ethernet/cortina/gemini.c`.

Right, how *exactly* does `gemini.c` perform its probing? What's the process? I need to clarify the sequence of events.

Alright, let's get into the details of the probe functions. I'll need to scrutinize both `gemini_ethernet_probe` and `gemini_ethernet_port_probe` to understand how the driver attempts to find and initialize the hardware. Understanding the probing logic in these functions is key to understanding how, or why, the AMD64 instantiation is failing.



14/2 2026/10/11 18:17 tool grepper
0m Args:
{
  "Expression": "gemini_ethernet.*probe",
  "PathPrefixes": [
    "drivers/net/ethernet/cortina/gemini.c"
  ]
}

Results:
{
  "Output": "drivers/net/ethernet/cortina/gemini.c=2814=static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)\n--\ndrivers/net/ethernet/cortina/gemini.c-2823-\ndrivers/net/ethernet/cortina/gemini.c:2824:static int gemini_ethernet_port_probe(struct platform_device *pdev)\ndrivers/net/ethernet/cortina/gemini.c-2825-{\n--\ndrivers/net/ethernet/cortina/gemini.c=3006=static struct platform_driver gemini_ethernet_port_driver = {\n--\ndrivers/net/ethernet/cortina/gemini.c-3011-\t},\ndrivers/net/ethernet/cortina/gemini.c:3012:\t.probe = gemini_ethernet_port_probe,\ndrivers/net/ethernet/cortina/gemini.c-3013-\t.remove = gemini_ethernet_port_remove,\n--\ndrivers/net/ethernet/cortina/gemini.c-3015-\ndrivers/net/ethernet/cortina/gemini.c:3016:static int gemini_ethernet_probe(struct platform_device *pdev)\ndrivers/net/ethernet/cortina/gemini.c-3017-{\n--\ndrivers/net/ethernet/cortina/gemini.c=3077=static struct platform_driver gemini_ethernet_driver = {\n--\ndrivers/net/ethernet/cortina/gemini.c-3081-\t},\ndrivers/net/ethernet/cortina/gemini.c:3082:\t.probe = gemini_ethernet_probe,\ndrivers/net/ethernet/cortina/gemini.c-3083-\t.remove = gemini_ethernet_remove,\n"
}

15/2 2026/10/11 18:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28916
							output: 44
							thoughts: 38
						

Thoughts:
Here's a summary of my current thought process, tailored for an expert audience:

**Analyzing Ethernet Probes in Gemini Network Monitoring**

Okay, time to dive back into the code. I need to zero in on how the Ethernet probes are behaving within the Gemini system, specifically focusing on `gemini_ethernet_probe` and `gemini_ethernet_port_probe`. I'm going to scan the code around lines 2824 to 3100. My immediate goal is to understand the control and data flow within these functions. I'm looking for potential bottlenecks, race conditions, or anything that might be causing performance anomalies or data integrity issues. I'll be quickly assessing the algorithms used, checking for efficiency. I'll need to pay close attention to the data structures involved, ensuring they're thread-safe or appropriately synchronized if needed.



16/2 2026/10/11 18:18 tool read-file
0m Args:
{
  "File": "drivers/net/ethernet/cortina/gemini.c",
  "FirstLine": 3000,
  "LineCount": 100
}

Results:
{
  "Contents": "3000:\t\t\t.compatible = \"cortina,gemini-ethernet-port\",\n3001:\t\t},\n3002:\t\t{},\n3003:\t};\n3004:\tMODULE_DEVICE_TABLE(of, gemini_ethernet_port_of_match);\n3005:\t\n3006:\tstatic struct platform_driver gemini_ethernet_port_driver = {\n3007:\t\t.driver = {\n3008:\t\t\t.name = \"gemini-ethernet-port\",\n3009:\t\t\t.of_match_table = gemini_ethernet_port_of_match,\n3010:\t\t\t.suppress_bind_attrs = true,\n3011:\t\t},\n3012:\t\t.probe = gemini_ethernet_port_probe,\n3013:\t\t.remove = gemini_ethernet_port_remove,\n3014:\t};\n3015:\t\n3016:\tstatic int gemini_ethernet_probe(struct platform_device *pdev)\n3017:\t{\n3018:\t\tstruct device *dev = \u0026pdev-\u003edev;\n3019:\t\tstruct gemini_ethernet *geth;\n3020:\t\tunsigned int retry = 5;\n3021:\t\tu32 val;\n3022:\t\n3023:\t\t/* Global registers */\n3024:\t\tgeth = devm_kzalloc(dev, sizeof(*geth), GFP_KERNEL);\n3025:\t\tif (!geth)\n3026:\t\t\treturn -ENOMEM;\n3027:\t\tgeth-\u003ebase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);\n3028:\t\tif (IS_ERR(geth-\u003ebase))\n3029:\t\t\treturn PTR_ERR(geth-\u003ebase);\n3030:\t\tgeth-\u003edev = dev;\n3031:\t\n3032:\t\t/* Wait for ports to stabilize */\n3033:\t\tdo {\n3034:\t\t\tudelay(2);\n3035:\t\t\tval = readl(geth-\u003ebase + GLOBAL_TOE_VERSION_REG);\n3036:\t\t\tbarrier();\n3037:\t\t} while (!val \u0026\u0026 --retry);\n3038:\t\tif (!retry) {\n3039:\t\t\tdev_err(dev, \"failed to reset ethernet\\n\");\n3040:\t\t\treturn -EIO;\n3041:\t\t}\n3042:\t\tdev_info(dev, \"Ethernet device ID: 0x%03x, revision 0x%01x\\n\",\n3043:\t\t\t (val \u003e\u003e 4) \u0026 0xFFFU, val \u0026 0xFU);\n3044:\t\n3045:\t\tspin_lock_init(\u0026geth-\u003eirq_lock);\n3046:\t\tspin_lock_init(\u0026geth-\u003efreeq_lock);\n3047:\t\txa_init(\u0026geth-\u003efreeq_mappings);\n3048:\t\n3049:\t\t/* The children will use this */\n3050:\t\tplatform_set_drvdata(pdev, geth);\n3051:\t\n3052:\t\t/* Spawn child devices for the two ports */\n3053:\t\treturn devm_of_platform_populate(dev);\n3054:\t}\n3055:\t\n3056:\tstatic void gemini_ethernet_remove(struct platform_device *pdev)\n3057:\t{\n3058:\t\tstruct gemini_ethernet *geth = platform_get_drvdata(pdev);\n3059:\t\n3060:\t\trtnl_lock();\n3061:\t\tgeth-\u003einitialized = false;\n3062:\t\trtnl_unlock();\n3063:\t\n3064:\t\tdevm_of_platform_depopulate(\u0026pdev-\u003edev);\n3065:\t\twritel(0, geth-\u003ebase + GLOBAL_INTERRUPT_ENABLE_4_REG);\n3066:\t\tgeth_cleanup_freeq(geth);\n3067:\t}\n3068:\t\n3069:\tstatic const struct of_device_id gemini_ethernet_of_match[] = {\n3070:\t\t{\n3071:\t\t\t.compatible = \"cortina,gemini-ethernet\",\n3072:\t\t},\n3073:\t\t{},\n3074:\t};\n3075:\tMODULE_DEVICE_TABLE(of, gemini_ethernet_of_match);\n3076:\t\n3077:\tstatic struct platform_driver gemini_ethernet_driver = {\n3078:\t\t.driver = {\n3079:\t\t\t.name = DRV_NAME,\n3080:\t\t\t.of_match_table = gemini_ethernet_of_match,\n3081:\t\t},\n3082:\t\t.probe = gemini_ethernet_probe,\n3083:\t\t.remove = gemini_ethernet_remove,\n3084:\t};\n3085:\t\n3086:\tstatic int __init gemini_ethernet_module_init(void)\n3087:\t{\n3088:\t\tint ret;\n3089:\t\n3090:\t\tret = platform_driver_register(\u0026gemini_ethernet_port_driver);\n3091:\t\tif (ret)\n3092:\t\t\treturn ret;\n3093:\t\n3094:\t\tret = platform_driver_register(\u0026gemini_ethernet_driver);\n3095:\t\tif (ret) {\n3096:\t\t\tplatform_driver_unregister(\u0026gemini_ethernet_port_driver);\n3097:\t\t\treturn ret;\n3098:\t\t}\n3099:\t\n"
}

17/2 2026/10/11 18:18 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30677
							output: 33
							thoughts: 788
						

Thoughts:
**Analyzing the Cortina Gemini Ethernet Driver for Fuzzing Feasibility**

Okay, so I've been looking at `gemini_ethernet_probe` and `gemini_ethernet_port_driver` and immediately a few red flags are popping up. This `gemini_ethernet` driver is for a Cortina Gemini SoC (SL351x), which is a fairly old ARMv4-based design from around 2007. Right away, this screams "legacy" and "unlikely to be relevant to current fuzzing efforts" unless there's a specific use case around reverse engineering old equipment.

The driver relies on a Device Tree node named "cortina,gemini-ethernet" with child nodes "cortina,gemini-ethernet-port." Furthermore, it directly accesses hardware registers using `readl`: `geth->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);` and specifically `readl(geth->base + GLOBAL_TOE_VERSION_REG)`.  I can already tell that this is going to be a problem.

Now, looking deeper, the `gemini_ethernet_port_probe` function gets a reset controller and clock and DMA region: `port->reset = devm_reset_control_get_exclusive(dev, NULL);`, `port->pclk = devm_clk_get(dev, "PCLK");`, and `port->dma_base = devm_platform_ioremap_resource_byname(pdev, "dma");`. It then calls `reset_control_reset(port->reset);`, `clk_prepare_enable(port->pclk);`, etc.

The immediate question is whether this can even be *instantiated* or probed in an amd64 QEMU environment. The answer, as I suspect, is a resounding NO.

1.  This is because the target architecture is amd64, and there *is no* Cortina Gemini SoC on amd64. 
2.  Even on ARM, this is a legacy ARMv4/ARM926EJ-S SoC (`arch/arm/mach-gemini`). QEMU doesn't emulate the Cortina Gemini SoC or its specific Ethernet controller. QEMU generally provides a few standard boards (versatilepb, virt, integratorcp, realview, etc.).
3.  Standard virtualization on amd64 uses QEMU x86\_64 or environments like GCE which don't emulate this kind of hardware.

Even if someone were to try to force the issue and manually bind or create a platform device, it's a dead end. I see that `gemini_ethernet_port_driver` has `.suppress_bind_attrs = true`! That's a huge clue right there. The `gemini_ethernet_driver` matches solely on the Device Tree match table ("cortina,gemini-ethernet"). More importantly, even if a platform device were conjured, calls like `readl(geth->base + GLOBAL_TOE_VERSION_REG)` would *fail*. Likewise, `reset_control`, `clk_get`, and others would all fail. We are dealing with hardware that is not emulated in the target environment.

This brings me to the fundamental point, and it's something I've stressed before: "REACHABILITY IS THE PRIMARY GATE." Fuzzing is only effective on code that can *actually* execute in the standard virtualized environments we're using (GCE or QEMU, using software emulated devices). If the modified code is structurally unreachable, *it cannot be fuzzed*, no matter how much logic or assertions are added.

Section 2 clarifies this: We're looking at structurally unreachable hardware. That includes vendor-specific PCIe switches, SmartNICs, GPU drivers (like mlxsw, pds\_core, qed, ionic, amdgpu) that need physical ASIC/PCIe cards that are not emulated in standard QEMU. Also, code paths exclusive to architectures other than the target.

I think it's worth a double-check to verify if Cortina Gemini ethernet has *any* QEMU emulation or can be used on amd64, but I'm not optimistic. Let me just confirm that Cortina or Gemini support is present in QEMU.



18/2 2026/10/11 18:18 tool grepper
0m Args:
{
  "Expression": "cortina.*gemini|sl351",
  "PathPrefixes": [
    "drivers/"
  ]
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 512 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (20 files in total):\ndrivers/ata/pata_ftide010.c:1\ndrivers/ata/sata_gemini.c:4\ndrivers/clk/clk-gemini.c:4\ndrivers/clocksource/timer-fttmr010.c:1\ndrivers/crypto/Kconfig:1\ndrivers/crypto/gemini/Makefile:2\ndrivers/crypto/gemini/sl3516-ce-cipher.c:43\ndrivers/crypto/gemini/sl3516-ce-core.c:63\ndrivers/crypto/gemini/sl3516-ce-rng.c:8\ndrivers/crypto/gemini/sl3516-ce.h:23\ndrivers/gpio/gpio-ftgpio010.c:1\ndrivers/irqchip/irq-ftintc010.c:1\ndrivers/mtd/maps/physmap-gemini.c:1\ndrivers/net/ethernet/cortina/gemini.c:2\ndrivers/pinctrl/pinctrl-gemini.c:1\ndrivers/power/reset/gemini-poweroff.c:1\ndrivers/rtc/rtc-ftrtc010.c:1\ndrivers/soc/gemini/soc-gemini.c:2\ndrivers/usb/fotg210/fotg210-core.c:1\ndrivers/watchdog/ftwdt010_wdt.c:1\n\ndrivers/ata/pata_ftide010.c=451=static int pata_ftide010_probe(struct platform_device *pdev)\n--\ndrivers/ata/pata_ftide010.c-485-\t/* Some special Cortina Gemini init, if needed */\ndrivers/ata/pata_ftide010.c:486:\tif (of_device_is_compatible(np, \"cortina,gemini-pata\")) {\ndrivers/ata/pata_ftide010.c-487-\t\t/*\n--\ndrivers/ata/sata_gemini.c=285=static int gemini_sata_probe(struct platform_device *pdev)\n--\ndrivers/ata/sata_gemini.c-311-\t/* Set up the SATA bridge if need be */\ndrivers/ata/sata_gemini.c:312:\tif (of_property_read_bool(np, \"cortina,gemini-enable-sata-bridge\")) {\ndrivers/ata/sata_gemini.c-313-\t\tret = gemini_sata_bridge_init(sg);\n--\ndrivers/ata/sata_gemini.c-317-\ndrivers/ata/sata_gemini.c:318:\tif (of_property_read_bool(np, \"cortina,gemini-enable-ide-pins\"))\ndrivers/ata/sata_gemini.c-319-\t\tsg-\u003eide_pins = true;\n--\ndrivers/ata/sata_gemini.c-326-\ndrivers/ata/sata_gemini.c:327:\tret = of_property_read_u32(np, \"cortina,gemini-ata-muxmode\", \u0026muxmode);\ndrivers/ata/sata_gemini.c-328-\tif (ret) {\n--\ndrivers/ata/sata_gemini.c=384=static const struct of_device_id gemini_sata_of_match[] = {\ndrivers/ata/sata_gemini.c:385:\t{ .compatible = \"cortina,gemini-sata-bridge\", },\ndrivers/ata/sata_gemini.c-386-\t{ /* sentinel */ }\n--\ndrivers/clk/clk-gemini.c-21-#include \u003clinux/reset-controller.h\u003e\ndrivers/clk/clk-gemini.c:22:#include \u003cdt-bindings/reset/cortina,gemini-reset.h\u003e\ndrivers/clk/clk-gemini.c:23:#include \u003cdt-bindings/clock/cortina,gemini-clock.h\u003e\ndrivers/clk/clk-gemini.c-24-\n--\ndrivers/clk/clk-gemini.c=376=static const struct of_device_id gemini_clk_dt_ids[] = {\ndrivers/clk/clk-gemini.c:377:\t{ .compatible = \"cortina,gemini-syscon\", },\ndrivers/clk/clk-gemini.c-378-\t{ /* sentinel */ },\n--\ndrivers/clk/clk-gemini.c=391=static void __init gemini_cc_init(struct device_node *np)\n--\ndrivers/clk/clk-gemini.c-459-}\ndrivers/clk/clk-gemini.c:460:CLK_OF_DECLARE_DRIVER(gemini_cc, \"cortina,gemini-syscon\", gemini_cc_init);\n--\ndrivers/clocksource/timer-fttmr010.c=454=TIMER_OF_DECLARE(fttmr010, \"faraday,fttmr010\", fttmr010_timer_init);\ndrivers/clocksource/timer-fttmr010.c:455:TIMER_OF_DECLARE(gemini, \"cortina,gemini-timer\", fttmr010_timer_init);\ndrivers/clocksource/timer-fttmr010.c-456-TIMER_OF_DECLARE(moxart, \"moxa,moxart-timer\", fttmr010_timer_init);\n--\ndrivers/crypto/Kconfig=229=config CRYPTO_DEV_SL3516_DEBUG\n--\ndrivers/crypto/Kconfig-234-\t  Say y to enable SL3516 debug stats.\ndrivers/crypto/Kconfig:235:\t  This will create /sys/kernel/debug/sl3516/stats for displaying\ndrivers/crypto/Kconfig-236-\t  the number of requests per algorithm and other internal stats.\n--\ndrivers/crypto/gemini/Makefile:1:obj-$(CONFIG_CRYPTO_DEV_SL3516) += sl3516-ce.o\ndrivers/crypto/gemini/Makefile:2:sl3516-ce-y += sl3516-ce-core.o sl3516-ce-cipher.o sl3516-ce-rng.o\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-2-/*\ndrivers/crypto/gemini/sl3516-ce-cipher.c:3: * sl3516-ce-cipher.c - hardware cryptographic offloader for Storlink SL3516 SoC\ndrivers/crypto/gemini/sl3516-ce-cipher.c-4- *\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-21-#include \u003clinux/string.h\u003e\ndrivers/crypto/gemini/sl3516-ce-cipher.c:22:#include \"sl3516-ce.h\"\ndrivers/crypto/gemini/sl3516-ce-cipher.c-23-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:24:/* sl3516_ce_need_fallback - check if a request can be handled by the CE */\ndrivers/crypto/gemini/sl3516-ce-cipher.c:25:static bool sl3516_ce_need_fallback(struct skcipher_request *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-26-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c-27-\tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:28:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:29:\tstruct sl3516_ce_dev *ce = op-\u003ece;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-30-\tstruct scatterlist *in_sg;\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-94-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:95:static int sl3516_ce_cipher_fallback(struct skcipher_request *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-96-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c-97-\tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:98:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:99:\tstruct sl3516_ce_cipher_req_ctx *rctx = skcipher_request_ctx(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-100-\tstruct skcipher_alg *alg = crypto_skcipher_alg(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:101:\tstruct sl3516_ce_alg_template *algt;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-102-\tint err;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-103-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:104:\talgt = container_of(alg, struct sl3516_ce_alg_template, alg.skcipher.base);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-105-\talgt-\u003estat_fb++;\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-118-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:119:static int sl3516_ce_cipher(struct skcipher_request *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-120-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c-121-\tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:122:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:123:\tstruct sl3516_ce_dev *ce = op-\u003ece;\ndrivers/crypto/gemini/sl3516-ce-cipher.c:124:\tstruct sl3516_ce_cipher_req_ctx *rctx = skcipher_request_ctx(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-125-\tstruct skcipher_alg *alg = crypto_skcipher_alg(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:126:\tstruct sl3516_ce_alg_template *algt;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-127-\tstruct scatterlist *sg;\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-134-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:135:\talgt = container_of(alg, struct sl3516_ce_alg_template, alg.skcipher.base);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-136-\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-238-\trctx-\u003enr_sgd = nr_sgd;\ndrivers/crypto/gemini/sl3516-ce-cipher.c:239:\terr = sl3516_ce_run_task(ce, rctx, crypto_tfm_alg_name(areq-\u003ebase.tfm));\ndrivers/crypto/gemini/sl3516-ce-cipher.c-240-\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-256-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:257:int sl3516_ce_handle_cipher_request(struct crypto_engine *engine, void *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-258-{\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-261-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:262:\terr = sl3516_ce_cipher(breq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-263-\tlocal_bh_disable();\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-269-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:270:int sl3516_ce_skdecrypt(struct skcipher_request *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-271-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c-272-\tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:273:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:274:\tstruct sl3516_ce_cipher_req_ctx *rctx = skcipher_request_ctx(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-275-\tstruct crypto_engine *engine;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-276-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:277:\tmemset(rctx, 0, sizeof(struct sl3516_ce_cipher_req_ctx));\ndrivers/crypto/gemini/sl3516-ce-cipher.c-278-\trctx-\u003eop_dir = CE_DECRYPTION;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-279-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:280:\tif (sl3516_ce_need_fallback(areq))\ndrivers/crypto/gemini/sl3516-ce-cipher.c:281:\t\treturn sl3516_ce_cipher_fallback(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-282-\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-287-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:288:int sl3516_ce_skencrypt(struct skcipher_request *areq)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-289-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c-290-\tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:291:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:292:\tstruct sl3516_ce_cipher_req_ctx *rctx = skcipher_request_ctx(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-293-\tstruct crypto_engine *engine;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-294-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:295:\tmemset(rctx, 0, sizeof(struct sl3516_ce_cipher_req_ctx));\ndrivers/crypto/gemini/sl3516-ce-cipher.c-296-\trctx-\u003eop_dir = CE_ENCRYPTION;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-297-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:298:\tif (sl3516_ce_need_fallback(areq))\ndrivers/crypto/gemini/sl3516-ce-cipher.c:299:\t\treturn sl3516_ce_cipher_fallback(areq);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-300-\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-305-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:306:int sl3516_ce_cipher_init(struct crypto_tfm *tfm)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-307-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c:308:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:309:\tstruct sl3516_ce_alg_template *algt;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-310-\tconst char *name = crypto_tfm_alg_name(tfm);\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-314-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:315:\tmemset(op, 0, sizeof(struct sl3516_ce_cipher_tfm_ctx));\ndrivers/crypto/gemini/sl3516-ce-cipher.c-316-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:317:\talgt = container_of(alg, struct sl3516_ce_alg_template, alg.skcipher.base);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-318-\top-\u003ece = algt-\u003ece;\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-326-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:327:\tcrypto_skcipher_set_reqsize(sktfm, sizeof(struct sl3516_ce_cipher_req_ctx) +\ndrivers/crypto/gemini/sl3516-ce-cipher.c-328-\t\t\t\t    crypto_skcipher_reqsize(op-\u003efallback_tfm));\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-344-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:345:void sl3516_ce_cipher_exit(struct crypto_tfm *tfm)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-346-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c:347:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c-348-\n--\ndrivers/crypto/gemini/sl3516-ce-cipher.c-353-\ndrivers/crypto/gemini/sl3516-ce-cipher.c:354:int sl3516_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,\ndrivers/crypto/gemini/sl3516-ce-cipher.c-355-\t\t\t unsigned int keylen)\ndrivers/crypto/gemini/sl3516-ce-cipher.c-356-{\ndrivers/crypto/gemini/sl3516-ce-cipher.c:357:\tstruct sl3516_ce_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);\ndrivers/crypto/gemini/sl3516-ce-cipher.c:358:\tstruct sl3516_ce_dev *ce = op-\u003ece;\ndrivers/crypto/gemini/sl3516-ce-cipher.c-359-\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-2-/*\ndrivers/crypto/gemini/sl3516-ce-core.c:3: * sl3516-ce-core.c - hardware cryptographic offloader for Storlink SL3516 SoC\ndrivers/crypto/gemini/sl3516-ce-core.c-4- *\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-27-\ndrivers/crypto/gemini/sl3516-ce-core.c:28:#include \"sl3516-ce.h\"\ndrivers/crypto/gemini/sl3516-ce-core.c-29-\ndrivers/crypto/gemini/sl3516-ce-core.c:30:static int sl3516_ce_desc_init(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-31-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-66-\ndrivers/crypto/gemini/sl3516-ce-core.c:67:static void sl3516_ce_free_descs(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-68-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-76-\ndrivers/crypto/gemini/sl3516-ce-core.c:77:static void start_dma_tx(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-78-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-86-\ndrivers/crypto/gemini/sl3516-ce-core.c:87:static void start_dma_rx(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-88-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-98-\ndrivers/crypto/gemini/sl3516-ce-core.c:99:static struct descriptor *get_desc_tx(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-100-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-109-\ndrivers/crypto/gemini/sl3516-ce-core.c:110:static struct descriptor *get_desc_rx(struct sl3516_ce_dev *ce)\ndrivers/crypto/gemini/sl3516-ce-core.c-111-{\n--\ndrivers/crypto/gemini/sl3516-ce-core.c-120-\ndrivers/crypto/gemini/sl3516-ce-core.c:121:int sl3516_ce_run_task(struct sl3516_ce_dev *ce, struct sl3516_ce_cipher_req_ctx *rctx,\ndrivers/crypto/gemini/sl3516-ce-core.c-122-\t\t       const char *name)\n\n"
}

19/2 2026/10/11 18:18 llm patch-evaluator
2m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38670
							output: 110
							thoughts: 664
						

Thoughts:
**Fuzzing Verdict: Cortina Gemini Driver**

Okay, let's break this down. We're looking at the Cortina Gemini driver, specifically `drivers/net/ethernet/cortina/gemini.c`. This is designed for the Cortina Gemini, and it looks like it's built for the Storlink SL351x SoC – an ARM architecture. My understanding is that this is SoC-specific hardware, meaning it's tied to that particular chip.

Now, according to the guidelines, the primary gate is reachability. Can the code actually *execute* in a standard virtualized environment like QEMU or Google Compute Engine? The answer here is a resounding no. This isn't something that's emulated in standard QEMU on an amd64 architecture, and even on ARM, it needs very specific hardware (that Storlink SL3516 board) and configuration. The fact that the patch even includes `suppress_bind_attrs = true` is another significant indicator. This driver won't even bind normally.

The rules are pretty clear: if the modified code is *structurally unreachable* due to hardware constraints, we're not fuzzing it. This definitely falls into that category. The code requires physical, non-emulated hardware.

Therefore, `WorthFuzzing` is `false`. There's no point in even attempting fuzzing here. There's no benefit to it. No `FocusSymbols` or `EnableConfigs` are needed.

The reasoning is straightforward: The modified driver is specific to the Cortina Systems Gemini (StorLink SL351x) ARM SoC ethernet controller, it requires a specific hardware platform and is not emulated in standard virtualized environments (QEMU/GCE) on the target architecture (amd64). It is, therefore, structurally unreachable. Time to call `set-results`.



20/2 2026/10/11 18:21 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patched file (drivers/net/ethernet/cortina/gemini.c) is a platform driver for the Cortina Systems Gemini (StorLink SL351x) Ethernet controller, which is an ARM-specific SoC peripheral. This hardware is not emulated in standard QEMU/GCE virtualization environments and is structurally unreachable on the target architecture (amd64).",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patched file (drivers/net/ethernet/cortina/gemini.c) is a platform driver for the Cortina Systems Gemini (StorLink SL351x) Ethernet controller, which is an ARM-specific SoC peripheral. This hardware is not emulated in standard QEMU/GCE virtualization environments and is structurally unreachable on the target architecture (amd64).",
  "WorthFuzzing": false
}

21/1 2026/10/11 18:21 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)