Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120612
b: refs/heads/master
c: 3416158
h: refs/heads/master
v: v3
  • Loading branch information
Patrick McHardy authored and Herbert Xu committed Dec 25, 2008
1 parent 08d56db commit b033013
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75741a034024f146ba5431602f3ad33a5df8363c
refs/heads/master: 3416158680d5ba6fdb939e5bb52a8eba1ad5c027
75 changes: 33 additions & 42 deletions trunk/drivers/crypto/hifn_795x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,32 +1378,40 @@ static int hifn_setup_dma(struct hifn_device *dev, struct hifn_context *ctx,
unsigned int soff, doff;
unsigned int n, len;

n = nbytes;
while (n) {
spage = sg_page(src);
soff = src->offset;
len = min(src->length, n);

dprintk("%s: spage: %p, soffset: %u, nbytes: %u, "
"priv: %p, ctx: %p.\n",
dev->name, spage, soff, nbytes, priv, ctx);
hifn_setup_src_desc(dev, spage, soff, len, n - len == 0);

src++;
n -= len;
}

t = &ctx->walk.cache[0];
n = nbytes;
while (n) {
if (t->length) {
spage = dpage = sg_page(t);
soff = doff = 0;
dpage = sg_page(t);
doff = 0;
len = t->length;
} else {
spage = sg_page(src);
soff = src->offset;

dpage = sg_page(dst);
doff = dst->offset;

len = dst->length;
}
len = min(len, n);

dprintk("%s: spage: %p, soffset: %u, dpage: %p, doffset: %u, "
"nbytes: %u, priv: %p, ctx: %p.\n",
dev->name, spage, soff, dpage, doff, nbytes, priv, ctx);

hifn_setup_src_desc(dev, spage, soff, len, n - len == 0);
dprintk("%s: dpage: %p, doffset: %u, nbytes: %u, "
"priv: %p, ctx: %p.\n",
dev->name, dpage, doff, nbytes, priv, ctx);
hifn_setup_dst_desc(dev, dpage, doff, len, n - len == 0);

src++;
dst++;
t++;
n -= len;
Expand Down Expand Up @@ -1454,32 +1462,26 @@ static void ablkcipher_walk_exit(struct ablkcipher_walk *w)
w->num = 0;
}

static int ablkcipher_add(void *daddr, unsigned int *drestp, struct scatterlist *src,
static int ablkcipher_add(unsigned int *drestp, struct scatterlist *dst,
unsigned int size, unsigned int *nbytesp)
{
unsigned int copy, drest = *drestp, nbytes = *nbytesp;
int idx = 0;
void *saddr;

if (drest < size || size > nbytes)
return -EINVAL;

while (size) {
copy = min(drest, min(size, src->length));

saddr = kmap_atomic(sg_page(src), KM_SOFTIRQ1);
memcpy(daddr, saddr + src->offset, copy);
kunmap_atomic(saddr, KM_SOFTIRQ1);
copy = min(drest, min(size, dst->length));

size -= copy;
drest -= copy;
nbytes -= copy;
daddr += copy;

dprintk("%s: copy: %u, size: %u, drest: %u, nbytes: %u.\n",
__func__, copy, size, drest, nbytes);

src++;
dst++;
idx++;
}

Expand All @@ -1492,8 +1494,7 @@ static int ablkcipher_add(void *daddr, unsigned int *drestp, struct scatterlist
static int ablkcipher_walk(struct ablkcipher_request *req,
struct ablkcipher_walk *w)
{
struct scatterlist *src, *dst, *t;
void *daddr;
struct scatterlist *dst, *t;
unsigned int nbytes = req->nbytes, offset, copy, diff;
int idx, tidx, err;

Expand All @@ -1503,26 +1504,22 @@ static int ablkcipher_walk(struct ablkcipher_request *req,
if (idx >= w->num && (w->flags & ASYNC_FLAGS_MISALIGNED))
return -EINVAL;

src = &req->src[idx];
dst = &req->dst[idx];

dprintk("\n%s: slen: %u, dlen: %u, soff: %u, doff: %u, offset: %u, "
"nbytes: %u.\n",
__func__, src->length, dst->length, src->offset,
dst->offset, offset, nbytes);
dprintk("\n%s: dlen: %u, doff: %u, offset: %u, nbytes: %u.\n",
__func__, dst->length, dst->offset, offset, nbytes);

if (!IS_ALIGNED(dst->offset, HIFN_D_DST_DALIGN) ||
!IS_ALIGNED(dst->length, HIFN_D_DST_DALIGN) ||
offset) {
unsigned slen = min(src->length - offset, nbytes);
unsigned slen = min(dst->length - offset, nbytes);
unsigned dlen = PAGE_SIZE;

t = &w->cache[idx];

daddr = kmap_atomic(sg_page(t), KM_SOFTIRQ0);
err = ablkcipher_add(daddr, &dlen, src, slen, &nbytes);
err = ablkcipher_add(&dlen, dst, slen, &nbytes);
if (err < 0)
goto err_out_unmap;
return err;

idx += err;

Expand Down Expand Up @@ -1558,32 +1555,26 @@ static int ablkcipher_walk(struct ablkcipher_request *req,
} else {
copy += diff + nbytes;

src = &req->src[idx];
dst = &req->dst[idx];

err = ablkcipher_add(daddr + slen, &dlen, src, nbytes, &nbytes);
err = ablkcipher_add(&dlen, dst, nbytes, &nbytes);
if (err < 0)
goto err_out_unmap;
return err;

idx += err;
}

t->length = copy;
t->offset = offset;

kunmap_atomic(daddr, KM_SOFTIRQ0);
} else {
nbytes -= min(src->length, nbytes);
nbytes -= min(dst->length, nbytes);
idx++;
}

tidx++;
}

return tidx;

err_out_unmap:
kunmap_atomic(daddr, KM_SOFTIRQ0);
return err;
}

static int hifn_setup_session(struct ablkcipher_request *req)
Expand Down

0 comments on commit b033013

Please sign in to comment.