linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Md Sadre Alam <quic_mdalam@quicinc.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: <vkoul@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
	<conor+dt@kernel.org>, <konradybcio@kernel.org>,
	<thara.gopinath@gmail.com>, <herbert@gondor.apana.org.au>,
	<davem@davemloft.net>, <gustavoars@kernel.org>,
	<u.kleine-koenig@pengutronix.de>, <kees@kernel.org>,
	<agross@kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<dmaengine@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-crypto@vger.kernel.org>,
	<quic_srichara@quicinc.com>, <quic_varada@quicinc.com>,
	<quic_utiwari@quicinc.com>
Subject: Re: [PATCH v2 03/16] dmaengine: qcom: bam_dma: add LOCK & UNLOCK flag support
Date: Wed, 21 Aug 2024 22:01:51 +0530	[thread overview]
Message-ID: <24909c0b-ad83-e33b-e11f-22d0fb2ec979@quicinc.com> (raw)
In-Reply-To: <knhqbj2pyluwrvr2f4h6zgpfosa6o2qgnhtl4qltadpuyfexgu@kk5knurc4v7h>



On 8/16/2024 9:52 PM, Bjorn Andersson wrote:
> On Thu, Aug 15, 2024 at 02:27:12PM GMT, Md Sadre Alam wrote:
>> Add lock and unlock flag support on command descriptor.
>> Once lock set in requester pipe, then the bam controller
>> will lock all others pipe and process the request only
>> from requester pipe. Unlocking only can be performed from
>> the same pipe.
>>
> 
> Is the lock per channel, or for the whole BAM instance?
   This lock is for whole BAM instance. Once LOCK bit will
   set on initiator CMD descriptor BAM will lock all pipes
   which belongs to other EE's and Pipes not in the current
   group.
> 
>> If DMA_PREP_LOCK flag passed in command descriptor then requester
>> of this transaction wanted to lock the BAM controller for this
>> transaction so BAM driver should set LOCK bit for the HW descriptor.
> 
> You use the expression "this transaction" here, but if I understand the
> calling code the lock is going to be held over multiple DMA operations
> and even across asynchronous operations in the crypto driver.
   Yes its correct.
> 
> DMA_PREP_LOCK indicates that this is the beginning of a transaction,
> consisting of multiple operations that needs to happen while other EEs
> are being locked out, and DMA_PREP_UNLOCK marks the end of the
> transaction.
   Yes its correct.
> 
> That said, I'm not entirely fond of the fact that these flags are not
> just used on first and last operation in one sequence, but spread out.
   Yes its correct.
> 
> Locking is hard, when you spread the responsibility of locking and
> unlocking across different entities it's made harder...
   The locking/unlocking always synchronous because unlocking happening
   in the dma callback.
> 
>>
>> If DMA_PREP_UNLOCK flag passed in command descriptor then requester
>> of this transaction wanted to unlock the BAM controller.so BAM driver
>> should set UNLOCK bit for the HW descriptor.
>>
>> Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
>> ---
>>
>> Change in [v2]
>>
>> * Added LOCK and UNLOCK flag in bam driver
>>
>> Change in [v1]
>>
>> * This patch was not included in [v1]
> 
> v1 can be found here:
> https://lore.kernel.org/all/20231214114239.2635325-7-quic_mdalam@quicinc.com/
> 
> And it was also posted once before that:
> https://lore.kernel.org/all/1608215842-15381-1-git-send-email-mdalam@codeaurora.org/
> 
> In particular during the latter (i.e. first post) we had a rather long
> discussion about this feature, so that's certainly worth linking to.
> 
> Looks like this series provides some answers to the questions we had
> back then.
   Will add the link in next post
