linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] net: sfp: small improvements
@ 2018-05-22 10:17 Antoine Tenart
  2018-05-22 10:17 ` [PATCH net-next v2 1/3] net: phy: sfp: warn the user when no tx_disable pin is available Antoine Tenart
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Antoine Tenart @ 2018-05-22 10:17 UTC (permalink / raw)
  To: davem, linux
  Cc: Antoine Tenart, netdev, linux-kernel, thomas.petazzoni,
	maxime.chevallier, gregory.clement, miquel.raynal, nadavh,
	stefanc, ymarkman, mw

Hi Russell, David,

A small series of patches improving the SFP support by adding a warning
when no Tx disable pin is available, and making the i2c-bus property
mandatory.

Thanks!
Antoine

Since v1:
  - Removed the patch fixing the sfp driver when no i2c bus was described.
  - Made two new patches to make the i2c-bus property mandatory for sfp modules.

Since the phylink series:
  - s/-EOPNOTSUPP/-ENODEV/ in patch 1/2.
  - I added the acked-by tag in patch 2/2.

Antoine Tenart (3):
  net: phy: sfp: warn the user when no tx_disable pin is available
  net: phy: sfp: make the i2c-bus dt property mandatory
  Documentation/bindings: net: the sfp i2c-bus property is now mandatory

 .../devicetree/bindings/net/sff,sfp.txt       |  4 +-
 drivers/net/phy/sfp.c                         | 37 ++++++++++++-------
 2 files changed, 26 insertions(+), 15 deletions(-)

-- 
2.17.0

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

* [PATCH net-next v2 1/3] net: phy: sfp: warn the user when no tx_disable pin is available
  2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
@ 2018-05-22 10:17 ` Antoine Tenart
  2018-05-22 10:18 ` [PATCH net-next v2 2/3] net: phy: sfp: make the i2c-bus dt property mandatory Antoine Tenart
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Antoine Tenart @ 2018-05-22 10:17 UTC (permalink / raw)
  To: davem, linux
  Cc: Antoine Tenart, netdev, linux-kernel, thomas.petazzoni,
	maxime.chevallier, gregory.clement, miquel.raynal, nadavh,
	stefanc, ymarkman, mw

In case no Tx disable pin is available the SFP modules will always be
emitting. This could be an issue when using modules using laser as their
light source as we would have no way to disable it when the fiber is
removed. This patch adds a warning when registering an SFP cage which do
not have its tx_disable pin wired or available.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/sfp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 4ab6e9a50bbe..a91d12209a81 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -1065,6 +1065,15 @@ static int sfp_probe(struct platform_device *pdev)
 	if (poll)
 		mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
 
+	/* We could have an issue in cases no Tx disable pin is available or
+	 * wired as modules using a laser as their light source will continue to
+	 * be active when the fiber is removed. This could be a safety issue and
+	 * we should at least warn the user about that.
+	 */
+	if (!sfp->gpio[GPIO_TX_DISABLE])
+		dev_warn(sfp->dev,
+			 "No tx_disable pin: SFP modules will always be emitting.\n");
+
 	return 0;
 }
 
-- 
2.17.0

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

* [PATCH net-next v2 2/3] net: phy: sfp: make the i2c-bus dt property mandatory
  2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
  2018-05-22 10:17 ` [PATCH net-next v2 1/3] net: phy: sfp: warn the user when no tx_disable pin is available Antoine Tenart
@ 2018-05-22 10:18 ` Antoine Tenart
  2018-05-22 10:18 ` [PATCH net-next v2 3/3] Documentation/bindings: net: the sfp i2c-bus property is now mandatory Antoine Tenart
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Antoine Tenart @ 2018-05-22 10:18 UTC (permalink / raw)
  To: davem, linux
  Cc: Antoine Tenart, netdev, linux-kernel, thomas.petazzoni,
	maxime.chevallier, gregory.clement, miquel.raynal, nadavh,
	stefanc, ymarkman, mw

