Re: [PATCH v3 3/3] scsi: ufs: Add inline encryption support to UFS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 06, 2020 at 07:10:16PM +0000, Satya Tangirala wrote:
> Wire up ufshcd.c with the UFS Crypto API, the block layer inline
> encryption additions and the keyslot manager.
> 
> Many existing inline crypto devices require some additional behaviour not
> specified in the UFSHCI v2.1 specification - as such the vendor specific
> drivers will need to be updated where necessary to make it possible to use
> those devices. Some of these changes have already been proposed upstream,
> such as for the Qualcomm 845 SoC at
> https://lkml.kernel.org/linux-scsi/20200501045111.665881-1-ebiggers@xxxxxxxxxx/
> and for ufs-mediatek at
> https://lkml.kernel.org/linux-scsi/20200304022101.14165-1-stanley.chu@xxxxxxxxxxxx/
> 
> This patch has been tested on the db845c, sm8150-mtp and sm8250-mtp
> (which have Qualcomm chipsets) and on some mediatek chipsets using these
> aforementioned vendor specific driver updates.
> 
> Signed-off-by: Satya Tangirala <satyat@xxxxxxxxxx>
> Reviewed-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> Reviewed-by: Stanley Chu <stanley.chu@xxxxxxxxxxxx>
> ---
>  drivers/scsi/ufs/ufshcd-crypto.c | 30 ++++++++++++++------
>  drivers/scsi/ufs/ufshcd-crypto.h | 41 +++++++++++++++++++++++++--
>  drivers/scsi/ufs/ufshcd.c        | 48 +++++++++++++++++++++++++++-----
>  drivers/scsi/ufs/ufshcd.h        |  6 ++++
>  4 files changed, 107 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c
> index 65a3115d2a2d..c13cf42652aa 100644
> --- a/drivers/scsi/ufs/ufshcd-crypto.c
> +++ b/drivers/scsi/ufs/ufshcd-crypto.c
> @@ -138,18 +138,17 @@ ufshcd_find_blk_crypto_mode(union ufs_crypto_cap_entry cap)
>  }
>  
>  /**
> - * ufshcd_hba_init_crypto - Read crypto capabilities, init crypto fields in hba
> + * ufshcd_hba_init_crypto_capabilities - Read crypto capabilities, init crypto
> + *					 fields in hba
>   * @hba: Per adapter instance
>   *
>   * Return: 0 if crypto was initialized or is not supported, else a -errno value.
>   */
> -int ufshcd_hba_init_crypto(struct ufs_hba *hba)
> +int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
>  {
>  	int cap_idx = 0;
>  	int err = 0;
>  	enum blk_crypto_mode_num blk_mode_num;
> -	int slot = 0;
> -	int num_keyslots;
>  
>  	/*
>  	 * Don't use crypto if either the hardware doesn't advertise the
> @@ -173,8 +172,8 @@ int ufshcd_hba_init_crypto(struct ufs_hba *hba)
>  	}
>  
>  	/* The actual number of configurations supported is (CFGC+1) */
> -	num_keyslots = hba->crypto_capabilities.config_count + 1;
> -	err = blk_ksm_init(&hba->ksm, num_keyslots);
> +	err = blk_ksm_init(&hba->ksm,
> +			   hba->crypto_capabilities.config_count + 1);
>  	if (err)
>  		goto out_free_caps;
>  
> @@ -200,9 +199,6 @@ int ufshcd_hba_init_crypto(struct ufs_hba *hba)
>  				hba->crypto_cap_array[cap_idx].sdus_mask * 512;
>  	}
>  
> -	for (slot = 0; slot < num_keyslots; slot++)
> -		ufshcd_clear_keyslot(hba, slot);
> -
>  	return 0;
>  
>  out_free_caps:
> @@ -213,6 +209,22 @@ int ufshcd_hba_init_crypto(struct ufs_hba *hba)
>  	return err;
>  }
>  
> +/**
> + * ufshcd_init_crypto - Initialize crypto hardware
> + * @hba: Per adapter instance
> + */
> +void ufshcd_init_crypto(struct ufs_hba *hba)
> +{
> +	int slot = 0;
> +
> +	if (!(hba->caps & UFSHCD_CAP_CRYPTO))
> +		return;
> +
> +	/* Clear all keyslots - the number of keyslots is (CFGC + 1) */
> +	for (slot = 0; slot < hba->crypto_capabilities.config_count + 1; slot++)
> +		ufshcd_clear_keyslot(hba, slot);
> +}
> +
>  void ufshcd_crypto_setup_rq_keyslot_manager(struct ufs_hba *hba,
>  					    struct request_queue *q)
>  {

Seems that these changes got folded into the wrong patch.
They should go in patch 2.

- Eric



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux