From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8A2B38F935 for ; Sat, 26 Sep 2026 23:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790466635; cv=none; b=uoejALjU/8LYW5/D7NvZzWzX7YP34Zv4goufiHM5fRW8fb2EC5ZFB2SlVcbWzVXbSDF9e9lkBqGhdy+qnPa0U5h6zjaGkvSJ73mHb/Uo9X30JNgLUVLPOcSj7DxH2V68ReJFRNjtMTZ9X3RD3q8P8UrhOoFuZHrTtFPEVfq6MhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790466635; c=relaxed/simple; bh=8jMU1Dl9hhLUv5U752LLGbRGkvb/y7qgoM5KbktG3Ks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgU5diNfLC63YcDHbSSTi7PsMycvepJD+XLcApVQiu+UMmT3xo6POcpoJ7O5ozV4WNQQiqQ0XfgaVFO6n9Oclxp5uQvI9i1NnnBLsSU4L6izk+XP3o9qypO4Mf1zwWhBy9muRdy9+X/FbSZo+SUM9g7vxgF5ljJr9IEhvyf2Ans= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=J4/gq92E; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="J4/gq92E" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-48870973bddso845537f8f.1 for ; Sat, 26 Sep 2026 16:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1790466632; x=1791071432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qteUU/69D9osiNFS2h08w3Fe+zYvU7Pt0cpz1kBDxMs=; b=J4/gq92ESeBShUeKplDKIX7kq5OUYXq5aCUoLrOTl/VxYi2klkbyZ+YrBJZjVbau3g zhNEVPWPFjjKtTJn+K3Uje7JupA0Mme11hFUuGBWje7OYlvCP8KUaV1SRQM762fZTIxQ qXSbjW3R7HbLUJeSBpS+yPXxWEikBxPh+34y9dVqU5N7oxve5D/fO1JkVy1k8tGunxSd kGcJunyyjNtjfoK35lpuxfWlhiZw4YtRtQhF55/cJv2MnVrUvi2VnW0SGqVitUt/FoxW VtMv597Bww8Zjnb5k29O5tUl+gyBsQeumUJgjvXqn8ZSIxZ4ekgWsmSs1J81/cbxVQs8 d3dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790466632; x=1791071432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qteUU/69D9osiNFS2h08w3Fe+zYvU7Pt0cpz1kBDxMs=; b=JQwZEpBObeR2crnwqhgt+ZVBQPkl7fnS7W2BkchnJizU+eI61bqHFzLVlrNxblUwi8 MY8/+PGZlP0ghfsYdpiqFIACSFsYDxRyf1gtDXES3Sg8sy8s3SoEKdwmfnxHutcmYsQq AWzJu+z00PZ0PvJHDLlUiKTWBzE3C+52m52DupfMPBP3aUv0z49lLpSTH1zeN2Bjw449 XZkMqFvp5S2/k/uFuWwsvGcOCElfbf3uxoatpWz4D9vVAFJoSTJmweWDWqyyddk3ckCI 3hgqbRaEJSKJMCbwDe1mVk1uG3XaQJZdE8wiiUGc2j5r40CpykuK3xA3A9FndZ5WrEAV U9Bw== X-Forwarded-Encrypted: i=1; AKwUvByg3oC8HouiZEtGaGTVjyfVbuiASnXFsCaPzLVhQg50v7wBHckNoLcyQdndvXz6iAEQfRentsdppfce6hw=@vger.kernel.org X-Gm-Message-State: AFq9FYJQHS62P6BLS8cohii9MOBsohApJqA71YWESYWTPTVRClqCg/me 9mdu+TuoxReqsOPF/xphC5PS5KJVKaq11PfqBeqH43VRJsYS0TMUWpzrYLMRQinrKoU= X-Gm-Gg: AYBFou3ae+a7BdI7itrv4p2CjoS6lvEJBQZAiZQnLrdma12kio7mlBwzkc/ZexJF0vB ffpraEmr6H0A0F6CuH7mEqLRndsVQlzeqm352mco/F0KxzmRSFYKbvXB6ThzkDhJiAG86OaOghr zjVQvhTvu2ZIYorIBD8yWtRt3BY/dXadPf/ZwpSgncNf8pz/UWP72l8OZeZpq+idHctxTpi9bQo 3H3uRkPgryeqODfBpemaTgSK/oimUPmFeaMoErgXv4VyFc1hsDuNFE5jTqjQE+l4wfssraU53MV Dx8TFdJjA2Vh20YJEIWd2x87sG8nKzg7GXbhVXmnJ28XkN4DgQ5G7+N1wutl+KbxYwn8LP1L/Vl vD5EBlEPuCWEcF0QMjuz6ykCGMoQukaTUwFh4ZdwkBFvjIu13a9tRt5qyo9RRktGwRPTP1Bb8tt DCsQJdug/+9x3IUGcdjdkhRuOukZIfSCJdBDmGAOXUNf+UJXtNjuUMPuRZcYQb X-Received: by 2002:a05:6000:25fb:b0:487:25:71c7 with SMTP id ffacd0b85a97d-488716b96cemr19111229f8f.12.1790466632023; Sat, 26 Sep 2026 16:50:32 -0700 (PDT) Received: from remote-01 ([84.17.55.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4887a349fa1sm24716798f8f.8.2026.09.26.16.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Sep 2026 16:50:31 -0700 (PDT) From: Aleksei Sviridkin To: netdev@vger.kernel.org Cc: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, olteanv@gmail.com, Thangaraj.S@microchip.com, UNGLinuxDriver@microchip.com, steve.glendinning@shawell.net, f.fainelli@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [PATCH net v11 1/4] net: usb: lan78xx: register the PHY interrupt with the MDIO bus Date: Sun, 27 Sep 2026 02:50:21 +0300 Message-ID: <20260926235024.705646-2-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260926235024.705646-1-f@lex.la> References: <20260926235024.705646-1-f@lex.la> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The interrupt this driver maps for its PHY is written only into phydev->irq, while the bus table mdiobus->irq[] keeps reading PHY_POLL for the same address. That table is where phylib records what the bus described - phy_device_create() seeds phydev->irq from it - so the number lives only as long as nothing else writes that one field. Put it in the table before the bus is registered, so that the PHY the scan creates is born with the number, and drop the write to phydev->irq that phylib then makes by itself. Fill the whole table rather than one entry: for 7801 the address is not known until the scan, and for the other two phy_mask leaves only address 1 readable, so a loop costs less than a second switch on the chip id. A devicetree PHY node that describes an interrupt now overrides that, where the driver's number used to win. Found going through the drivers that keep a PHY interrupt outside the bus table, so that the restore on detach later in this series has a number to hand back here as well. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- Notes: Compile-tested only; I have no LAN78xx device. No Fixes: tag on this one. On its own it fixes nothing - nothing reads the bus table back until patch 3 - which is also why it sorts ahead of that patch rather than after it. lan78xx_setup_irq_domain() runs before lan78xx_mdio_init() in lan78xx_bind(), so the number is already mapped where the table is filled. The fill covers the whole table because only the 7801 case leaves the address open until of_mdiobus_register() has scanned; 7800 and 7850 set phy_mask a few lines above, so every entry but address 1 is unreachable and writing them costs nothing. The fill is a default rather than an override. For a PHY node that describes an interrupt, fwnode_mdiobus_phy_device_register() writes the devicetree number over the table entry, and into phydev->irq, once the device exists. That inverts the old order, where the driver's own number was written last and won. Neither in-tree lan78xx PHY node carries an interrupts property, so nothing in tree changes, but a devicetree that described one would now be believed. Teardown order keeps the number live for as long as it is read: lan78xx_disconnect() detaches the PHY through phylink_disconnect_phy(), and lan78xx_unbind() calls lan78xx_remove_irq_domain() only afterwards. drivers/net/usb/lan78xx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 5655941f1478..522fb4daeb46 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2092,6 +2092,7 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) { struct device_node *node; int ret; + int i; dev->mdiobus = mdiobus_alloc(); if (!dev->mdiobus) { @@ -2118,6 +2119,10 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) break; } + if (dev->domain_data.phyirq > 0) + for (i = 0; i < PHY_MAX_ADDR; i++) + dev->mdiobus->irq[i] = dev->domain_data.phyirq; + node = of_get_child_by_name(dev->udev->dev.of_node, "mdio"); ret = of_mdiobus_register(dev->mdiobus, node); of_node_put(node); @@ -2892,13 +2897,6 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) return 0; } - /* if phyirq is not set, use polling mode in phylib */ - if (dev->domain_data.phyirq > 0) - phydev->irq = dev->domain_data.phyirq; - else - phydev->irq = PHY_POLL; - netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq); - ret = phylink_connect_phy(dev->phylink, phydev); if (ret) { netdev_err(dev->net, "can't attach PHY to %s, error %pe\n", -- 2.53.0