mbox series

[v5,0/5] spi: Add DMA mode support to spi-qcom-qspi

Message ID 1682328761-17517-1-git-send-email-quic_vnivarth@quicinc.com
Headers show
Series spi: Add DMA mode support to spi-qcom-qspi | expand

Message

Vijaya Krishna Nivarthi April 24, 2023, 9:32 a.m. UTC
There are large number of QSPI irqs that fire during boot/init and later
on every suspend/resume.
This could be made faster by doing DMA instead of PIO.
Below is comparison for number of interrupts raised in 2 scenarios...
Boot up and stabilise
Suspend/Resume

Sequence   PIO    DMA
=======================
Boot-up    69088  19284
S/R        5066   3430

Speed test results...
spi-nor read times in sec after 2 min uptime
============================================
PIO - Iterations-1000, min=3.18, max=3.74, avg=3.53
DMA - Iterations-1000, min=1.21, max=2.28, avg=1.79

spi-nor write times in sec after 2 min uptime
=============================================
PIO - Iterations-1000, min=3.20, max=8.24, avg=3.58
DMA - Iterations-1000, min=1.25, max=5.13, avg=1.82

Further testing performed...
a) multiple entries in sgt (simulated by max_dma_len = 1024)
b) fallback to pio (simulated by dma setup failure)

Vijaya Krishna Nivarthi (5):
  spi: dt-bindings: qcom,spi-qcom-qspi: Add iommus
  arm64: dts: qcom: sc7180: Add stream-id of qspi to iommus
  arm64: dts: qcom: sc7280: Add stream-id of qspi to iommus
  arm64: dts: qcom: sdm845: Add stream-id of qspi to iommus
  spi: spi-qcom-qspi: Add DMA mode support
---
v4 -> v5:
- Added Reviewed-by tags to dtsis
- Addressed review comments in driver

v3 -> v4:
- Dropped unaligned dma buffer handling
- Added sdm845, sc7180 dtsis to the series

v2 -> v3:
- Modified commit messages
- Made a change to driver based on re-review

v1 -> v2:
- Added documentation file to the series
- Made changes to driver based on HPG re-review
---
 .../bindings/spi/qcom,spi-qcom-qspi.yaml           |   3 +
 arch/arm64/boot/dts/qcom/sc7180.dtsi               |   1 +
 arch/arm64/boot/dts/qcom/sc7280.dtsi               |   1 +
 arch/arm64/boot/dts/qcom/sdm845.dtsi               |   1 +
 drivers/spi/spi-qcom-qspi.c                        | 218 ++++++++++++++++++++-
 5 files changed, 218 insertions(+), 6 deletions(-)

Comments

Douglas Anderson April 24, 2023, 2:51 p.m. UTC | #1
Hi,

On Mon, Apr 24, 2023 at 2:32 AM Vijaya Krishna Nivarthi
<quic_vnivarth@quicinc.com> wrote:
>
> Current driver supports only PIO mode.
>
> HW supports DMA, so add DMA mode support to the driver
> for better performance for larger xfers.
>
> Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
> ---
> v4 -> v5:
> - dropped xfer_mode
> - clear all interrupts in handle_err()
> - dont log ptr value
> - dropped some dev_err()
> - converted some dev_err() to dev_warn_once()
> - drop few redundant comments
> - can_dma() disabled if iommus not present in dev_node
> - other nits
>
> v3 -> v4:
> - corrected tabs spacing
> - dropped dma data descriptors
> - dropped INVALID from xfer_mode enum
> - qspi_buswidth_to_iomode() to return iomode without shifting
> - dropped non-functional change in qcom_qspi_set_speed()
> - drop redundant call to wmb()
> - fallback to pio if dma fails to setup
> - use dmam_pool_create() the devm version
> - thus drop dma_pool_destroy()
> - set dma_alignment field in probe()
> - other minor changes
>
> v2 -> v3:
> - dropped Reported-by tag
>
> v1 -> v2:
> - modified commit message
> - addressed kernel test robot error
> - correct placement of header file includes
> - added more comments
> - coding style related changes
> - renamed variables
> - used u32/u8 instead of uint32_t/8_t
> - removed unnecessary casting
> - retain same MSTR_CONFIG as PIO for DMA
> - unset fragment bit only for last cmd_desc of last xfer
> ---
>  drivers/spi/spi-qcom-qspi.c | 218 ++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 212 insertions(+), 6 deletions(-)

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Douglas Anderson May 25, 2023, 2:25 p.m. UTC | #2
Hi Bjorn,

On Mon, Apr 24, 2023 at 2:32 AM Vijaya Krishna Nivarthi
<quic_vnivarth@quicinc.com> wrote:
>
> There are large number of QSPI irqs that fire during boot/init and later
> on every suspend/resume.
> This could be made faster by doing DMA instead of PIO.
> Below is comparison for number of interrupts raised in 2 scenarios...
> Boot up and stabilise
> Suspend/Resume
>
> Sequence   PIO    DMA
> =======================
> Boot-up    69088  19284
> S/R        5066   3430
>
> Speed test results...
> spi-nor read times in sec after 2 min uptime
> ============================================
> PIO - Iterations-1000, min=3.18, max=3.74, avg=3.53
> DMA - Iterations-1000, min=1.21, max=2.28, avg=1.79
>
> spi-nor write times in sec after 2 min uptime
> =============================================
> PIO - Iterations-1000, min=3.20, max=8.24, avg=3.58
> DMA - Iterations-1000, min=1.25, max=5.13, avg=1.82
>
> Further testing performed...
> a) multiple entries in sgt (simulated by max_dma_len = 1024)
> b) fallback to pio (simulated by dma setup failure)
>
> Vijaya Krishna Nivarthi (5):
>   spi: dt-bindings: qcom,spi-qcom-qspi: Add iommus
>   arm64: dts: qcom: sc7180: Add stream-id of qspi to iommus
>   arm64: dts: qcom: sc7280: Add stream-id of qspi to iommus
>   arm64: dts: qcom: sdm845: Add stream-id of qspi to iommus
>   spi: spi-qcom-qspi: Add DMA mode support

Mark has landed the bindings / code changes:

b5762d95607e spi: spi-qcom-qspi: Add DMA mode support
64c05eb3a0f4 spi: dt-bindings: qcom,spi-qcom-qspi: Add iommus

...so I think the dts changes here are ready for you to land. There
are no hard dependencies here so you can land the dts without needing
the code changes.

Thanks!

-Doug
Bjorn Andersson May 27, 2023, 1:07 a.m. UTC | #3
On Mon, 24 Apr 2023 15:02:36 +0530, Vijaya Krishna Nivarthi wrote:
> There are large number of QSPI irqs that fire during boot/init and later
> on every suspend/resume.
> This could be made faster by doing DMA instead of PIO.
> Below is comparison for number of interrupts raised in 2 scenarios...
> Boot up and stabilise
> Suspend/Resume
> 
> [...]

Applied, thanks!

[2/5] arm64: dts: qcom: sc7180: Add stream-id of qspi to iommus
      commit: 8164116023acb6dd600776a3391d5b0cd7699adc
[3/5] arm64: dts: qcom: sc7280: Add stream-id of qspi to iommus
      commit: cc406006126e89c5330ff5c75da20deb5cafedf8
[4/5] arm64: dts: qcom: sdm845: Add stream-id of qspi to iommus
      commit: 0aa2811cf5eb2355cd91035b4a76a6120a5c6382

Best regards,