From patchwork Thu Mar 5 16:46:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 5948091 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8D1E7BF440 for ; Thu, 5 Mar 2015 17:06:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6471E2026C for ; Thu, 5 Mar 2015 17:06:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0DBE201CE for ; Thu, 5 Mar 2015 17:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758370AbbCERFf (ORCPT ); Thu, 5 Mar 2015 12:05:35 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:48383 "EHLO mailhub1.si.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758361AbbCERFd (ORCPT ); Thu, 5 Mar 2015 12:05:33 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id E0A731C8338; Thu, 5 Mar 2015 17:46:21 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8u54ln41iE6E; Thu, 5 Mar 2015 17:46:21 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id BB6C21C8330; Thu, 5 Mar 2015 17:46:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D4FB2C73DC; Thu, 5 Mar 2015 17:46:20 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id vDaCbnCmTTfS; Thu, 5 Mar 2015 17:46:20 +0100 (CET) Received: from PO10863.localdomain (unknown [172.25.231.75]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 89BC7C73C5; Thu, 5 Mar 2015 17:46:11 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id C9E3A1A2421; Thu, 5 Mar 2015 17:46:06 +0100 (CET) From: Christophe Leroy To: Kim Phillips , Herbert Xu , "David S. Miller" CC: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org Subject: [PATCH 08/17] crypto: talitos - Deport SEC2 error handling Message-Id: <20150305164606.C9E3A1A2421@localhost.localdomain> Date: Thu, 5 Mar 2015 17:46:06 +0100 (CET) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SEC2 and SEC1 error handling will be different because so many bits are different. So we move error handling into talitos2.c Signed-off-by: Christophe Leroy --- drivers/crypto/talitos.c | 103 +++++----------------------------------------- drivers/crypto/talitos.h | 8 ++++ drivers/crypto/talitos2.c | 82 ++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 92 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 32848e5..de31ab0 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -68,7 +68,7 @@ static unsigned int do_reset_channel(struct talitos_private *priv, int ch) return timeout; } -static int reset_channel(struct device *dev, int ch) +int talitos_reset_channel(struct device *dev, int ch) { struct talitos_private *priv = dev_get_drvdata(dev); unsigned int timeout = do_reset_channel(priv, ch); @@ -124,7 +124,7 @@ static void do_init_device(struct talitos_private *priv) setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); } -static int init_device(struct device *dev) +int talitos_init_device(struct device *dev) { struct talitos_private *priv = dev_get_drvdata(dev); int ch, err; @@ -145,7 +145,7 @@ static int init_device(struct device *dev) /* reset channels */ for (ch = 0; ch < priv->num_channels; ch++) { - err = reset_channel(dev, ch); + err = talitos_reset_channel(dev, ch); if (err) return err; } @@ -223,7 +223,7 @@ EXPORT_SYMBOL(talitos_submit); /* * process what was done, notify callback of error if not */ -static void flush_channel(struct device *dev, int ch, int error, int reset_ch) +void talitos_flush_channel(struct device *dev, int ch, int error, int reset_ch) { struct talitos_private *priv = dev_get_drvdata(dev); struct talitos_request *request, saved_req; @@ -289,15 +289,15 @@ static void talitos_done_##name(unsigned long data) \ unsigned long flags; \ \ if (ch_done_mask & 1) \ - flush_channel(dev, 0, 0, 0); \ + talitos_flush_channel(dev, 0, 0, 0); \ if (priv->num_channels == 1) \ goto out; \ if (ch_done_mask & (1 << 2)) \ - flush_channel(dev, 1, 0, 0); \ + talitos_flush_channel(dev, 1, 0, 0); \ if (ch_done_mask & (1 << 4)) \ - flush_channel(dev, 2, 0, 0); \ + talitos_flush_channel(dev, 2, 0, 0); \ if (ch_done_mask & (1 << 6)) \ - flush_channel(dev, 3, 0, 0); \ + talitos_flush_channel(dev, 3, 0, 0); \ \ out: \ /* At this point, all completed channels have been processed */ \ @@ -345,10 +345,11 @@ static u32 current_desc_hdr(struct device *dev, int ch) /* * user diagnostics; report root cause of error based on execution unit status */ -static void report_eu_error(struct device *dev, int ch, u32 desc_hdr) +void talitos_report_eu_error(struct device *dev, int ch) { struct talitos_private *priv = dev_get_drvdata(dev); int i; + u32 desc_hdr = current_desc_hdr(dev, ch); if (!desc_hdr) desc_hdr = in_be32(priv->chan[ch].reg + TALITOS_DESCBUF); @@ -417,88 +418,6 @@ static void report_eu_error(struct device *dev, int ch, u32 desc_hdr) in_be32(priv->chan[ch].reg + TALITOS_DESCBUF_LO + 8*i)); } -/* - * recover from error interrupts - */ -static void talitos_error(struct device *dev, u32 isr, u32 isr_lo) -{ - struct talitos_private *priv = dev_get_drvdata(dev); - unsigned int timeout = TALITOS_TIMEOUT; - int ch, error, reset_dev = 0, reset_ch = 0; - u32 v, v_lo; - - for (ch = 0; ch < priv->num_channels; ch++) { - /* skip channels without errors */ - if (!(isr & (1 << (ch * 2 + 1)))) - continue; - - error = -EINVAL; - - v = in_be32(priv->chan[ch].reg + TALITOS_CCPSR); - v_lo = in_be32(priv->chan[ch].reg + TALITOS_CCPSR_LO); - - if (v_lo & TALITOS_CCPSR_LO_DOF) { - dev_err(dev, "double fetch fifo overflow error\n"); - error = -EAGAIN; - reset_ch = 1; - } - if (v_lo & TALITOS_CCPSR_LO_SOF) { - /* h/w dropped descriptor */ - dev_err(dev, "single fetch fifo overflow error\n"); - error = -EAGAIN; - } - if (v_lo & TALITOS_CCPSR_LO_MDTE) - dev_err(dev, "master data transfer error\n"); - if (v_lo & TALITOS_CCPSR_LO_SGDLZ) - dev_err(dev, "s/g data length zero error\n"); - if (v_lo & TALITOS_CCPSR_LO_FPZ) - dev_err(dev, "fetch pointer zero error\n"); - if (v_lo & TALITOS_CCPSR_LO_IDH) - dev_err(dev, "illegal descriptor header error\n"); - if (v_lo & TALITOS_CCPSR_LO_IEU) - dev_err(dev, "invalid execution unit error\n"); - if (v_lo & TALITOS_CCPSR_LO_EU) - report_eu_error(dev, ch, current_desc_hdr(dev, ch)); - if (v_lo & TALITOS_CCPSR_LO_GB) - dev_err(dev, "gather boundary error\n"); - if (v_lo & TALITOS_CCPSR_LO_GRL) - dev_err(dev, "gather return/length error\n"); - if (v_lo & TALITOS_CCPSR_LO_SB) - dev_err(dev, "scatter boundary error\n"); - if (v_lo & TALITOS_CCPSR_LO_SRL) - dev_err(dev, "scatter return/length error\n"); - - flush_channel(dev, ch, error, reset_ch); - - if (reset_ch) { - reset_channel(dev, ch); - } else { - setbits32(priv->chan[ch].reg + TALITOS_CCCR, - TALITOS_CCCR_CONT); - setbits32(priv->chan[ch].reg + TALITOS_CCCR_LO, 0); - while ((in_be32(priv->chan[ch].reg + TALITOS_CCCR) & - TALITOS_CCCR_CONT) && --timeout) - cpu_relax(); - if (timeout == 0) { - dev_err(dev, "failed to restart channel %d\n", - ch); - reset_dev = 1; - } - } - } - if (reset_dev || isr & ~TALITOS_ISR_4CHERR || isr_lo) { - dev_err(dev, "done overflow, internal time out, or rngu error: " - "ISR 0x%08x_%08x\n", isr, isr_lo); - - /* purge request queues */ - for (ch = 0; ch < priv->num_channels; ch++) - flush_channel(dev, ch, -EIO, 1); - - /* reset and reinitialize the device */ - init_device(dev); - } -} - #define DEF_TALITOS_INTERRUPT(name, ch_done_mask, ch_err_mask, tlet) \ static irqreturn_t talitos_interrupt_##name(int irq, void *data) \ { \ @@ -2106,7 +2025,7 @@ static int talitos_probe(struct platform_device *ofdev) dma_set_mask(dev, DMA_BIT_MASK(36)); /* reset and initialize the h/w */ - err = init_device(dev); + err = talitos_init_device(dev); if (err) { dev_err(dev, "failed to initialize device\n"); goto err_out; diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h index 46233cb..f95e4bc 100644 --- a/drivers/crypto/talitos.h +++ b/drivers/crypto/talitos.h @@ -145,6 +145,14 @@ extern struct talitos_edesc *talitos_edesc_alloc(struct device *dev, int icv_stashing, u32 cryptoflags, bool encrypt); + +extern int talitos_reset_channel(struct device *dev, int ch); +extern int talitos_init_device(struct device *dev); +extern void talitos_flush_channel(struct device *dev, int ch, int error, + int reset_ch); +extern void talitos_report_eu_error(struct device *dev, int ch); +extern void talitos_error(struct device *dev, u32 isr, u32 isr_lo); + extern int talitos_cra_init(struct crypto_tfm *tfm); /* .features flag */ diff --git a/drivers/crypto/talitos2.c b/drivers/crypto/talitos2.c index 024cbbd..80f6bc0 100644 --- a/drivers/crypto/talitos2.c +++ b/drivers/crypto/talitos2.c @@ -183,6 +183,88 @@ void map_sg_out_talitos_ptr(struct device *dev, struct scatterlist *dst, } } +/* + * recover from error interrupts + */ +void talitos_error(struct device *dev, u32 isr, u32 isr_lo) +{ + struct talitos_private *priv = dev_get_drvdata(dev); + unsigned int timeout = TALITOS_TIMEOUT; + int ch, error, reset_dev = 0, reset_ch = 0; + u32 v, v_lo; + + for (ch = 0; ch < priv->num_channels; ch++) { + /* skip channels without errors */ + if (!(isr & (1 << (ch * 2 + 1)))) + continue; + + error = -EINVAL; + + v = in_be32(priv->chan[ch].reg + TALITOS_CCPSR); + v_lo = in_be32(priv->chan[ch].reg + TALITOS_CCPSR_LO); + + if (v_lo & TALITOS_CCPSR_LO_DOF) { + dev_err(dev, "double fetch fifo overflow error\n"); + error = -EAGAIN; + reset_ch = 1; + } + if (v_lo & TALITOS_CCPSR_LO_SOF) { + /* h/w dropped descriptor */ + dev_err(dev, "single fetch fifo overflow error\n"); + error = -EAGAIN; + } + if (v_lo & TALITOS_CCPSR_LO_MDTE) + dev_err(dev, "master data transfer error\n"); + if (v_lo & TALITOS_CCPSR_LO_SGDLZ) + dev_err(dev, "s/g data length zero error\n"); + if (v_lo & TALITOS_CCPSR_LO_FPZ) + dev_err(dev, "fetch pointer zero error\n"); + if (v_lo & TALITOS_CCPSR_LO_IDH) + dev_err(dev, "illegal descriptor header error\n"); + if (v_lo & TALITOS_CCPSR_LO_IEU) + dev_err(dev, "invalid execution unit error\n"); + if (v_lo & TALITOS_CCPSR_LO_EU) + talitos_report_eu_error(dev, ch); + if (v_lo & TALITOS_CCPSR_LO_GB) + dev_err(dev, "gather boundary error\n"); + if (v_lo & TALITOS_CCPSR_LO_GRL) + dev_err(dev, "gather return/length error\n"); + if (v_lo & TALITOS_CCPSR_LO_SB) + dev_err(dev, "scatter boundary error\n"); + if (v_lo & TALITOS_CCPSR_LO_SRL) + dev_err(dev, "scatter return/length error\n"); + + talitos_flush_channel(dev, ch, error, reset_ch); + + if (reset_ch) { + talitos_reset_channel(dev, ch); + } else { + setbits32(priv->chan[ch].reg + TALITOS_CCCR, + TALITOS_CCCR_CONT); + setbits32(priv->chan[ch].reg + TALITOS_CCCR_LO, 0); + while ((in_be32(priv->chan[ch].reg + TALITOS_CCCR) & + TALITOS_CCCR_CONT) && --timeout) + cpu_relax(); + if (timeout == 0) { + dev_err(dev, "failed to restart channel %d\n", + ch); + reset_dev = 1; + } + } + } + if (reset_dev || isr & ~TALITOS_ISR_4CHERR || isr_lo) { + dev_err(dev, "done overflow, internal time out, or rngu error: " + "ISR 0x%08x_%08x\n", isr, isr_lo); + + /* purge request queues */ + for (ch = 0; ch < priv->num_channels; ch++) + talitos_flush_channel(dev, ch, -EIO, 1); + + /* reset and reinitialize the device */ + talitos_init_device(dev); + } +} + int aead_setauthsize(struct crypto_aead *authenc, unsigned int authsize) {