lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200617082235.GA1523@laureti-dev>
Date:   Wed, 17 Jun 2020 10:22:37 +0200
From:   Helmut Grohne <helmut.grohne@...enta.de>
To:     Woojung Huh <woojung.huh@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        <netdev@...r.kernel.org>
Subject: net/dsa/microchip: correct placement of dt property phy-mode?

Hi,

According to Documentation/devicetree/bindings/net/dsa/dsa.txt, the
phy-mode property should be specified on port nodes rather than the
enclosing switch node.

In drivers/net/dsa/microchip/ksz_common.c, ksz_switch_register parses
the phy-mode property from the switch node instead:
| int ksz_switch_register(struct ksz_device *dev,
|                         const struct ksz_dev_ops *ops)
| {
...
|         /* Host port interface will be self detected, or specifically set in
|          * device tree.
|          */
|         if (dev->dev->of_node) {
|                 ret = of_get_phy_mode(dev->dev->of_node, &interface);
|                 if (ret == 0)
|                         dev->interface = interface;
...

In drivers/net/dsa/microchip/ksz9477.c, this phy_interface_t is used to
configure the MAC ports:
| static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
| {
...
|                 switch (dev->interface) {
...
|                 }
|                 ksz_pwrite8(dev, port, REG_PORT_XMII_CTRL_1, data8);

KSZ9477 has two MAC interfaces (GMAC 6 -> RGMII/MII/RMII and GMAC 7 ->
SGMII). Now we're trying to configure the same interface mode for both
MACs here even though these MACs only support distinct interface modes.
This may not be problematic in practice as GMAC 7 ignores most of the
settings on the XMII Port Control 1 Register, but it still sounds wrong.

If nothing else, it makes the device tree unintuitive to use.

Is this placement of the phy-mode on the switch intentional?

If yes: I think this should be prominently documented in
Documentation/devicetree/bindings/net/dsa/ksz.txt.

If no: The microchip driver should follow the documented dsa convention
and place the phy-mode on the relevant port nodes.

If no: Do we have to support old device trees that have the phy-mode
property on the switch?

Helmut

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