23 Commits

Author SHA1 Message Date
Gaurav Kashyap
e866686954 Variant ops for UFS crypto and new crypto lib
Add QTI implementation for variant ops required for inline
encryption with wrapped key support. These include UFS
crypto ops and KSM ops. Also add crypto common library to cater
to different key programing mechanisms.

Change-Id: Ica930a8a806a78d4c2d074639cbed355b895a459
Signed-off-by: Gaurav Kashyap <gaurkash@codeaurora.org>
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2020-08-18 05:12:51 -07:00
Neeraj Soni
bf54c9e71d Integrate the new file encryption framework
These changes integrate new file encryption framework to use new V2 encryption policies.

These changes were earlier reverted in 'commit 4211691d298c ("Reverting crypto and incrementalfs changes")',
as part of android-4.14.171 merge from Android common kernel. This patch attempts to bring them back
post validation.

commit a9a5450 ANDROID: dm: prevent default-key from being enabled without needed hooks
commit e1a94e6 ANDROID: dm: add dm-default-key target for metadata encryption
commit commit 232fd35 ANDROID: dm: enable may_passthrough_inline_crypto on some targets
commit 53bc059 ANDROID: dm: add support for passing through inline crypto support
commit aeed6db ANDROID: block: Introduce passthrough keyslot manager
commit 4f27c8b ANDROID: ext4, f2fs: enable direct I/O with inline encryption
commit c91db46 BACKPORT: FROMLIST: scsi: ufs: add program_key() variant op
commit f9a8e4a ANDROID: block: export symbols needed for modules to use inline crypto
commit 75fea5f ANDROID: block: fix some inline crypto bugs
commit 2871f73 ANDROID: fscrypt: add support for hardware-wrapped keys
commit bb5a657 ANDROID: block: add KSM op to derive software secret from wrapped key
commit d42ba87 ANDROID: block: provide key size as input to inline crypto APIs
commit 86646eb ANDROID: ufshcd-crypto: export cap find API
commit 83bc20e ANDROID: scsi: ufs-qcom: Enable BROKEN_CRYPTO quirk flag
commit c266a13 ANDROID: scsi: ufs: Add quirk bit for controllers that don't play well with inline crypto
commit ea09b99 ANDROID: cuttlefish_defconfig: Enable blk-crypto fallback
commit e12563c BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series
commit 8e8f55d ANDROID: scsi: ufs: UFS init should not require inline crypto
commit dae9899 ANDROID: scsi: ufs: UFS crypto variant operations API
commit a69516d ANDROID: cuttlefish_defconfig: enable inline encryption
commit b8f7b23 BACKPORT: FROMLIST: ext4: add inline encryption support
commit e64327f BACKPORT: FROMLIST: f2fs: add inline encryption support
commit a0dc8da BACKPORT: FROMLIST: fscrypt: add inline encryption support
commit 19c3c62 BACKPORT: FROMLIST: scsi: ufs: Add inline encryption support to UFS
commit f858a99 BACKPORT: FROMLIST: scsi: ufs: UFS crypto API
commit 011b834 BACKPORT: FROMLIST: scsi: ufs: UFS driver v2.1 spec crypto additions
commit ec0b569 BACKPORT: FROMLIST: block: blk-crypto for Inline Encryption
commit 760b328 ANDROID: block: Fix bio_crypt_should_process WARN_ON
commit 138adbb BACKPORT: FROMLIST: block: Add encryption context to struct bio
commit 66b5609 BACKPORT: FROMLIST: block: Keyslot Manager for Inline Encryption

