Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2140782/?format=api
{ "id": 2140782, "url": "http://patchwork.ozlabs.org/api/patches/2140782/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20250923071315.276114-4-root@infi.wang/", "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": "<20250923071315.276114-4-root@infi.wang>", "list_archive_url": null, "date": "2025-09-23T07:13:00", "name": "[RESEND,3/4] net: phy: aquantia: use generic firmware loader", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "98980fd5b21694164a61e179ef6abf641fc2e057", "submitter": { "id": 91745, "url": "http://patchwork.ozlabs.org/api/people/91745/?format=api", "name": "Beiyan Yun", "email": "root@infi.wang" }, "delegate": { "id": 157425, "url": "http://patchwork.ozlabs.org/api/users/157425/?format=api", "username": "jforissier", "first_name": "Jerome", "last_name": "Forissier", "email": "jerome.forissier@linaro.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20250923071315.276114-4-root@infi.wang/mbox/", "series": [ { "id": 474795, "url": "http://patchwork.ozlabs.org/api/series/474795/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=474795", "date": "2025-09-23T07:12:57", "name": "net: phy: aquantia: Switch to generic firmware loader", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/474795/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2140782/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2140782/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 (2048-bit key;\n unprotected) header.d=infi.wang header.i=@infi.wang header.a=rsa-sha256\n header.s=sig1 header.b=dXEgg/K4;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=infi.wang", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=infi.wang header.i=@infi.wang header.b=\"dXEgg/K4\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=infi.wang", "phobos.denx.de; spf=pass smtp.mailfrom=root@infi.wang" ], "Received": [ "from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4cWB7K04WGz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 23 Sep 2025 17:14:36 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 6103483526;\n\tTue, 23 Sep 2025 09:14:19 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 2915783510; Tue, 23 Sep 2025 09:14:19 +0200 (CEST)", "from outbound.st.icloud.com\n (npq-east2-cluster1-host8-snip4-6.eps.apple.com [57.103.77.119])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 21C99834D4\n for <u-boot@lists.denx.de>; Tue, 23 Sep 2025 09:14:17 +0200 (CEST)", "from outbound.st.icloud.com (unknown [127.0.0.2])\n by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id\n 95C78180060F; Tue, 23 Sep 2025 07:14:12 +0000 (UTC)", "from debian.. (st-asmtp-me-k8s.p00.prod.me.com [17.42.251.67])\n by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id\n EC1DB1800283; Tue, 23 Sep 2025 07:14:08 +0000 (UTC)" ], "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_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "Dkim-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=infi.wang; s=sig1;\n bh=2cmfoFowTLkjHW4NpJRTTHH/Wy2uF6okE0gcy+Sf8CY=;\n h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme;\n b=dXEgg/K4TqyJ6RbEG+ppgqC6j1nyxXTxwJWC91aH/TgJdUgsnA2ckqNtRZw3DXB2GB/R7qpsn/sgn76MDPUN9raqXDyUkBQgtwiajMaL8xDdu4e13tQ/NwErbet71oiKhfVins/K+TbNI99tJXrphLIFUJc0Kj7x4YsSEEBRH62Mf/eV9dg4LkGVLga2B79tPf/7kFHJhrSdNF2Qgj3l2Jq5tQWWmYXfi0TSNf2ljze64uLqepXvYVx8r2hx21Rjh5DdFU8THsKHSQr1mOYlFtR1w7mEIV3Dc/SXfUr51kviGNocf9hlpP9uffvbVBoRv9mrt/wXs0MpxNLKKwWPdA==", "mail-alias-created-date": "1549370554000", "From": "Beiyan Yun <root@infi.wang>", "To": "u-boot@lists.denx.de", "Cc": "Beiyan Yun <root@infi.wang>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Jerome Forissier <jerome.forissier@linaro.org>,\n Joe Hershberger <joe.hershberger@ni.com>,\n \"Lucien.Jheng\" <lucienzx159@gmail.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Ramon Fried <rfried.dev@gmail.com>,\n Romain Gantois <romain.gantois@bootlin.com>,\n Siddharth Vadapalli <s-vadapalli@ti.com>, Tom Rini <trini@konsulko.com>", "Subject": "[PATCH RESEND 3/4] net: phy: aquantia: use generic firmware loader", "Date": "Tue, 23 Sep 2025 15:13:00 +0800", "Message-ID": "<20250923071315.276114-4-root@infi.wang>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20250923071315.276114-1-root@infi.wang>", "References": "<20250923071315.276114-1-root@infi.wang>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjUwOTIzMDA2NiBTYWx0ZWRfX4lZLQ/3Ob+lq\n aB814LroV+wEtXqHf8V9I7PdBPCKfSoUzkg0k4g7Rrw4NqQIO2sh7WMTTLzGn+vk6lpr69YJzK9\n VK4nHk5TyhxwyEIqPU3ayXlh2Ta4QW6zODaHe/EzGlbm9L3+PtPXsP7bxu9MlDA0pLRzzSdrtHu\n dJVzi7O/LiiRvahyPn2e8hs6/kmR1o/4atIq2DWby45Dm4Dx2rOkF8oHESk0RLZIgr2LIh0U7XL\n BbONkhA4yCD9NAsZxTWtm54aME/wy5NCHfMBpv5kVQz/dWXllVgCqA6l3GPE/A0BhuFFiq9ng=", "X-Proofpoint-GUID": "Wp_-l5vQxNlfB7S0P9DYZJRj657gm8tA", "X-Proofpoint-ORIG-GUID": "Wp_-l5vQxNlfB7S0P9DYZJRj657gm8tA", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40\n definitions=2025-09-23_01,2025-09-22_05,2025-03-28_01", "X-Proofpoint-Spam-Details": "rule=notspam policy=default score=0 mlxlogscore=845\n spamscore=0 malwarescore=0 mlxscore=0 adultscore=0\n suspectscore=0\n clxscore=1030 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx\n scancount=1 engine=8.22.0-2506270000 definitions=main-2509230066", "X-JNJ": "\n AAAAAAAB2Kg5QhGK3fGO2/606ry99MKXGqDLgnYHXVzycKnAiDRQ1PEqTaBIWLDTz2p1fBtVCrd4urrdiRDQNvAIFkonR/l0CkxYnyeXTLIq6vjp602kRtJn7JatyevCDZX4PcglPakxFFePPhxvKhbe9wrjPLecZVSsAA5gLO9V1BsJg2wEvEiF7GyAPTNwhFPy34Igi+YlAteUsqHE7/N3XfE5LQGAm41y1+rkPW6zWF4xKTaY5zi4BreyD5ynycnSVSG55selEJz0oKILvPrDTd2/37P1huipXfukPOvr845YrDO8j5daXfEAch2Wkn/fM+iCp/E2U92iBRrzMGfnU4W0HETjtTHGs6Eo0mPoSxGSK8bEM9ORXm/LseVdVIXR9byy6AvtLUHONFk0a+TuZBTyB7+1KQvA7ghEe6XnWSEPQkM4x6Wn3zG0Ol+iPKdL829TAG5uLNUan34M/9H2q2edRQm3B7R+rhd9fAyf3AoBDkTs7MbS45KgfjxYLcLFgFksbOUjADvRHsPIfLdKOXSsyFc6jpcVCnGA9L64J8y+B6LDY+ERWv9ZFCW7AmrOGZwCCyLiH8qreWDOcfXzbKxQhluB6Y4o5Z7FzhvgroHKWKizMaxofIESRmamzjotAZy15aXF+09hGnvv06PE9aqFB3maVT/FeSfnFykxGdwfsAnp+LWSuJVvRX5E3MO8yLVGEQ==", "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": "Aquantia PHYs are being used w/o SPI flash in some routers recently.\nCurrent firmware loader only attempts to load from FS on top of MMC,\nlimiting the use on many devices.\n\nRemoved the old firmware loader, migrate to generic firmware loader\nto allow a wider range of firmware source (e.g., USB, UBIFS).\n\nTested on Buffalo WXR18000BE10P with UBIFS.\n\nTested-by: Beiyan Yun <root@infi.wang>\nSigned-off-by: Beiyan Yun <root@infi.wang>\n---\n\n drivers/net/phy/Kconfig | 19 +++---\n drivers/net/phy/aquantia.c | 122 +++++++++++++++++++------------------\n 2 files changed, 71 insertions(+), 70 deletions(-)", "diff": "diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig\nindex 21bf983056a..16a853793c5 100644\n--- a/drivers/net/phy/Kconfig\n+++ b/drivers/net/phy/Kconfig\n@@ -90,23 +90,22 @@ menuconfig PHY_AQUANTIA\n config PHY_AQUANTIA_UPLOAD_FW\n \tbool \"Aquantia firmware loading support\"\n \tdepends on PHY_AQUANTIA\n+\tselect FS_LOADER\n \thelp\n \t\tAquantia PHYs use firmware which can be either loaded automatically\n \t\tfrom storage directly attached to the phy or loaded by the boot loader\n-\t\tvia MDIO commands. The firmware is loaded from a file, specified by\n-\t\tthe PHY_AQUANTIA_FW_PART and PHY_AQUANTIA_FW_NAME options.\n+\t\tvia MDIO commands.\n \n-config PHY_AQUANTIA_FW_PART\n-\tstring \"Aquantia firmware partition\"\n-\tdepends on PHY_AQUANTIA_UPLOAD_FW\n-\thelp\n-\t\tPartition containing the firmware file.\n+\t\tThis option enables loading the firmware using the generic\n+\t\tfile system firmware loader framework.\n \n-config PHY_AQUANTIA_FW_NAME\n-\tstring \"Aquantia firmware filename\"\n+config PHY_AQUANTIA_FW_MAX_SIZE\n+\thex \"Max firmware size\"\n \tdepends on PHY_AQUANTIA_UPLOAD_FW\n+\tdefault 0x80000\n \thelp\n-\t\tFirmware filename.\n+\t The maximum size of the Aquantia PHY firmware. This is used to\n+\t allocate a buffer to load the firmware into.\n \n config PHY_ATHEROS\n \tbool \"Atheros Ethernet PHYs support\"\ndiff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c\nindex 903fcd667f6..dc5f30a9e53 100644\n--- a/drivers/net/phy/aquantia.c\n+++ b/drivers/net/phy/aquantia.c\n@@ -17,6 +17,9 @@\n #include <malloc.h>\n #include <asm/byteorder.h>\n #include <fs.h>\n+#if (IS_ENABLED(CONFIG_PHY_AQUANTIA_UPLOAD_FW))\n+#include <fs_loader.h>\n+#endif\n \n #define AQUNTIA_10G_CTL\t\t0x20\n #define AQUNTIA_VENDOR_P1\t0xc400\n@@ -127,53 +130,7 @@ struct fw_header {\n \n #pragma pack()\n \n-#if defined(CONFIG_PHY_AQUANTIA_UPLOAD_FW)\n-static int aquantia_read_fw(u8 **fw_addr, size_t *fw_length)\n-{\n-\tloff_t length, read;\n-\tint ret;\n-\tvoid *addr = NULL;\n-\n-\t*fw_addr = NULL;\n-\t*fw_length = 0;\n-\tdebug(\"Loading Aquantia microcode from %s %s\\n\",\n-\t CONFIG_PHY_AQUANTIA_FW_PART, CONFIG_PHY_AQUANTIA_FW_NAME);\n-\tret = fs_set_blk_dev(\"mmc\", CONFIG_PHY_AQUANTIA_FW_PART, FS_TYPE_ANY);\n-\tif (ret < 0)\n-\t\tgoto cleanup;\n-\n-\tret = fs_size(CONFIG_PHY_AQUANTIA_FW_NAME, &length);\n-\tif (ret < 0)\n-\t\tgoto cleanup;\n-\n-\taddr = malloc(length);\n-\tif (!addr) {\n-\t\tret = -ENOMEM;\n-\t\tgoto cleanup;\n-\t}\n-\n-\tret = fs_set_blk_dev(\"mmc\", CONFIG_PHY_AQUANTIA_FW_PART, FS_TYPE_ANY);\n-\tif (ret < 0)\n-\t\tgoto cleanup;\n-\n-\tret = fs_read(CONFIG_PHY_AQUANTIA_FW_NAME, (ulong)addr, 0, length,\n-\t\t &read);\n-\tif (ret < 0)\n-\t\tgoto cleanup;\n-\n-\t*fw_addr = addr;\n-\t*fw_length = length;\n-\tdebug(\"Found Aquantia microcode.\\n\");\n-\n-cleanup:\n-\tif (ret < 0) {\n-\t\tprintf(\"loading firmware file %s %s failed with error %d\\n\",\n-\t\t CONFIG_PHY_AQUANTIA_FW_PART,\n-\t\t CONFIG_PHY_AQUANTIA_FW_NAME, ret);\n-\t\tfree(addr);\n-\t}\n-\treturn ret;\n-}\n+#if (IS_ENABLED(CONFIG_PHY_AQUANTIA_UPLOAD_FW))\n \n /* load data into the phy's memory */\n static int aquantia_load_memory(struct phy_device *phydev, u32 addr,\n@@ -218,27 +175,27 @@ static u32 unpack_u24(const u8 *data)\n \treturn (data[2] << 16) + (data[1] << 8) + data[0];\n }\n \n-static int aquantia_upload_firmware(struct phy_device *phydev)\n+/* Common firmware upload implementation */\n+static int aquantia_do_upload_firmware(struct phy_device *phydev,\n+\t\t\t\t const u8 *addr, size_t fw_length)\n {\n \tint ret;\n-\tu8 *addr = NULL;\n-\tsize_t fw_length = 0;\n \tu16 calculated_crc, read_crc;\n \tchar version[VERSION_STRING_SIZE];\n \tu32 primary_offset, iram_offset, iram_size, dram_offset, dram_size;\n \tconst struct fw_header *header;\n \n-\tret = aquantia_read_fw(&addr, &fw_length);\n-\tif (ret != 0)\n-\t\treturn ret;\n+\tif (!addr || !fw_length) {\n+\t\tprintf(\"%s: Invalid firmware data\\n\", phydev->dev->name);\n+\t\treturn -EINVAL;\n+\t}\n \n-\tread_crc = (addr[fw_length - 2] << 8) | addr[fw_length - 1];\n+\tread_crc = (addr[fw_length - 2] << 8) | addr[fw_length - 1];\n \tcalculated_crc = crc16_ccitt(0, addr, fw_length - 2);\n \tif (read_crc != calculated_crc) {\n \t\tprintf(\"%s bad firmware crc: file 0x%04x calculated 0x%04x\\n\",\n \t\t phydev->dev->name, read_crc, calculated_crc);\n-\t\tret = -EINVAL;\n-\t\tgoto done;\n+\t\treturn -EINVAL;\n \t}\n \n \t/* Find the DRAM and IRAM sections within the firmware file. */\n@@ -268,14 +225,14 @@ static int aquantia_upload_firmware(struct phy_device *phydev)\n \tret = aquantia_load_memory(phydev, DRAM_BASE_ADDR, &addr[dram_offset],\n \t\t\t\t dram_size);\n \tif (ret != 0)\n-\t\tgoto done;\n+\t\treturn ret;\n \n \tdebug(\"loading iram 0x%08x from offset=%d size=%d\\n\",\n \t IRAM_BASE_ADDR, iram_offset, iram_size);\n \tret = aquantia_load_memory(phydev, IRAM_BASE_ADDR, &addr[iram_offset],\n \t\t\t\t iram_size);\n \tif (ret != 0)\n-\t\tgoto done;\n+\t\treturn ret;\n \n \t/* make sure soft reset and low power mode are clear */\n \tphy_write(phydev, MDIO_MMD_VEND1, GLOBAL_STANDARD_CONTROL, 0);\n@@ -289,8 +246,53 @@ static int aquantia_upload_firmware(struct phy_device *phydev)\n \tphy_write(phydev, MDIO_MMD_VEND1, UP_CONTROL, UP_RUN_STALL_OVERRIDE);\n \n \tprintf(\"%s firmware loading done.\\n\", phydev->dev->name);\n-done:\n-\tfree(addr);\n+\treturn 0;\n+}\n+\n+static int aquantia_upload_firmware(struct phy_device *phydev)\n+{\n+\tint ret;\n+\tofnode node;\n+\tstruct udevice *loader_dev;\n+\tconst char *fw_name;\n+\tu8 *fw_addr = NULL;\n+\tsize_t fw_length;\n+\n+\tnode = phy_get_ofnode(phydev);\n+\tif (!ofnode_valid(node)) {\n+\t\tprintf(\"Failed to get PHY node\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfw_name = ofnode_read_string(node, \"firmware-name\");\n+\tif (!fw_name) {\n+\t\tprintf(\"Failed to get firmware name\\n\");\n+\t\treturn -ENOENT;\n+\t}\n+\n+\tret = get_fs_loader(&loader_dev);\n+\tif (ret) {\n+\t\tprintf(\"Failed to get fs_loader instance: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tfw_addr = malloc(CONFIG_PHY_AQUANTIA_FW_MAX_SIZE);\n+\tif (!fw_addr) {\n+\t\tprintf(\"Failed to allocate memory for firmware\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tret = request_firmware_into_buf(loader_dev, fw_name, fw_addr,\n+\t\t\t\t\tCONFIG_PHY_AQUANTIA_FW_MAX_SIZE, 0);\n+\tif (ret < 0) {\n+\t\tprintf(\"Failed to load firmware %s: %d\\n\", fw_name, ret);\n+\t\tfree(fw_addr);\n+\t\treturn ret;\n+\t}\n+\tfw_length = ret;\n+\n+\tret = aquantia_do_upload_firmware(phydev, fw_addr, fw_length);\n+\tfree(fw_addr);\n \treturn ret;\n }\n #else\n", "prefixes": [ "RESEND", "3/4" ] }