All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: iaa - A couple of bugfixes
@ 2024-03-21 21:08 Tom Zanussi
  2024-03-21 21:08 ` [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case Tom Zanussi
  2024-03-21 21:08 ` [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation Tom Zanussi
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Zanussi @ 2024-03-21 21:08 UTC (permalink / raw
  To: herbert, davem; +Cc: jsnitsel, linux-kernel, linux-crypto

Hi Herbert,

Here are a couple of bugfixes to iaa_crypto.

The first is a documentation fix from Jerry Snitselaar, which I added
my Reviewed-by: to.

The second is a fix for a divide-by-0 bug when running with a single
cpu, which was reported by Jerry as well, and which I've tested with
various numbers of cpus and other permutations with no problems.

Thanks to Jerry for the patch and bug report.

Thanks,

Tom

Jerry Snitselaar (1):
  crypto: iaa: Fix some errors in IAA documentation

Tom Zanussi (1):
  crypto: iaa - Fix nr_cpus < nr_iaa case

 .../driver-api/crypto/iaa/iaa-crypto.rst      | 22 ++++++++++++++-----
 drivers/crypto/intel/iaa/iaa_crypto_main.c    | 10 ++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case
  2024-03-21 21:08 [PATCH 0/2] crypto: iaa - A couple of bugfixes Tom Zanussi
@ 2024-03-21 21:08 ` Tom Zanussi
  2024-03-22 11:44   ` Herbert Xu
  2024-03-21 21:08 ` [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation Tom Zanussi
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Zanussi @ 2024-03-21 21:08 UTC (permalink / raw
  To: herbert, davem; +Cc: jsnitsel, linux-kernel, linux-crypto

If nr_cpus < nr_iaa, the calculated cpus_per_iaa will be 0, which
causes a divide-by-0 in rebalance_wq_table().

Make sure cpus_per_iaa is 1 in that case, and also in the nr_iaa == 0
case, even though cpus_per_iaa is never used if nr_iaa == 0, for
paranoia.

Reported-by: Jerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
index 1cd304de5388..b2191ade9011 100644
--- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
+++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
@@ -806,6 +806,8 @@ static int save_iaa_wq(struct idxd_wq *wq)
 		return -EINVAL;
 
 	cpus_per_iaa = (nr_nodes * nr_cpus_per_node) / nr_iaa;
+	if (!cpus_per_iaa)
+		cpus_per_iaa = 1;
 out:
 	return 0;
 }
@@ -821,10 +823,12 @@ static void remove_iaa_wq(struct idxd_wq *wq)
 		}
 	}
 
-	if (nr_iaa)
+	if (nr_iaa) {
 		cpus_per_iaa = (nr_nodes * nr_cpus_per_node) / nr_iaa;
-	else
-		cpus_per_iaa = 0;
+		if (!cpus_per_iaa)
+			cpus_per_iaa = 1;
+	} else
+		cpus_per_iaa = 1;
 }
 
 static int wq_table_add_wqs(int iaa, int cpu)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation
  2024-03-21 21:08 [PATCH 0/2] crypto: iaa - A couple of bugfixes Tom Zanussi
  2024-03-21 21:08 ` [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case Tom Zanussi
@ 2024-03-21 21:08 ` Tom Zanussi
  2024-03-28 10:57   ` Herbert Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Zanussi @ 2024-03-21 21:08 UTC (permalink / raw
  To: herbert, davem; +Cc: jsnitsel, linux-kernel, linux-crypto

From: Jerry Snitselaar <jsnitsel@redhat.com>

This cleans up the following issues I ran into when trying to use the
scripts and commands in the iaa-crypto.rst document.

- Fix incorrect arguments being passed to accel-config
  config-wq.
    - Replace --device_name with --driver-name.
    - Replace --driver_name with --driver-name.
    - Replace --size with --wq-size.
    - Add missing --priority argument.
- Add missing accel-config config-engine command after the
  config-wq commands.
- Fix wq name passed to accel-config config-wq.
- Add rmmod/modprobe of iaa_crypto to script that disables,
  then enables all devices and workqueues to avoid enable-wq
  failing with -EEXIST when trying to register to compression
  algorithm.
- Fix device name in cases where iaa was used instead of iax.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-crypto@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 .../driver-api/crypto/iaa/iaa-crypto.rst      | 22 ++++++++++++++-----
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/Documentation/driver-api/crypto/iaa/iaa-crypto.rst b/Documentation/driver-api/crypto/iaa/iaa-crypto.rst
index de587cf9cbed..330d35df5f16 100644
--- a/Documentation/driver-api/crypto/iaa/iaa-crypto.rst
+++ b/Documentation/driver-api/crypto/iaa/iaa-crypto.rst
@@ -179,7 +179,9 @@ has the old 'iax' device naming in place) ::
 
   # configure wq1.0
 
-  accel-config config-wq --group-id=0 --mode=dedicated --type=kernel --name="iaa_crypto" --device_name="crypto" iax1/wq1.0
+  accel-config config-wq --group-id=0 --mode=dedicated --type=kernel --priority=10 --name="iaa_crypto" --driver-name="crypto" iax1/wq1.0
+
+  accel-config config-engine iax1/engine1.0 --group-id=0
 
   # enable IAA device iax1
 
@@ -536,12 +538,20 @@ The below script automatically does that::
 
   echo "End Disable IAA"
 
+  echo "Reload iaa_crypto module"
+
+  rmmod iaa_crypto
+  modprobe iaa_crypto
+
+  echo "End Reload iaa_crypto module"
+
   #
   # configure iaa wqs and devices
   #
   echo "Configure IAA"
   for ((i = 1; i < ${num_iaa} * 2; i += 2)); do
-      accel-config config-wq --group-id=0 --mode=dedicated --size=128 --priority=10 --type=kernel --name="iaa_crypto" --driver_name="crypto" iax${i}/wq${i}
+      accel-config config-wq --group-id=0 --mode=dedicated --wq-size=128 --priority=10 --type=kernel --name="iaa_crypto" --driver-name="crypto" iax${i}/wq${i}.0
+      accel-config config-engine iax${i}/engine${i}.0 --group-id=0
   done
 
   echo "End Configure IAA"
@@ -552,10 +562,10 @@ The below script automatically does that::
   echo "Enable IAA"
 
   for ((i = 1; i < ${num_iaa} * 2; i += 2)); do
-      echo enable iaa iaa${i}
-      accel-config enable-device iaa${i}
-      echo enable wq iaa${i}/wq${i}.0
-      accel-config enable-wq iaa${i}/wq${i}.0
+      echo enable iaa iax${i}
+      accel-config enable-device iax${i}
+      echo enable wq iax${i}/wq${i}.0
+      accel-config enable-wq iax${i}/wq${i}.0
   done
 
   echo "End Enable IAA"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case
  2024-03-21 21:08 ` [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case Tom Zanussi
@ 2024-03-22 11:44   ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2024-03-22 11:44 UTC (permalink / raw
  To: Tom Zanussi; +Cc: davem, jsnitsel, linux-kernel, linux-crypto

On Thu, Mar 21, 2024 at 04:08:45PM -0500, Tom Zanussi wrote:
> If nr_cpus < nr_iaa, the calculated cpus_per_iaa will be 0, which
> causes a divide-by-0 in rebalance_wq_table().
> 
> Make sure cpus_per_iaa is 1 in that case, and also in the nr_iaa == 0
> case, even though cpus_per_iaa is never used if nr_iaa == 0, for
> paranoia.
> 
> Reported-by: Jerry Snitselaar <jsnitsel@redhat.com>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
>  drivers/crypto/intel/iaa/iaa_crypto_main.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation
  2024-03-21 21:08 ` [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation Tom Zanussi
@ 2024-03-28 10:57   ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2024-03-28 10:57 UTC (permalink / raw
  To: Tom Zanussi; +Cc: davem, jsnitsel, linux-kernel, linux-crypto

On Thu, Mar 21, 2024 at 04:08:46PM -0500, Tom Zanussi wrote:
> From: Jerry Snitselaar <jsnitsel@redhat.com>
> 
> This cleans up the following issues I ran into when trying to use the
> scripts and commands in the iaa-crypto.rst document.
> 
> - Fix incorrect arguments being passed to accel-config
>   config-wq.
>     - Replace --device_name with --driver-name.
>     - Replace --driver_name with --driver-name.
>     - Replace --size with --wq-size.
>     - Add missing --priority argument.
> - Add missing accel-config config-engine command after the
>   config-wq commands.
> - Fix wq name passed to accel-config config-wq.
> - Add rmmod/modprobe of iaa_crypto to script that disables,
>   then enables all devices and workqueues to avoid enable-wq
>   failing with -EEXIST when trying to register to compression
>   algorithm.
> - Fix device name in cases where iaa was used instead of iax.
> 
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: linux-crypto@vger.kernel.org
> Cc: linux-doc@vger.kernel.org
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
> Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> ---
>  .../driver-api/crypto/iaa/iaa-crypto.rst      | 22 ++++++++++++++-----
>  1 file changed, 16 insertions(+), 6 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-28 10:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 21:08 [PATCH 0/2] crypto: iaa - A couple of bugfixes Tom Zanussi
2024-03-21 21:08 ` [PATCH 1/2] crypto: iaa - Fix nr_cpus < nr_iaa case Tom Zanussi
2024-03-22 11:44   ` Herbert Xu
2024-03-21 21:08 ` [PATCH 2/2] crypto: iaa: Fix some errors in IAA documentation Tom Zanussi
2024-03-28 10:57   ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.