From: Mogens Lauridsen <mlauridsen171@gmail.com>
To: linux-crypto@vger.kernel.org
Subject: Fix dma unmap direction in iMX sahara aes calculation
Date: Sun, 16 Jul 2017 23:21:04 +0200	[thread overview]
Message-ID: <CACA-NJv69LnyR-xcJC8OU-_WRfg1Mtawq9UapswQczrdAonFDA@mail.gmail.com> (raw)
Hi,
The direction used in dma_unmap_sg in aes calc in sahara.c is wrong.
This result in the cache not being invalidated correct when aes
calculation is done and result is dma'ed to memory.
This is seen as sporadic wrong result from aes calc.
Thanks,
Mogens
Signed-off-by: Mogens Lauridsen <mlauridsen171@gmail.com>
diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index 1d9ecd3..9538c52 100644ae
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -543,10 +543,10 @@ static int sahara_hw_descriptor_create(struct sahara_dev *
 unmap_out:
        dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
-               DMA_TO_DEVICE);
+               DMA_FROM_DEVICE);
 unmap_in:
        dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
-               DMA_FROM_DEVICE);
+               DMA_TO_DEVICE);
        return -EINVAL;
 }
@@ -594,9 +594,9 @@ static int sahara_aes_process(struct ablkcipher_request *req
        }
        dma_unmap_sg(dev->device, dev->out_sg, dev->nb_out_sg,
-               DMA_TO_DEVICE);
-       dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
                DMA_FROM_DEVICE);
+       dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
+               DMA_TO_DEVICE);
        return 0;
 }
next             reply	other threads:[~2017-07-16 21:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-16 21:21 Mogens Lauridsen [this message]
2017-07-25 17:51 ` Fix dma unmap direction in iMX sahara aes calculation Fabio Estevam
2017-07-28  9:57 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=CACA-NJv69LnyR-xcJC8OU-_WRfg1Mtawq9UapswQczrdAonFDA@mail.gmail.com \
    --to=mlauridsen171@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
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).