Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: Stephan Gerhold <stephan.gerhold@linaro.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Thara Gopinath <thara.gopinath@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Udit Tiwari <quic_utiwari@quicinc.com>,
	Md Sadre Alam <mdalam@qti.qualcomm.com>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@gmail.com>,
	Michal Simek <michal.simek@amd.com>,
	Frank Li <Frank.Li@kernel.org>,
	Andy Gross <agross@codeaurora.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	dmaengine@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: Re: [PATCH v21 06/14] dmaengine: qcom: bam_dma: add support for BAM locking
Date: Wed, 15 Jul 2026 21:06:46 +0530	[thread overview]
Message-ID: <alepDnRJmRLbFGRQ@vaman> (raw)
In-Reply-To: <CAMRc=MevqXga1u-XC8LYc3hnjjzmdESntsSGYP25XECeeySfJA@mail.gmail.com>

On 15-07-26, 14:43, Bartosz Golaszewski wrote:
> On Tue, 14 Jul 2026 11:49:14 +0200, Stephan Gerhold
> <stephan.gerhold@linaro.org> said:
> > On Mon, Jul 13, 2026 at 03:01:07PM +0200, Bartosz Golaszewski wrote:
> >> Add support for BAM pipe locking. To that end: when starting DMA on an RX
> >> channel - prepend the existing queue of issued descriptors with an
> >> additional "dummy" command descriptor with the LOCK bit set. Once the
> >> transaction is done (no more issued descriptors), issue one more dummy
> >> descriptor with the UNLOCK bit.
> >>
> >> We *must* wait until the transaction is signalled as done because we
> >> must not perform any writes into config registers while the engine is
> >> busy.
> >>
> >> The dummy writes must be issued into a scratchpad register of the client
> >> so provide a mechanism to communicate the right address via descriptor
> >> metadata.
> >>
> >> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
> >> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> >
> > Thanks for the fixes. The lock/unlock sequence looks good to me now,
> > I commented on a couple of minor things below that would be good to fix
> > (some of them are also reported by Sashiko).
> >
> 
> Thanks.
> 
> >> ---
> >>  drivers/dma/qcom/bam_dma.c       | 191 +++++++++++++++++++++++++++++++++++++--
> >>  include/linux/dma/qcom_bam_dma.h |  14 +++
> >>  2 files changed, 198 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
> >> index f3e713a5259c2c7c24cfdcec094814eb1202971a..f08549ee3872eece85884606d6ee9e540ee688ca 100644
> >> --- a/drivers/dma/qcom/bam_dma.c
> >> +++ b/drivers/dma/qcom/bam_dma.c
> >> [...]
> >> @@ -686,6 +702,35 @@ static int bam_slave_config(struct dma_chan *chan,
> >>  	return 0;
> >>  }
> >>
> >> +static int bam_metadata_attach(struct dma_async_tx_descriptor *desc, void *data, size_t len)
> >> +{
> >> +	struct bam_chan *bchan = to_bam_chan(desc->chan);
> >> +	const struct bam_device_data *bdata = bchan->bdev->dev_data;
> >> +	struct bam_desc_metadata *metadata = data;
> >> +
> >> +	if (!data)
> >
> > Doesn't really matter much, but since the parameter exists you might as
> > well add
> >
> > 	&& len == sizeof(*metadata)
> >
> > here to be sure.
> >
> 
> Ok.
> 
> >> +		return -EINVAL;
> >> +
> >> +	if (!bdata->pipe_lock_supported)
> >> +		/*
> >> +		 * The client wants to use locking but this BAM version doesn't
> >> +		 * support it. Don't return an error here as this will stop the
> >> +		 * client from using DMA at all for no reason.
> >> +		 */
> >> +		return 0;
> >> +
> >> +	guard(spinlock_irqsave)(&bchan->vc.lock);
> >> +
> >> +	bchan->scratchpad_addr = metadata->scratchpad_addr;
> >> +	bchan->direction = metadata->direction;
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static const struct dma_descriptor_metadata_ops bam_metadata_ops = {
> >> +	.attach = bam_metadata_attach,
> >> +};
> >
> > I'm not sure if we have discussed this before, but could we avoid
> > re-programming the scratchpad_addr all the time by placing it into
> > struct dma_slave_config -> peripheral_config? It still feels awkward to
> > me to place a global constant configuration value into per-descriptor
> > metadata.

The concept is that a dmaengine can handle multiple peripherals, so the
peripheral is always per desciptor

> Yes, this was discussed several versions ago. I went with using
> dmaengine_slave_config() until v11. I think Vinod or Dmitry requested we change
> it to the metadata.

metadata seems better fit for this.

> >>  /**
> >>   * bam_prep_slave_sg - Prep slave sg transaction
> >>   *
> >> [...]
> >> @@ -802,6 +851,7 @@ static int bam_dma_terminate_all(struct dma_chan *chan)
> >>  		}
> >>
> >>  		vchan_get_all_descriptors(&bchan->vc, &head);
> >> +		bchan->bam_locked = false;
> >
> > I wonder about the implications of this. If the LOCK descriptor was
> > already processed, will we cause a deadlock if we never submit the
> > UNLOCK descriptor? Or I guess bam_reset_channel() might reset the lock
> > as well?

Good point

-- 
~Vinod


  reply	other threads:[~2026-07-15 15:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:01 [PATCH v21 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 01/14] dmaengine: constify struct dma_descriptor_metadata_ops Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 02/14] dmaengine: qcom: bam_dma: free interrupt before the clock in error path Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 03/14] dmaengine: qcom: bam_dma: convert tasklet to a BH workqueue Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 04/14] dmaengine: qcom: bam_dma: Extend the driver's device match data Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 05/14] dmaengine: qcom: bam_dma: Add pipe_lock_supported flag support Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 06/14] dmaengine: qcom: bam_dma: add support for BAM locking Bartosz Golaszewski
2026-07-14  9:49   ` Stephan Gerhold
2026-07-15 14:43     ` Bartosz Golaszewski
2026-07-15 15:36       ` Vinod Koul [this message]
2026-07-15 16:06         ` Stephan Gerhold
2026-07-13 13:01 ` [PATCH v21 07/14] crypto: qce - Cancel work on device detach Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 08/14] crypto: qce - Include algapi.h in the core.h header Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 09/14] crypto: qce - Remove unused ignore_buf Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 10/14] crypto: qce - Simplify arguments of devm_qce_dma_request() Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 11/14] crypto: qce - Use existing devres APIs in devm_qce_dma_request() Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 12/14] crypto: qce - Map crypto memory for DMA Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 13/14] crypto: qce - Add BAM DMA support for crypto register I/O Bartosz Golaszewski
2026-07-13 13:01 ` [PATCH v21 14/14] crypto: qce - Communicate the base physical address to the dmaengine Bartosz Golaszewski

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=alepDnRJmRLbFGRQ@vaman \
    --to=vkoul@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=agross@codeaurora.org \
    --cc=andersson@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=mani@kernel.org \
    --cc=mdalam@qti.qualcomm.com \
    --cc=michal.simek@amd.com \
    --cc=neil.armstrong@linaro.org \
    --cc=peter.ujfalusi@gmail.com \
    --cc=quic_utiwari@quicinc.com \
    --cc=stephan.gerhold@linaro.org \
    --cc=thara.gopinath@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