Skip to contentSkip to conversation

i2c: mux: demux-pinctrl: improve device relationships

PATCH Superseded Wolfram Sang 3 participants 10 messages Apr 30, 2018 – May 20, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wolfram Sang

author maintainer
#0 lore raw

cover i2c: mux: demux-pinctrl: improve device relationships

While researching some PM behaviour within I2C, I found out that the i2c-demux driver does not play well with that due to broken relationship with other devices. Patch 1 ensures the right parent-child relationship. Patch 2 makes the connection between the demux device and the demuxed bus similar to that we have in the mux core.

Tested on a Renesas Lager board (R-Car H2).

Wolfram Sang (2):
i2c: mux: demux-pinctrl: use proper parent device for demux adapter
i2c: mux: demux-pinctrl: add symlinks to the demux device in sysfs

 drivers/i2c/muxes/i2c-demux-pinctrl.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/2 i2c: mux: demux-pinctrl: use proper parent device for demux adapter

Due to a typo, the wrong parent device was assigned to the newly created demuxing adapter device. It got connected to the demuxing platform device but not to the selected parent I2C adapter device. Fix it to get a proper parent-child relationship of the demuxed busses, needed also for proper PM.

---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/muxes/i2c-demux-pinctrl.c +1 -1
index 428de4c97fb2..035032e20327 100644
@@ -106,7 +106,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
 	priv->cur_adap.owner = THIS_MODULE;
 	priv->cur_adap.algo = &priv->algo;
 	priv->cur_adap.algo_data = priv;
-	priv->cur_adap.dev.parent = priv->dev;
+	priv->cur_adap.dev.parent = &adap->dev;
 	priv->cur_adap.class = adap->class;
 	priv->cur_adap.retries = adap->retries;
 	priv->cur_adap.timeout = adap->timeout;
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 1/2] i2c: mux: demux-pinctrl: use proper parent device for demux adapter

Quoted 6 lines · Wolfram Sang

Due to a typo, the wrong parent device was assigned to the newly created demuxing adapter device. It got connected to the demuxing platform device but not to the selected parent I2C adapter device. Fix it to get a proper parent-child relationship of the demuxed busses, needed also for proper PM.

Should this one have a Fixes: tag? Should it go to current or next? Is a backport to stable good enough?

Cheers,
Peter

Quoted 19 lines
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/muxes/i2c-demux-pinctrl.c +1 -1
index 428de4c97fb2..035032e20327 100644
@@ -106,7 +106,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
 	priv->cur_adap.owner = THIS_MODULE;
 	priv->cur_adap.algo = &priv->algo;
 	priv->cur_adap.algo_data = priv;
-	priv->cur_adap.dev.parent = priv->dev;
+	priv->cur_adap.dev.parent = &adap->dev;
 	priv->cur_adap.class = adap->class;
 	priv->cur_adap.retries = adap->retries;
 	priv->cur_adap.timeout = adap->timeout;
#3 lore raw

Re: [PATCH 1/2] i2c: mux: demux-pinctrl: use proper parent device for demux adapter

Quoted 10 lines · Peter Rosin
Quoted 6 lines · Wolfram Sang

Due to a typo, the wrong parent device was assigned to the newly created demuxing adapter device. It got connected to the demuxing platform device but not to the selected parent I2C adapter device. Fix it to get a proper parent-child relationship of the demuxed busses, needed also for proper PM.

Should this one have a Fixes: tag? Should it go to current or next? Is a backport to stable good enough?

A Fixes tag is probably apropriate. I don't think it should go to stable, though, because it will break a scheme a user might be using. This can't be avoided for a kernel upgrade here, but IMO we shouldn't enforce it for a stable update. Especially, given this is not a real bug, but more something improper. For the same reason, I'd think -next is good enough.

Thanks, will resend!

Wolfram

#4 lore raw

Re: [PATCH 1/2] i2c: mux: demux-pinctrl: use proper parent device for demux adapter

Quoted 12 lines · Wolfram Sang
Quoted 10 lines · Peter Rosin
Quoted 6 lines · Wolfram Sang

Due to a typo, the wrong parent device was assigned to the newly created demuxing adapter device. It got connected to the demuxing platform device but not to the selected parent I2C adapter device. Fix it to get a proper parent-child relationship of the demuxed busses, needed also for proper PM.

Should this one have a Fixes: tag? Should it go to current or next? Is a backport to stable good enough?

Quoted 8 lines

A Fixes tag is probably apropriate. I don't think it should go to stable, though, because it will break a scheme a user might be using. This can't be avoided for a kernel upgrade here, but IMO we shouldn't enforce it for a stable update. Especially, given this is not a real bug, but more something improper. For the same reason, I'd think -next is good enough.

Thanks, will resend!