Git-repo: https://android.googlesource.com/kernel/common/+/refs/heads/android-4.14-stable
Git-commit: a9a545067a93d9821f965989b8eaea6fba7d27f7
Git-commit: e1a94e6b17e2610b56c5740b763df7858dad40f0
Git-commit: 232fd353e45d13576d507a011b5dac17e3c320ab
Git-commit: 53bc059bc6d98631e8936ab9eeb7ac780c9ab2c3
Git-commit: aeed6db424b22148964d9788d4f9abac6e6cd7d8
Git-commit: 4f27c8b90bd223e967c98dc658961e67b9b864ae
Git-commit: c91db466b51479ae761becc233d79c50ca3748a5
Git-commit: f9a8e4a5c5455a6bada70ed6d2f0af8900a872cb
Git-commit: 75fea5f6057df78af1655f2f79a9c66a94bc838f
Git-commit: 2871f731940165ed4042001a36bbe7d58f9d983b
Git-commit: bb5a65771a206ae39086af1a9e78afeaf654cf03
Git-commit: d42ba87e29ab44aac446b5434298d1369c44fe3c
Git-commit: 86646ebb1742a663c4c9c39c06d58dcb3f8f89e5
Git-commit: 83bc20ed4ba7dbf76964fd68905fde591b5de8b2
Git-commit: c266a1311e74b3ae1047a9d6abd6c6044059995c
Git-commit: ea09b9954cc40b3088b8b2778b2daab12820a7e6
Git-commit: e12563c18d484e6379d03105b4565db7bb3a7975
Git-commit: 8e8f55d1a7e865562d2e3e022a7fcf13753a9c8e
Git-commit: dae9899044f320bb119e02b45d816a493b1488ae
Git-commit: a69516d0913e7f2c9bdde17c2ea6a793bb474830
Git-commit: b8f7b236748261bec545b69b39d7fb75e519f4ed
Git-commit: e64327f5719b4a41e0de341ead7d48ed73216a23
Git-commit: a0dc8da519ccf2040af2dbbd6b4f688b50eb1755
Git-commit: 19c3c62836e5dbc9ceb620ecef0aa0c81578ed43
Git-commit: f858a9981a94a4e1d1b77b00bc05ab61b8431bce
Git-commit: 011b8344c36d39255b8057c63d98e593e364ed7f
Git-commit: ec0b569b5cc89391d9d6c90d2f76dc0a4db03e57
Git-commit: 760b3283e8056ffa6382722457c2e0cf08328629
Git-commit: 138adbbe5e4bfb6dee0571261f4d96a98f71d228
Git-commit: 66b5609826d60f80623643f1a7a1d865b5233f19

Change-Id: I171d90de41185824e0c7515f3a3b43ab88f4e058
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2020-08-18 04:58:02 -07:00
Neeraj Soni
1924eafba6 Remove Per File Key based hardware crypto framework
Remove the Per File Key logic based inline crypto support
for file encryption framework.

Change-Id: I90071562ba5c41b9db470363edac35c9fe5e4efa
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
2020-08-18 04:50:20 -07:00
Can Guo
c8c473fca0 scsi: ufs: Kconfig: remove EXTCON and EXTCON_GPIO selections
As extcon is not used anymore, remove the selections of them in Kconfig
file.

Change-Id: I764b63b83a9c91b2a02026211b14dc23cad1ff43
Signed-off-by: Can Guo <cang@codeaurora.org>
2018-01-19 16:03:04 +08:00
Subhash Jadavani
3789e2aac5 scsi: ufs: add hot plug support for removable UFS cards
Now that we can have the removable UFS cards which can be plugged in/out
at runtime, we need to add the support for gpio based card
insertion/removal event detection support. But this is bit complicated
as current platforms have the combo card slot which can either take UFS
or SD card at one time and there is a single GPIO assigned for card detect
event. This means we need some module which takes the responsibility of
controlling (configuration, interrupt handling) this shared card detection
GPIO and pass card detection event to both UFS and SD card drivers so they
can probe to see what card is inserted. Kernel already have the extcon-gpio
module which can be used as gpio control module and can pass the card
detection event to both UFS & SD card drivers. So UFS driver registers the
notification callback with extcon driver and tries to detect/remove the UFS
card.

