spi: fsl-lpspi: Option to prevent FIFO under/overrun
Subsystems (3)
cover spi: fsl-lpspi: Option to prevent FIFO under/overrun
Certain devices don't work well when a transmit FIFO underrun or receive FIFO overrun occurs. Example is the SAF400x radio chip when running at high speed which leads to garbage being sent to/received from the chip. In which case, it should stall waiting for further data to be available before proceeding. This patch add option to configure the SPI controller to allow stalling (unset NOSTALL bit in CFGR1).
Hieu Tran Dang (2):
dt-bindings: spi: fsl-lpspi: Option to allow stalling
spi: fsl-lpspi: Option to prevent FIFO under/overrun
.../devicetree/bindings/spi/spi-fsl-lpspi.txt | 2 ++ drivers/spi/spi-fsl-lpspi.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/2 dt-bindings: spi: fsl-lpspi: Option to allow stalling
This patch add fsl,allow-stalling property documentation for fsl-lpspi
--- Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt +2 -0
@@ -6,6 +6,8 @@ Required properties: - reg : address and length of the lpspi master registers - interrupts : lpspi interrupt - clocks : lpspi clock specifier +- fsl,allow-stall : allow stalling of transfers when the transmit FIFO is empty + or when the receive FIFO is full Examples:
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 1/2] dt-bindings: spi: fsl-lpspi: Option to allow stalling
DT bindings should be sent to DT list.
Quoted 13 lines · Hieu Tran Dang
This patch add fsl,allow-stalling property documentation for fsl-lpspi
Signed-off-by Hieu Tran Dang <[email protected]>--- Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt +0
-0
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt Required properties: · line 10
Quoted 5 lines
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt +2
-0@@ -6,6 +6,8 @@ Required properties: - reg : address and length of the lpspi master registers - interrupts : lpspi interrupt - clocks : lpspi clock specifier +- fsl,allow-stall : allow stalling of transfers when the transmit FIFO is empty + or when the receive FIFO is full
This seems odd. That seems like what normal behavior should be.
Rob
Re: [PATCH 1/2] dt-bindings: spi: fsl-lpspi: Option to allow stalling
Quoted 3 lines
DT bindings should be sent to DT list.
DT bindings already sent to DT list, included here for completeness sake. Of course, this is my first patch to the kernel so I might have completely been wrong about the process. I can create another patch set to send to correct list if necessary.
Quoted 23 lines
Quoted 13 lines · Hieu Tran Dang
This patch add fsl,allow-stalling property documentation for fsl-lpspi
Signed-off-by Hieu Tran Dang <[email protected]>--- Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt +0
-0Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt Required properties: · line 10
Quoted 5 lines
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.txt +2
-0@@ -6,6 +6,8 @@ Required properties: - reg : address and length of the lpspi master registers - interrupts : lpspi interrupt - clocks : lpspi clock specifier +- fsl,allow-stall : allow stalling of transfers when the transmit FIFO is empty + or when the receive FIFO is fullThis seems odd. That seems like what normal behavior should be.
Quoted 1 line
Rob
Default value of the register is to allow stalling (NOSTALL bit not set) but the spi-fsl-lpspi driver defaults to setting the NOSTALL bit in CFGR1. To me, it's more logical to leave the NOSTALL bit off with fsl,nostall binding to set the bit but as I am not sure if there are other drivers depending on the NOSTALL bit being set and not wanting to break other drivers hence introduction of this binding to keep the current default behavior.
Mark Brown
maintainerRe: [PATCH 1/2] dt-bindings: spi: fsl-lpspi: Option to allow stalling
Quoted 7 lines · Đặng Trần Hiếu
Default value of the register is to allow stalling (NOSTALL bit not set) but the spi-fsl-lpspi driver defaults to setting the NOSTALL bit in CFGR1. To me, it's more logical to leave the NOSTALL bit off with fsl,nostall binding to set the bit but as I am not sure if there are other drivers depending on the NOSTALL bit being set and not wanting to break other drivers hence introduction of this binding to keep the current default behavior.
I can't see a situation where you'd actively want to report an error rather than stall, stalling allows us to handle things gracefully by restarting things. Even if it's a timeout situation it sounds like we can unblock by reading/writing the stalled FIFO, and normally you'd be resetting the entire IP anyway. I'd imagine the driver is this way either through an oversight or because there's some bug on some silicon which means that stalling breaks.
Probably best to just always enable stalling unless I'm misreading things, if it is silicon bugs on some versions then either a whitelist or blacklist of SoCs to enable on (depending on how common the bug is) would be the way forwards - that way SoCs where it works get the benefit.
Re: [PATCH 1/2] dt-bindings: spi: fsl-lpspi: Option to allow stalling
Agree. I will create new patch which will just allow stalling by default.
Vào Th 6, 28 thg 9, 2018 vào lúc 05:47 Mark Brown <[email protected]> đã viết:
Quoted 23 lines · Đặng Trần Hiếu
Quoted 8 lines
Default value of the register is to allow stalling (NOSTALL bit not set) but the spi-fsl-lpspi driver defaults to setting the NOSTALL bit in CFGR1. To me, it's more logical to leave the NOSTALL bit off with fsl,nostall binding to set the bit but as I am not sure if there are other drivers depending on the NOSTALL bit being set and not wanting to break other drivers hence introduction of this binding to keep the current default behavior.
I can't see a situation where you'd actively want to report an error rather than stall, stalling allows us to handle things gracefully by restarting things. Even if it's a timeout situation it sounds like we can unblock by reading/writing the stalled FIFO, and normally you'd be resetting the entire IP anyway. I'd imagine the driver is this way either through an oversight or because there's some bug on some silicon which means that stalling breaks.
Probably best to just always enable stalling unless I'm misreading things, if it is silicon bugs on some versions then either a whitelist or blacklist of SoCs to enable on (depending on how common the bug is) would be the way forwards - that way SoCs where it works get the benefit.
PATCH 2/2 spi: fsl-lpspi: Option to prevent FIFO under/overrun
In reply to Hieu Tran DangCertain devices don't work well when a transmit FIFO underrun or receive FIFO overrun occurs. Example is the SAF400x radio chip when running at high speed which leads to garbage being sent to/received from the chip. In which case, it should stall waiting for further data to be available before proceeding. This patch add option to configure the SPI controller to allow stalling (unset NOSTALL bit in CFGR1).
--- drivers/spi/spi-fsl-lpspi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-lpspi.c +9 -1
@@ -73,6 +73,7 @@ struct lpspi_config {u8 prescale;u16 mode;u32 speed_hz; +bool nostall; };struct fsl_lpspi_data {
@@ -276,7 +277,11 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi)fsl_lpspi_set_watermark (fsl_lpspi); - temp =CFGR1_PCSCFG |CFGR1_MASTER |CFGR1_NOSTALL ; + temp =CFGR1_PCSCFG |CFGR1_MASTER ; + +if (fsl_lpspi->config.nostall) + temp |=CFGR1_NOSTALL ; +if (fsl_lpspi->config.mode &SPI_CS_HIGH ) temp |=CFGR1_PCSPOL ;writel (temp, fsl_lpspi->base +IMX7ULP_CFGR1 );
@@ -475,6 +480,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev)clk_disable_unprepare (fsl_lpspi->clk); + fsl_lpspi->config.nostall = + !of_get_property (pdev->dev.of_node,"fsl,allow-stall" ,NULL ); + ret =devm_spi_register_master (&pdev->dev, master);if (ret <0 ) {dev_err (&pdev->dev,"spi_register_master error.\n" );
Signature · 1 line
2.17.1