Commit Graph

304 Commits

Author SHA1 Message Date
Dan Carpenter
4d61427603 staging: ccree: don't break lines unnecessarily
These lines are less than 80 characters so we don't need to break them
up into chunks.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15 15:50:35 +01:00
Gilad Ben-Yossef
f24d41169a staging: ccree: dma mask is type u64
The dma mask var was defined as dma_addr_t but should be
u64. This showed as a sparse warning when building for 32 bit.
Fix it by changing type to u64 and drop the cast.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:02:18 +01:00
Gilad Ben-Yossef
5d5583d0e2 staging: ccree: make stub function static inline
The debugfs interface defines stub function if debugfs is not
enabled, which were missing the 'static inline' qualifiers causing
sparse warnings.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:02:18 +01:00
Gilad Ben-Yossef
65073e6ea9 staging: ccree: add missing include
Add the missing include of include file with function declarations.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:02:18 +01:00
Gilad Ben-Yossef
6daa971b57 staging: ccree: remove unneeded includes
Remove include files not needed for compilation.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:01:35 +01:00
Gilad Ben-Yossef
e7660d2d47 staging: ccree: use a consistent file naming convention
The ccree driver source files were using an inconsistent
naming convention stemming from what the company was called
when they were added.

Move to a single consistent naming convention for better
code readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:00:07 +01:00
Gilad Ben-Yossef
3c464ca5b8 staging: ccree: update TODO
Update TODO to reflect work done

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:29:39 +01:00
Gilad Ben-Yossef
2392b84fb2 stating: ccree: fix allocation of void sized buf
We were allocating buffers using sizeof(*struct->field) where field was
type void.  Fix it by having a local variable with the real type.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:29:36 +01:00
Gilad Ben-Yossef
abb8492b2a staging: ccree: put pointer next to var name
Put pointer next to var name as per coding style.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:29:36 +01:00
Gilad Ben-Yossef
28b1ad901f staging: ccree: fold common code into service func
Fold common code in hash call into service functions.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:29:36 +01:00
Gilad Ben-Yossef
0d207bd44d staging: ccree: fix indentation of func params
Fix indentation of some function params in hash code for
better readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:29:36 +01:00
Gilad Ben-Yossef
2c8cdb6b5d staging: ccree: do not map bufs in ahash_init
hash_init was mapping DMA memory that were then being unmap in
hash_digest/final/finup callbacks, which is against the Crypto API
usage rules (see discussion at
https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg30077.html)

Fix it by moving all buffer mapping/unmapping or each Crypto API op.

This also properly deals with hash_import() not knowing if
hash_init was called or not as it now no longer matters.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
9b3044b88e staging: ccree: allocate hash bufs inside req ctx
Move to allocating the buffers needed for requests as part of
the request structure instead of malloc'ing each one on it's
own, making for simpler (and more efficient) code.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
89c2db889d staging: ccree: use array for double buffer
The ccree hash code is using a double buffer to hold data
for processing but manages the buffers and their associated
data count in two separate fields and uses a predicate to
chose which to use.

