From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: Rong Song Shen <shenrs@cn.ibm.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH] Handle vmalloc addresses
Date: Tue, 11 Feb 2014 11:19:46 +1100 [thread overview]
Message-ID: <1392077986.3996.34.camel@pasglop> (raw)
In-Reply-To: <52E92DB0.1050902@linux.vnet.ibm.com>
Hi Nathan !
Please do a better submission :-)
Your subject is to be honest, crap. Something like
[PATCH] crypto/nx/nx-842: Fix handling of vmalloc addresses
Would have been much more informative.
Additionally, this is a patch for drivers/crypto, and while that driver
is powerpc-specific meaning I *could* take that patch, it should at
least be CCed to the crypto list/maintainer since that would
be the normal path for such a patch to be applied.
I'm taking it this time around but I know you can do better !
Cheers,
Ben.
On Wed, 2014-01-29 at 10:34 -0600, Nathan Fontenot wrote:
> The nx-842 compression driver does not currently handle getting
> a physical address for vmalloc addresses. The current driver
> uses __pa() for all addresses which does not properly handle
> vmalloc addresses and thus causes a failure since we do not pass
> a proper physical address to phyp.
>
> This patch adds a routine to convert an address to a physical
> address by checking for vmalloc addresses and handling them properly.
>
> Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> ---
> drivers/crypto/nx/nx-842.c | 29 +++++++++++++++++++----------
> 1 file changed, 19 insertions(+), 10 deletions(-)
>
> Index: linux/drivers/crypto/nx/nx-842.c
> ===================================================================
> --- linux.orig/drivers/crypto/nx/nx-842.c 2014-01-22 08:52:55.000000000 -0600
> +++ linux/drivers/crypto/nx/nx-842.c 2014-01-29 08:25:33.000000000 -0600
> @@ -158,6 +158,15 @@
> return sl->entry_nr * sizeof(struct nx842_slentry);
> }
>
> +static inline unsigned long nx842_get_pa(void *addr)
> +{
> + if (is_vmalloc_addr(addr))
> + return page_to_phys(vmalloc_to_page(addr))
> + + offset_in_page(addr);
> + else
> + return __pa(addr);
> +}
> +
> static int nx842_build_scatterlist(unsigned long buf, int len,
> struct nx842_scatterlist *sl)
> {
> @@ -168,7 +177,7 @@
>
> entry = sl->entries;
> while (len) {
> - entry->ptr = __pa(buf);
> + entry->ptr = nx842_get_pa((void *)buf);
> nextpage = ALIGN(buf + 1, NX842_HW_PAGE_SIZE);
> if (nextpage < buf + len) {
> /* we aren't at the end yet */
> @@ -370,8 +379,8 @@
> op.flags = NX842_OP_COMPRESS;
> csbcpb = &workmem->csbcpb;
> memset(csbcpb, 0, sizeof(*csbcpb));
> - op.csbcpb = __pa(csbcpb);
> - op.out = __pa(slout.entries);
> + op.csbcpb = nx842_get_pa(csbcpb);
> + op.out = nx842_get_pa(slout.entries);
>
> for (i = 0; i < hdr->blocks_nr; i++) {
> /*
> @@ -401,13 +410,13 @@
> */
> if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) {
> /* Create direct DDE */
> - op.in = __pa(inbuf);
> + op.in = nx842_get_pa((void *)inbuf);
> op.inlen = max_sync_size;
>
> } else {
> /* Create indirect DDE (scatterlist) */
> nx842_build_scatterlist(inbuf, max_sync_size, &slin);
> - op.in = __pa(slin.entries);
> + op.in = nx842_get_pa(slin.entries);
> op.inlen = -nx842_get_scatterlist_size(&slin);
> }
>
> @@ -565,7 +574,7 @@
> op.flags = NX842_OP_DECOMPRESS;
> csbcpb = &workmem->csbcpb;
> memset(csbcpb, 0, sizeof(*csbcpb));
> - op.csbcpb = __pa(csbcpb);
> + op.csbcpb = nx842_get_pa(csbcpb);
>
> /*
> * max_sync_size may have changed since compression,
> @@ -597,12 +606,12 @@
> if (likely((inbuf & NX842_HW_PAGE_MASK) ==
> ((inbuf + hdr->sizes[i] - 1) & NX842_HW_PAGE_MASK))) {
> /* Create direct DDE */
> - op.in = __pa(inbuf);
> + op.in = nx842_get_pa((void *)inbuf);
> op.inlen = hdr->sizes[i];
> } else {
> /* Create indirect DDE (scatterlist) */
> nx842_build_scatterlist(inbuf, hdr->sizes[i] , &slin);
> - op.in = __pa(slin.entries);
> + op.in = nx842_get_pa(slin.entries);
> op.inlen = -nx842_get_scatterlist_size(&slin);
> }
>
> @@ -613,12 +622,12 @@
> */
> if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) {
> /* Create direct DDE */
> - op.out = __pa(outbuf);
> + op.out = nx842_get_pa((void *)outbuf);
> op.outlen = max_sync_size;
> } else {
> /* Create indirect DDE (scatterlist) */
> nx842_build_scatterlist(outbuf, max_sync_size, &slout);
> - op.out = __pa(slout.entries);
> + op.out = nx842_get_pa(slout.entries);
> op.outlen = -nx842_get_scatterlist_size(&slout);
> }
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
prev parent reply other threads:[~2014-02-11 0:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 16:34 [PATCH] Handle vmalloc addresses Nathan Fontenot
2014-02-11 0:19 ` Benjamin Herrenschmidt [this message]
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=1392077986.3996.34.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nfont@linux.vnet.ibm.com \
--cc=shenrs@cn.ibm.com \
/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).