Re: [PATCH v3 1/3] i3c: master: dw: Report actual GET CCC payload length on success
Frank Li <[email protected]>
| Newsgroups | org.infradead.lists.linux-i3c,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <ajWWqkwDzzhEMXZO@lizhi-Precision-Tower-5810> |
On Wed, Jun 10, 2026 at 06:54:06PM -0700, [email protected] wrote: > From: Adrian Ng Ho Yin <[email protected]> > > On successful GET CCC transfers, set dests[0].payload.len from > RESPONSE_PORT_DATA_LEN so the I3C core receives the number of bytes > actually read. Core helpers such as i3c_master_getmrl_locked() use > dest.payload.len after the transfer to interpret the response. > > Save the requested length in a local variable before programming the > hardware so the caller's buffer size is not conflated with the bytes > received. > > Signed-off-by: Adrian Ng Ho Yin <[email protected]> > Signed-off-by: Tze Yee Ng <[email protected]> > --- > drivers/i3c/master/dw-i3c-master.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c > index 655693a2187e..06fdf8857b9c 100644 > --- a/drivers/i3c/master/dw-i3c-master.c > +++ b/drivers/i3c/master/dw-i3c-master.c > @@ -751,21 +751,24 @@ static int dw_i3c_ccc_set(struct dw_i3c_master *master, > static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc) > { > struct dw_i3c_cmd *cmd; > + u16 req_len; > int ret, pos; > > pos = dw_i3c_master_get_addr_pos(master, ccc->dests[0].addr); > if (pos < 0) > return pos; > > + req_len = ccc->dests[0].payload.len; > + > struct dw_i3c_xfer *xfer __free(kfree) = dw_i3c_master_alloc_xfer(master, 1); > if (!xfer) > return -ENOMEM; > > cmd = xfer->cmds; > cmd->rx_buf = ccc->dests[0].payload.data; > - cmd->rx_len = ccc->dests[0].payload.len; > + cmd->rx_len = req_len; > > - cmd->cmd_hi = COMMAND_PORT_ARG_DATA_LEN(ccc->dests[0].payload.len) | > + cmd->cmd_hi = COMMAND_PORT_ARG_DATA_LEN(req_len) | > COMMAND_PORT_TRANSFER_ARG; not sure how req_len help it. Prevously everything copy into cmd. now copy req_len then copy to cmd, No difference? > > cmd->cmd_lo = COMMAND_PORT_READ_TRANSFER | > @@ -780,7 +783,10 @@ static int dw_i3c_ccc_get(struct dw_i3c_master *master, struct i3c_ccc_cmd *ccc) > dw_i3c_master_dequeue_xfer(master, xfer); > > ret = xfer->ret; > - if (xfer->cmds[0].error == RESPONSE_ERROR_IBA_NACK) > + cmd = &xfer->cmds[0]; > + if (!ret) > + ccc->dests[0].payload.len = cmd->rx_len; Only this line is validate. Frank > + if (cmd->error == RESPONSE_ERROR_IBA_NACK) > ccc->err = I3C_ERROR_M2; > > return ret; > -- > 2.43.7 > -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c