i2c: mux: demux-pinctrl: improve device relationships
Subsystems (2)
Wolfram Sang
maintainercover 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
Wolfram Sang
maintainerPATCH 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
@@ -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
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
Signed-off-by Wolfram Sang <[email protected]>--- drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/muxes/i2c-demux-pinctrl.c +1
-1@@ -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;
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
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
Wolfram Sang
maintainerPATCH 2/2 i2c: mux: demux-pinctrl: add symlinks to the demux device in sysfs
In reply to Wolfram SangSimilar 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
@@ -116,6 +116,11 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 neif (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
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.
Signed-off-by Wolfram Sang <[email protected]>--- drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/i2c/muxes/i2c-demux-pinctrl.c +5
-0@@ -116,6 +116,11 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 neif (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
-0return 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);
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_checksysfs_create_link(...);
Darn, right... Will fix!
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.
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