linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
@ 2020-06-15 14:44 Heiko Stuebner
  2020-06-15 14:45 ` [PATCH v3 2/3] dt-bindings: net: ethernet-phy: add enet-phy-clock-out-frequency Heiko Stuebner
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Heiko Stuebner @ 2020-06-15 14:44 UTC (permalink / raw)
  To: davem, kuba
  Cc: robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, heiko, christoph.muellner,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

The different probe functions share a lot of code, so move the
common parts into a helper to reduce duplication.

This moves the devm_phy_package_join below the general allocation
but as all components just allocate things, this should be ok.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
changes in v3:
- adapt to 5.8 merge-window results
changes in v2:
- new patch as suggested by Andrew

 drivers/net/phy/mscc/mscc_main.c | 123 +++++++++++++++----------------
 1 file changed, 60 insertions(+), 63 deletions(-)

diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index 5ddc44f87eaf..68308d3e9589 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -1935,12 +1935,11 @@ static int vsc85xx_read_status(struct phy_device *phydev)
 	return genphy_read_status(phydev);
 }
 
-static int vsc8514_probe(struct phy_device *phydev)
+static int vsc85xx_probe_helper(struct phy_device *phydev,
+				u32 *leds, int num_leds, u16 led_modes,
+				const struct vsc85xx_hw_stat *stats, int nstats)
 {
 	struct vsc8531_private *vsc8531;
-	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
-	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
-	   VSC8531_DUPLEX_COLLISION};
 
 	vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
 	if (!vsc8531)
@@ -1948,54 +1947,65 @@ static int vsc8514_probe(struct phy_device *phydev)
 
 	phydev->priv = vsc8531;
 
-	vsc8584_get_base_addr(phydev);
-	devm_phy_package_join(&phydev->mdio.dev, phydev,
-			      vsc8531->base_addr, 0);
-
-	vsc8531->nleds = 4;
-	vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES;
-	vsc8531->hw_stats = vsc85xx_hw_stats;
-	vsc8531->nstats = ARRAY_SIZE(vsc85xx_hw_stats);
+	vsc8531->nleds = num_leds;
+	vsc8531->supp_led_modes = led_modes;
+	vsc8531->hw_stats = stats;
+	vsc8531->nstats = nstats;
 	vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats,
 				      sizeof(u64), GFP_KERNEL);
 	if (!vsc8531->stats)
 		return -ENOMEM;
 
-	return vsc85xx_dt_led_modes_get(phydev, default_mode);
+	return vsc85xx_dt_led_modes_get(phydev, leds);
 }
 
-static int vsc8574_probe(struct phy_device *phydev)
+static int vsc8514_probe(struct phy_device *phydev)
 {
 	struct vsc8531_private *vsc8531;
+	int rc;
 	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
 	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
 	   VSC8531_DUPLEX_COLLISION};
 
-	vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
-	if (!vsc8531)
-		return -ENOMEM;
-
-	phydev->priv = vsc8531;
+	rc = vsc85xx_probe_helper(phydev, default_mode,
+				  ARRAY_SIZE(default_mode),
+				  VSC85XX_SUPP_LED_MODES,
+				  vsc85xx_hw_stats,
+				  ARRAY_SIZE(vsc85xx_hw_stats));
+	if (rc < 0)
+		return rc;
 
+	vsc8531 = phydev->priv;
 	vsc8584_get_base_addr(phydev);
-	devm_phy_package_join(&phydev->mdio.dev, phydev,
-			      vsc8531->base_addr, 0);
+	return devm_phy_package_join(&phydev->mdio.dev, phydev,
+				     vsc8531->base_addr, 0);
+}
 
-	vsc8531->nleds = 4;
-	vsc8531->supp_led_modes = VSC8584_SUPP_LED_MODES;
-	vsc8531->hw_stats = vsc8584_hw_stats;
-	vsc8531->nstats = ARRAY_SIZE(vsc8584_hw_stats);
-	vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats,
-				      sizeof(u64), GFP_KERNEL);
-	if (!vsc8531->stats)
-		return -ENOMEM;
+static int vsc8574_probe(struct phy_device *phydev)
+{
+	struct vsc8531_private *vsc8531;
+	int rc;
+	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
+	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
+	   VSC8531_DUPLEX_COLLISION};
+
+	rc = vsc85xx_probe_helper(phydev, default_mode,
+				  ARRAY_SIZE(default_mode),
+				  VSC8584_SUPP_LED_MODES,
+				  vsc8584_hw_stats,
+				  ARRAY_SIZE(vsc8584_hw_stats));
+	if (rc < 0)
+		return rc;
 
-	return vsc85xx_dt_led_modes_get(phydev, default_mode);
+	vsc8584_get_base_addr(phydev);
+	return devm_phy_package_join(&phydev->mdio.dev, phydev,
+				     vsc8531->base_addr, 0);
 }
 
 static int vsc8584_probe(struct phy_device *phydev)
 {
 	struct vsc8531_private *vsc8531;
+	int rc;
 	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
 	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
 	   VSC8531_DUPLEX_COLLISION};
@@ -2005,32 +2015,24 @@ static int vsc8584_probe(struct phy_device *phydev)
 		return -ENOTSUPP;
 	}
 
-	vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
-	if (!vsc8531)
-		return -ENOMEM;
-
-	phydev->priv = vsc8531;
+	rc = vsc85xx_probe_helper(phydev, default_mode,
+				  ARRAY_SIZE(default_mode),
+				  VSC8584_SUPP_LED_MODES,
+				  vsc8584_hw_stats,
+				  ARRAY_SIZE(vsc8584_hw_stats));
+	if (rc < 0)
+		return rc;
 
+	vsc8531 = phydev->priv;
 	vsc8584_get_base_addr(phydev);
-	devm_phy_package_join(&phydev->mdio.dev, phydev,
-			      vsc8531->base_addr, 0);
-
-	vsc8531->nleds = 4;
-	vsc8531->supp_led_modes = VSC8584_SUPP_LED_MODES;
-	vsc8531->hw_stats = vsc8584_hw_stats;
-	vsc8531->nstats = ARRAY_SIZE(vsc8584_hw_stats);
-	vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats,
-				      sizeof(u64), GFP_KERNEL);
-	if (!vsc8531->stats)
-		return -ENOMEM;
-
-	return vsc85xx_dt_led_modes_get(phydev, default_mode);
+	return devm_phy_package_join(&phydev->mdio.dev, phydev,
+				     vsc8531->base_addr, 0);
 }
 
 static int vsc85xx_probe(struct phy_device *phydev)
 {
 	struct vsc8531_private *vsc8531;
-	int rate_magic;
+	int rate_magic, rc;
 	u32 default_mode[2] = {VSC8531_LINK_1000_ACTIVITY,
 	   VSC8531_LINK_100_ACTIVITY};
 
@@ -2038,23 +2040,18 @@ static int vsc85xx_probe(struct phy_device *phydev)
 	if (rate_magic < 0)
 		return rate_magic;
 
-	vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
-	if (!vsc8531)
-		return -ENOMEM;
-
-	phydev->priv = vsc8531;
+	rc = vsc85xx_probe_helper(phydev, default_mode,
+				  ARRAY_SIZE(default_mode),
+				  VSC85XX_SUPP_LED_MODES,
+				  vsc85xx_hw_stats,
+				  ARRAY_SIZE(vsc85xx_hw_stats));
+	if (rc < 0)
+		return rc;
 
+	vsc8531 = phydev->priv;
 	vsc8531->rate_magic = rate_magic;
-	vsc8531->nleds = 2;
-	vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES;
-	vsc8531->hw_stats = vsc85xx_hw_stats;
-	vsc8531->nstats = ARRAY_SIZE(vsc85xx_hw_stats);
-	vsc8531->stats = devm_kcalloc(&phydev->mdio.dev, vsc8531->nstats,
-				      sizeof(u64), GFP_KERNEL);
-	if (!vsc8531->stats)
-		return -ENOMEM;
 
-	return vsc85xx_dt_led_modes_get(phydev, default_mode);
+	return 0;
 }
 
 /* Microsemi VSC85xx PHYs */
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 2/3] dt-bindings: net: ethernet-phy: add enet-phy-clock-out-frequency
  2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
@ 2020-06-15 14:45 ` Heiko Stuebner
  2020-06-15 14:45 ` [PATCH v3 3/3] net: phy: mscc: handle the clkout control on some phy variants Heiko Stuebner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2020-06-15 14:45 UTC (permalink / raw)
  To: davem, kuba
  Cc: robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, heiko, christoph.muellner,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

Some ethernet phys have a configurable clock output, so add a generic
property to describe its target rate.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
changes in v3:
- new patch

 Documentation/devicetree/bindings/net/ethernet-phy.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
index 9b1f1147ca36..4dcf93f1c555 100644
--- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
@@ -84,6 +84,11 @@ properties:
       the turn around line low at end of the control phase of the
       MDIO transaction.
 
+  enet-phy-clock-out-frequency:
+    $ref: /schemas/types.yaml#definitions/uint32
+    description:
+      Frequency in Hz to set an available clock output to.
+
   enet-phy-lane-swap:
     $ref: /schemas/types.yaml#definitions/flag
     description:
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 3/3] net: phy: mscc: handle the clkout control on some phy variants
  2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
  2020-06-15 14:45 ` [PATCH v3 2/3] dt-bindings: net: ethernet-phy: add enet-phy-clock-out-frequency Heiko Stuebner