> 
> Regards,
> Bjorn
> 
>>
>>   drivers/dma/qcom/bam_dma.c | 10 +++++++++-
>>   include/linux/dmaengine.h  |  6 ++++++
>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
>> index 1ac7e250bdaa..ab3b5319aa68 100644
>> --- a/drivers/dma/qcom/bam_dma.c
>> +++ b/drivers/dma/qcom/bam_dma.c
>> @@ -58,6 +58,8 @@ struct bam_desc_hw {
>>   #define DESC_FLAG_EOB BIT(13)
>>   #define DESC_FLAG_NWD BIT(12)
>>   #define DESC_FLAG_CMD BIT(11)
>> +#define DESC_FLAG_LOCK BIT(10)
>> +#define DESC_FLAG_UNLOCK BIT(9)
>>   
>>   struct bam_async_desc {
>>   	struct virt_dma_desc vd;
>> @@ -692,9 +694,15 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
>>   		unsigned int curr_offset = 0;
>>   
>>   		do {
>> -			if (flags & DMA_PREP_CMD)
>> +			if (flags & DMA_PREP_CMD) {
>>   				desc->flags |= cpu_to_le16(DESC_FLAG_CMD);
>>   
>> +				if (bdev->bam_pipe_lock && flags & DMA_PREP_LOCK)
>> +					desc->flags |= cpu_to_le16(DESC_FLAG_LOCK);
>> +				else if (bdev->bam_pipe_lock && flags & DMA_PREP_UNLOCK)
>> +					desc->flags |= cpu_to_le16(DESC_FLAG_UNLOCK);
>> +			}
>> +
>>   			desc->addr = cpu_to_le32(sg_dma_address(sg) +
>>   						 curr_offset);
>>   
>> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
>> index b137fdb56093..70f23068bfdc 100644
>> --- a/include/linux/dmaengine.h
>> +++ b/include/linux/dmaengine.h
>> @@ -200,6 +200,10 @@ struct dma_vec {
>>    *  transaction is marked with DMA_PREP_REPEAT will cause the new transaction
>>    *  to never be processed and stay in the issued queue forever. The flag is
>>    *  ignored if the previous transaction is not a repeated transaction.
>> + *  @DMA_PREP_LOCK: tell the driver that there is a lock bit set on command
>> + *  descriptor.
>> + *  @DMA_PREP_UNLOCK: tell the driver that there is a un-lock bit set on command
>> + *  descriptor.
>>    */
>>   enum dma_ctrl_flags {
>>   	DMA_PREP_INTERRUPT = (1 << 0),
>> @@ -212,6 +216,8 @@ enum dma_ctrl_flags {
>>   	DMA_PREP_CMD = (1 << 7),
>>   	DMA_PREP_REPEAT = (1 << 8),
>>   	DMA_PREP_LOAD_EOT = (1 << 9),
>> +	DMA_PREP_LOCK = (1 << 10),
>> +	DMA_PREP_UNLOCK = (1 << 11),
>>   };
>>   
>>   /**
>> -- 
>> 2.34.1
>>

  reply	other threads:[~2024-08-21 16:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15  8:57 [PATCH v2 00/16] Add cmd descriptor support Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 01/16] dt-bindings: dma: qcom,bam: Add bam pipe lock Md Sadre Alam
2024-08-16 15:53   ` Bjorn Andersson
2024-08-21  4:54     ` Md Sadre Alam
2024-08-17  9:08   ` Krzysztof Kozlowski
2024-08-21 16:34     ` Md Sadre Alam
2024-08-22  6:27       ` Krzysztof Kozlowski
2024-08-22 11:45         ` Md Sadre Alam
2024-08-23  9:07           ` Krzysztof Kozlowski
2024-08-24  7:07             ` Md Sadre Alam
2024-08-23 15:39   ` Manivannan Sadhasivam
2024-08-24  7:04     ` Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 02/16] dmaengine: qcom: bam_dma: add bam_pipe_lock dt property Md Sadre Alam
2024-08-17  9:08   ` Krzysztof Kozlowski
2024-08-21 16:36     ` Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 03/16] dmaengine: qcom: bam_dma: add LOCK & UNLOCK flag support Md Sadre Alam
2024-08-16 16:22   ` Bjorn Andersson
2024-08-21 16:31     ` Md Sadre Alam [this message]
2024-08-15  8:57 ` [PATCH v2 04/16] crypto: qce - Add support for crypto address read Md Sadre Alam
2024-08-17  9:10   ` Krzysztof Kozlowski
2024-08-21 16:40     ` Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 05/16] crypto: qce - Add bam dma support for crypto register r/w Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 06/16] crypto: qce - Convert register r/w for skcipher via BAM/DMA Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 07/16] crypto: qce - Convert register r/w for sha " Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 08/16] crypto: qce - Convert register r/w for aead " Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 09/16] crypto: qce - Add LOCK and UNLOCK flag support Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 10/16] crypto: qce - Add support for lock aquire,lock release api Md Sadre Alam
2024-08-16 16:38   ` Bjorn Andersson
2024-08-21  5:14     ` Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 11/16] crypto: qce - Add support for lock/unlock in skcipher Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 12/16] crypto: qce - Add support for lock/unlock in sha Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 13/16] crypto: qce - Add support for lock/unlock in aead Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 14/16] arm64: dts: qcom: ipq9574: enable bam pipe locking/unlocking Md Sadre Alam
2024-08-16 16:40   ` Bjorn Andersson
2024-08-21  5:16     ` Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 15/16] arm64: dts: qcom: ipq8074: " Md Sadre Alam
2024-08-15  8:57 ` [PATCH v2 16/16] arm64: dts: qcom: ipq6018: " Md Sadre Alam
2024-08-15 13:08 ` [PATCH v2 00/16] Add cmd descriptor support Caleb Connolly
2024-08-16 12:03   ` Md Sadre Alam
2024-08-16 15:45     ` Bjorn Andersson
2024-09-06  7:06       ` Md Sadre Alam
2024-08-16 16:01 ` Bjorn Andersson
2024-08-21  4:57   ` Md Sadre Alam

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=24909c0b-ad83-e33b-e11f-22d0fb2ec979@quicinc.com \
    --to=quic_mdalam@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kees@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_utiwari@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=robh@kernel.org \
    --cc=thara.gopinath@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vkoul@kernel.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).