linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@linaro.org>
To: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>,
	agross@kernel.org, andersson@kernel.org, broonie@kernel.org,
	dianders@chromium.org, linux-arm-msm@vger.kernel.org,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: quic_msavaliy@quicinc.com, mka@chromium.org, swboyd@chromium.org,
	quic_vtanuku@quicinc.com, quic_ptalari@quicinc.com
Subject: Re: [PATCH v2 1/2] soc: qcom: geni-se: Add interfaces geni_se_tx_init_dma() and geni_se_rx_init_dma()
Date: Tue, 6 Jun 2023 18:53:35 +0200	[thread overview]
Message-ID: <dec20727-bf6f-fdfc-c5fd-2c00a4848987@linaro.org> (raw)
In-Reply-To: <1684325894-30252-2-git-send-email-quic_vnivarth@quicinc.com>



On 17.05.2023 14:18, Vijaya Krishna Nivarthi wrote:
> The geni_se_xx_dma_prep() interfaces necessarily do DMA mapping before
> initiating DMA transfers. This is not suitable for spi where framework
> is expected to handle map/unmap.
> 
> Expose new interfaces geni_se_xx_init_dma() which do only DMA transfer.
> 
> Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
> v1 -> v2:
> - interfaces to take dma address as argument instead of its pointer
> ---
>  drivers/soc/qcom/qcom-geni-se.c  | 67 +++++++++++++++++++++++++++++-----------
>  include/linux/soc/qcom/geni-se.h |  4 +++
>  2 files changed, 53 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 795a2e1..dd50a25 100644
> --- a/drivers/soc/qcom/qcom-geni-se.c
> +++ b/drivers/soc/qcom/qcom-geni-se.c
> @@ -682,6 +682,30 @@ EXPORT_SYMBOL(geni_se_clk_freq_match);
>  #define GENI_SE_DMA_EOT_EN BIT(1)
>  #define GENI_SE_DMA_AHB_ERR_EN BIT(2)
>  #define GENI_SE_DMA_EOT_BUF BIT(0)
> +
> +/**
> + * geni_se_tx_init_dma() - Initiate TX DMA transfer on the serial engine
> + * @se:			Pointer to the concerned serial engine.
> + * @iova:		Mapped DMA address.
> + * @len:		Length of the TX buffer.
> + *
> + * This function is used to initiate DMA TX transfer.
> + */
> +void geni_se_tx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len)
> +{
> +	u32 val;
> +
> +	val = GENI_SE_DMA_DONE_EN;
> +	val |= GENI_SE_DMA_EOT_EN;
> +	val |= GENI_SE_DMA_AHB_ERR_EN;
> +	writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET);
> +	writel_relaxed(lower_32_bits(iova), se->base + SE_DMA_TX_PTR_L);
> +	writel_relaxed(upper_32_bits(iova), se->base + SE_DMA_TX_PTR_H);
> +	writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR);
> +	writel(len, se->base + SE_DMA_TX_LEN);
> +}
> +EXPORT_SYMBOL(geni_se_tx_init_dma);
> +
>  /**
>   * geni_se_tx_dma_prep() - Prepare the serial engine for TX DMA transfer
>   * @se:			Pointer to the concerned serial engine.
> @@ -697,7 +721,6 @@ int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  			dma_addr_t *iova)
>  {
>  	struct geni_wrapper *wrapper = se->wrapper;
> -	u32 val;
>  
>  	if (!wrapper)
>  		return -EINVAL;
> @@ -706,17 +729,34 @@ int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  	if (dma_mapping_error(wrapper->dev, *iova))
>  		return -EIO;
>  
> +	geni_se_tx_init_dma(se, *iova, len);
> +	return 0;
> +}
> +EXPORT_SYMBOL(geni_se_tx_dma_prep);
> +
> +/**
> + * geni_se_rx_init_dma() - Initiate RX DMA transfer on the serial engine
> + * @se:			Pointer to the concerned serial engine.
> + * @iova:		Mapped DMA address.
> + * @len:		Length of the RX buffer.
> + *
> + * This function is used to initiate DMA RX transfer.
> + */
> +void geni_se_rx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len)
> +{
> +	u32 val;
> +
>  	val = GENI_SE_DMA_DONE_EN;
>  	val |= GENI_SE_DMA_EOT_EN;
>  	val |= GENI_SE_DMA_AHB_ERR_EN;
> -	writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET);
> -	writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_TX_PTR_L);
> -	writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_TX_PTR_H);
> -	writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR);
> -	writel(len, se->base + SE_DMA_TX_LEN);
> -	return 0;
> +	writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET);
> +	writel_relaxed(lower_32_bits(iova), se->base + SE_DMA_RX_PTR_L);
> +	writel_relaxed(upper_32_bits(iova), se->base + SE_DMA_RX_PTR_H);
> +	/* RX does not have EOT buffer type bit. So just reset RX_ATTR */
> +	writel_relaxed(0, se->base + SE_DMA_RX_ATTR);
> +	writel(len, se->base + SE_DMA_RX_LEN);
>  }
> -EXPORT_SYMBOL(geni_se_tx_dma_prep);
> +EXPORT_SYMBOL(geni_se_rx_init_dma);
>  
>  /**
>   * geni_se_rx_dma_prep() - Prepare the serial engine for RX DMA transfer
> @@ -733,7 +773,6 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  			dma_addr_t *iova)
>  {
>  	struct geni_wrapper *wrapper = se->wrapper;
> -	u32 val;
>  
>  	if (!wrapper)
>  		return -EINVAL;
> @@ -742,15 +781,7 @@ int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  	if (dma_mapping_error(wrapper->dev, *iova))
>  		return -EIO;
>  
> -	val = GENI_SE_DMA_DONE_EN;
> -	val |= GENI_SE_DMA_EOT_EN;
> -	val |= GENI_SE_DMA_AHB_ERR_EN;
> -	writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET);
> -	writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_RX_PTR_L);
> -	writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_RX_PTR_H);
> -	/* RX does not have EOT buffer type bit. So just reset RX_ATTR */
> -	writel_relaxed(0, se->base + SE_DMA_RX_ATTR);
> -	writel(len, se->base + SE_DMA_RX_LEN);
> +	geni_se_rx_init_dma(se, *iova, len);
>  	return 0;
>  }
>  EXPORT_SYMBOL(geni_se_rx_dma_prep);
> diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
> index c55a0bc..821a191 100644
> --- a/include/linux/soc/qcom/geni-se.h
> +++ b/include/linux/soc/qcom/geni-se.h
> @@ -490,9 +490,13 @@ int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq,
>  			   unsigned int *index, unsigned long *res_freq,
>  			   bool exact);
>  
> +void geni_se_tx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len);
> +
>  int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  			dma_addr_t *iova);
>  
> +void geni_se_rx_init_dma(struct geni_se *se, dma_addr_t iova, size_t len);
> +
>  int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
>  			dma_addr_t *iova);
>  

  parent reply	other threads:[~2023-06-06 16:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 12:18 [PATCH v2 0/2] spi-geni-qcom: Add new interfaces and utilise them to do map/unmap in framework for SE DMA Vijaya Krishna Nivarthi
2023-05-17 12:18 ` [PATCH v2 1/2] soc: qcom: geni-se: Add interfaces geni_se_tx_init_dma() and geni_se_rx_init_dma() Vijaya Krishna Nivarthi
2023-05-17 14:18   ` Doug Anderson
2023-06-06 15:53     ` Mark Brown
2023-06-06 16:53   ` Konrad Dybcio [this message]
2023-05-17 12:18 ` [PATCH v2 2/2] spi: spi-geni-qcom: Do not do DMA map/unmap inside driver, use framework instead Vijaya Krishna Nivarthi
2023-05-17 14:20   ` Doug Anderson
2023-06-06 16:56   ` Konrad Dybcio
2023-06-06 17:49 ` [PATCH v2 0/2] spi-geni-qcom: Add new interfaces and utilise them to do map/unmap in framework for SE DMA Mark Brown
2023-06-07  1:14   ` Vijaya Krishna Nivarthi
2023-06-07 12:28 ` 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=dec20727-bf6f-fdfc-c5fd-2c00a4848987@linaro.org \
    --to=konrad.dybcio@linaro.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=quic_msavaliy@quicinc.com \
    --cc=quic_ptalari@quicinc.com \
    --cc=quic_vnivarth@quicinc.com \
    --cc=quic_vtanuku@quicinc.com \
    --cc=swboyd@chromium.org \
    /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).