@ 2020-06-15 14:45 ` Heiko Stuebner
  2020-06-15 20:56 ` [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper kernel test robot
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Heiko Stuebner @ 2020-06-15 14:45 UTC (permalink / raw)
  To: davem, kuba
  Cc: robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, heiko, christoph.muellner,
	Heiko Stuebner

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

At least VSC8530/8531/8540/8541 contain a clock output that can emit
a predefined rate of 25, 50 or 125MHz.

This may then feed back into the network interface as source clock.
So follow the example the at803x already set and introduce a
vsc8531,clk-out-frequency property to set that output.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
changes in v3:
- switch to the new generic enet-phy-property

 drivers/net/phy/mscc/mscc.h      |  9 ++++
 drivers/net/phy/mscc/mscc_main.c | 87 +++++++++++++++++++++++++++++---
 2 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
index fbcee5fce7b2..a3afc35c3eab 100644
--- a/drivers/net/phy/mscc/mscc.h
+++ b/drivers/net/phy/mscc/mscc.h
@@ -218,6 +218,13 @@ enum rgmii_clock_delay {
 #define INT_MEM_DATA_M			  0x00ff
 #define INT_MEM_DATA(x)			  (INT_MEM_DATA_M & (x))
 
+#define MSCC_CLKOUT_CNTL		  13
+#define CLKOUT_ENABLE			  BIT(15)
+#define CLKOUT_FREQ_MASK		  GENMASK(14, 13)
+#define CLKOUT_FREQ_25M			  (0x0 << 13)
+#define CLKOUT_FREQ_50M			  (0x1 << 13)
+#define CLKOUT_FREQ_125M		  (0x2 << 13)
+
 #define MSCC_PHY_PROC_CMD		  18
 #define PROC_CMD_NCOMPLETED		  0x8000
 #define PROC_CMD_FAILED			  0x4000
@@ -360,6 +367,8 @@ struct vsc8531_private {
 	 */
 	unsigned int base_addr;
 
+	u32 clkout_rate;
+
 #if IS_ENABLED(CONFIG_MACSEC)
 	/* MACsec fields:
 	 * - One SecY per device (enforced at the s/w implementation level)
diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
index 68308d3e9589..bfb83ab9aad6 100644
--- a/drivers/net/phy/mscc/mscc_main.c
+++ b/drivers/net/phy/mscc/mscc_main.c
@@ -432,6 +432,18 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
 	return led_mode;
 }
 
+static void vsc8531_dt_clkout_rate_get(struct phy_device *phydev)
+{
+	struct vsc8531_private *priv = phydev->priv;
+	struct device *dev = &phydev->mdio.dev;
+	struct device_node *of_node = dev->of_node;
+
+	if (!of_node)
+		return;
+
+	of_property_read_u32(of_node, "enet-phy-clock-out-frequency",
+			     &priv->clkout_rate);
+}
 #else
 static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
 {
@@ -444,6 +456,10 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
 {
 	return default_mode;
 }
+
+static void vsc8531_dt_clkout_rate_get(struct phy_device *phydev)
+{
+}
 #endif /* CONFIG_OF_MDIO */
 
 static int vsc85xx_dt_led_modes_get(struct phy_device *phydev,
@@ -1508,6 +1524,37 @@ static int vsc85xx_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int vsc8531_config_init(struct phy_device *phydev)
+{
+	struct vsc8531_private *vsc8531 = phydev->priv;
+	u16 val;
+	int rc;
+
+	rc = vsc85xx_config_init(phydev);
+	if (rc)
+		return rc;
+
+	switch (vsc8531->clkout_rate) {
+	case 0:
+		val = 0;
+		break;
+	case 25000000:
+		val = CLKOUT_FREQ_25M | CLKOUT_ENABLE;
+		break;
+	case 50000000:
+		val = CLKOUT_FREQ_50M | CLKOUT_ENABLE;
+		break;
+	case 125000000:
+		val = CLKOUT_FREQ_125M | CLKOUT_ENABLE;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return phy_write_paged(phydev, MSCC_PHY_PAGE_EXTENDED_GPIO,
+			       MSCC_CLKOUT_CNTL, val);
+}
+
 static int vsc8584_did_interrupt(struct phy_device *phydev)
 {
 	int rc = 0;
@@ -1981,6 +2028,32 @@ static int vsc8514_probe(struct phy_device *phydev)
 				     vsc8531->base_addr, 0);
 }
 
+static int vsc8531_probe(struct phy_device *phydev)
+{
+	struct vsc8531_private *vsc8531;
+	int rate_magic, rc;
+	u32 default_mode[2] = {VSC8531_LINK_1000_ACTIVITY,
+	   VSC8531_LINK_100_ACTIVITY};
+
+	rate_magic = vsc85xx_edge_rate_magic_get(phydev);
+	if (rate_magic < 0)
+		return rate_magic;
+
+	rc = vsc85xx_probe_helper(phydev, default_mode,
+				  ARRAY_SIZE(default_mode),
+				  VSC85XX_SUPP_LED_MODES,
+				  vsc85xx_hw_stats,
+				  ARRAY_SIZE(vsc85xx_hw_stats));
+	if (rc < 0)
+		return rc;
+
+	vsc8531 = phydev->priv;
+	vsc8531->rate_magic = rate_magic;
+	vsc8531_dt_clkout_rate_get(phydev);
+
+	return 0;
+}
+
 static int vsc8574_probe(struct phy_device *phydev)
 {
 	struct vsc8531_private *vsc8531;
@@ -2135,14 +2208,14 @@ static struct phy_driver vsc85xx_driver[] = {
 	.phy_id_mask	= 0xfffffff0,
 	/* PHY_BASIC_FEATURES */
 	.soft_reset	= &genphy_soft_reset,
-	.config_init	= &vsc85xx_config_init,
+	.config_init	= &vsc8531_config_init,
 	.config_aneg    = &vsc85xx_config_aneg,
 	.read_status	= &vsc85xx_read_status,
 	.ack_interrupt	= &vsc85xx_ack_interrupt,
 	.config_intr	= &vsc85xx_config_intr,
 	.suspend	= &genphy_suspend,
 	.resume		= &genphy_resume,
-	.probe		= &vsc85xx_probe,
+	.probe		= &vsc8531_probe,
 	.set_wol	= &vsc85xx_wol_set,
 	.get_wol	= &vsc85xx_wol_get,
 	.get_tunable	= &vsc85xx_get_tunable,
@@ -2159,14 +2232,14 @@ static struct phy_driver vsc85xx_driver[] = {
 	.phy_id_mask    = 0xfffffff0,
 	/* PHY_GBIT_FEATURES */
 	.soft_reset	= &genphy_soft_reset,
-	.config_init    = &vsc85xx_config_init,
+	.config_init    = &vsc8531_config_init,
 	.config_aneg    = &vsc85xx_config_aneg,
 	.read_status	= &vsc85xx_read_status,
 	.ack_interrupt  = &vsc85xx_ack_interrupt,
 	.config_intr    = &vsc85xx_config_intr,
 	.suspend	= &genphy_suspend,
 	.resume		= &genphy_resume,
-	.probe		= &vsc85xx_probe,
+	.probe		= &vsc8531_probe,
 	.set_wol	= &vsc85xx_wol_set,
 	.get_wol	= &vsc85xx_wol_get,
 	.get_tunable	= &vsc85xx_get_tunable,
@@ -2183,14 +2256,14 @@ static struct phy_driver vsc85xx_driver[] = {
 	.phy_id_mask	= 0xfffffff0,
 	/* PHY_BASIC_FEATURES */
 	.soft_reset	= &genphy_soft_reset,
-	.config_init	= &vsc85xx_config_init,
+	.config_init	= &vsc8531_config_init,
 	.config_aneg	= &vsc85xx_config_aneg,
 	.read_status	= &vsc85xx_read_status,
 	.ack_interrupt	= &vsc85xx_ack_interrupt,
 	.config_intr	= &vsc85xx_config_intr,
 	.suspend	= &genphy_suspend,
 	.resume		= &genphy_resume,
-	.probe		= &vsc85xx_probe,
+	.probe		= &vsc8531_probe,
 	.set_wol	= &vsc85xx_wol_set,
 	.get_wol	= &vsc85xx_wol_get,
 	.get_tunable	= &vsc85xx_get_tunable,
@@ -2207,7 +2280,7 @@ static struct phy_driver vsc85xx_driver[] = {
 	.phy_id_mask    = 0xfffffff0,
 	/* PHY_GBIT_FEATURES */
 	.soft_reset	= &genphy_soft_reset,
-	.config_init    = &vsc85xx_config_init,
+	.config_init    = &vsc8531_config_init,
 	.config_aneg    = &vsc85xx_config_aneg,
 	.read_status	= &vsc85xx_read_status,
 	.ack_interrupt  = &vsc85xx_ack_interrupt,
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
  2020-06-15 14:45 ` [PATCH v3 2/3] dt-bindings: net: ethernet-phy: add enet-phy-clock-out-frequency Heiko Stuebner
  2020-06-15 14:45 ` [PATCH v3 3/3] net: phy: mscc: handle the clkout control on some phy variants Heiko Stuebner
@ 2020-06-15 20:56 ` kernel test robot
  2020-06-16  1:11 ` David Miller
  2020-06-16 12:27 ` [kbuild] " Dan Carpenter
  4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-06-15 20:56 UTC (permalink / raw)
  To: Heiko Stuebner, davem, kuba
  Cc: kbuild-all, clang-built-linux, robh+dt, andrew, f.fainelli,
	hkallweit1, linux, netdev, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2685 bytes --]

Hi Heiko,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on sparc-next/master net/master linus/master v5.8-rc1 next-20200615]
[cannot apply to robh/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Heiko-Stuebner/net-phy-mscc-move-shared-probe-code-into-a-helper/20200615-224727
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 3d8149c2a1228609fd7d7c91a04681304a2f0ca9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/net/phy/mscc/mscc_main.c:2002:10: warning: variable 'vsc8531' is uninitialized when used here [-Wuninitialized]
vsc8531->base_addr, 0);
^~~~~~~
drivers/net/phy/mscc/mscc_main.c:1986:33: note: initialize the variable 'vsc8531' to silence this warning
struct vsc8531_private *vsc8531;
^
= NULL
1 warning generated.

vim +/vsc8531 +2002 drivers/net/phy/mscc/mscc_main.c

  1983	
  1984	static int vsc8574_probe(struct phy_device *phydev)
  1985	{
  1986		struct vsc8531_private *vsc8531;
  1987		int rc;
  1988		u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
  1989		   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
  1990		   VSC8531_DUPLEX_COLLISION};
  1991	
  1992		rc = vsc85xx_probe_helper(phydev, default_mode,
  1993					  ARRAY_SIZE(default_mode),
  1994					  VSC8584_SUPP_LED_MODES,
  1995					  vsc8584_hw_stats,
  1996					  ARRAY_SIZE(vsc8584_hw_stats));
  1997		if (rc < 0)
  1998			return rc;
  1999	
  2000		vsc8584_get_base_addr(phydev);
  2001		return devm_phy_package_join(&phydev->mdio.dev, phydev,
> 2002					     vsc8531->base_addr, 0);
  2003	}
  2004	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 73919 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
                   ` (2 preceding siblings ...)
  2020-06-15 20:56 ` [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper kernel test robot
@ 2020-06-16  1:11 ` David Miller
  2020-06-16  1:12   ` David Miller
  2020-06-16 12:27 ` [kbuild] " Dan Carpenter
  4 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2020-06-16  1:11 UTC (permalink / raw)
  To: heiko
  Cc: kuba, robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, christoph.muellner, heiko.stuebner

From: Heiko Stuebner <heiko@sntech.de>
Date: Mon, 15 Jun 2020 16:44:59 +0200

>  static int vsc8584_probe(struct phy_device *phydev)
>  {
>  	struct vsc8531_private *vsc8531;
> +	int rc;
>  	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
>  	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
>  	   VSC8531_DUPLEX_COLLISION};
> @@ -2005,32 +2015,24 @@ static int vsc8584_probe(struct phy_device *phydev)
>  		return -ENOTSUPP;
>  	}
>  
> -	vsc8531 = devm_kzalloc(&phydev->mdio.dev, sizeof(*vsc8531), GFP_KERNEL);
> -	if (!vsc8531)
> -		return -ENOMEM;

Because you removed this devm_kzalloc() code, vsc8531 is never initialized.

> +	return devm_phy_package_join(&phydev->mdio.dev, phydev,
> +				     vsc8531->base_addr, 0);

But it is still dereferenced here.

Did the compiler really not warn you about this when you test built
these changes?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-16  1:11 ` David Miller
@ 2020-06-16  1:12   ` David Miller
  2020-06-16  9:10     ` Heiko Stübner
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2020-06-16  1:12 UTC (permalink / raw)
  To: heiko
  Cc: kuba, robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, christoph.muellner, heiko.stuebner

From: David Miller <davem@davemloft.net>
Date: Mon, 15 Jun 2020 18:11:29 -0700 (PDT)

> Because you removed this devm_kzalloc() code, vsc8531 is never initialized.

You also need to provide a proper header posting when you repost this series
after fixing this bug.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-16  1:12   ` David Miller
@ 2020-06-16  9:10     ` Heiko Stübner
  2020-06-16 10:13       ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 9+ messages in thread
From: Heiko Stübner @ 2020-06-16  9:10 UTC (permalink / raw)
  To: David Miller
  Cc: kuba, robh+dt, andrew, f.fainelli, hkallweit1, linux, netdev,
	devicetree, linux-kernel, christoph.muellner

Hi,

Am Dienstag, 16. Juni 2020, 03:12:25 CEST schrieb David Miller:
> From: David Miller <davem@davemloft.net>
> Date: Mon, 15 Jun 2020 18:11:29 -0700 (PDT)
> > +	return devm_phy_package_join(&phydev->mdio.dev, phydev,
> > +				     vsc8531->base_addr, 0);
> 
> But it is still dereferenced here.
> 
> Did the compiler really not warn you about this when you test built
> these changes?

I'm wondering that myself ... it probably did and I overlooked it, which
also is indicated by the fact that  I did add the declaration of the
vsc8531 when rebasing.

> > Because you removed this devm_kzalloc() code, vsc8531 is never initialized.
> 
> You also need to provide a proper header posting when you repost this series
> after fixing this bug.

not sure I understand what you mean with "header posting" here.

Thanks
Heiko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-16  9:10     ` Heiko Stübner
@ 2020-06-16 10:13       ` Russell King - ARM Linux admin
  0 siblings, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux admin @ 2020-06-16 10:13 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: David Miller, kuba, robh+dt, andrew, f.fainelli, hkallweit1,
	netdev, devicetree, linux-kernel, christoph.muellner

On Tue, Jun 16, 2020 at 11:10:27AM +0200, Heiko Stübner wrote:
> > 
> > You also need to provide a proper header posting when you repost this series
> > after fixing this bug.
> 
> not sure I understand what you mean with "header posting" here.

David is requesting that you send a "0/N" email summarising the purpose
of the patch series and any other relevant information to the series as
a whole.  The subsequent patches should be threaded to the 0/N email.

The 0/N email should also contain the overall diffstat for the series.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [kbuild] Re: [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper
  2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
                   ` (3 preceding siblings ...)
  2020-06-16  1:11 ` David Miller
@ 2020-06-16 12:27 ` Dan Carpenter
  4 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2020-06-16 12:27 UTC (permalink / raw)
  To: kbuild, Heiko Stuebner, davem, kuba
  Cc: lkp, kbuild-all, robh+dt, andrew, f.fainelli, hkallweit1, linux,
	netdev, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3962 bytes --]

Hi Heiko,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on sparc-next/master net/master linus/master v5.8-rc1 next-20200616]
[cannot apply to robh/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Heiko-Stuebner/net-phy-mscc-move-shared-probe-code-into-a-helper/20200615-224727
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2
config: i386-randconfig-m021-20200616 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/net/phy/mscc/mscc_main.c:2002 vsc8574_probe() error: potentially dereferencing uninitialized 'vsc8531'.

# https://github.com/0day-ci/linux/commit/5be350208c014ad5e0afd06868ccaaefd6216345
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 5be350208c014ad5e0afd06868ccaaefd6216345
vim +/vsc8531 +2002 drivers/net/phy/mscc/mscc_main.c

5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1984  static int vsc8574_probe(struct phy_device *phydev)
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1985  {
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1986  	struct vsc8531_private *vsc8531;
                                                                                                                ^^^^^^^

5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1987  	int rc;
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1988  	u32 default_mode[4] = {VSC8531_LINK_1000_ACTIVITY,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1989  	   VSC8531_LINK_100_ACTIVITY, VSC8531_LINK_ACTIVITY,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1990  	   VSC8531_DUPLEX_COLLISION};
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1991  
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1992  	rc = vsc85xx_probe_helper(phydev, default_mode,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1993  				  ARRAY_SIZE(default_mode),
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1994  				  VSC8584_SUPP_LED_MODES,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1995  				  vsc8584_hw_stats,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1996  				  ARRAY_SIZE(vsc8584_hw_stats));
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1997  	if (rc < 0)
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  1998  		return rc;
00d70d8e0e7811 drivers/net/phy/mscc.c           Quentin Schulz 2018-10-08  1999  
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  2000  	vsc8584_get_base_addr(phydev);
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15  2001  	return devm_phy_package_join(&phydev->mdio.dev, phydev,
5be350208c014a drivers/net/phy/mscc/mscc_main.c Heiko Stuebner 2020-06-15 @2002  				     vsc8531->base_addr, 0);
                                                                                                                     ^^^^^^^^^^^^^^^^^^
Not initialized.

00d70d8e0e7811 drivers/net/phy/mscc.c           Quentin Schulz 2018-10-08  2003  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32738 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-16 12:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 14:44 [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper Heiko Stuebner
2020-06-15 14:45 ` [PATCH v3 2/3] dt-bindings: net: ethernet-phy: add enet-phy-clock-out-frequency Heiko Stuebner
2020-06-15 14:45 ` [PATCH v3 3/3] net: phy: mscc: handle the clkout control on some phy variants Heiko Stuebner
2020-06-15 20:56 ` [PATCH v3 1/3] net: phy: mscc: move shared probe code into a helper kernel test robot
2020-06-16  1:11 ` David Miller
2020-06-16  1:12   ` David Miller
2020-06-16  9:10     ` Heiko Stübner
2020-06-16 10:13       ` Russell King - ARM Linux admin
2020-06-16 12:27 ` [kbuild] " Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).