linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Cc: broonie@kernel.org, thierry.reding@gmail.com,
	jonathanh@nvidia.com, linux-spi@vger.kernel.org,
	linux-tegra@vger.kernel.org, skomatineni@nvidia.com,
	ldewangan@nvidia.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] spi: tegra210-quad: native dma support
Date: Sun, 2 Oct 2022 12:37:15 +0200	[thread overview]
Message-ID: <CAMuHMdUoABDeLrdudfY09jGmCcnFpJmFGf0OieVBG6OuEpk7ZA@mail.gmail.com> (raw)
In-Reply-To: <20221001122148.9158-5-kyarlagadda@nvidia.com>

Hi Krishna,

On Sat, Oct 1, 2022 at 2:26 PM Krishna Yarlagadda
<kyarlagadda@nvidia.com> wrote:
> Enable Native DMA support for Tegra23 & Tegra24
>
> Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>

Thanks for your patch!

> --- a/drivers/spi/spi-tegra210-quad.c
> +++ b/drivers/spi/spi-tegra210-quad.c

> @@ -163,7 +169,7 @@
>  #define DATA_TRANSFER                          3
>
>  struct tegra_qspi_soc_data {
> -       bool has_dma;
> +       int has_dma;

unsigned int

Please rename the variable to e.g. "dma_mode", as "has_<foo>" suggests
it is a boolean flag.

>         bool cmb_xfer_capable;
>         unsigned int cs_count;
>  };

> @@ -629,23 +640,35 @@ static int tegra_qspi_start_dma_based_transfer(struct tegra_qspi *tqspi, struct
>                 len = tqspi->curr_dma_words * 4;
>
>         /* set attention level based on length of transfer */
> -       val = 0;
> -       if (len & 0xf) {
> -               val |= QSPI_TX_TRIG_1 | QSPI_RX_TRIG_1;
> -               dma_burst = 1;
> -       } else if (((len) >> 4) & 0x1) {
> -               val |= QSPI_TX_TRIG_4 | QSPI_RX_TRIG_4;
> -               dma_burst = 4;
> -       } else {
> -               val |= QSPI_TX_TRIG_8 | QSPI_RX_TRIG_8;
> -               dma_burst = 8;
> +       if (has_ext_dma) {
> +               val = 0;
> +               if (len & 0xf) {
> +                       val |= QSPI_TX_TRIG_1 | QSPI_RX_TRIG_1;
> +                       dma_burst = 1;
> +               } else if (((len) >> 4) & 0x1) {
> +                       val |= QSPI_TX_TRIG_4 | QSPI_RX_TRIG_4;
> +                       dma_burst = 4;
> +               } else {
> +                       val |= QSPI_TX_TRIG_8 | QSPI_RX_TRIG_8;
> +                       dma_burst = 8;
> +               }
>         }
>
>         tegra_qspi_writel(tqspi, val, QSPI_DMA_CTL);
>         tqspi->dma_control_reg = val;
>
>         dma_sconfig.device_fc = true;
> -       if (tqspi->cur_direction & DATA_DIR_TX) {
> +       if ((tqspi->cur_direction & DATA_DIR_TX) && !has_ext_dma) {
> +               if (tqspi->is_packed)
> +                       tx_dma_phys = t->tx_dma;
> +               else
> +                       tx_dma_phys = tqspi->tx_dma_phys;
> +               tegra_qspi_copy_client_txbuf_to_qspi_txbuf(tqspi, t);
> +               tegra_qspi_writel(tqspi, (tx_dma_phys & 0xffffffff),

lower_32_bits(), for consistency with below.

> +                                 QSPI_DMA_MEM_ADDRESS_REG);
> +               tegra_qspi_writel(tqspi, ((tx_dma_phys >> 32) & 0xff),

upper_32_bits(), to fix the build failures reported by 0-day
("warning: shift count >= width of type").

> +                                 QSPI_DMA_HI_ADDRESS_REG);
> +       } else if ((tqspi->cur_direction & DATA_DIR_TX) && has_ext_dma) {
>                 dma_sconfig.dst_addr = tqspi->phys + QSPI_TX_FIFO;
>                 dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>                 dma_sconfig.dst_maxburst = dma_burst;

> @@ -1045,6 +1085,8 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
>                                         struct spi_message *msg)
>  {
>         bool is_first_msg = true;
> +       bool has_ext_dma = (tqspi->soc_data->has_dma &
> +                           QSPI_DMA_EXT) ? true : false;

No need for the "? true : false" (everywhere)

>         struct spi_transfer *xfer;
>         struct spi_device *spi = msg->spi;
>         u8 transfer_phase = 0;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2022-10-02 10:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 12:21 [PATCH 1/5] spi: tegra210-quad: Fix combined sequence Krishna Yarlagadda
2022-10-01 12:21 ` [PATCH 2/5] spi: tegra210-quad: Fix duplicate resource error Krishna Yarlagadda
2022-11-11  9:49   ` Jon Hunter
2022-10-01 12:21 ` [PATCH 3/5] spi: tegra210-quad: Use nbits in combined seq Krishna Yarlagadda
2022-10-03 15:24   ` Mark Brown
2022-10-01 12:21 ` [PATCH 4/5] spi: tegra210-quad: combined seq for 4READ Krishna Yarlagadda
2022-10-01 12:21 ` [PATCH 5/5] spi: tegra210-quad: native dma support Krishna Yarlagadda
2022-10-01 20:08   ` kernel test robot
2022-10-01 20:50   ` kernel test robot
2022-10-02 10:37   ` Geert Uytterhoeven [this message]
2022-10-03 16:47 ` (subset) [PATCH 1/5] spi: tegra210-quad: Fix combined sequence Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMuHMdUoABDeLrdudfY09jGmCcnFpJmFGf0OieVBG6OuEpk7ZA@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kyarlagadda@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).