linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: qat - adf_dev_stop should not be called in atomic context
@ 2016-03-29 17:20 Tadeusz Struk
  2016-04-01 17:51 ` Tadeusz Struk
  0 siblings, 1 reply; 2+ messages in thread
From: Tadeusz Struk @ 2016-03-29 17:20 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, tadeusz.struk

VFs call adf_dev_stop() from a PF to VF interrupt bottom half.
This causes an oops "scheduling while atomic", because it tries
to aquire a mutex to unregister crypto algorithms.
This patch fixes the issue by calling adf_dev_stop() asynchronusely.

Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
 drivers/crypto/qat/qat_common/adf_vf_isr.c |   31 +++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
index 09427b3..8702b0e 100644
--- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
@@ -51,6 +51,7 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
+#include <linux/kthread.h>
 #include "adf_accel_devices.h"
 #include "adf_common_drv.h"
 #include "adf_cfg.h"
@@ -90,6 +91,18 @@ static void adf_disable_msi(struct adf_accel_dev *accel_dev)
 	pci_disable_msi(pdev);
 }
 
+static int adf_dev_stop_async(void *vf)
+{
+	struct adf_accel_dev *accel_dev = vf;
+
+	adf_dev_stop(accel_dev);
+	adf_dev_shutdown(accel_dev);
+
+	/* Re-enable PF2VF interrupts */
+	adf_enable_pf2vf_interrupts(accel_dev);
+	return 0;
+}
+
 static void adf_pf2vf_bh_handler(void *data)
 {
 	struct adf_accel_dev *accel_dev = data;
@@ -107,11 +120,23 @@ static void adf_pf2vf_bh_handler(void *data)
 		goto err;
 
 	switch ((msg & ADF_PF2VF_MSGTYPE_MASK) >> ADF_PF2VF_MSGTYPE_SHIFT) {
-	case ADF_PF2VF_MSGTYPE_RESTARTING:
+	case ADF_PF2VF_MSGTYPE_RESTARTING: {
+		struct task_struct *tsk;
+
 		dev_dbg(&GET_DEV(accel_dev),
 			"Restarting msg received from PF 0x%x\n", msg);
-		adf_dev_stop(accel_dev);
-		break;
+		tsk = kthread_run(adf_dev_stop_async, accel_dev,
+				  "adf_stop_vf%d", accel_dev->accel_id);
+		if (IS_ERR(tsk))
+			dev_err(&GET_DEV(accel_dev),
+				"Couldn't schedule stop for vf_%d\n",
+				accel_dev->accel_id);
+
+		/* To ack, clear the PF2VFINT bit */
+		msg &= ~BIT(0);
+		ADF_CSR_WR(pmisc_bar_addr, hw_data->get_pf2vf_offset(0), msg);
+		return;
+	}
 	case ADF_PF2VF_MSGTYPE_VERSION_RESP:
 		dev_dbg(&GET_DEV(accel_dev),
 			"Version resp received from PF 0x%x\n", msg);

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

* Re: [PATCH] crypto: qat - adf_dev_stop should not be called in atomic context
  2016-03-29 17:20 [PATCH] crypto: qat - adf_dev_stop should not be called in atomic context Tadeusz Struk
@ 2016-04-01 17:51 ` Tadeusz Struk
  0 siblings, 0 replies; 2+ messages in thread
From: Tadeusz Struk @ 2016-04-01 17:51 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

Hi Herbert,
On 03/29/2016 10:20 AM, Tadeusz Struk wrote:
> VFs call adf_dev_stop() from a PF to VF interrupt bottom half.
> This causes an oops "scheduling while atomic", because it tries
> to aquire a mutex to unregister crypto algorithms.
> This patch fixes the issue by calling adf_dev_stop() asynchronusely.
> 
> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
> ---
>  drivers/crypto/qat/qat_common/adf_vf_isr.c |   31 +++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)

This patch in not correct. Please drop it.
I'll sent a v2 early next week.
Thanks,
-- 
TS

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

end of thread, other threads:[~2016-04-01 17:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29 17:20 [PATCH] crypto: qat - adf_dev_stop should not be called in atomic context Tadeusz Struk
2016-04-01 17:51 ` Tadeusz Struk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).