tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
Subsystems (2)
PATCH 1/1 tty: serial: imx: initialize peripheral_config/peripheral_size for sdma config
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.
--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/imx.c +4 -0
@@ -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." );
Signature · 1 line
2.17.1
Hello Sherry,
Quoted 7 lines · Sherry Sun
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 variableslave_configmay cause unexpectedperipheral_configand make sdma mess up.
If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport)
Quoted 10 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)
This function starts with
struct dma_slave_config slave_config = {};
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 5 lines
drivers/tty/serial/imx.c +2
-0slave_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.
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1352
Quoted 9 lines
drivers/tty/serial/imx.c +2
-0ret =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
Quoted 3 lines
drivers/tty/serial/imx.c +0
-0ret =dmaengine_slave_config (sport->dma_chan_tx, &slave_config);if (ret) {dev_err (dev,"error in TX dma configuration." );
Signature · 4 lines
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 |
Quoted 11 lines · Sherry Sun
Quoted 6 lines
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 variableslave_configmay cause unexpected
peripheral_configand make sdma mess up.Quoted 1 line
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.
Quoted 17 lines
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1320
Quoted 12 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c index renamed from drivers/tty/serial/imx.c +0
-0
522445a8f666..bb8c2a712e94100644drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)This function starts with
struct
dma_slave_configslave_config= {};
Quoted 8 lines
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1322
Quoted 2 lines
drivers/tty/serial/imx.c +0
-0slave_config.src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;/* one byte less than the watermark level to enable the aging timer */
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 3 lines
drivers/tty/serial/imx.c +2
-0slave_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
Quoted 15 lines
Quoted 4 lines
drivers/tty/serial/imx.c +0
-0ret =dmaengine_slave_config (sport->dma_chan_rx, &slave_config);if (ret) {
dev_err(dev, "error in RX dma configuration.\n"); @@ -1346,6
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1352
Quoted 6 lines
+1348,8 @@ static int
imx_uart_dma_init(struct imx_port *sport)drivers/tty/serial/imx.c +2
-0slave_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.
[email protected]
maintainerQuoted 34 lines · Sherry Sun
Quoted 11 lines · Sherry Sun
Quoted 6 lines
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 variableslave_configmay cause unexpected
peripheral_configand make sdma mess up.Quoted 1 line
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.Quoted 19 lines
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1320
Quoted 12 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c index renamed from drivers/tty/serial/imx.c +0
-0
522445a8f666..bb8c2a712e94100644drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)This function starts with
struct
dma_slave_configslave_config= {};Quoted 2 lines
drivers/tty/serial/imx.c +0
-0slave_config.src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;/* one byte less than the watermark level to enable the aging timer
Quoted 8 lines
Quoted 6 lines
*/
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 3 lines
drivers/tty/serial/imx.c +2
-0slave_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
Quoted 46 lines · Sherry Sun
Quoted 7 lines
Quoted 7 lines · Sherry Sun
Quoted 6 lines
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 variableslave_configmay cause unexpectedQuoted 7 lines
Quoted 4 lines
peripheral_configand make sdma mess up.Quoted 1 line
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 theFixes tag.
Quoted 29 lines
Quoted 28 lines
Quoted 13 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c +0
-0index
522445a8f666..bb8c2a712e94100644drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1320
Quoted 1 line
drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)This function starts with
struct
dma_slave_configslave_config= {};Quoted 3 lines
drivers/tty/serial/imx.c +0
-0slave_config.src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;/* one byte less than the watermark level to enable the aging timer
*/
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 3 lines
drivers/tty/serial/imx.c +2
-0slave_config.src_maxburst =RXTL_DMA -1 ; + slave_config.peripheral_config =NULL ; + slave_config.peripheral_size =0 ;So these are already zero-initialized.
Quoted 5 lines
Quoted 1 line
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
Quoted 41 lines · Sherry Sun
Quoted 11 lines · Sherry Sun
Quoted 6 lines
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 variableslave_configmay cause unexpected
peripheral_configand make sdma mess up.Quoted 1 line
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.Quoted 17 lines
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1320
Quoted 12 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c index renamed from drivers/tty/serial/imx.c +0
-0
522445a8f666..bb8c2a712e94100644drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)This function starts with
struct
dma_slave_configslave_config= {};Quoted 8 lines
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1322
Quoted 2 lines
drivers/tty/serial/imx.c +0
-0slave_config.src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;/* one byte less than the watermark level to enable the aging timer */
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 3 lines
drivers/tty/serial/imx.c +2
-0slave_config.src_maxburst =RXTL_DMA -1 ; + slave_config.peripheral_config =NULL ; + slave_config.peripheral_size =0 ;So these are already zero-initialized.
Quoted 3 lines
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
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 62 lines
Subject: Re: [PATCH] tty: serial: imx: initialize
peripheral_config/peripheral_size for sdma configQuoted 7 lines · Sherry Sun
Quoted 7 lines · Sherry Sun
Quoted 6 lines
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 variableslave_configmay cause unexpectedQuoted 7 lines
Quoted 4 lines
peripheral_configand make sdma mess up.Quoted 1 line
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 theFixes tag.
Quoted 29 lines
Quoted 22 lines
Quoted 13 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/imx.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/tty/serial/imx.c +0
-0index
522445a8f666..bb8c2a712e94100644drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port · line 1320
Quoted 1 line
drivers/tty/serial/imx.c +0
-0@@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port *sport)This function starts with
struct
dma_slave_configslave_config= {};Quoted 3 lines
drivers/tty/serial/imx.c +0
-0slave_config.src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ;/* one byte less than the watermark level to enable the aging timer
Quoted 6 lines
*/
drivers/tty/serial/imx.c static int imx_uart_dma_init(struct imx_port *sport) · line 1324
Quoted 3 lines
drivers/tty/serial/imx.c +2
-0slave_config.src_maxburst =RXTL_DMA -1 ; + slave_config.peripheral_config =NULL ; + slave_config.peripheral_size =0 ;So these are already zero-initialized.
Quoted 3 lines
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.
Quoted 5 lines
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