static void s5p_sg_done(struct s5p_aes_dev *dev)
 {
+       struct ablkcipher_request *req = dev->req;
+       struct s5p_aes_reqctx *reqctx = ablkcipher_request_ctx(req);
+
        if (dev->sg_dst_cpy) {
                dev_dbg(dev->dev,
                        "Copying %d bytes of output data back to original place\n",
        }
        s5p_free_sg_cpy(dev, &dev->sg_src_cpy);
        s5p_free_sg_cpy(dev, &dev->sg_dst_cpy);
+       if (reqctx->mode & FLAGS_AES_CBC)
+               memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_IV_DATA(0), AES_BLOCK_SIZE);
+
+       else if (reqctx->mode & FLAGS_AES_CTR)
+               memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_CNT_DATA(0), AES_BLOCK_SIZE);
 }
 
 /* Calls the completion. Cannot be called with dev->lock hold. */