i3c: master: svc: some bug fixes and add runtime pm support
Subsystems (2)
v4 cover i3c: master: svc: some bug fixes and add runtime pm support
Hi,
V4 changes:
- New patches:
- i3c: master: svc: separate err, fifo and disable interrupt of reset function
- i3c: master: svc: add the missing module device table
- i3c: master: svc: enable the interrupt in the enable ibi function
- i3c: master: svc: add support for slave to stop returning data
- Only use COMPLETE flag in the read function.
- Add a reset before each transfer.
- i3c: master: svc: add runtime pm support
- error path emit_stop only used in svc_i3c_master_do_daa() for one time, so remove it. Or it needs another goto command at the end of the function to skip it and to go to rpm_out.
V3 changes:
- i3c: master: svc: add runtime pm support:
- restore the error path of probe function
- enable runtime pm just before i3c module reset
V2 changes:
- align the parameters of the function in the second patch
- add a new patch to support runtime PM.
Clark Wang (8):
i3c: master: svc: move module reset behind clk enable
i3c: master: svc: fix atomic issue
i3c: master: svc: separate err, fifo and disable interrupt of reset
function
i3c: master: svc: add support for slave to stop returning data
i3c: master: svc: set ODSTOP to let I2C device see the STOP signal
i3c: master: svc: add runtime pm support
i3c: master: svc: add the missing module device table
i3c: master: svc: enable the interrupt in the enable ibi function
drivers/i3c/master/svc-i3c-master.c | 307 +++++++++++++++++++++------- 1 file changed, 231 insertions(+), 76 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/8 i3c: master: svc: move module reset behind clk enable
Reset I3C module will R/W its regs, so enable its clocks first.
---
V2/V3/V4: No change.
--- drivers/i3c/master/svc-i3c-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/svc-i3c-master.c +2 -2
@@ -1381,8 +1381,6 @@ static int svc_i3c_master_probe(struct platform_device *pdev) master->dev = dev; -svc_i3c_master_reset (master); - ret =clk_prepare_enable (master->pclk);if (ret)return ret;
@@ -1419,6 +1417,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev)platform_set_drvdata (pdev, master); +svc_i3c_master_reset (master); +/* Register the master */ ret =i3c_master_register (&master->base, &pdev->dev, &svc_i3c_master_ops, false);
Signature · 1 line
2.25.1
PATCH v4 2/8 i3c: master: svc: fix atomic issue
In reply to Clark Wangdo_daa_locked() function is in a spin lock environment, use readl_poll_timeout_atomic() to replace the origin readl_poll_timeout().
---
V3/V4: No change.
V2: align the parameters of the function.
--- drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/i3c/master/svc-i3c-master.c +15 -11
@@ -656,8 +656,10 @@ static int svc_i3c_master_readb(struct svc_i3c_master *master, u8 *dst,u32 reg;for (i =0 ; i < len; i++) { - ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg, -SVC_I3C_MSTATUS_RXPEND (reg),0 ,1000 ); + ret =readl_poll_timeout_atomic (master->regs +SVC_I3C_MSTATUS , + reg, +SVC_I3C_MSTATUS_RXPEND (reg), +0 ,1000 );if (ret)return ret;
@@ -687,10 +689,11 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,* Either one slave will send its ID, or the assignment process * is done. */ - ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg, -SVC_I3C_MSTATUS_RXPEND (reg) | -SVC_I3C_MSTATUS_MCTRLDONE (reg), -1 ,1000 ); + ret =readl_poll_timeout_atomic (master->regs +SVC_I3C_MSTATUS , + reg, +SVC_I3C_MSTATUS_RXPEND (reg) | +SVC_I3C_MSTATUS_MCTRLDONE (reg), +1 ,1000 );if (ret)return ret;
@@ -744,11 +747,12 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master, }/* Wait for the slave to be ready to receive its address */ - ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg, -SVC_I3C_MSTATUS_MCTRLDONE (reg) && -SVC_I3C_MSTATUS_STATE_DAA (reg) && -SVC_I3C_MSTATUS_BETWEEN (reg), -0 ,1000 ); + ret =readl_poll_timeout_atomic (master->regs +SVC_I3C_MSTATUS , + reg, +SVC_I3C_MSTATUS_MCTRLDONE (reg) && +SVC_I3C_MSTATUS_STATE_DAA (reg) && +SVC_I3C_MSTATUS_BETWEEN (reg), +0 ,1000 );if (ret)return ret;
Signature · 1 line
2.25.1
PATCH v4 3/8 i3c: master: svc: separate err, fifo and disable interrupt of reset function
In reply to Clark WangSometimes only need to reset err and fifo regs, so split the origin reset function to three functions.
Put them at the top of the file, to let more functions can call them.
---
V4: New patch in this patchset
--- drivers/i3c/master/svc-i3c-master.c | 59 +++++++++++++++++------------ 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/i3c/master/svc-i3c-master.c +34 -25
@@ -236,6 +236,40 @@ static void svc_i3c_master_disable_interrupts(struct svc_i3c_master *master)writel (mask, master->regs +SVC_I3C_MINTCLR ); } +static void svc_i3c_master_clear_merrwarn (struct svc_i3c_master *master) +{ +/* Clear pending warnings */ +writel (readl (master->regs +SVC_I3C_MERRWARN ), + master->regs +SVC_I3C_MERRWARN ); +} + +static void svc_i3c_master_flush_fifo (struct svc_i3c_master *master) +{ +/* Flush FIFOs */ +writel (SVC_I3C_MDATACTRL_FLUSHTB |SVC_I3C_MDATACTRL_FLUSHRB , + master->regs +SVC_I3C_MDATACTRL ); +} + +static void svc_i3c_master_reset_fifo_trigger (struct svc_i3c_master *master) +{ +u32 reg; + +/* Set RX and TX tigger levels, flush FIFOs */ + reg =SVC_I3C_MDATACTRL_FLUSHTB | +SVC_I3C_MDATACTRL_FLUSHRB | +SVC_I3C_MDATACTRL_UNLOCK_TRIG | +SVC_I3C_MDATACTRL_TXTRIG_FIFO_NOT_FULL | +SVC_I3C_MDATACTRL_RXTRIG_FIFO_NOT_EMPTY ; +writel (reg, master->regs +SVC_I3C_MDATACTRL ); +} + +static void svc_i3c_master_reset (struct svc_i3c_master *master) +{ +svc_i3c_master_clear_merrwarn (master); +svc_i3c_master_reset_fifo_trigger (master); +svc_i3c_master_disable_interrupts (master); +} +static inline struct svc_i3c_master *to_svc_i3c_master (struct i3c_master_controller *master) {
@@ -279,12 +313,6 @@ static void svc_i3c_master_emit_stop(struct svc_i3c_master *master)udelay (1 ); } -static void svc_i3c_master_clear_merrwarn (struct svc_i3c_master *master) -{ -writel (readl (master->regs +SVC_I3C_MERRWARN ), - master->regs +SVC_I3C_MERRWARN ); -} -static int svc_i3c_master_handle_ibi (struct svc_i3c_master *master,struct i3c_dev_desc *dev) {
@@ -1334,25 +1362,6 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .disable_ibi = svc_i3c_master_disable_ibi, }; -static void svc_i3c_master_reset (struct svc_i3c_master *master) -{ -u32 reg; - -/* Clear pending warnings */ -writel (readl (master->regs +SVC_I3C_MERRWARN ), - master->regs +SVC_I3C_MERRWARN ); - -/* Set RX and TX tigger levels, flush FIFOs */ - reg =SVC_I3C_MDATACTRL_FLUSHTB | -SVC_I3C_MDATACTRL_FLUSHRB | -SVC_I3C_MDATACTRL_UNLOCK_TRIG | -SVC_I3C_MDATACTRL_TXTRIG_FIFO_NOT_FULL | -SVC_I3C_MDATACTRL_RXTRIG_FIFO_NOT_EMPTY ; -writel (reg, master->regs +SVC_I3C_MDATACTRL ); - -svc_i3c_master_disable_interrupts (master); -} -static int svc_i3c_master_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH V4 3/8] i3c: master: svc: separate err, fifo and disable interrupt of reset function
Hi Clark,
Clark Wang <[email protected]> wrote on Mon, 9 Aug 2021 14:36:40 +0800:
Quoted 6 lines
Sometimes only need to reset err and fifo regs, so split the origin reset function to three functions.
Put them at the top of the file, to let more functions can call them.Signed-off-by Clark Wang <[email protected]>Reviewed-by Jun Li <[email protected]>
Thanks,
Miquèl
PATCH v4 4/8 i3c: master: svc: add support for slave to stop returning data
In reply to Clark WangWhen i3c controller reads data from slave device, slave device can stop returning data with an ACK after any byte.
Add this support for svc i3c controller. Otherwise, it will go TIMEOUT error path when the slave device ends the read operation early.
---
V4 changes:
- Only use COMPLETE flag in the read function.
- Add a reset before each transfer.
V2/V3: No change.
--- drivers/i3c/master/svc-i3c-master.c | 56 ++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 17 deletions(-)
drivers/i3c/master/svc-i3c-master.c +39 -17
@@ -896,27 +896,35 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)static int svc_i3c_master_read (struct svc_i3c_master *master,u8 *in,unsigned int len) { -int offset =0 , i, ret; -u32 mdctrl; +int offset =0 , i; +u32 mdctrl, mstatus; +bool completed = false; +unsigned int count; +unsigned long start = jiffies; -while (offset < len) { -unsigned int count; +while (!completed) { + mstatus =readl (master->regs +SVC_I3C_MSTATUS ); +if (SVC_I3C_MSTATUS_COMPLETE (mstatus) !=0 ) + completed = true; - ret =readl_poll_timeout (master->regs +SVC_I3C_MDATACTRL , - mdctrl, - !(mdctrl &SVC_I3C_MDATACTRL_RXEMPTY ), -0 ,1000 ); -if (ret) -return ret; +if (time_after (jiffies, start +msecs_to_jiffies (1000 ))) { +dev_dbg (master->dev,"<%s> timeout\n" , __func__); +return -ETIMEDOUT ; + } + mdctrl =readl (master->regs +SVC_I3C_MDATACTRL ); count =SVC_I3C_MDATACTRL_RXCOUNT (mdctrl); +if (offset + count > len) { +dev_err (master->dev,"<%s> recv len too long!\n" , + __func__); +return -EINVAL ; + }for (i =0 ; i < count; i++) in[offset + i] =readl (master->regs +SVC_I3C_MRDATAB ); - offset += count; } -return 0 ; +return offset; } static int svc_i3c_master_write(struct svc_i3c_master *master,
@@ -949,7 +957,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,static int svc_i3c_master_xfer (struct svc_i3c_master *master,bool rnw,unsigned int xfer_type,u8 addr,u8 *in,const u8 *out,unsigned int xfer_len, -unsigned int read_len,bool continued) +unsigned int *read_len,bool continued) {u32 reg;int ret;
@@ -959,7 +967,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,SVC_I3C_MCTRL_IBIRESP_NACK |SVC_I3C_MCTRL_DIR (rnw) |SVC_I3C_MCTRL_ADDR (addr) | -SVC_I3C_MCTRL_RDTERM (read_len), +SVC_I3C_MCTRL_RDTERM (*read_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
@@ -971,17 +979,25 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, ret =svc_i3c_master_read (master, in, xfer_len); else ret =svc_i3c_master_write (master, out, xfer_len); -if (ret) +if (ret <0 ) goto emit_stop; +if (rnw) + *read_len = ret; ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg,SVC_I3C_MSTATUS_COMPLETE (reg),0 ,1000 );if (ret) goto emit_stop; +writel (SVC_I3C_MINT_COMPLETE , master->regs +SVC_I3C_MSTATUS ); -if (!continued) +if (!continued) {svc_i3c_master_emit_stop (master); +/* Wait idle if stop is sent. */ +readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg, + !SVC_I3C_MSTATUS_STATE (reg),0 ,1000 ); + } +return 0 ; emit_stop:
@@ -1039,12 +1055,15 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)if (!xfer)return ; +svc_i3c_master_clear_merrwarn (master); +svc_i3c_master_flush_fifo (master); +for (i =0 ; i < xfer->ncmds; i++) {struct svc_i3c_cmd *cmd = &xfer->cmds[i]; ret =svc_i3c_master_xfer (master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, - cmd->len, cmd->read_len, + cmd->len, &cmd->read_len, cmd->continued);if (ret)break ;
@@ -1173,6 +1192,9 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +if (cmd->read_len != xfer_len) + ccc->dests[0 ].payload.len = cmd->read_len; + ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Miquel Raynal
maintainerRe: [PATCH V4 4/8] i3c: master: svc: add support for slave to stop returning data
Hi Clark,
Just a few nitpicks.
Clark Wang <[email protected]> wrote on Mon, 9 Aug 2021 14:36:41 +0800:
Quoted 3 lines
When i3c controller reads data from slave device, slave device can stop returning data with an ACK after any byte.
Add this support for svc i3c controller. Otherwise, it will go TIMEOUT
"it will timeout when the slave..."
Quoted 34 lines
error path when the slave device ends the read operation early.
Signed-off-by Clark Wang <[email protected]>Reviewed-by Jun Li <[email protected]>---
V4 changes:
- Only use COMPLETE flag in the read function.
- Add a reset before each transfer.
V2/V3: No change.--- drivers/i3c/master/svc-i3c-master.c | 56 ++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 17 deletions(-)drivers/i3c/master/svc-i3c-master.c +8
-4@@ -896,27 +896,35 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)static int svc_i3c_master_read (struct svc_i3c_master *master,u8 *in,unsigned int len) { -int offset =0 , i, ret; -u32 mdctrl; +int offset =0 , i; +u32 mdctrl, mstatus; +bool completed = false; +unsigned int count; +unsigned long start = jiffies; -while (offset < len) { -unsigned int count; +while (!completed) { + mstatus =readl (master->regs +SVC_I3C_MSTATUS ); +if (SVC_I3C_MSTATUS_COMPLETE (mstatus) !=0 )
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_do_daa(struct i3c_master_controller *m) · line 911
Quoted 10 lines
drivers/i3c/master/svc-i3c-master.c +3
-6+ completed = true; - ret =readl_poll_timeout (master->regs +SVC_I3C_MDATACTRL , - mdctrl, - !(mdctrl &SVC_I3C_MDATACTRL_RXEMPTY ), -0 ,1000 ); -if (ret) -return ret; +if (time_after (jiffies, start +msecs_to_jiffies (1000 ))) { +dev_dbg (master->dev,"<%s> timeout\n" , __func__);
Can you get rid of this <%s>/__func__ parameter and just tell that we got a read timeout?
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_do_daa(struct i3c_master_controller *m) · line 921
Quoted 10 lines
drivers/i3c/master/svc-i3c-master.c +8
-0+return -ETIMEDOUT ; + } + mdctrl =readl (master->regs +SVC_I3C_MDATACTRL ); count =SVC_I3C_MDATACTRL_RXCOUNT (mdctrl); +if (offset + count > len) { +dev_err (master->dev,"<%s> recv len too long!\n" , + __func__); +return -EINVAL ; + }
And is this something theoretical or a real error that can happen?
If you think this is really needed, please keep the same dev_err() formatting as in the other places in this driver.
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_do_daa(struct i3c_master_controller *m) · line 915
Quoted 3 lines
drivers/i3c/master/svc-i3c-master.c +0
-1for (i =0 ; i < count; i++) in[offset + i] =readl (master->regs +SVC_I3C_MRDATAB ); -
Please keep that space
Quoted 27 lines
drivers/i3c/master/svc-i3c-master.c +3
-3offset += count; } -return 0 ; +return offset; } static int svc_i3c_master_write(struct svc_i3c_master *master,@@ -949,7 +957,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,static int svc_i3c_master_xfer (struct svc_i3c_master *master,bool rnw,unsigned int xfer_type,u8 addr,u8 *in,const u8 *out,unsigned int xfer_len, -unsigned int read_len,bool continued) +unsigned int *read_len,bool continued) {u32 reg;int ret;@@ -959,7 +967,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,SVC_I3C_MCTRL_IBIRESP_NACK |SVC_I3C_MCTRL_DIR (rnw) |SVC_I3C_MCTRL_ADDR (addr) | -SVC_I3C_MCTRL_RDTERM (read_len), +SVC_I3C_MCTRL_RDTERM (*read_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_xfer(struct svc_i3c_master *master, · line 983
Quoted 6 lines
drivers/i3c/master/svc-i3c-master.c +1
-1@@ -971,17 +979,25 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, ret =svc_i3c_master_read (master, in, xfer_len); else ret =svc_i3c_master_write (master, out, xfer_len); -if (ret) +if (ret <0 ) goto emit_stop;
Space?
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_xfer(struct svc_i3c_master *master, · line 990
Quoted 7 lines
drivers/i3c/master/svc-i3c-master.c +2
-0+if (rnw) + *read_len = ret; ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg,SVC_I3C_MSTATUS_COMPLETE (reg),0 ,1000 );if (ret) goto emit_stop;
Space?
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_xfer(struct svc_i3c_master *master, · line 998
Quoted 9 lines
drivers/i3c/master/svc-i3c-master.c +5
-1+writel (SVC_I3C_MINT_COMPLETE , master->regs +SVC_I3C_MSTATUS ); -if (!continued) +if (!continued) {svc_i3c_master_emit_stop (master); +/* Wait idle if stop is sent. */ +readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg, + !SVC_I3C_MSTATUS_STATE (reg),0 ,1000 );
Please use _MSTATUS_STATE_IDLE() for more clarity.
If this wait loop is really needed, better adding it to _master_emit_stop()? (in another patch)
Quoted 23 lines
drivers/i3c/master/svc-i3c-master.c +6
-1+ } +return 0 ; emit_stop:@@ -1039,12 +1055,15 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)if (!xfer)return ; +svc_i3c_master_clear_merrwarn (master); +svc_i3c_master_flush_fifo (master); +for (i =0 ; i < xfer->ncmds; i++) {struct svc_i3c_cmd *cmd = &xfer->cmds[i]; ret =svc_i3c_master_xfer (master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, - cmd->len, cmd->read_len, + cmd->len, &cmd->read_len, cmd->continued);if (ret)break ;
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, · line 1200
Quoted 9 lines
drivers/i3c/master/svc-i3c-master.c +3
-0@@ -1173,6 +1192,9 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,if (!wait_for_completion_timeout (&xfer->comp,msecs_to_jiffies (1000 )))svc_i3c_master_dequeue_xfer (master, xfer); +if (cmd->read_len != xfer_len) + ccc->dests[0 ].payload.len = cmd->read_len; + ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
Thanks,
Miquèl
PATCH v4 5/8 i3c: master: svc: set ODSTOP to let I2C device see the STOP signal
In reply to Clark WangIf using I2C/I3C mixed mode, need to set ODSTOP. Otherwise, the I2C devices cannot see the stop signal. It may cause message sending errors.
---
V2/V3/V4: No change.
--- drivers/i3c/master/svc-i3c-master.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/i3c/master/svc-i3c-master.c +5 -2
@@ -477,7 +477,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)struct i3c_device_info info = {};unsigned long fclk_rate, fclk_period_ns;unsigned int high_period_ns, od_low_period_ns; -u32 ppbaud, pplow, odhpp, odbaud, i2cbaud, reg; +u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg;int ret;/* Timings derivation */
@@ -507,6 +507,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)switch (bus->mode) {case I3C_BUS_MODE_PURE : i2cbaud =0 ; + odstop =0 ;break ;case I3C_BUS_MODE_MIXED_FAST :case I3C_BUS_MODE_MIXED_LIMITED :
@@ -515,6 +516,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)* between the high and low period does not really matter. */ i2cbaud =DIV_ROUND_UP (1000 , od_low_period_ns) -2 ; + odstop =1 ;break ;case I3C_BUS_MODE_MIXED_SLOW :/*
@@ -522,6 +524,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)* constraints as the FM+ mode. */ i2cbaud =DIV_ROUND_UP (2500 , od_low_period_ns) -2 ; + odstop =1 ;break ;default :return -EINVAL ;
@@ -530,7 +533,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) reg =SVC_I3C_MCONFIG_MASTER_EN |SVC_I3C_MCONFIG_DISTO (0 ) |SVC_I3C_MCONFIG_HKEEP (0 ) | -SVC_I3C_MCONFIG_ODSTOP (0 ) | +SVC_I3C_MCONFIG_ODSTOP (odstop) |SVC_I3C_MCONFIG_PPBAUD (ppbaud) |SVC_I3C_MCONFIG_PPLOW (pplow) | SVC_I3C_MCONFIG_ODBAUD(odbaud) |
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
PATCH v4 6/8 i3c: master: svc: add runtime pm support
In reply to Clark WangAdd runtime pm support to dynamically manage the clock.
---
V4:
- error path emit_stop only used in svc_i3c_master_do_daa() for one time, so remove it. Or it needs another goto command at the end of the function to skip it and to go to rpm_out.
V3:
- restore the error path of probe function
- enable runtime pm just before i3c module reset
V2: New patch in V2.
--- drivers/i3c/master/svc-i3c-master.c | 154 ++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 19 deletions(-)
drivers/i3c/master/svc-i3c-master.c +135 -19
@@ -17,7 +17,9 @@#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> /* Master Mode Registers */ #define SVC_I3C_MCONFIG 0x000
@@ -119,6 +121,7 @@#define SVC_MDYNADDR_ADDR (x) FIELD_PREP(GENMASK(7, 1), (x))#define SVC_I3C_MAX_DEVS 32 +#define SVC_I3C_PM_TIMEOUT_MS 1000/* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16
@@ -480,10 +483,20 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg;int ret; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev, +"<%s> cannot resume i3c bus master, err: %d\n" , + __func__, ret); +return ret; + } +/* Timings derivation */ fclk_rate =clk_get_rate (master->fclk); -if (!fclk_rate) -return -EINVAL ; +if (!fclk_rate) { + ret = -EINVAL ; + goto rpm_out; + } fclk_period_ns =DIV_ROUND_UP (1000000000 , fclk_rate);
@@ -527,7 +540,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) odstop =1 ;break ;default : -return -EINVAL ; + goto rpm_out; } reg = SVC_I3C_MCONFIG_MASTER_EN |
@@ -545,7 +558,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)/* Master core's registration */ ret =i3c_master_get_free_addr (m,0 );if (ret <0 ) -return ret; + goto rpm_out; info.dyn_addr = ret;
@@ -554,21 +567,35 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) ret =i3c_master_set_info (&master->base, &info);if (ret) -return ret; + goto rpm_out;svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); -return 0 ; +rpm_out: +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return ret; }static void svc_i3c_master_bus_cleanup (struct i3c_master_controller *m) {struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ; + }svc_i3c_master_disable_interrupts (master);/* Disable master */ writel (0 , master->regs +SVC_I3C_MCONFIG ); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); }static int svc_i3c_master_reserve_slot (struct svc_i3c_master *master)
@@ -867,31 +894,36 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)unsigned int dev_nb;int ret, i; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + } +spin_lock_irqsave (&master->xferqueue.lock, flags); ret =svc_i3c_master_do_daa_locked (master, addrs, &dev_nb);spin_unlock_irqrestore (&master->xferqueue.lock, flags); -if (ret) - goto emit_stop; +if (ret) { +svc_i3c_master_emit_stop (master); +svc_i3c_master_clear_merrwarn (master); + goto rpm_out; + }/* Register all devices who participated to the core */ for (i =0 ; i < dev_nb; i++) { ret =i3c_master_add_i3c_dev_locked (m, addrs[i]);if (ret) -return ret; + goto rpm_out; }/* Configure IBI auto-rules */ ret =svc_i3c_update_ibirules (master); -if (ret) { +if (ret)dev_err (master->dev,"Cannot handle such a list of devices" ); -return ret; - } -return 0 ; - -emit_stop: -svc_i3c_master_emit_stop (master); -svc_i3c_master_clear_merrwarn (master); +rpm_out: +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev);return ret; }
@@ -1058,6 +1090,12 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)if (!xfer)return ; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ; + } +svc_i3c_master_clear_merrwarn (master);svc_i3c_master_flush_fifo (master);
@@ -1072,6 +1110,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)break ; } +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + xfer->ret = ret;complete (&xfer->comp);
@@ -1348,6 +1389,14 @@ static void svc_i3c_master_free_ibi(struct i3c_dev_desc *dev)static int svc_i3c_master_enable_ibi (struct i3c_dev_desc *dev) {struct i3c_master_controller *m =i3c_dev_get_master (dev); +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + }return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); }
@@ -1355,8 +1404,15 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)static int svc_i3c_master_disable_ibi (struct i3c_dev_desc *dev) {struct i3c_master_controller *m =i3c_dev_get_master (dev); +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; -return i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); + ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return ret; } static void svc_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev,
@@ -1455,16 +1511,31 @@ static int svc_i3c_master_probe(struct platform_device *pdev)platform_set_drvdata (pdev, master); +pm_runtime_set_autosuspend_delay (&pdev->dev,SVC_I3C_PM_TIMEOUT_MS ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +svc_i3c_master_reset (master);/* Register the master */ ret =i3c_master_register (&master->base, &pdev->dev, &svc_i3c_master_ops, false);if (ret) - goto err_disable_sclk; + goto rpm_disable; + +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_put_autosuspend (&pdev->dev);return 0 ; +rpm_disable: +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); +pm_runtime_disable (&pdev->dev); + err_disable_sclk:clk_disable_unprepare (master->sclk);
@@ -1486,13 +1557,57 @@ static int svc_i3c_master_remove(struct platform_device *pdev)if (ret)return ret; +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_disable (&pdev->dev); + +return 0 ; +} + +static int __maybe_unused svc_i3c_runtime_suspend (struct device *dev) +{ +struct svc_i3c_master *master =dev_get_drvdata (dev); +clk_disable_unprepare (master->pclk);clk_disable_unprepare (master->fclk);clk_disable_unprepare (master->sclk); +pinctrl_pm_select_sleep_state (dev);return 0 ; } +static int __maybe_unused svc_i3c_runtime_resume (struct device *dev) +{ +struct svc_i3c_master *master =dev_get_drvdata (dev); +int ret =0 ; + +pinctrl_pm_select_default_state (dev); + ret =clk_prepare_enable (master->pclk); +if (ret) +return ret; + + ret =clk_prepare_enable (master->fclk); +if (ret) { +clk_disable_unprepare (master->pclk); +return ret; + } + + ret =clk_prepare_enable (master->sclk); +if (ret) { +clk_disable_unprepare (master->pclk); +clk_disable_unprepare (master->fclk); +return ret; + } + +return ret; +} + +static const struct dev_pm_ops svc_i3c_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +SET_RUNTIME_PM_OPS (svc_i3c_runtime_suspend, + svc_i3c_runtime_resume,NULL ) +}; +static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible ="silvaco,i3c-master" }, {/* sentinel */ },
@@ -1504,6 +1619,7 @@ static struct platform_driver svc_i3c_master = { .driver = { .name = "silvaco-i3c-master", .of_match_table = svc_i3c_master_of_match_tbl, + .pm = &svc_i3c_pm_ops, }, };module_platform_driver (svc_i3c_master);
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH V4 6/8] i3c: master: svc: add runtime pm support
Hi Clark,
Clark Wang <[email protected]> wrote on Mon, 9 Aug 2021 14:36:43 +0800:
Quoted 291 lines
Add runtime pm support to dynamically manage the clock.
Signed-off-by Clark Wang <[email protected]>Reviewed-by Jun Li <[email protected]>---
V4:
- error pathemit_stoponly used insvc_i3c_master_do_daa()for one time, so remove it. Or it needs another goto command at the end of the function to skip it and to go torpm_out.
V3:
- restore the error path of probe function
- enable runtime pm just before i3c module reset
V2: New patch in V2.--- drivers/i3c/master/svc-i3c-master.c | 154 ++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 19 deletions(-)drivers/i3c/master/svc-i3c-master.c +116
-19@@ -17,7 +17,9 @@#include <linux/list.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> /* Master Mode Registers */ #define SVC_I3C_MCONFIG 0x000@@ -119,6 +121,7 @@#define SVC_MDYNADDR_ADDR (x) FIELD_PREP(GENMASK(7, 1), (x))#define SVC_I3C_MAX_DEVS 32 +#define SVC_I3C_PM_TIMEOUT_MS 1000/* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16@@ -480,10 +483,20 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)u32 ppbaud, pplow, odhpp, odbaud, odstop, i2cbaud, reg;int ret; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev, +"<%s> cannot resume i3c bus master, err: %d\n" , + __func__, ret); +return ret; + } +/* Timings derivation */ fclk_rate =clk_get_rate (master->fclk); -if (!fclk_rate) -return -EINVAL ; +if (!fclk_rate) { + ret = -EINVAL ; + goto rpm_out; + } fclk_period_ns =DIV_ROUND_UP (1000000000 , fclk_rate);@@ -527,7 +540,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) odstop =1 ;break ;default : -return -EINVAL ; + goto rpm_out; } reg = SVC_I3C_MCONFIG_MASTER_EN |@@ -545,7 +558,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)/* Master core's registration */ ret =i3c_master_get_free_addr (m,0 );if (ret <0 ) -return ret; + goto rpm_out; info.dyn_addr = ret;@@ -554,21 +567,35 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m) ret =i3c_master_set_info (&master->base, &info);if (ret) -return ret; + goto rpm_out;svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); -return 0 ; +rpm_out: +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return ret; }static void svc_i3c_master_bus_cleanup (struct i3c_master_controller *m) {struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ; + }svc_i3c_master_disable_interrupts (master);/* Disable master */ writel (0 , master->regs +SVC_I3C_MCONFIG ); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); }static int svc_i3c_master_reserve_slot (struct svc_i3c_master *master)@@ -867,31 +894,36 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)unsigned int dev_nb;int ret, i; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + } +spin_lock_irqsave (&master->xferqueue.lock, flags); ret =svc_i3c_master_do_daa_locked (master, addrs, &dev_nb);spin_unlock_irqrestore (&master->xferqueue.lock, flags); -if (ret) - goto emit_stop; +if (ret) { +svc_i3c_master_emit_stop (master); +svc_i3c_master_clear_merrwarn (master); + goto rpm_out; + }/* Register all devices who participated to the core */ for (i =0 ; i < dev_nb; i++) { ret =i3c_master_add_i3c_dev_locked (m, addrs[i]);if (ret) -return ret; + goto rpm_out; }/* Configure IBI auto-rules */ ret =svc_i3c_update_ibirules (master); -if (ret) { +if (ret)dev_err (master->dev,"Cannot handle such a list of devices" ); -return ret; - } -return 0 ; - -emit_stop: -svc_i3c_master_emit_stop (master); -svc_i3c_master_clear_merrwarn (master); +rpm_out: +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev);return ret; }@@ -1058,6 +1090,12 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)if (!xfer)return ; + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ; + } +svc_i3c_master_clear_merrwarn (master);svc_i3c_master_flush_fifo (master);@@ -1072,6 +1110,9 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)break ; } +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + xfer->ret = ret;complete (&xfer->comp);@@ -1348,6 +1389,14 @@ static void svc_i3c_master_free_ibi(struct i3c_dev_desc *dev)static int svc_i3c_master_enable_ibi (struct i3c_dev_desc *dev) {struct i3c_master_controller *m =i3c_dev_get_master (dev); +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + }return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); }@@ -1355,8 +1404,15 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)static int svc_i3c_master_disable_ibi (struct i3c_dev_desc *dev) {struct i3c_master_controller *m =i3c_dev_get_master (dev); +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; -return i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); + ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return ret; } static void svc_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev,@@ -1455,16 +1511,31 @@ static int svc_i3c_master_probe(struct platform_device *pdev)platform_set_drvdata (pdev, master); +pm_runtime_set_autosuspend_delay (&pdev->dev,SVC_I3C_PM_TIMEOUT_MS ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_get_noresume (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +svc_i3c_master_reset (master);/* Register the master */ ret =i3c_master_register (&master->base, &pdev->dev, &svc_i3c_master_ops, false);if (ret) - goto err_disable_sclk; + goto rpm_disable; + +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_put_autosuspend (&pdev->dev);return 0 ; +rpm_disable: +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev); +pm_runtime_disable (&pdev->dev); + err_disable_sclk:clk_disable_unprepare (master->sclk);@@ -1486,13 +1557,57 @@ static int svc_i3c_master_remove(struct platform_device *pdev)if (ret)return ret; +pm_runtime_dont_use_autosuspend (&pdev->dev); +pm_runtime_disable (&pdev->dev); + +return 0 ; +} + +static int __maybe_unused svc_i3c_runtime_suspend (struct device *dev) +{ +struct svc_i3c_master *master =dev_get_drvdata (dev); +clk_disable_unprepare (master->pclk);clk_disable_unprepare (master->fclk);clk_disable_unprepare (master->sclk); +pinctrl_pm_select_sleep_state (dev);return 0 ; } +static int __maybe_unused svc_i3c_runtime_resume (struct device *dev) +{ +struct svc_i3c_master *master =dev_get_drvdata (dev); +int ret =0 ; + +pinctrl_pm_select_default_state (dev); + ret =clk_prepare_enable (master->pclk); +if (ret) +return ret; + + ret =clk_prepare_enable (master->fclk); +if (ret) { +clk_disable_unprepare (master->pclk); +return ret; + }
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_remove(struct platform_device *pdev) · line 1602
Quoted 10 lines
drivers/i3c/master/svc-i3c-master.c +10
-0+ + ret =clk_prepare_enable (master->sclk); +if (ret) { +clk_disable_unprepare (master->pclk); +clk_disable_unprepare (master->fclk); +return ret; + } + +return ret; +}
Can you create svc_i3c_master_prepare_clks() with the current content of the above helper, then, use that from _runtime_resume() and _probe() to avoid copying these lines?
With this change you can add my
Quoted 12 lines
drivers/i3c/master/svc-i3c-master.c +8
-0+ +static const struct dev_pm_ops svc_i3c_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +SET_RUNTIME_PM_OPS (svc_i3c_runtime_suspend, + svc_i3c_runtime_resume,NULL ) +}; +static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible ="silvaco,i3c-master" }, {/* sentinel */ },
drivers/i3c/master/svc-i3c-master.c static struct platform_driver svc_i3c_master = { · line 1625
Quoted 7 lines
drivers/i3c/master/svc-i3c-master.c +1
-0@@ -1504,6 +1619,7 @@ static struct platform_driver svc_i3c_master = { .driver = { .name = "silvaco-i3c-master", .of_match_table = svc_i3c_master_of_match_tbl, + .pm = &svc_i3c_pm_ops, }, };module_platform_driver (svc_i3c_master);
Thanks,
Miquèl
PATCH v4 7/8 i3c: master: svc: add the missing module device table
In reply to Clark WangThe missing MODULE_DEVICE_TABLE() will cause the svc-i3c-master cannot be auto probed when it is built in moudle.
So add it.
---
V4: New patch in this patchset
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -1612,6 +1612,7 @@ static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible = "silvaco,i3c-master" }, { /* sentinel */ }, }; +MODULE_DEVICE_TABLE (of, svc_i3c_master_of_match_tbl);static struct platform_driver svc_i3c_master = { .probe = svc_i3c_master_probe,
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH V4 7/8] i3c: master: svc: add the missing module device table
Hi Clark,
Clark Wang <[email protected]> wrote on Mon, 9 Aug 2021 14:36:44 +0800:
Quoted 6 lines
The missing
MODULE_DEVICE_TABLE()will cause the svc-i3c-master cannot be auto probed when it is built in moudle.
So add it.Signed-off-by Clark Wang <[email protected]>Reviewed-by Jun Li <[email protected]>
Quoted 11 lines
---
V4: New patch in this patchset--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)drivers/i3c/master/svc-i3c-master.c +0
-0
drivers/i3c/master/svc-i3c-master.c static const struct of_device_id svc_i3c_master_of_match_tbl[] = { · line 1618
Quoted 7 lines
drivers/i3c/master/svc-i3c-master.c +1
-0@@ -1612,6 +1612,7 @@ static const struct of_device_id svc_i3c_master_of_match_tbl[] = { { .compatible = "silvaco,i3c-master" }, { /* sentinel */ }, }; +MODULE_DEVICE_TABLE (of, svc_i3c_master_of_match_tbl);static struct platform_driver svc_i3c_master = { .probe = svc_i3c_master_probe,
Thanks,
Miquèl
PATCH v4 8/8 i3c: master: svc: enable the interrupt in the enable ibi function
In reply to Clark WangIf enable interrupt in the svc_i3c_master_bus_init() but do not call enable ibi in the device driver, it will cause a kernel dump in the svc_i3c_master_handle_ibi() when a slave start occurs on the i3c bus, because the data->ibi_pool is not initialized.
So only enable the interrupt in svc_i3c_master_enable_ibi() function.
---
V4: New patch in this patchset
--- drivers/i3c/master/svc-i3c-master.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i3c/master/svc-i3c-master.c +4 -2
@@ -569,8 +569,6 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)if (ret) goto rpm_out; -svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); - rpm_out:pm_runtime_mark_last_busy (master->dev);pm_runtime_put_autosuspend (master->dev);
@@ -1398,6 +1396,8 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)return ret; } +svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); +return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); }
@@ -1407,6 +1407,8 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)struct svc_i3c_master *master =to_svc_i3c_master (m);int ret; +svc_i3c_master_disable_interrupts (master); + ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );pm_runtime_mark_last_busy (master->dev);
Signature · 7 lines
2.25.1 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH V4 8/8] i3c: master: svc: enable the interrupt in the enable ibi function
Hi Clark,
Clark Wang <[email protected]> wrote on Mon, 9 Aug 2021 14:36:45 +0800:
Quoted 5 lines
If enable interrupt in the
svc_i3c_master_bus_init()but do not call enable ibi in the device driver, it will cause a kernel dump in thesvc_i3c_master_handle_ibi()when a slave start occurs on the i3c bus, because thedata->ibi_poolis not initialized.
So only enable the interrupt insvc_i3c_master_enable_ibi()function.
Is this situation actually happening or is this purely theoretical?
Anyway this doesn't hurt so:
Quoted 31 lines
Signed-off-by Clark Wang <[email protected]>---
V4: New patch in this patchset--- drivers/i3c/master/svc-i3c-master.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/i3c/master/svc-i3c-master.c +2
-2@@ -569,8 +569,6 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)if (ret) goto rpm_out; -svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); - rpm_out:pm_runtime_mark_last_busy (master->dev);pm_runtime_put_autosuspend (master->dev);@@ -1398,6 +1396,8 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)return ret; } +svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); +return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR ); }
drivers/i3c/master/svc-i3c-master.c static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev) · line 1414
Quoted 8 lines
drivers/i3c/master/svc-i3c-master.c +2
-0@@ -1407,6 +1407,8 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)struct svc_i3c_master *master =to_svc_i3c_master (m);int ret; +svc_i3c_master_disable_interrupts (master); + ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );pm_runtime_mark_last_busy (master->dev);
Thanks,
Miquèl