Hmm, in that case, I think a Fixes tag is best left out, because I suspect the net effect is mostly a bunch of mails from the stable trees as the automatic patch-picker finds this patch. So, I plan to go with this patch.

Ok?

Cheers,
Peter

author maintainer
#5 lore raw

PATCH 2/2 i2c: mux: demux-pinctrl: add symlinks to the demux device in sysfs

In reply to Wolfram Sang

Similar to mux devices, create special symlinks to connect the demuxed bus with the demux device.

---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/i2c/muxes/i2c-demux-pinctrl.c +8 -0
index 035032e20327..d5e7d4aa6ee1 100644
@@ -116,6 +116,11 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
 	if (ret < 0)
 		goto err_with_put;
 
+	sysfs_create_link(&priv->cur_adap.dev.kobj, &priv->dev->kobj,
+			       "demux_device");
+	sysfs_create_link(&priv->dev->kobj, &priv->cur_adap.dev.kobj,
+			       "channel-0");
+
 	return 0;
 
  err_with_put:
@@ -135,6 +140,9 @@ static int i2c_demux_deactivate_master(struct i2c_demux_pinctrl_priv *priv)
 	if (cur < 0)
 		return 0;
 
+	sysfs_remove_link(&priv->dev->kobj, "channel-0");
+	sysfs_remove_link(&priv->cur_adap.dev.kobj, "demux_device");
+
 	i2c_del_adapter(&priv->cur_adap);
 	i2c_put_adapter(priv->chan[cur].parent_adap);
 
Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH 2/2] i2c: mux: demux-pinctrl: add symlinks to the demux device in sysfs

Quoted 22 lines · Wolfram Sang

Similar to mux devices, create special symlinks to connect the demuxed bus with the demux device.

---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/i2c/muxes/i2c-demux-pinctrl.c +5 -0
index 035032e20327..d5e7d4aa6ee1 100644
@@ -116,6 +116,11 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
 	if (ret < 0)
 		goto err_with_put;
 
+	sysfs_create_link(&priv->cur_adap.dev.kobj, &priv->dev->kobj,
+			       "demux_device");
+	sysfs_create_link(&priv->dev->kobj, &priv->cur_adap.dev.kobj,
+			       "channel-0");
+
 
Quoted 1 line

From sysfs.h:

int __must_check sysfs_create_link(...);

Cheers,
Peter

Quoted 14 lines
drivers/i2c/muxes/i2c-demux-pinctrl.c +3 -0
 	return 0;
 
  err_with_put:
@@ -135,6 +140,9 @@ static int i2c_demux_deactivate_master(struct i2c_demux_pinctrl_priv *priv)
 	if (cur < 0)
 		return 0;
 
+	sysfs_remove_link(&priv->dev->kobj, "channel-0");
+	sysfs_remove_link(&priv->cur_adap.dev.kobj, "demux_device");
+
 	i2c_del_adapter(&priv->cur_adap);
 	i2c_put_adapter(priv->chan[cur].parent_adap);
 
#7 lore raw

Re: [PATCH 2/2] i2c: mux: demux-pinctrl: add symlinks to the demux device in sysfs

Quoted 9 lines

drivers/i2c/muxes/i2c-demux-pinctrl.c static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne · line 123

Quoted 6 lines
drivers/i2c/muxes/i2c-demux-pinctrl.c +5 -0
+	sysfs_create_link(&priv->cur_adap.dev.kobj, &priv->dev->kobj,
+			       "demux_device");
+	sysfs_create_link(&priv->dev->kobj, &priv->cur_adap.dev.kobj,
+			       "channel-0");
+

From sysfs.h:
int __must_check sysfs_create_link(...);

Darn, right... Will fix!

#8 lore raw
In reply to Wolfram Sang
Quoted 7 lines · Wolfram Sang

While researching some PM behaviour within I2C, I found out that the i2c-demux driver does not play well with that due to broken relationship with other devices. Patch 1 ensures the right parent-child relationship. Patch 2 makes the connection between the demux device and the demuxed bus similar to that we have in the mux core.

Tested on a Renesas Lager board (R-Car H2).

Peter, I'd think these demux patches (and the single one later) should go via your tree. Let me know if you prefer that I pick them up.

#9 lore raw
Quoted 11 lines · Wolfram Sang
Quoted 7 lines · Wolfram Sang

While researching some PM behaviour within I2C, I found out that the i2c-demux driver does not play well with that due to broken relationship with other devices. Patch 1 ensures the right parent-child relationship. Patch 2 makes the connection between the demux device and the demuxed bus similar to that we have in the mux core.

Tested on a Renesas Lager board (R-Car H2).

Peter, I'd think these demux patches (and the single one later) should go via your tree. Let me know if you prefer that I pick them up.

Agreed, sorry for being a bit slow. I'll add some comments to the individual patches...

Cheers,
Peter