Move to using a proper 2 members array for a much cleaner code.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
46856e6cf2 staging: ccree: remove unused field
Remove unused struct field.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
327256908d staging: ccree: use Makefile to include PM code
Replace ugly ifdefs with some inline macros and Makefile magic
for optionally including power management related code for
better readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
6e92010b01 staging: ccree: handle end of sg list gracefully
If we are asked for number of entries of an offset bigger than the
sg list we should not crash.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
2f7caf6b02 staging: ccree: check DMA pool buf !NULL before free
If we ran out of DMA pool buffers, we get into the unmap
code path with a NULL before. Deal with this by checking
the virtual mapping is not NULL.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
5ced266469 staging: ccree: failing the suspend is not an error
PM suspend returning a none zero value is not an error. It simply
indicates a suspend is not advised right now so don't treat it as
an error.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
293edc27f8 stating: ccree: revert "staging: ccree: fix leak of import() after init()"
This reverts commit c5f39d0786 ("staging: ccree: fix leak of import()
after init()") and commit aece090244 ("staging: ccree: Uninitialized
return in ssi_ahash_import()").

This is the wrong solution and ends up relying on uninitialized memory,
although it was not obvious to me at the time.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
7345b14dea staging: ccree: add backlog processing
Crypto API tfm providers are required to provide a backlog
service, if so indicated, that queues up requests in the case
of the provider being busy and processing them later.

The ccree driver did not provide this facility. Add it now.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
0f70db7033 staging: ccree: break send_request and fix ret val
The send_request() function was handling both synchronous
and asynchronous invocations, but were not handling
the asynchronous case, which may be called in an atomic
context, properly as it was sleeping.

Start to fix the problem by breaking up the two use
cases to separate functions calling a common internal
service function and return error instead of sleeping
for the asynchronous case.

The next patch will complete the fix by implementing
proper backlog handling.

Fixes: abefd6741d ("staging: ccree: introduce CryptoCell HW driver").
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
266844f13e staging: ccree: remove unused leftover field
Remove the unused monitor_desc field.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
48520f8cfa staging: ccree: tag debugfs init/exit func properly
The debugfs global init and exit functions were missing
__init and __exit tags, potentially wasting memory.
Fix it by properly tagging them.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
b070ed04c3 staging: ccree: copy larval digest from RAM
The ccree driver was using a DMA operation to copy larval digest
from the ccree SRAM to RAM. Replace it with a simple memcpy.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
1b33fb7aed staging: ccree: pick alloc mem flags based on req flags
The ccree driver was allocating memory using GFP_KERNEL flag
always, ignoring the flags set in the crypto request. Fix it
by choosing gfp flags based on crypto request flags.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
ee70ad833a staging: ccree: remove GFP_DMA flag from mem allocs
Remove bogus GFP_DMA flag from memory allocations. ccree driver
does not operate over an ISA or similar limited bus.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
a3ddcf6604 staging: ccree: fold reg common defines into driver
Fold the 2 macro defined in dx_reg_common.h into the file they
are used in and delete the file.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
977cd76c2d staging: ccree: fold hash defs into queue defs
Fold the two remaining enum in hash defs into the queue defs
that are using them and delete the hash defs include file.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
70da8241af staging: ccree: SPDXify driver
Replace verbatim GPL v2 copy with SPDX tag.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:26:15 +01:00
Arnd Bergmann
c7fc46fd14 staging: ccree: mark debug_regs[] as static
The global array clashes with an existing symbol of the same name:

drivers/staging/ccree/cc_debugfs.o:(.data+0x0): multiple definition of `debug_regs'
drivers/mmc/host/s3cmci.o:(.data+0x70): first defined here

We should fix both, this one addresses the ccree driver by removing
the symbol from the global namespace.

Fixes: 9bdd203b4d ("s3cmci: add debugfs support for examining driver and hardware state")
Fixes: b3ec9a6736 ("staging: ccree: staging: ccree: replace sysfs by debugfs interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:26:15 +01:00
Gilad Ben-Yossef
11cc84e708 staging: ccree: use size_t consistently
Fix declaration, implementation and wrapper function to use
the same size_t type we actually define the parameter to be.

Fixes: 3f268f5d66 ("staging: ccree: turn compile time debug log to params")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-20 08:41:16 +01:00
Kamal Heib
ac3c7776b1 Staging: ccree: Add blank line after declarations
This patch adds a blank line after declarations to
improve code readability.

Issue find by checkpatch.pl script.
WARNING: Missing a blank line after declarations

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
5cba3082ff staging: ccree: update TODO
Update TODO with handling on sysfs -> debugfs transition

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
dc5591dc9c staging: ccree: fix fips event irq handling build
When moving from internal for kernel FIPS infrastructure the FIPS event irq
handling code was left with the old ifdef by mistake. Fix it.

Fixes: b7e607bf33 ("staging: ccree: move FIPS support to kernel infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
a92d24a8bc staging: ccree: remove ssi_config.h
Now that the only thing left in ssi_config is the maximum
DMA mask length we get move that to ssi_driver.h and get
rid of the file.

All of ccree is now runtime configurable or under Kbuild control.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
3f268f5d66 staging: ccree: turn compile time debug log to params
The ccree driver has some support to dump runtime data
to kernel log to assist in debugging. The code used to be
enabled by a build time flag. Refactor to enable it via
module/kernel parameters.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
829def3312 staging: ccree: remove useless debug code
Remove a bunch of useless debug code ifdef'ed out

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
96e31ecc62 staging: ccree: remove CC_IRQ_DELAY dead code
Remove dead code from older version which is not supported in current
hardware.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
b3ec9a6736 staging: ccree: staging: ccree: replace sysfs by debugfs interface
The ccree driver has had a none standard sysfs interface for debugging.
Replace it with a proper debugfs interface.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
31aeaca4d2 staging: ccree: add explicit module init/exit func
We need to do a module global scope init/exit operation to support
the debugfs interface we are about to introduce in the next patch,
so wean the module of the boiler plate saving macro as it will no
longer be sufficient.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
4ba5895bd3 staging: ccree: clean up PM registration
Clean up power management registration.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
16bcccb774 staging: ccree: drop ifdef CONFIG_OF in code
As we already depend on CONFIG_OF via Kconfig no need to
support conditional build without it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Greg Kroah-Hartman
7f9d04bc56 Merge 4.15-rc4 into staging-next
We want the staging fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-18 09:12:51 +01:00
Gilad Ben-Yossef
6dc4d30252 staging: ccree: fix FIPS mgr naming convention
The FIPS manager files were using a naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
e24673641e staging: ccree: simplify freeing SRAM memory address
The code freeing the SRAM memory address was zeroing the address
on release although there is nothing secret about it. Simplify
the code by simply calling kfree directly.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
7358733a5c staging: ccree: fix sram mgr naming convention
The SRAM manager files were using a naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
84d39a90b8 staging: ccree: fix buf mgr naming convention
The buffer manager files were using a func naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
961559f317 staging: ccree: rename vars/structs/enums from ssi_ to cc_
Unify naming convention by renaming all ssi_ vars/structs/enums
and variables to cc_*

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
9021a014bd staging: ccree: rename all DX to CC
Unify naming convention by renaming all DX macros to CC.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00