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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 20 Jun 2022 17:02:23 +0200
From:   Marcin Wojtas <mw@...ihalf.com>
To:     linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
        netdev@...r.kernel.org
Cc:     rafael@...nel.org, andriy.shevchenko@...ux.intel.com,
        lenb@...nel.org, andrew@...n.ch, vivien.didelot@...il.com,
        f.fainelli@...il.com, olteanv@...il.com, davem@...emloft.net,
        edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
        linux@...linux.org.uk, hkallweit1@...il.com, gjb@...ihalf.com,
        mw@...ihalf.com, jaz@...ihalf.com, tn@...ihalf.com,
        Samer.El-Haj-Mahmoud@....com, upstream@...ihalf.com
Subject: [net-next: PATCH 10/12] net: dsa: add ACPI support

Although the recent switch to device_/fwnode_ API covers the most
of modifications required for supporting ACPI, minor additional
changes should be applied:

* Use different subnode names with ACPI for 'ports' and 'mdio':
  * Naming of the nodes in ACPI must conform the namespace
    constraints, with regards to the characters' type
    and ACPI_NAMESEG_SIZE [1]. Because of that, the 'ports'
    subnode name used in device tree case, is not appropriate
    in ACPI world. This patch updates the subnode name depending on
    the hardware description type in runtime.
* Obtain ports indexes from _ADR fields
  * Same as in the MDIO PHY case, use this standard field instead of
    parsing 'reg' property from _DSD object.
* For now cascade topology remains unsupported in ACPI world, so
  disable ports connected to other switch devices.

[1] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#acpi-namespace

Signed-off-by: Marcin Wojtas <mw@...ihalf.com>
---
 net/dsa/dsa2.c | 35 +++++++++++++++++---
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 5e11d66f9057..53837dad1cca 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -6,6 +6,8 @@
  * Copyright (c) 2016 Andrew Lunn <andrew@...n.ch>
  */
 
+#include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/err.h>
@@ -854,6 +856,7 @@ static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds)
 static int dsa_switch_setup(struct dsa_switch *ds)
 {
 	struct dsa_devlink_priv *dl_priv;
+	char mdio_node_name[] = "mdio";
 	struct fwnode_handle *fwnode;
 	struct dsa_port *dp;
 	int err;
@@ -910,9 +913,16 @@ static int dsa_switch_setup(struct dsa_switch *ds)
 
 		dsa_slave_mii_bus_init(ds);
 
-		fwnode = fwnode_get_named_child_node(ds->dev->fwnode, "mdio");
+		/* Update subnode name if operating in the ACPI world. */
+		if (is_acpi_node(fwnode))
+			strncpy(mdio_node_name, "MDIO", ACPI_NAMESEG_SIZE);
 
-		err = of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode));
+		fwnode = fwnode_get_named_child_node(ds->dev->fwnode, mdio_node_name);
+
+		if (is_acpi_node(fwnode))
+			err = acpi_mdiobus_register(ds->slave_mii_bus, fwnode);
+		else
+			err = of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode));
 		fwnode_handle_put(fwnode);
 		if (err < 0)
 			goto free_slave_mii_bus;
@@ -1374,6 +1384,15 @@ static int dsa_port_parse_user(struct dsa_port *dp, const char *name)
 
 static int dsa_port_parse_dsa(struct dsa_port *dp)
 {
+	/* Cascade switch connection is not supported in ACPI world. */
+	if (is_acpi_node(dp->fwnode)) {
+		dev_warn(dp->ds->dev,
+			 "DSA type is not supported with ACPI, disable port #%d\n",
+			 dp->index);
+		dp->type = DSA_PORT_TYPE_UNUSED;
+		return 0;
+	}
+
 	dp->type = DSA_PORT_TYPE_DSA;
 
 	return 0;
@@ -1524,11 +1543,16 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 				     struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *ports, *port;
+	char ports_node_name[] = "ports";
 	struct dsa_port *dp;
 	int err = 0;
 	u32 reg;
 
-	ports = fwnode_get_named_child_node(fwnode, "ports");
+	/* Update subnode name if operating in the ACPI world. */
+	if (is_acpi_node(fwnode))
+		strncpy(ports_node_name, "PRTS", ACPI_NAMESEG_SIZE);
+
+	ports = fwnode_get_named_child_node(fwnode, ports_node_name);
 	if (!ports) {
 		/* The second possibility is "ethernet-ports" */
 		ports = fwnode_get_named_child_node(fwnode, "ethernet-ports");
@@ -1539,7 +1563,10 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 	}
 
 	fwnode_for_each_available_child_node(ports, port) {
-		err = fwnode_property_read_u32(port, "reg", &reg);
+		if (is_acpi_node(port))
+			err = acpi_get_local_address(ACPI_HANDLE_FWNODE(port), &reg);
+		else
+			err = fwnode_property_read_u32(port, "reg", &reg);
 		if (err) {
 			fwnode_handle_put(port);
 			goto out_put_node;
-- 
2.29.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