get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2216087/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2216087,
    "url": "http://patchwork.ozlabs.org/api/patches/2216087/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260325192628.750398-2-lukas.schmid@netcube.li/",
    "project": {
        "id": 18,
        "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api",
        "name": "U-Boot",
        "link_name": "uboot",
        "list_id": "u-boot.lists.denx.de",
        "list_email": "u-boot@lists.denx.de",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260325192628.750398-2-lukas.schmid@netcube.li>",
    "list_archive_url": null,
    "date": "2026-03-25T19:26:08",
    "name": "[1/6] sunxi: move SID MAC fallback from board env setup to EMAC read_rom_hwaddr",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "c3c610420f9c820b4e588fea754da61257cd909f",
    "submitter": {
        "id": 90004,
        "url": "http://patchwork.ozlabs.org/api/people/90004/?format=api",
        "name": "Lukas Schmid",
        "email": "lukas.schmid@netcube.li"
    },
    "delegate": {
        "id": 114289,
        "url": "http://patchwork.ozlabs.org/api/users/114289/?format=api",
        "username": "apritzel",
        "first_name": "Andre",
        "last_name": "Przywara",
        "email": "andre.przywara@arm.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260325192628.750398-2-lukas.schmid@netcube.li/mbox/",
    "series": [
        {
            "id": 497505,
            "url": "http://patchwork.ozlabs.org/api/series/497505/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=497505",
            "date": "2026-03-25T19:26:07",
            "name": "sunxi: add NetCube Nagami support and T113 secure boot enablement",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/497505/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2216087/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2216087/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<u-boot-bounces@lists.denx.de>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=netcube.li header.i=@netcube.li header.a=rsa-sha256\n header.s=s1 header.b=UJwkBTo5;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)",
            "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=netcube.li",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de",
            "phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=netcube.li header.i=@netcube.li header.b=\"UJwkBTo5\";\n\tdkim-atps=neutral",
            "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=netcube.li",
            "phobos.denx.de;\n spf=pass smtp.mailfrom=lukas.schmid@netcube.li"
        ],
        "Received": [
            "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgxkr2C3lz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 06:27:48 +1100 (AEDT)",
            "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 653438406D;\n\tWed, 25 Mar 2026 20:27:27 +0100 (CET)",
            "by phobos.denx.de (Postfix, from userid 109)\n id F06AA83FC6; Wed, 25 Mar 2026 20:27:25 +0100 (CET)",
            "from mail.netcube.li (mail.netcube.li [173.249.15.149])\n (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id CFE9783FA7\n for <u-boot@lists.denx.de>; Wed, 25 Mar 2026 20:27:23 +0100 (CET)",
            "from lukas-hpz440workstation.lan.sk100508.local\n (193-80-178-216.hdsl.highway.telekom.at [193.80.178.216])\n by mail.netcube.li with ESMTPA ; Wed, 25 Mar 2026 20:27:14 +0100"
        ],
        "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de",
        "X-Spam-Level": "",
        "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,\n SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2",
        "dkim-signature": "v=1; a=rsa-sha256; d=netcube.li; s=s1;\n c=relaxed/relaxed; q=dns/txt;\n h=From:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References;\n bh=NFbNTkgbgyURLl6Y/Z1CTk7IxE9bF2QiSeHVd5MQ3uY=;\n b=UJwkBTo51nbfoiMiprAq6LyL0nxrXXF5W9hcZa2KBpY37icl3f5DvlNJYeFDB5zxFHwXbOeL0A0wes4r0hIqTCiMEbFZkcOurxj04e6xnzwfY+lqS9r4aedMkeQ0cAEGknS0xjRoWLV+Te8RiBeHGehRhzBl6qdxiJLrLzbphEg=",
        "From": "Lukas Schmid <lukas.schmid@netcube.li>",
        "To": "Andre Przywara <andre.przywara@arm.com>, Tom Rini <trini@konsulko.com>,\n Hans de Goede <hdegoede@redhat.com>,\n Jerome Forissier <jerome.forissier@arm.com>",
        "Cc": "Lukas Schmid <lukas.schmid@netcube.li>,\n\tu-boot@lists.denx.de",
        "Subject": "[PATCH 1/6] sunxi: move SID MAC fallback from board env setup to EMAC\n read_rom_hwaddr",
        "Date": "Wed, 25 Mar 2026 20:26:08 +0100",
        "Message-ID": "<20260325192628.750398-2-lukas.schmid@netcube.li>",
        "X-Mailer": "git-send-email 2.47.3",
        "In-Reply-To": "<20260325192628.750398-1-lukas.schmid@netcube.li>",
        "References": "<20260325192628.750398-1-lukas.schmid@netcube.li>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "u-boot@lists.denx.de",
        "X-Mailman-Version": "2.1.39",
        "Precedence": "list",
        "List-Id": "U-Boot discussion <u-boot.lists.denx.de>",
        "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>",
        "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>",
        "List-Post": "<mailto:u-boot@lists.denx.de>",
        "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>",
        "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>",
        "Errors-To": "u-boot-bounces@lists.denx.de",
        "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>",
        "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de",
        "X-Virus-Status": "Clean"
    },
    "content": "sunxi currently seeds ethaddr/ethXaddr in setup_environment() from SID.\nThat happens before Ethernet probe, so even with a clean persisted\nenvironment we can populate env with a generated MAC and later get a\nmismatch warning when DM Ethernet reads a different MAC from DT/NVMEM.\n\nStop generating Ethernet MAC env variables in setup_environment() and\nprovide SID-derived fallback addresses through read_rom_hwaddr in the\nsunxi EMAC drivers instead.\n\nAlso move the SID uniqueness/MAC derivation logic into shared sunxi arch\nhelpers so board code and drivers use one implementation and keep legacy\nalgorithm compatibility across SoCs.\n\nThis keeps the generic MAC source order (DT/NVMEM first, fallback second),\navoids board-level MAC policy special-casing, and prevents same-boot\nenv-vs-NVMEM mismatch warnings caused by early env seeding.\n\nSigned-off-by: Lukas Schmid <lukas.schmid@netcube.li>\n---\n arch/arm/include/asm/arch-sunxi/sys_proto.h |  6 +++\n arch/arm/mach-sunxi/cpu_info.c              | 44 ++++++++++++++++\n board/sunxi/board.c                         | 57 +--------------------\n drivers/net/sun8i_emac.c                    | 15 ++++++\n drivers/net/sunxi_emac.c                    | 15 ++++++\n 5 files changed, 81 insertions(+), 56 deletions(-)",
    "diff": "diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h\nindex 92c7721a530..6f70753e948 100644\n--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h\n+++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h\n@@ -12,6 +12,12 @@\n \n void sdelay(unsigned long);\n \n+/* Read SID and apply legacy/newer-SoC normalization for uniqueness. */\n+bool sunxi_get_unique_sid(unsigned int *sid);\n+\n+/* Build legacy-compatible SID-derived locally administered MAC address. */\n+bool sunxi_get_sid_mac_addr(int index, u8 mac[6]);\n+\n /* return_to_fel() - Return to BROM from SPL\n  *\n  * This returns back into the BROM after U-Boot SPL has performed its initial\ndiff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c\nindex c3a51d9956e..d804307e280 100644\n--- a/arch/arm/mach-sunxi/cpu_info.c\n+++ b/arch/arm/mach-sunxi/cpu_info.c\n@@ -9,8 +9,10 @@\n #include <asm/io.h>\n #include <asm/arch/cpu.h>\n #include <asm/arch/clock.h>\n+#include <asm/arch/sys_proto.h>\n #include <axp_pmic.h>\n #include <errno.h>\n+#include <u-boot/crc.h>\n \n #ifdef CONFIG_MACH_SUN6I\n int sunxi_get_ss_bonding_id(void)\n@@ -175,3 +177,45 @@ int sunxi_get_sid(unsigned int *sid)\n \treturn -ENODEV;\n #endif\n }\n+\n+bool sunxi_get_unique_sid(unsigned int *sid)\n+{\n+\tif (sunxi_get_sid(sid) != 0)\n+\t\treturn false;\n+\n+\tif (!sid[0])\n+\t\treturn false;\n+\n+\t/*\n+\t * On newer SoCs use a CRC over SID words 1..3 for better uniqueness,\n+\t * while keeping the long-standing algorithm on older SoCs.\n+\t */\n+#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \\\n+\t!defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \\\n+\t!defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)\n+\tsid[3] = crc32(0, (unsigned char *)&sid[1], 12);\n+#endif\n+\n+\t/* Ensure the NIC-specific bytes are not all 0. */\n+\tif ((sid[3] & 0xffffff) == 0)\n+\t\tsid[3] |= 0x800000;\n+\n+\treturn true;\n+}\n+\n+bool sunxi_get_sid_mac_addr(int index, u8 mac[6])\n+{\n+\tunsigned int sid[4];\n+\n+\tif (!sunxi_get_unique_sid(sid))\n+\t\treturn false;\n+\n+\tmac[0] = ((index & 0xf) << 4) | 0x02;\n+\tmac[1] = (sid[0] >>  0) & 0xff;\n+\tmac[2] = (sid[3] >> 24) & 0xff;\n+\tmac[3] = (sid[3] >> 16) & 0xff;\n+\tmac[4] = (sid[3] >>  8) & 0xff;\n+\tmac[5] = (sid[3] >>  0) & 0xff;\n+\n+\treturn true;\n+}\ndiff --git a/board/sunxi/board.c b/board/sunxi/board.c\nindex d7722d1858a..420c4504720 100644\n--- a/board/sunxi/board.c\n+++ b/board/sunxi/board.c\n@@ -41,7 +41,6 @@\n #include <asm/gpio.h>\n #include <sunxi_gpio.h>\n #include <asm/io.h>\n-#include <u-boot/crc.h>\n #include <env_internal.h>\n #include <linux/libfdt.h>\n #include <fdt_support.h>\n@@ -750,34 +749,7 @@ static void parse_spl_header(const uint32_t spl_addr)\n \n static bool get_unique_sid(unsigned int *sid)\n {\n-\tif (sunxi_get_sid(sid) != 0)\n-\t\treturn false;\n-\n-\tif (!sid[0])\n-\t\treturn false;\n-\n-\t/*\n-\t * The single words 1 - 3 of the SID have quite a few bits\n-\t * which are the same on many models, so we take a crc32\n-\t * of all 3 words, to get a more unique value.\n-\t *\n-\t * Note we only do this on newer SoCs as we cannot change\n-\t * the algorithm on older SoCs since those have been using\n-\t * fixed mac-addresses based on only using word 3 for a\n-\t * long time and changing a fixed mac-address with an\n-\t * u-boot update is not good.\n-\t */\n-#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \\\n-    !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \\\n-    !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)\n-\tsid[3] = crc32(0, (unsigned char *)&sid[1], 12);\n-#endif\n-\n-\t/* Ensure the NIC specific bytes of the mac are not all 0 */\n-\tif ((sid[3] & 0xffffff) == 0)\n-\t\tsid[3] |= 0x800000;\n-\n-\treturn true;\n+\treturn sunxi_get_unique_sid(sid);\n }\n \n /*\n@@ -788,37 +760,10 @@ static void setup_environment(const void *fdt)\n {\n \tchar serial_string[17] = { 0 };\n \tunsigned int sid[4];\n-\tuint8_t mac_addr[6];\n-\tchar ethaddr[16];\n-\tint i;\n \n \tif (!get_unique_sid(sid))\n \t\treturn;\n \n-\tfor (i = 0; i < 4; i++) {\n-\t\tsprintf(ethaddr, \"ethernet%d\", i);\n-\t\tif (!fdt_get_alias(fdt, ethaddr))\n-\t\t\tcontinue;\n-\n-\t\tif (i == 0)\n-\t\t\tstrcpy(ethaddr, \"ethaddr\");\n-\t\telse\n-\t\t\tsprintf(ethaddr, \"eth%daddr\", i);\n-\n-\t\tif (env_get(ethaddr))\n-\t\t\tcontinue;\n-\n-\t\t/* Non OUI / registered MAC address */\n-\t\tmac_addr[0] = (i << 4) | 0x02;\n-\t\tmac_addr[1] = (sid[0] >>  0) & 0xff;\n-\t\tmac_addr[2] = (sid[3] >> 24) & 0xff;\n-\t\tmac_addr[3] = (sid[3] >> 16) & 0xff;\n-\t\tmac_addr[4] = (sid[3] >>  8) & 0xff;\n-\t\tmac_addr[5] = (sid[3] >>  0) & 0xff;\n-\n-\t\teth_env_set_enetaddr(ethaddr, mac_addr);\n-\t}\n-\n \tif (!env_get(\"serial#\")) {\n \t\tsnprintf(serial_string, sizeof(serial_string),\n \t\t\t\"%08x%08x\", sid[0], sid[3]);\ndiff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c\nindex 41c52f56d7a..a267b6cd7f5 100644\n--- a/drivers/net/sun8i_emac.c\n+++ b/drivers/net/sun8i_emac.c\n@@ -13,6 +13,7 @@\n #include <cpu_func.h>\n #include <log.h>\n #include <asm/cache.h>\n+#include <asm/arch/sys_proto.h>\n #include <asm/global_data.h>\n #include <asm/gpio.h>\n #include <asm/io.h>\n@@ -259,6 +260,19 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)\n \treturn 0;\n }\n \n+static int sun8i_eth_read_rom_hwaddr(struct udevice *dev)\n+{\n+\tstruct eth_pdata *pdata = dev_get_plat(dev);\n+\tu8 mac[ARP_HLEN];\n+\n+\tif (!sunxi_get_sid_mac_addr(dev_seq(dev), mac))\n+\t\treturn -ENODEV;\n+\n+\tmemcpy(pdata->enetaddr, mac, ARP_HLEN);\n+\n+\treturn 0;\n+}\n+\n static void sun8i_adjust_link(struct emac_eth_dev *priv,\n \t\t\t      struct phy_device *phydev)\n {\n@@ -715,6 +729,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)\n \n static const struct eth_ops sun8i_emac_eth_ops = {\n \t.start                  = sun8i_emac_eth_start,\n+\t.read_rom_hwaddr\t= sun8i_eth_read_rom_hwaddr,\n \t.write_hwaddr           = sun8i_eth_write_hwaddr,\n \t.send                   = sun8i_emac_eth_send,\n \t.recv                   = sun8i_emac_eth_recv,\ndiff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c\nindex 3dee849c97e..f45a0790a40 100644\n--- a/drivers/net/sunxi_emac.c\n+++ b/drivers/net/sunxi_emac.c\n@@ -15,6 +15,7 @@\n #include <miiphy.h>\n #include <net.h>\n #include <asm/io.h>\n+#include <asm/arch/sys_proto.h>\n #include <asm/arch/clock.h>\n #include <power/regulator.h>\n \n@@ -539,6 +540,19 @@ static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)\n \treturn _sunxi_emac_eth_send(priv, packet, length);\n }\n \n+static int sunxi_emac_read_rom_hwaddr(struct udevice *dev)\n+{\n+\tstruct eth_pdata *pdata = dev_get_plat(dev);\n+\tu8 mac[ARP_HLEN];\n+\n+\tif (!sunxi_get_sid_mac_addr(dev_seq(dev), mac))\n+\t\treturn -ENODEV;\n+\n+\tmemcpy(pdata->enetaddr, mac, ARP_HLEN);\n+\n+\treturn 0;\n+}\n+\n static int sunxi_emac_eth_recv(struct udevice *dev, int flags, uchar **packetp)\n {\n \tstruct emac_eth_dev *priv = dev_get_priv(dev);\n@@ -581,6 +595,7 @@ static int sunxi_emac_eth_probe(struct udevice *dev)\n \n static const struct eth_ops sunxi_emac_eth_ops = {\n \t.start\t\t\t= sunxi_emac_eth_start,\n+\t.read_rom_hwaddr\t= sunxi_emac_read_rom_hwaddr,\n \t.send\t\t\t= sunxi_emac_eth_send,\n \t.recv\t\t\t= sunxi_emac_eth_recv,\n \t.stop\t\t\t= sunxi_emac_eth_stop,\n",
    "prefixes": [
        "1/6"
    ]
}