Change-Id: Id65156289c2a722ac4a501020fdbfe6f97a354a9
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[cang@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Can Guo <cang@codeaurora.org>
2017-08-21 23:20:38 -07:00
Can Guo
b7352cb1d2 scsi: ufs: add command logging infrastructure
Add the necessary infrastructure to keep timestamp history
of commands, events and other useful info for debugging
complex issues. This helps in diagnosing events leading
upto failure.

Change-Id: I34f78b0c875262fa06c16d476be6255f7ae4d92f
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Sayali Lokhande <sayalil@codeaurora.org>
[cang@codeaurora.org: fixed trivial merge conflicts and
compilation errors]
Signed-off-by: Can Guo <cang@codeaurora.org>
[cang@codeaurora.org: resolved trivial merge conflicts and
fixed kernel compilation errors]
Signed-off-by: Can Guo <cang@codeaurora.org>
2017-08-21 23:20:29 -07:00
Maya Erez
c3d1dce045 scsi; ufs: compile UFS unit tests as module
UFS Unit tests are used by test teams to test stability
and performance of the UFS driver.
They are inactive unless manually activated and do not impact the
functionality of the UFS driver.

Change-Id: I41ae523dce60b05bb57554f9f8f38c42dbdea4a7
Signed-off-by: Maya Erez <merez@codeaurora.org>
2017-08-16 21:18:14 -07:00
Maya Erez
85cfb23ab0 scsi: ufs: add Inline Crypto Engine (ICE) support to UFS
In-order to enhance storage encryption performance,
an Inline Cryptographic Engine is introduced to UFS.
This patch adds in-line encryption capabilities to the UFS
driver.

Change-Id: Id3cb913498809b32e1f7eba96395b05a9bf3219f
Signed-off-by: Noa Rubens <noag@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[cang@codeaurora.org: Resolved trivial merge conflicts, fixed
kernel compilation errors]
Signed-off-by: Can Guo <cang@codeaurora.org>
2017-08-13 23:20:59 -07:00
Sujit Reddy Thumma
4152f8e3f7 scsi: ufs: Add UFS host PHY driver for MSM targets
Add MSM UFS host PHY driver which binds with UFSHCD platform
driver exposing vendor specific operations to initialize the
PHY. Since the controller and PHY are tightly coupled in the
system, some of the MSM specific controller register
configuration is also applied inline while initializing PHY.

Add a new compatible property "qcom,ufshc" which specifies the
UFS host controller on MSM platforms. The UFS controller driver
binds with UFS PHY driver using the phandle reference of PHY
devicetree node.

Change-Id: If695a844d03268151c6c846bdfa6cee8ff84491b
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[subhashj@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[cang@codeaurora.org: Resolved trivial merge conflicts, dropped
all changes from ufs-msm.c]
Signed-off-by: Can Guo <cang@codeaurora.org>
2017-08-13 23:17:46 -07:00
Dolev Raviv
6c8353a22a scsi: ufs: created UFS unit-tests framework
Created a new UFS block device test framework.
This test includes:
- Basic read after write command
- Random buffer length
- Ability to run test multiple times

Change-Id: I06fe7bf7d325037d6039a4acfdfb9c2c8960a435
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[cang@codeaurora.org: resolved trivial merge conflicts and
fixed kernel compilation error]
Signed-off-by: Can Guo <cang@codeaurora.org>
2017-08-13 23:17:40 -07:00
Joao Pinto
5404fb7cec scsi: ufs: Kconfig fix
Currently if we have PCI and UFSHCD configured in the kernel, both
SCSI_UFS_DWC_TC_PCI and SCSI_UFSHCD_PCI show up, which is not correct.
This patch changes the UFS Kconfig to assure hierarchy between the 2
options.

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-09-29 21:57:08 -04:00
Joao Pinto
ec658ea0c5 ufs: add TC G210 pci driver
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

[mkp: Fixed Kconfig depends and module name]

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-07-12 23:16:31 -04:00
Joao Pinto
fc040a3fc4 ufs: add TC G210 platform driver
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-07-12 23:16:31 -04:00
Arnd Bergmann
c80fa12e6d scsi: ufs: select CONFIG_NLS
A recent change to ufshcd introduced a call to utf16s_to_utf8s, a
function that is provided by the NLS module, so we get a link error when
that is not present:

drivers/scsi/built-in.o: In function `ufshcd_read_string_desc':
:(.text+0x124d0): undefined reference to `utf16s_to_utf8s'

This adds a Kconfig 'select' statement to avoid the build error.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: b573d484e4ff ("scsi: ufs: add support to read device and string descriptors")
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-03-18 15:35:23 -04:00
Yaniv Gardi
9bac5db4b2 scsi: ufs-qcom: update configuration option of SCSI_UFS_QCOM component
This change is required in order to be able to build the component
as a module.

Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-09 17:46:56 -05:00
Stephen Boyd
0d143c69a3 ufs-qcom: Switch dependency to ARCH_QCOM
This device only exists on platforms under ARCH_QCOM, not
ARCH_MSM.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Reviewed-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
2015-05-25 08:46:26 -07:00
Yaniv Gardi
81c0fc51b7 ufs-qcom: add support for Qualcomm Technologies Inc platforms
This change adds support for Qualcomm Technologies Inc platforms that
use UFS driver. for example, it adds :
- PM specific operations during hibern8, suspend, resume, clock setup
- qcom-ufs generic phy driver initialization, calibration,
  power-on/off sequence, etc.
- UFS Controller specific configuration
- Rate, Gear, Mode negotiation between device and controller

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-01-20 19:43:26 +01:00
Sahitya Tummala
856b348305 ufs: Add support for clock scaling using devfreq framework
The clocks for UFS device will be managed by generic DVFS (Dynamic
Voltage and Frequency Scaling) framework within kernel. This devfreq
framework works with different governors to scale the clocks. By default,
UFS devices uses simple_ondemand governor which scales the clocks up if
the load is more than upthreshold and scales down if the load is less than
downthreshold.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-10-01 13:11:25 +02:00
Geert Uytterhoeven
a4bfbcba69 [SCSI] ufs: SCSI_UFSHCD should depend on SCSI_DMA
If NO_DMA=y:

drivers/built-in.o: In function `ufshcd_transfer_req_compl':
drivers/scsi/ufs/ufshcd.c:1182: undefined reference to `scsi_dma_unmap'
drivers/built-in.o: In function `ufshcd_map_sg':
drivers/scsi/ufs/ufshcd.c:377: undefined reference to `scsi_dma_map'
drivers/built-in.o: In function `ufshcd_do_reset':
drivers/scsi/ufs/ufshcd.c:912: undefined reference to `scsi_dma_unmap'
drivers/built-in.o: In function `ufshcd_memory_alloc':
drivers/scsi/ufs/ufshcd.c:565: undefined reference to `dma_alloc_coherent'
drivers/built-in.o: In function `ufshcd_free_hba_memory':
drivers/scsi/ufs/ufshcd.c:185: undefined reference to `dma_free_coherent'
drivers/scsi/ufs/ufshcd.c:192: undefined reference to `dma_free_coherent'
drivers/scsi/ufs/ufshcd.c:199: undefined reference to `dma_free_coherent'
drivers/scsi/ufs/ufshcd.c:185: undefined reference to `dma_free_coherent'
drivers/scsi/ufs/ufshcd.c:192: undefined reference to `dma_free_coherent'
drivers/built-in.o:drivers/scsi/ufs/ufshcd.c:199: more undefined references to `dma_free_coherent' follow
drivers/built-in.o: In function `ufshcd_abort':
drivers/scsi/ufs/ufshcd.c:1498: undefined reference to `scsi_dma_unmap'
drivers/built-in.o: In function `ufshcd_device_reset':
drivers/scsi/ufs/ufshcd.c:1436: undefined reference to `scsi_dma_unmap'

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Santosh Y <santoshsy@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-06-04 11:16:20 -07:00
Vinayak Holikatti
03b1781aa9 [SCSI] ufs: Add Platform glue driver for ufshcd
This patch adds Platform glue driver for ufshcd.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Tested-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Vinayak Holikatti <vinholikatti@gmail.com>
Signed-off-by: Santosh Yaraganavi <santoshsy@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-05-02 16:16:50 -07:00
Vinayak Holikatti
e0eca63e34 [SCSI] ufs: Separate PCI code into glue driver
This patch separates PCI code from ufshcd.c and makes it as a
core driver module and adds a new file ufshcd-pci.c as PCI glue
driver.

[jejb: strip __devinit and devexit_p()]
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Tested-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Vinayak Holikatti <vinholikatti@gmail.com>
Signed-off-by: Santosh Yaraganavi <santoshsy@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-02-25 16:56:32 +00:00
Vinayak Holikatti
3b1d05807a [SCSI] ufs: Segregate PCI Specific Code
This patch segregates the PCI specific code in ufshcd.c to make it
ready for splitting into core ufs driver and PCI glue driver. Also
copyright header modification to remove extra warranty disclaim.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Tested-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Vinayak Holikatti <vinholikatti@gmail.com>
Signed-off-by: Santosh Yaraganavi <santoshsy@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-02-25 16:41:14 +00:00
Santosh Yaraganavi
7a3e97b0dc [SCSI] ufshcd: UFS Host controller driver
This patch adds support for Universal Flash Storage(UFS)
host controllers. The UFS host controller driver
includes host controller initialization method.

The Initialization process involves following steps:
 - Initiate UFS Host Controller initialization process by writing
   to Host controller enable register
 - Configure UFS Host controller registers with host memory space
   datastructure offsets.
 - Unipro link startup procedure
 - Check for connected device
 - Configure UFS host controller to process requests
 - Enable required interrupts
 - Configure interrupt aggregation

[jejb: fix warnings in 32 bit compile]
Signed-off-by: Santosh Yaraganavi <santoshsy@gmail.com>
Signed-off-by: Vinayak Holikatti <vinholikatti@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@linaro.org>
Reviewed-by: Vishak G <vishak.g@samsung.com>
Reviewed-by: Girish K S <girish.shivananjappa@linaro.org>
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-03-27 08:26:28 +01:00