This is to add fw_little_endian option, which can
be used for platform which firmware is using little-endian
(instead of big-endian).
Signed-off-by: Peter Harliman Liem <[email protected]>
---
drivers/crypto/inside-secure/safexcel.c | 15 +++++++++++----
drivers/crypto/inside-secure/safexcel.h | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
index 02c103da09a9..955170d2dd7c 100644
--- a/drivers/crypto/inside-secure/safexcel.c
+++ b/drivers/crypto/inside-secure/safexcel.c
@@ -316,14 +316,21 @@ static void eip197_init_firmware(struct safexcel_crypto_priv *priv)
static int eip197_write_firmware(struct safexcel_crypto_priv *priv,
const struct firmware *fw)
{
- const __be32 *data = (const __be32 *)fw->data;
+ const u32 *data = (const u32 *)fw->data;
+ u32 val;
int i;
/* Write the firmware */
- for (i = 0; i < fw->size / sizeof(u32); i++)
- writel(be32_to_cpu(data[i]),
+ for (i = 0; i < fw->size / sizeof(u32); i++) {
+ if (priv->data->fw_little_endian)
+ val = le32_to_cpu(data[i]);
+ else
+ val = be32_to_cpu(data[i]);
+
+ writel(val,
priv->base + EIP197_CLASSIFICATION_RAMS +
- i * sizeof(__be32));
+ i * sizeof(*data));
+ }
/* Exclude final 2 NOPs from size */
return i - EIP197_FW_TERMINAL_NOPS;
diff --git a/drivers/crypto/inside-secure/safexcel.h b/drivers/crypto/inside-secure/safexcel.h
index 1b8ccb33202b..a89dd8dc1ddd 100644
--- a/drivers/crypto/inside-secure/safexcel.h
+++ b/drivers/crypto/inside-secure/safexcel.h
@@ -735,6 +735,7 @@ enum safexcel_eip_version {
struct safexcel_of_data {
enum safexcel_eip_version version;
+ bool fw_little_endian;
};
/* Priority we use for advertising our algorithms */
--
2.17.1
Hi Peter,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.0-rc6 next-20220920]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Harliman-Liem/crypto-inside-secure-Expand-soc-data-structure/20220920-170235
base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: parisc-randconfig-s051-20220921 (https://download.01.org/0day-ci/archive/20220921/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/637d1b2810d1e9da47b6a637f9cea7c5bb4bf765
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Peter-Harliman-Liem/crypto-inside-secure-Expand-soc-data-structure/20220920-170235
git checkout 637d1b2810d1e9da47b6a637f9cea7c5bb4bf765
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash drivers/crypto/inside-secure/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
>> drivers/crypto/inside-secure/safexcel.c:326:31: sparse: sparse: cast to restricted __le32
drivers/crypto/inside-secure/safexcel.c:328:31: sparse: sparse: cast to restricted __be32
vim +326 drivers/crypto/inside-secure/safexcel.c
315
316 static int eip197_write_firmware(struct safexcel_crypto_priv *priv,
317 const struct firmware *fw)
318 {
319 const u32 *data = (const u32 *)fw->data;
320 u32 val;
321 int i;
322
323 /* Write the firmware */
324 for (i = 0; i < fw->size / sizeof(u32); i++) {
325 if (priv->data->fw_little_endian)
> 326 val = le32_to_cpu(data[i]);
327 else
328 val = be32_to_cpu(data[i]);
329
330 writel(val,
331 priv->base + EIP197_CLASSIFICATION_RAMS +
332 i * sizeof(*data));
333 }
334
335 /* Exclude final 2 NOPs from size */
336 return i - EIP197_FW_TERMINAL_NOPS;
337 }
338
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Quoting Peter Harliman Liem (2022-09-20 10:01:38)
> This is to add fw_little_endian option, which can
> be used for platform which firmware is using little-endian
> (instead of big-endian).
That's surprising, releasing fw in various endianness.
Cc Pascal who might know.
On 23/9/2022 5:23 pm, Antoine Tenart wrote:
> Quoting Peter Harliman Liem (2022-09-20 10:01:38)
>> This is to add fw_little_endian option, which can
>> be used for platform which firmware is using little-endian
>> (instead of big-endian).
>
> That's surprising, releasing fw in various endianness.
>
> Cc Pascal who might know.
>
Indeed. Would be great if someone could help confirm in case I'm wrong.
Thanks!
-Peter-