This patch makes the i2c-bus property mandatory when using a device
tree. If the sfp i2c bus isn't described it's impossible to guess the
protocol to use for a given module, and the sfp module would then not
work in most cases.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
 drivers/net/phy/sfp.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index a91d12209a81..c4c92db86dfa 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -976,6 +976,7 @@ static int sfp_probe(struct platform_device *pdev)
 	if (pdev->dev.of_node) {
 		struct device_node *node = pdev->dev.of_node;
 		const struct of_device_id *id;
+		struct i2c_adapter *i2c;
 		struct device_node *np;
 
 		id = of_match_node(sfp_of_match, node);
@@ -985,19 +986,20 @@ static int sfp_probe(struct platform_device *pdev)
 		sff = sfp->type = id->data;
 
 		np = of_parse_phandle(node, "i2c-bus", 0);
-		if (np) {
-			struct i2c_adapter *i2c;
-
-			i2c = of_find_i2c_adapter_by_node(np);
-			of_node_put(np);
-			if (!i2c)
-				return -EPROBE_DEFER;
-
-			err = sfp_i2c_configure(sfp, i2c);
-			if (err < 0) {
-				i2c_put_adapter(i2c);
-				return err;
-			}
+		if (!np) {
+			dev_err(sfp->dev, "missing 'i2c-bus' property\n");
+			return -ENODEV;
+		}
+
+		i2c = of_find_i2c_adapter_by_node(np);
+		of_node_put(np);
+		if (!i2c)
+			return -EPROBE_DEFER;
+
+		err = sfp_i2c_configure(sfp, i2c);
+		if (err < 0) {
+			i2c_put_adapter(i2c);
+			return err;
 		}
 	}
 
-- 
2.17.0

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

* [PATCH net-next v2 3/3] Documentation/bindings: net: the sfp i2c-bus property is now mandatory
  2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
  2018-05-22 10:17 ` [PATCH net-next v2 1/3] net: phy: sfp: warn the user when no tx_disable pin is available Antoine Tenart
  2018-05-22 10:18 ` [PATCH net-next v2 2/3] net: phy: sfp: make the i2c-bus dt property mandatory Antoine Tenart
@ 2018-05-22 10:18 ` Antoine Tenart
  2018-05-23 18:34 ` [PATCH net-next v2 0/3] net: sfp: small improvements David Miller
  2018-05-23 18:40 ` Florian Fainelli
  4 siblings, 0 replies; 7+ messages in thread
From: Antoine Tenart @ 2018-05-22 10:18 UTC (permalink / raw)
  To: davem, linux
  Cc: Antoine Tenart, netdev, linux-kernel, thomas.petazzoni,
	maxime.chevallier, gregory.clement, miquel.raynal, nadavh,
	stefanc, ymarkman, mw

The i2c-bus property for sfp modules was made mandatory. Update the
documentation to keep it in sync with the driver's behaviour.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
 Documentation/devicetree/bindings/net/sff,sfp.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/sff,sfp.txt b/Documentation/devicetree/bindings/net/sff,sfp.txt
index 929591d52ed6..832139919f20 100644
--- a/Documentation/devicetree/bindings/net/sff,sfp.txt
+++ b/Documentation/devicetree/bindings/net/sff,sfp.txt
@@ -7,11 +7,11 @@ Required properties:
   "sff,sfp" for SFP modules
   "sff,sff" for soldered down SFF modules
 
-Optional Properties:
-
 - i2c-bus : phandle of an I2C bus controller for the SFP two wire serial
   interface
 
+Optional Properties:
+
 - mod-def0-gpios : GPIO phandle and a specifier of the MOD-DEF0 (AKA Mod_ABS)
   module presence input gpio signal, active (module absent) high. Must
   not be present for SFF modules
-- 
2.17.0

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

* Re: [PATCH net-next v2 0/3] net: sfp: small improvements
  2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
                   ` (2 preceding siblings ...)
  2018-05-22 10:18 ` [PATCH net-next v2 3/3] Documentation/bindings: net: the sfp i2c-bus property is now mandatory Antoine Tenart
@ 2018-05-23 18:34 ` David Miller
  2018-05-23 18:40 ` Florian Fainelli
  4 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2018-05-23 18:34 UTC (permalink / raw)
  To: antoine.tenart
  Cc: linux, netdev, linux-kernel, thomas.petazzoni, maxime.chevallier,
	gregory.clement, miquel.raynal, nadavh, stefanc, ymarkman, mw

From: Antoine Tenart <antoine.tenart@bootlin.com>
Date: Tue, 22 May 2018 12:17:58 +0200

> A small series of patches improving the SFP support by adding a warning
> when no Tx disable pin is available, and making the i2c-bus property
> mandatory.
 ...
> Since v1:
>   - Removed the patch fixing the sfp driver when no i2c bus was described.
>   - Made two new patches to make the i2c-bus property mandatory for sfp modules.

Series applied, thank you.

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

* Re: [PATCH net-next v2 0/3] net: sfp: small improvements
  2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
                   ` (3 preceding siblings ...)
  2018-05-23 18:34 ` [PATCH net-next v2 0/3] net: sfp: small improvements David Miller
@ 2018-05-23 18:40 ` Florian Fainelli
  2018-05-24  6:56   ` Antoine Tenart
  4 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2018-05-23 18:40 UTC (permalink / raw)
  To: Antoine Tenart, davem, linux
  Cc: netdev, linux-kernel, thomas.petazzoni, maxime.chevallier,
	gregory.clement, miquel.raynal, nadavh, stefanc, ymarkman, mw

On 05/22/2018 03:17 AM, Antoine Tenart wrote:
> Hi Russell, David,
> 
> A small series of patches improving the SFP support by adding a warning
> when no Tx disable pin is available, and making the i2c-bus property
> mandatory.
> 
> Thanks!
> Antoine

Antoine, can you please do CC the people who worked on that code before,
arguably, send an update to MAINTAINERS file to create a specific
section for PHYLINK.

Thank you

> 
> Since v1:
>   - Removed the patch fixing the sfp driver when no i2c bus was described.
>   - Made two new patches to make the i2c-bus property mandatory for sfp modules.
> 
> Since the phylink series:
>   - s/-EOPNOTSUPP/-ENODEV/ in patch 1/2.
>   - I added the acked-by tag in patch 2/2.
> 
> Antoine Tenart (3):
>   net: phy: sfp: warn the user when no tx_disable pin is available
>   net: phy: sfp: make the i2c-bus dt property mandatory
>   Documentation/bindings: net: the sfp i2c-bus property is now mandatory
> 
>  .../devicetree/bindings/net/sff,sfp.txt       |  4 +-
>  drivers/net/phy/sfp.c                         | 37 ++++++++++++-------
>  2 files changed, 26 insertions(+), 15 deletions(-)
> 


-- 
Florian

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

* Re: [PATCH net-next v2 0/3] net: sfp: small improvements
  2018-05-23 18:40 ` Florian Fainelli
@ 2018-05-24  6:56   ` Antoine Tenart
  0 siblings, 0 replies; 7+ messages in thread
From: Antoine Tenart @ 2018-05-24  6:56 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Antoine Tenart, davem, linux, netdev, linux-kernel,
	thomas.petazzoni, maxime.chevallier, gregory.clement,
	miquel.raynal, nadavh, stefanc, ymarkman, mw

Hi Florian,

On Wed, May 23, 2018 at 11:40:50AM -0700, Florian Fainelli wrote:
> 
> Antoine, can you please do CC the people who worked on that code before,
> arguably, send an update to MAINTAINERS file to create a specific
> section for PHYLINK.

My bad, sorry for that, I'll make sure to Cc everyone involved next
time. As for an update to MAINTAINERS, I believe the one listed for a
particular file should do it himself.

Thanks!
Antoine

-- 
Antoine Ténart, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2018-05-24  6:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-22 10:17 [PATCH net-next v2 0/3] net: sfp: small improvements Antoine Tenart
2018-05-22 10:17 ` [PATCH net-next v2 1/3] net: phy: sfp: warn the user when no tx_disable pin is available Antoine Tenart
2018-05-22 10:18 ` [PATCH net-next v2 2/3] net: phy: sfp: make the i2c-bus dt property mandatory Antoine Tenart
2018-05-22 10:18 ` [PATCH net-next v2 3/3] Documentation/bindings: net: the sfp i2c-bus property is now mandatory Antoine Tenart
2018-05-23 18:34 ` [PATCH net-next v2 0/3] net: sfp: small improvements David Miller
2018-05-23 18:40 ` Florian Fainelli
2018-05-24  6:56   ` Antoine Tenart

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).