talitos: Freescale integrated security engine (SEC) driver
PATCH 2/2 talitos: Freescale integrated security engine (SEC) driver
Add support for the SEC available on a wide range of PowerQUICC devices, e.g. MPC8349E, MPC8548E.
this initial version supports authenc(hmac(sha1),cbc(aes)) for use with IPsec.
--- drivers/crypto/Kconfig | 15 + drivers/crypto/Makefile | 1 + drivers/crypto/talitos.c | 1373 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/talitos.h | 191 +++++++ 4 files changed, 1580 insertions(+), 0 deletions(-) create mode 100644 drivers/crypto/talitos.c create mode 100644 drivers/crypto/talitos.h
drivers/crypto/Kconfig +15 -0
@@ -174,4 +174,19 @@ config CRYPTO_DEV_HIFN_795X_RNG Select this option if you want to enable the random number generator on the HIFN 795x crypto adapters. +config CRYPTO_DEV_TALITOS + tristate "Talitos Freescale Security Engine (SEC)" + select CRYPTO_ALGAPI + select CRYPTO_AUTHENC + depends on FSL_SOC + help + Say 'Y' here to use the Freescale Security Engine (SEC) + to offload cryptographic algorithm computation. + + The Freescale SEC is present on PowerQUICC 'E' processors, such + as the MPC8349E and MPC8548E. + + To compile this driver as a module, choose M here: the module + will be called talitos. + endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o +obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
drivers/crypto/talitos.c new file +1373 -0
1,373 lines not on this page · raw message
drivers/crypto/talitos.h new file +191 -0
191 lines not on this page · raw message
Signature · 1 line
1.5.5.1.125.gc697a
Hi.
Quoted 16 lines · Kim Phillips
drivers/crypto/talitos.c new file +16
-0+static irqreturn_t talitos_interrupt (int irq,void *data) +{ +struct device *dev = data; +struct talitos_private *priv =dev_get_drvdata (dev); + + priv->status =in_be32 (priv->reg +TALITOS_ISR ); + priv->status_lo =in_be32 (priv->reg +TALITOS_ISR_LO ); + +if (unlikely (priv->status & ~TALITOS_ISR_CHDONE )) { +talitos_error ((unsigned long )data); +/* ack */ +out_be32 (priv->reg +TALITOS_ICR , priv->status); +out_be32 (priv->reg +TALITOS_ICR_LO , priv->status_lo); + } +else + {
drivers/crypto/talitos.c line 560
Quoted 10 lines
drivers/crypto/talitos.c new file +10
-0+/* ack */ +out_be32 (priv->reg +TALITOS_ICR , priv->status); +out_be32 (priv->reg +TALITOS_ICR_LO , priv->status_lo); + +if (likely (priv->status &TALITOS_ISR_CHDONE )) +tasklet_schedule (&priv->done_task); + } + +return (priv->status || priv->status_lo) ?IRQ_HANDLED :IRQ_NONE ; +}
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Signature · 1 line
Evgeniy Polyakov
Quoted 25 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Hi.
Quoted 21 lines · Kim Phillips
drivers/crypto/talitos.c new file +21
-0+static irqreturn_t talitos_interrupt (int irq,void *data) +{ +struct device *dev = data; +struct talitos_private *priv =dev_get_drvdata (dev); + + priv->status =in_be32 (priv->reg +TALITOS_ISR ); + priv->status_lo =in_be32 (priv->reg +TALITOS_ISR_LO ); + +if (unlikely (priv->status & ~TALITOS_ISR_CHDONE )) { +talitos_error ((unsigned long )data); +/* ack */ +out_be32 (priv->reg +TALITOS_ICR , priv->status); +out_be32 (priv->reg +TALITOS_ICR_LO , priv->status_lo); + } +else + { +/* ack */ +out_be32 (priv->reg +TALITOS_ICR , priv->status); +out_be32 (priv->reg +TALITOS_ICR_LO , priv->status_lo); + +if (likely (priv->status &TALITOS_ISR_CHDONE ))
Quoted 8 lines
drivers/crypto/talitos.c line 560
Quoted 5 lines
drivers/crypto/talitos.c new file +5
-0+tasklet_schedule (&priv->done_task); + } + +return (priv->status || priv->status_lo) ?IRQ_HANDLED :IRQ_NONE ; +}Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Kim
Quoted 7 lines · Kim Phillips
Quoted 2 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
-Scott
Quoted 8 lines · Scott Wood
Quoted 5 lines
Quoted 2 lines
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
Yes, that register space can be assigned from non-interrupt path on different cpu. I saw spin_lock_irqsave() is used in some other places, but not in interrupt handler itself.
Signature · 1 line
Evgeniy Polyakov
Quoted 11 lines · On Fri, 30 May 2008 14:41:17 -0500 Scott Wood <[email protected]> wrote:
Quoted 7 lines · Kim Phillips
Quoted 2 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
not that I can see - the fetch fifo register writes are protected with per-channel spinlocks.
Kim
Quoted 6 lines · Kim Phillips
Quoted 3 lines · On Fri, 30 May 2008 14:41:17 -0500 Scott Wood <[email protected]> wrote:
Quoted 2 lines · Kim Phillips
On Fri, 30 May 2008 22:09:04 +0400
Evgeniy Polyakov <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
not that I can see - the fetch fifo register writes are protected with per-channel spinlocks.
But you don't take the spinlocks from the interrupt handler.
-Scott
Quoted 14 lines · Kim Phillips
Quoted 11 lines · On Fri, 30 May 2008 15:19:43 -0500 Scott Wood <[email protected]> wrote:
Quoted 10 lines · Kim Phillips
Quoted 7 lines · On Fri, 30 May 2008 14:41:17 -0500 Scott Wood <[email protected]> wrote:
Quoted 6 lines · Kim Phillips
Quoted 2 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
not that I can see - the fetch fifo register writes are protected with per-channel spinlocks.
But you don't take the spinlocks from the interrupt handler.
why can't fetch fifo registers be written the same time the ISR is being accessed?
I don't know -- you brought them up. My question was whether there's anything that the ISR touches that is also touched by non-ISR code.
-Scott
Quoted 11 lines · On Fri, 30 May 2008 15:19:43 -0500 Scott Wood <[email protected]> wrote:
Quoted 10 lines · Kim Phillips
Quoted 7 lines · On Fri, 30 May 2008 14:41:17 -0500 Scott Wood <[email protected]> wrote:
Quoted 6 lines · Kim Phillips
Quoted 2 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
not that I can see - the fetch fifo register writes are protected with per-channel spinlocks.
But you don't take the spinlocks from the interrupt handler.
why can't fetch fifo registers be written the same time the ISR is being accessed?
Kim
Quoted 19 lines · On Fri, 30 May 2008 15:36:50 -0500 Scott Wood <[email protected]> wrote:
Quoted 18 lines · Kim Phillips
Quoted 15 lines · On Fri, 30 May 2008 15:19:43 -0500 Scott Wood <[email protected]> wrote:
Quoted 14 lines · Kim Phillips
Quoted 9 lines · On Fri, 30 May 2008 14:41:17 -0500 Scott Wood <[email protected]> wrote:
Quoted 6 lines · Kim Phillips
Quoted 2 lines · On Fri, 30 May 2008 22:09:04 +0400 Evgeniy Polyakov <[email protected]> wrote:
Don't you want to protect against simultaneous access to register space from different CPUs? Or it is single processor board only?
Doesn't linux mask the IRQ line for the interrupt currently being serviced, and on all processors?
Yes. Could there be interference from non-interrupt driver code on another cpu (or interrupted code), though?
not that I can see - the fetch fifo register writes are protected with per-channel spinlocks.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But you don't take the spinlocks from the interrupt handler.
why can't fetch fifo registers be written the same time the ISR is being accessed?
I don't know -- you brought them up. My question was whether there's anything that the ISR touches that is also touched by non-ISR code.
sorry, by ISR I meant interrupt status registers. but I can't tell where the suspected simultaneous accesses are. Evgeniy, can you point out the register accesses you're talking about?
Kim
Quoted 3 lines · Kim Phillips
sorry, by ISR I meant interrupt status registers. but I can't tell where the suspected simultaneous accesses are. Evgeniy, can you point out the register accesses you're talking about?
priv->status is accessed from tasklets, although readonly, but that rises a red flag... Also callback invocation tasklet drops the lock around callback, during that time cached status and priv itself (and tail like in two simultaneous flushes) could change (or not?)
Signature · 1 line
Evgeniy Polyakov
Quoted 7 lines · On Sat, 31 May 2008 01:12:08 +0400 Evgeniy Polyakov <[email protected]> wrote:
Quoted 3 lines · Kim Phillips
sorry, by ISR I meant interrupt status registers. but I can't tell where the suspected simultaneous accesses are. Evgeniy, can you point out the register accesses you're talking about?
priv->statusis accessed from tasklets, although readonly, but that rises a red flag... Also callback invocation tasklet drops the lock around
ok, I see what you are saying now; if a channel gets done during talitos_done processing, it'll trigger an interrupt and reset priv->status, leaving the tasklet in the dark as to which channel has done status, depending on how many channel dones it has already processed. I think the only solution here is to call flush_channel on each channel, regardless of the bits in the interrupt status - I'll send out a patch shortly.
Quoted 2 lines
callback, during that time cached status and priv itself (and tail like in two simultaneous flushes) could change (or not?)
I think you're talking about a different 'status' here; flush_channel's local 'status' doesn't resemble priv->status bits in any way, it looks at the descriptor header writeback bits for done status, on a per descriptor basis. It forwards this descriptor done vs. error status to the callback.
priv itself won't change; it's uniquely associated to the device.
Kim
Hi.
Quoted 7 lines · Kim Phillips
ok, I see what you are saying now; if a channel gets done during
talitos_doneprocessing, it'll trigger an interrupt and resetpriv->status, leaving the tasklet in the dark as to which channel has done status, depending on how many channel dones it has already processed. I think the only solution here is to callflush_channelon each channel, regardless of the bits in the interrupt status - I'll send out a patch shortly.
Out of curiosity, what is number of channels? I had simialar issue with HIFN crypto driver and limited number of descriptor to 80 iirc, since with that number HIFN traversal did not show perfromance degradataion on Ghz x86.
Quoted 10 lines
Quoted 2 lines
callback, during that time cached status and priv itself (and tail like in two simultaneous flushes) could change (or not?)
I think you're talking about a different 'status' here; flush_channel's local 'status' doesn't resemble
priv->statusbits in any way, it looks at the descriptor header writeback bits for done status, on a per descriptor basis. It forwards this descriptor done vs. error status to the callback.priv itself won't change; it's uniquely associated to the device.
I meant descriptor hdr value accessed via it - can it be checked in tasklet under the lock and in submit path without? Can they correlate somehow?
Signature · 1 line
Evgeniy Polyakov
Quoted 11 lines · On Sat, 31 May 2008 13:59:02 +0400 Evgeniy Polyakov <[email protected]> wrote:
Hi.
Quoted 7 lines · Kim Phillips
ok, I see what you are saying now; if a channel gets done during
talitos_doneprocessing, it'll trigger an interrupt and resetpriv->status, leaving the tasklet in the dark as to which channel has done status, depending on how many channel dones it has already processed. I think the only solution here is to callflush_channelon each channel, regardless of the bits in the interrupt status - I'll send out a patch shortly.
Quoted 1 line
Out of curiosity, what is number of channels? I had simialar issue with
typically four but some parts only have one.
Quoted 3 lines
HIFN crypto driver and limited number of descriptor to 80 iirc, since with that number HIFN traversal did not show perfromance degradataion on Ghz x86.
ok, I've been focusing on correctness for the time being.
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
callback, during that time cached status and priv itself (and tail like in two simultaneous flushes) could change (or not?)
I think you're talking about a different 'status' here; flush_channel's local 'status' doesn't resemble
priv->statusbits in any way, it looks at the descriptor header writeback bits for done status, on a per descriptor basis. It forwards this descriptor done vs. error status to the callback.
Quoted 5 lines
Quoted 1 line
priv itself won't change; it's uniquely associated to the device.
I meant descriptor hdr value accessed via it - can it be checked in tasklet under the lock and in submit path without? Can they correlate somehow?
I believe the check for a non-null request->desc (under lock) before the hdr value is accessed ensures this doesn't happen.
Kim
Quoted 6 lines · Kim Phillips
Quoted 3 lines
I meant descriptor hdr value accessed via it - can it be checked in tasklet under the lock and in submit path without? Can they correlate somehow?
I believe the check for a non-null
request->desc(under lock) before the hdr value is accessed ensures this doesn't happen.
But can it be changed? You write to it without lock, but read under the one (different for each channel though), so it attracted attention.
Signature · 1 line
Evgeniy Polyakov
Quoted 10 lines · On Mon, 2 Jun 2008 20:00:12 +0400 Evgeniy Polyakov <[email protected]> wrote:
Quoted 6 lines · Kim Phillips
Quoted 3 lines
I meant descriptor hdr value accessed via it - can it be checked in tasklet under the lock and in submit path without? Can they correlate somehow?
I believe the check for a non-null
request->desc(under lock) before the hdr value is accessed ensures this doesn't happen.But can it be changed? You write to it without lock, but read under the one (different for each channel though), so it attracted attention.
can you point where in the code your concern is?
desc is assigned under head lock and cleared under tail lock, both after an smp_wmb. hdr data is assigned before desc is written, and read after desc is found to be !NULL (i.e, hdr access is governed by if (desc)). head and tail indices get advanced each within their corresponding locks. So afaict there shouldn't be a case where data pointed to by desc can be accessed by both the consumer and the producer at any one point in time. Does that help?
Kim
Quoted 4 lines · Kim Phillips
Quoted 2 lines
But can it be changed? You write to it without lock, but read under the one (different for each channel though), so it attracted attention.
can you point where in the code your concern is?
talitos_submit() writes to hdr (initially I think?) without locks. It is read in flush_channel() under tail lock, but then it is dropped, so I rised a question, if it can be modified during that time, since if it can, status value, calculated from it, can be different and thus error check result can be false. Or this is not an issue?
Signature · 1 line
Evgeniy Polyakov
Quoted 7 lines · On Mon, 2 Jun 2008 21:57:51 +0400 Evgeniy Polyakov <[email protected]> wrote:
Quoted 4 lines · Kim Phillips
Quoted 2 lines
But can it be changed? You write to it without lock, but read under the one (different for each channel though), so it attracted attention.
can you point where in the code your concern is?
talitos_submit()writes to hdr (initially I think?) without locks.
ok, the desc whose hdr is being written was allocated by talitos_submit's caller, and it hasn't been made part of the circular buffer at that point. It becomes a part of the buffer (eligible for contention with the consumer side) when desc is assigned.
Quoted 4 lines
It is read in
flush_channel()under tail lock, but then it is dropped, so I rised a question, if it can be modified during that time, since if it can, status value, calculated from it, can be different and thus error check result can be false. Or this is not an issue?
it would be an issue if flush_cannel didn't save off the data required to call the callback with in saved_req. flush_channel does this on purpose to be able to call the callback outside of lock (as is commented). Note desc gets assigned NULL prior to releasing the lock, after copying its contents to saved_req.
Kim
Hi.
Quoted 5 lines · Kim Phillips
it would be an issue if
flush_canneldidn't save off the data required to call the callback with insaved_req.flush_channeldoes this on purpose to be able to call the callback outside of lock (as is commented). Note desc gets assigned NULL prior to releasing the lock, after copying its contents tosaved_req.
Excellent! It looks like there are no more issues and second version fixed found problem place.
Signature · 1 line
Evgeniy Polyakov