2017-04-20 20:24:07

by Gary R Hook

[permalink] [raw]
Subject: [PATCH V3 0/2] Interrupt management fixes

Correct the driver to attend to only relevant interrupt
bits, and ensure that interrupts are managed properly
at module unload.

Changes from V2:
- Apply patches to relevant stable branches

Changes from V1:
- Changed the #define to "SUPPORTED_INTERRUPTS"

---

Gary R Hook (2):
crypto: ccp - Use only the relevant interrupt bits
crypto: ccp - Disable interrupts early on unload


drivers/crypto/ccp/ccp-dev-v5.c | 11 ++++++-----
drivers/crypto/ccp/ccp-dev.h | 5 ++---
2 files changed, 8 insertions(+), 8 deletions(-)


2017-04-20 20:24:21

by Gary R Hook

[permalink] [raw]
Subject: [PATCH V3 1/2] crypto: ccp - Use only the relevant interrupt bits

Each CCP queue can product interrupts for 4 conditions:
operation complete, queue empty, error, and queue stopped.
This driver only works with completion and error events.

Cc: <[email protected]> # 4.9.x+

Signed-off-by: Gary R Hook <[email protected]>
---
drivers/crypto/ccp/ccp-dev-v5.c | 9 +++++----
drivers/crypto/ccp/ccp-dev.h | 5 ++---
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index e03d06a54d4e..c7972e733e43 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -801,7 +801,7 @@ static int ccp5_init(struct ccp_device *ccp)
ioread32(cmd_q->reg_status);

/* Clear the interrupts */
- iowrite32(ALL_INTERRUPTS, cmd_q->reg_interrupt_status);
+ iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status);
}

dev_dbg(dev, "Requesting an IRQ...\n");
@@ -882,7 +882,7 @@ static int ccp5_init(struct ccp_device *ccp)
/* Enable interrupts */
for (i = 0; i < ccp->cmd_q_count; i++) {
cmd_q = &ccp->cmd_q[i];
- iowrite32(ALL_INTERRUPTS, cmd_q->reg_int_enable);
+ iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_int_enable);
}

dev_dbg(dev, "Registering device...\n");
@@ -942,7 +942,7 @@ static void ccp5_destroy(struct ccp_device *ccp)
iowrite32(cmd_q->qcontrol & ~CMD5_Q_RUN, cmd_q->reg_control);

/* Disable the interrupts */
- iowrite32(ALL_INTERRUPTS, cmd_q->reg_interrupt_status);
+ iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status);

/* Clear the interrupt status */
iowrite32(0x00, cmd_q->reg_int_enable);
@@ -1002,7 +1002,8 @@ static irqreturn_t ccp5_irq_handler(int irq, void *data)
cmd_q->int_rcvd = 1;

/* Acknowledge the interrupt and wake the kthread */
- iowrite32(ALL_INTERRUPTS, cmd_q->reg_interrupt_status);
+ iowrite32(SUPPORTED_INTERRUPTS,
+ cmd_q->reg_interrupt_status);
wake_up_interruptible(&cmd_q->int_queue);
}
}
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 191274d41036..2dfec019a832 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -109,9 +109,8 @@
#define INT_COMPLETION 0x1
#define INT_ERROR 0x2
#define INT_QUEUE_STOPPED 0x4
-#define ALL_INTERRUPTS (INT_COMPLETION| \
- INT_ERROR| \
- INT_QUEUE_STOPPED)
+#define INT_EMPTY_QUEUE 0x8
+#define SUPPORTED_INTERRUPTS (INT_COMPLETION | INT_ERROR)

#define LSB_REGION_WIDTH 5
#define MAX_LSB_CNT 8

2017-04-20 20:24:40

by Gary R Hook

[permalink] [raw]
Subject: [PATCH V3 2/2] crypto: ccp - Disable interrupts early on unload

From: Gary R Hook <[email protected]>

Ensure that we disable interrupts first when shutting down
the driver.

Cc: <[email protected]> # 4.9.x+

Signed-off-by: Gary R Hook <[email protected]>
---
drivers/crypto/ccp/ccp-dev-v5.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index c7972e733e43..13b81a1c1184 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -942,10 +942,10 @@ static void ccp5_destroy(struct ccp_device *ccp)
iowrite32(cmd_q->qcontrol & ~CMD5_Q_RUN, cmd_q->reg_control);

/* Disable the interrupts */
- iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status);
+ iowrite32(0x00, cmd_q->reg_int_enable);

/* Clear the interrupt status */
- iowrite32(0x00, cmd_q->reg_int_enable);
+ iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status);
ioread32(cmd_q->reg_int_status);
ioread32(cmd_q->reg_status);
}

2017-04-21 13:17:35

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH V3 0/2] Interrupt management fixes

On Thu, Apr 20, 2017 at 03:24:00PM -0500, Gary R Hook wrote:
> Correct the driver to attend to only relevant interrupt
> bits, and ensure that interrupts are managed properly
> at module unload.
>
> Changes from V2:
> - Apply patches to relevant stable branches

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