2019-10-15 20:10:44

by Davidlohr Bueso

[permalink] [raw]
Subject: [PATCH] drivers,crypto/cavium: Fix barrier barrier usage after atomic_set()

Because it is not a Rmw operation, atomic_set() is not serialized,
and therefore the 'upgradable' smp_mb__after_atomic() call after
the atomic_set() is completely bogus (not to mention the comment
could also use some love, but that's a different matter).

This patch replaces these with smp_mb(), which seems like the
original intent of when the code was written.

Signed-off-by: Davidlohr Bueso <[email protected]>
---
drivers/crypto/cavium/nitrox/nitrox_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c
index bc924980e10c..da2e0edceb50 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -504,7 +504,7 @@ static int nitrox_probe(struct pci_dev *pdev,

atomic_set(&ndev->state, __NDEV_READY);
/* barrier to sync with other cpus */
- smp_mb__after_atomic();
+ smp_mb();

err = nitrox_crypto_register();
if (err)
@@ -551,7 +551,7 @@ static void nitrox_remove(struct pci_dev *pdev)

atomic_set(&ndev->state, __NDEV_NOT_READY);
/* barrier to sync with other cpus */
- smp_mb__after_atomic();
+ smp_mb();

nitrox_remove_from_devlist(ndev);

--
2.16.4


2019-10-16 10:21:03

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] drivers,crypto/cavium: Fix barrier barrier usage after atomic_set()

On Tue, Oct 15, 2019 at 09:16:57AM -0700, Davidlohr Bueso wrote:
> Because it is not a Rmw operation, atomic_set() is not serialized,
> and therefore the 'upgradable' smp_mb__after_atomic() call after
> the atomic_set() is completely bogus (not to mention the comment
> could also use some love, but that's a different matter).
>
> This patch replaces these with smp_mb(), which seems like the
> original intent of when the code was written.
>
> Signed-off-by: Davidlohr Bueso <[email protected]>
> ---
> drivers/crypto/cavium/nitrox/nitrox_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

So what does this actually synchronise against?

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt