* [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
@ 2022-08-03 6:57 Sherry Sun
2022-08-03 8:16 ` Ahmad Fatoum
0 siblings, 1 reply; 7+ messages in thread
From: Sherry Sun @ 2022-08-03 6:57 UTC (permalink / raw)
To: gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam
Cc: linux-serial, linux-kernel, linux-imx
Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo support")
adds the use of dma_slave_config->peripheral_config/peripheral_size to
sdma driver, the client drivers like uart need to initialize the
peripheral_config/peripheral_size for sdma, otherwise, the random value
of local variable slave_config may cause unexpected peripheral_config
and make sdma mess up.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
drivers/tty/serial/imx.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 522445a8f666..bb8c2a712e94 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
/* one byte less than the watermark level to enable the aging timer */
slave_config.src_maxburst = RXTL_DMA - 1;
+ slave_config.peripheral_config = NULL;
+ slave_config.peripheral_size = 0;
ret = dmaengine_slave_config(sport->dma_chan_rx, &slave_config);
if (ret) {
dev_err(dev, "error in RX dma configuration.\n");
@@ -1346,6 +1348,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
slave_config.dst_addr = sport->port.mapbase + URTX0;
slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
slave_config.dst_maxburst = TXTL_DMA;
+ slave_config.peripheral_config = NULL;
+ slave_config.peripheral_size = 0;
ret = dmaengine_slave_config(sport->dma_chan_tx, &slave_config);
if (ret) {
dev_err(dev, "error in TX dma configuration.");
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 6:57 [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config Sherry Sun
@ 2022-08-03 8:16 ` Ahmad Fatoum
2022-08-03 9:15 ` Sherry Sun
0 siblings, 1 reply; 7+ messages in thread
From: Ahmad Fatoum @ 2022-08-03 8:16 UTC (permalink / raw)
To: Sherry Sun, gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam
Cc: linux-kernel, linux-serial, linux-imx
Hello Sherry,
On 03.08.22 08:57, Sherry Sun wrote:
> Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo support")
> adds the use of dma_slave_config->peripheral_config/peripheral_size to
> sdma driver, the client drivers like uart need to initialize the
> peripheral_config/peripheral_size for sdma, otherwise, the random value
> of local variable slave_config may cause unexpected peripheral_config
> and make sdma mess up.
>
If this a fix, please add a Fixes: tag. I am not sure it is though,
see below.
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
> drivers/tty/serial/imx.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 522445a8f666..bb8c2a712e94 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
This function starts with
struct dma_slave_config slave_config = {};
> slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> /* one byte less than the watermark level to enable the aging timer */
> slave_config.src_maxburst = RXTL_DMA - 1;
> + slave_config.peripheral_config = NULL;
> + slave_config.peripheral_size = 0;
So these are already zero-initialized.
> ret = dmaengine_slave_config(sport->dma_chan_rx, &slave_config);
> if (ret) {
> dev_err(dev, "error in RX dma configuration.\n");
> @@ -1346,6 +1348,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
> slave_config.dst_addr = sport->port.mapbase + URTX0;
> slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> slave_config.dst_maxburst = TXTL_DMA;
> + slave_config.peripheral_config = NULL;
> + slave_config.peripheral_size = 0;
Not sure if this is required. If preceding dmaengine_slave_config()
indeed makes clearing necessary, you should note that in the commit
message.
Cheers,
Ahmad
> ret = dmaengine_slave_config(sport->dma_chan_tx, &slave_config);
> if (ret) {
> dev_err(dev, "error in TX dma configuration.");
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 8:16 ` Ahmad Fatoum
@ 2022-08-03 9:15 ` Sherry Sun
2022-08-03 9:22 ` gregkh
2022-08-03 9:40 ` Uwe Kleine-König
0 siblings, 2 replies; 7+ messages in thread
From: Sherry Sun @ 2022-08-03 9:15 UTC (permalink / raw)
To: Ahmad Fatoum, gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam
Cc: linux-kernel, linux-serial, dl-linux-imx
> On 03.08.22 08:57, Sherry Sun wrote:
> > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > support") adds the use of
> > dma_slave_config->peripheral_config/peripheral_size to sdma driver,
> > the client drivers like uart need to initialize the
> > peripheral_config/peripheral_size for sdma, otherwise, the random
> > value of local variable slave_config may cause unexpected
> peripheral_config and make sdma mess up.
> >
>
> If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
Hi Ahmad, thanks for the comments.
I don't think this patch is a fix for a specific commit, so we don't need the Fixes tag.
>
> > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > ---
> > drivers/tty/serial/imx.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > 522445a8f666..bb8c2a712e94 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > *sport)
>
> This function starts with
>
> struct dma_slave_config slave_config = {};
>
> > slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > /* one byte less than the watermark level to enable the aging timer
> */
> > slave_config.src_maxburst = RXTL_DMA - 1;
> > + slave_config.peripheral_config = NULL;
> > + slave_config.peripheral_size = 0;
>
> So these are already zero-initialized.
I am not sure actually, I think initialize a struct with {} cannot guarantee that all members are initialized to 0, it may depend on the compiler.
Best regards
Sherry
>
> > ret = dmaengine_slave_config(sport->dma_chan_rx, &slave_config);
> > if (ret) {
> > dev_err(dev, "error in RX dma configuration.\n"); @@ -
> 1346,6
> > +1348,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
> > slave_config.dst_addr = sport->port.mapbase + URTX0;
> > slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > slave_config.dst_maxburst = TXTL_DMA;
> > + slave_config.peripheral_config = NULL;
> > + slave_config.peripheral_size = 0;
>
> Not sure if this is required. If preceding dmaengine_slave_config() indeed
> makes clearing necessary, you should note that in the commit message.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 9:15 ` Sherry Sun
@ 2022-08-03 9:22 ` gregkh
2022-08-03 9:30 ` Sherry Sun
2022-08-03 9:40 ` Uwe Kleine-König
1 sibling, 1 reply; 7+ messages in thread
From: gregkh @ 2022-08-03 9:22 UTC (permalink / raw)
To: Sherry Sun
Cc: Ahmad Fatoum, jirislaby, shawnguo, s.hauer, kernel, festevam,
linux-kernel, linux-serial, dl-linux-imx
On Wed, Aug 03, 2022 at 09:15:58AM +0000, Sherry Sun wrote:
> > On 03.08.22 08:57, Sherry Sun wrote:
> > > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > > support") adds the use of
> > > dma_slave_config->peripheral_config/peripheral_size to sdma driver,
> > > the client drivers like uart need to initialize the
> > > peripheral_config/peripheral_size for sdma, otherwise, the random
> > > value of local variable slave_config may cause unexpected
> > peripheral_config and make sdma mess up.
> > >
> >
> > If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
>
> Hi Ahmad, thanks for the comments.
> I don't think this patch is a fix for a specific commit, so we don't need the Fixes tag.
>
> >
> > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > ---
> > > drivers/tty/serial/imx.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > > 522445a8f666..bb8c2a712e94 100644
> > > --- a/drivers/tty/serial/imx.c
> > > +++ b/drivers/tty/serial/imx.c
> > > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > > *sport)
> >
> > This function starts with
> >
> > struct dma_slave_config slave_config = {};
> >
> > > slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > > /* one byte less than the watermark level to enable the aging timer
> > */
> > > slave_config.src_maxburst = RXTL_DMA - 1;
> > > + slave_config.peripheral_config = NULL;
> > > + slave_config.peripheral_size = 0;
> >
> > So these are already zero-initialized.
>
> I am not sure actually, I think initialize a struct with {} cannot guarantee that all members are initialized to 0, it may depend on the compiler.
Not true, it's part of the C standard somewhere...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 9:22 ` gregkh
@ 2022-08-03 9:30 ` Sherry Sun
0 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-08-03 9:30 UTC (permalink / raw)
To: gregkh
Cc: Ahmad Fatoum, jirislaby, shawnguo, s.hauer, kernel, festevam,
linux-kernel, linux-serial, dl-linux-imx
> On Wed, Aug 03, 2022 at 09:15:58AM +0000, Sherry Sun wrote:
> > > On 03.08.22 08:57, Sherry Sun wrote:
> > > > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > > > support") adds the use of
> > > > dma_slave_config->peripheral_config/peripheral_size to sdma
> > > > driver, the client drivers like uart need to initialize the
> > > > peripheral_config/peripheral_size for sdma, otherwise, the random
> > > > value of local variable slave_config may cause unexpected
> > > peripheral_config and make sdma mess up.
> > > >
> > >
> > > If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
> >
> > Hi Ahmad, thanks for the comments.
> > I don't think this patch is a fix for a specific commit, so we don't need the
> Fixes tag.
> >
> > >
> > > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > > ---
> > > > drivers/tty/serial/imx.c | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > > > index
> > > > 522445a8f666..bb8c2a712e94 100644
> > > > --- a/drivers/tty/serial/imx.c
> > > > +++ b/drivers/tty/serial/imx.c
> > > > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > > > *sport)
> > >
> > > This function starts with
> > >
> > > struct dma_slave_config slave_config = {};
> > >
> > > > slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > > > /* one byte less than the watermark level to enable the aging
> > > > timer
> > > */
> > > > slave_config.src_maxburst = RXTL_DMA - 1;
> > > > + slave_config.peripheral_config = NULL;
> > > > + slave_config.peripheral_size = 0;
> > >
> > > So these are already zero-initialized.
> >
> > I am not sure actually, I think initialize a struct with {} cannot guarantee that
> all members are initialized to 0, it may depend on the compiler.
>
> Not true, it's part of the C standard somewhere...
>
Hi Greg, okay, thanks for the confirmation!
Then I think this patch is not needed any more. ^_^
Best regards
Sherry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 9:15 ` Sherry Sun
2022-08-03 9:22 ` gregkh
@ 2022-08-03 9:40 ` Uwe Kleine-König
2022-08-03 9:51 ` Sherry Sun
1 sibling, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2022-08-03 9:40 UTC (permalink / raw)
To: Sherry Sun
Cc: Ahmad Fatoum, gregkh, jirislaby, shawnguo, s.hauer, kernel,
festevam, linux-kernel, linux-serial, dl-linux-imx
[-- Attachment #1: Type: text/plain, Size: 2369 bytes --]
On Wed, Aug 03, 2022 at 09:15:58AM +0000, Sherry Sun wrote:
> > On 03.08.22 08:57, Sherry Sun wrote:
> > > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > > support") adds the use of
> > > dma_slave_config->peripheral_config/peripheral_size to sdma driver,
> > > the client drivers like uart need to initialize the
> > > peripheral_config/peripheral_size for sdma, otherwise, the random
> > > value of local variable slave_config may cause unexpected
> > peripheral_config and make sdma mess up.
> > >
> >
> > If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
>
> Hi Ahmad, thanks for the comments.
> I don't think this patch is a fix for a specific commit, so we don't need the Fixes tag.
>
> >
> > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > ---
> > > drivers/tty/serial/imx.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > > 522445a8f666..bb8c2a712e94 100644
> > > --- a/drivers/tty/serial/imx.c
> > > +++ b/drivers/tty/serial/imx.c
> > > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > > *sport)
> >
> > This function starts with
> >
> > struct dma_slave_config slave_config = {};
> >
> > > slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > > /* one byte less than the watermark level to enable the aging timer
> > */
> > > slave_config.src_maxburst = RXTL_DMA - 1;
> > > + slave_config.peripheral_config = NULL;
> > > + slave_config.peripheral_size = 0;
> >
> > So these are already zero-initialized.
>
> I am not sure actually, I think initialize a struct with {} cannot
> guarantee that all members are initialized to 0, it may depend on the
> compiler.
I'm sure and even reverified in my C book[1].
struct mystruct variable = {};
results in all components being initialized to their default initial
value (which is 0 for numbers and NULL for pointers). This works for
automatic variables since "Standard C" which should cover everthing that
is capable to compile today's kernel.
Best regards
Uwe
[1] C - A Reference Manual, 978-0130895929
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
2022-08-03 9:40 ` Uwe Kleine-König
@ 2022-08-03 9:51 ` Sherry Sun
0 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-08-03 9:51 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Ahmad Fatoum, gregkh, jirislaby, shawnguo, s.hauer, kernel,
festevam, linux-kernel, linux-serial, dl-linux-imx
> Subject: Re: [PATCH] tty: serial: imx: initialize
> peripheral_config/peripheral_size for sdma config
>
> On Wed, Aug 03, 2022 at 09:15:58AM +0000, Sherry Sun wrote:
> > > On 03.08.22 08:57, Sherry Sun wrote:
> > > > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > > > support") adds the use of
> > > > dma_slave_config->peripheral_config/peripheral_size to sdma
> > > > driver, the client drivers like uart need to initialize the
> > > > peripheral_config/peripheral_size for sdma, otherwise, the random
> > > > value of local variable slave_config may cause unexpected
> > > peripheral_config and make sdma mess up.
> > > >
> > >
> > > If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
> >
> > Hi Ahmad, thanks for the comments.
> > I don't think this patch is a fix for a specific commit, so we don't need the
> Fixes tag.
> >
> > >
> > > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > > ---
> > > > drivers/tty/serial/imx.c | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > > > index
> > > > 522445a8f666..bb8c2a712e94 100644
> > > > --- a/drivers/tty/serial/imx.c
> > > > +++ b/drivers/tty/serial/imx.c
> > > > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > > > *sport)
> > >
> > > This function starts with
> > >
> > > struct dma_slave_config slave_config = {};
> > >
> > > > slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > > > /* one byte less than the watermark level to enable the aging
> > > > timer
> > > */
> > > > slave_config.src_maxburst = RXTL_DMA - 1;
> > > > + slave_config.peripheral_config = NULL;
> > > > + slave_config.peripheral_size = 0;
> > >
> > > So these are already zero-initialized.
> >
> > I am not sure actually, I think initialize a struct with {} cannot
> > guarantee that all members are initialized to 0, it may depend on the
> > compiler.
>
> I'm sure and even reverified in my C book[1].
>
> struct mystruct variable = {};
>
> results in all components being initialized to their default initial value (which
> is 0 for numbers and NULL for pointers). This works for automatic variables
> since "Standard C" which should cover everthing that is capable to compile
> today's kernel.
>
> Best regards
> Uwe
>
> [1] C - A Reference Manual, 978-0130895929
>
Hi Uwe, wow, this really resolved my confusion, thanks a lot for your confirmation! ^_^
Best regards
Sherry
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-08-03 9:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 6:57 [PATCH] tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config Sherry Sun
2022-08-03 8:16 ` Ahmad Fatoum
2022-08-03 9:15 ` Sherry Sun
2022-08-03 9:22 ` gregkh
2022-08-03 9:30 ` Sherry Sun
2022-08-03 9:40 ` Uwe Kleine-König
2022-08-03 9:51 ` Sherry Sun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.