mbox series

[v6,0/5] Inline crypto support on DragonBoard 845c

Message ID 20200710072013.177481-1-ebiggers@kernel.org
Headers show
Series Inline crypto support on DragonBoard 845c | expand

Message

Eric Biggers July 10, 2020, 7:20 a.m. UTC
Hello,

This patchset implements UFS inline encryption support on the
DragonBoard 845c, using the Qualcomm Inline Crypto Engine (ICE)
that's present on the Snapdragon 845 SoC.

This is based on top of scsi/5.9/scsi-queue, which contains the
ufshcd-crypto patches by Satya Tangirala.

Most of the logic needed to use ICE is already handled by the blk-crypto
framework (introduced in v5.8-rc1) and by ufshcd-crypto.  This new
patchset just adds the vendor-specific parts.  I also only implemented
support for version 3 of the ICE hardware, which seems to be easier to
use than older versions.

Due to these factors and others, I was able to greatly simplify the
driver from the vendor's original.  It works fine in testing with
fscrypt and with a blk-crypto self-test I'm also working on.

This driver also works on several other Snapdragon SoCs.
See the commit messages for details.

This patchset is also available in git at:
    Repo: https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git
    Tag: db845c-crypto-v6

(To actually test this with fscrypt, it's also needed to merge the
master branch of https://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git
to get the fscrypt patches.)

Changed v5 => v6:
    - Rebased onto scsi/5.9/scsi-queue.

Changed v4 => v5:
    - Rebased onto v5.8-rc1 + the latest ufshcd-crypto patchset.
    - Refer to the ICE registers by name rather than by index.
    - Added Tested-by and Acked-by tags.

Changed v3 => v4:
    - Rebased onto the v12 inline encryption patchset.
    - A couple small cleanups.

Changed v2 => v3:
    - Rebased onto the v8 inline encryption patchset.  Now the driver
      has to opt into inline crypto support rather than opting out.
    - Switched qcom_scm_ice_set_key() to use dma_alloc_coherent()
      so that we can reliably zeroing the key without assuming that
      bounce buffers aren't used.  Also added a comment.
    - Made the key_size and data_unit_size arguments to
      qcom_scm_ice_set_key() be 'u32' instead of 'int'.

Changed v1 => v2:
    - Rebased onto the v7 inline encryption patchset.
    - Account for all the recent qcom_scm changes.
    - Don't ignore errors from ->program_key().
    - Don't dereference NULL hba->vops.
    - Dropped the patch that added UFSHCD_QUIRK_BROKEN_CRYPTO, as this
      flag is now included in the main inline encryption patchset.
    - Many other cleanups.

Eric Biggers (5):
  firmware: qcom_scm: Add support for programming inline crypto keys
  scsi: ufs-qcom: name the dev_ref_clk_ctrl registers
  arm64: dts: sdm845: add Inline Crypto Engine registers and clock
  scsi: ufs: add program_key() variant op
  scsi: ufs-qcom: add Inline Crypto Engine support

 MAINTAINERS                          |   2 +-
 arch/arm64/boot/dts/qcom/sdm845.dtsi |  13 +-
 drivers/firmware/qcom_scm.c          | 101 +++++++++++
 drivers/firmware/qcom_scm.h          |   4 +
 drivers/scsi/ufs/Kconfig             |   1 +
 drivers/scsi/ufs/Makefile            |   4 +-
 drivers/scsi/ufs/ufs-qcom-ice.c      | 245 +++++++++++++++++++++++++++
 drivers/scsi/ufs/ufs-qcom.c          |  15 +-
 drivers/scsi/ufs/ufs-qcom.h          |  27 +++
 drivers/scsi/ufs/ufshcd-crypto.c     |  27 +--
 drivers/scsi/ufs/ufshcd.h            |   3 +
 include/linux/qcom_scm.h             |  19 +++
 12 files changed, 443 insertions(+), 18 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufs-qcom-ice.c


base-commit: b53293fa662e28ae0cdd40828dc641c09f133405

Comments

Martin K. Petersen July 22, 2020, 4:28 a.m. UTC | #1
On Fri, 10 Jul 2020 00:20:07 -0700, Eric Biggers wrote:

> This patchset implements UFS inline encryption support on the
> DragonBoard 845c, using the Qualcomm Inline Crypto Engine (ICE)
> that's present on the Snapdragon 845 SoC.
> 
> This is based on top of scsi/5.9/scsi-queue, which contains the
> ufshcd-crypto patches by Satya Tangirala.
> 
> [...]

Applied to 5.9/scsi-queue, thanks!

[1/5] scsi: firmware: qcom_scm: Add support for programming inline crypto keys
      https://git.kernel.org/mkp/scsi/c/e10d24786adb
[2/5] scsi: ufs-qcom: Name the dev_ref_clk_ctrl registers
      https://git.kernel.org/mkp/scsi/c/12700db4f9f7
[4/5] scsi: ufs: Add program_key() variant op
      https://git.kernel.org/mkp/scsi/c/a5fedfacb402
[5/5] scsi: ufs-qcom: Add Inline Crypto Engine support
      https://git.kernel.org/mkp/scsi/c/de9063fbd769
Eric Biggers July 22, 2020, 5:25 a.m. UTC | #2
Hi Martin,

On Wed, Jul 22, 2020 at 12:28:29AM -0400, Martin K. Petersen wrote:
> On Fri, 10 Jul 2020 00:20:07 -0700, Eric Biggers wrote:
> 
> > This patchset implements UFS inline encryption support on the
> > DragonBoard 845c, using the Qualcomm Inline Crypto Engine (ICE)
> > that's present on the Snapdragon 845 SoC.
> > 
> > This is based on top of scsi/5.9/scsi-queue, which contains the
> > ufshcd-crypto patches by Satya Tangirala.
> > 
> > [...]
> 
> Applied to 5.9/scsi-queue, thanks!
> 
> [1/5] scsi: firmware: qcom_scm: Add support for programming inline crypto keys
>       https://git.kernel.org/mkp/scsi/c/e10d24786adb
> [2/5] scsi: ufs-qcom: Name the dev_ref_clk_ctrl registers
>       https://git.kernel.org/mkp/scsi/c/12700db4f9f7
> [4/5] scsi: ufs: Add program_key() variant op
>       https://git.kernel.org/mkp/scsi/c/a5fedfacb402
> [5/5] scsi: ufs-qcom: Add Inline Crypto Engine support
>       https://git.kernel.org/mkp/scsi/c/de9063fbd769

Seems that something went wrong when you applied patch 5.  It's supposed to add
the file ufs-qcom-ice.c, but the committed version doesn't have that file.

- Eric
Martin K. Petersen July 22, 2020, 12:21 p.m. UTC | #3
Eric,

> Seems that something went wrong when you applied patch 5.  It's
> supposed to add the file ufs-qcom-ice.c, but the committed version
> doesn't have that file.

Not sure what happened there, I recall it being a clean b4 am.

I fixed it up. Sorry about that!