Re: [PATCH RFC v11 00/12] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O
From: Bartosz Golaszewski <brgl@kernel.org>
Date: 2026-03-03 12:57:07
Also in:
dmaengine, linux-arm-msm, linux-crypto, linux-doc, lkml
On Tue, Mar 3, 2026 at 1:44 PM Manivannan Sadhasivam [off-list ref] wrote:
On Mon, Mar 02, 2026 at 04:57:13PM +0100, Bartosz Golaszewski wrote:quoted
NOTE: Please note that even though this is version 11, I changed the prefix to RFC as this is an entirely new approach resulting from discussions under v9. I AM AWARE of the existing memory leaks in the last patch of this series - I'm sending it because I want to first discuss the approach and get a green light from Vinod as well as Mani and Bjorn. Especially when it comes to communicating the address for the dummy rights from the client to the BAM driver. /NOTE Currently the QCE crypto driver accesses the crypto engine registers directly via CPU. Trust Zone may perform crypto operations simultaneously resulting in a race condition. To remedy that, let's introduce support for BAM locking/unlocking to the driver. The BAM driver will now wrap any existing issued descriptor chains with additional descriptors performing the locking when the client starts the transaction (dmaengine_issue_pending()). The client wanting to profit from locking needs to switch to performing register I/O over DMA and communicate the address to which to perform the dummy writes via a call to dmaengine_slave_config().Thanks for moving the LOCK/UNLOCK bits out of client to the BAM driver. It looks neat now. I understand the limitation that for LOCK/UNLOCK, BAM needs to perform a dummy write to an address in the client register space. So in this case, you can also use the previous metadata approach to pass the scratchpad register to the BAM driver from clients. The BAM driver can use this register to perform LOCK/UNLOCK.
I thought about reusing descriptor metadata but this is attached to every descriptor created with dmaengine_prep_slave_sg() (as opposed to doing it once with dmaengine_slave_config()). We would also still need a custom struct in the existing BAM DMA header. I'm fine with that. Vinod: could you please say if that's sound for you and if so - I'll rework it and also fix the memory leaks by reworking the cleanup path.
It may sound like I'm suggesting a part of your previous design, but it fits the design more cleanly IMO. The BAM performs LOCK/UNLOCK on its own, but it gets the scratchpad register address from the clients through the metadata once.
If that gets it upstream, then it's fine with me.
It is very unfortunate that the IP doesn't accept '0' address for LOCK/UNLOCK or some of them cannot append LOCK/UNLOCK to the actual CMD descriptors passed from the clients. These would've made the code/design even more cleaner.
For sure but I double-checked this. :( Bart