Re: [PATCH v8 0/4] Broadcom SBA RAID support

2017-05-15 Thread Vinod Koul
On Mon, May 15, 2017 at 10:34:51AM +0530, Anup Patel wrote:
> The Broadcom SBA RAID is a stream-based device which provides
> RAID5/6 offload.
> 
> It requires a SoC specific ring manager (such as Broadcom FlexRM
> ring manager) to provide ring-based programming interface. Due to
> this, the Broadcom SBA RAID driver (mailbox client) implements
> DMA device having one DMA channel using a set of mailbox channels
> provided by Broadcom SoC specific ring manager driver (mailbox
> controller).
> 
> The Broadcom SBA RAID hardware requires PQ disk position instead
> of PQ disk coefficient. To address this, we have added raid_gflog
> table which will help driver to convert PQ disk coefficient to PQ
> disk position.

Applied, now

-- 
~Vinod


Re: [PATCH v2 2/2] crypto: scomp - add support for deflate rfc1950 (zlib)

2017-05-15 Thread abed mohammad kamaluddin
Hi,

I have a few queries regarding zlib and in general on whether changes
to acomp interface is planned or would be acceptable. Some of these
are from point of view of exporting compression to user space and
utilizing HW implementations.

- A setup api is required to support different configurations; this
was also proposed as part of initial acomp implementations.
- Zlib also supports notion of preset dictionary and for
decompression, history bytes upto window size might be required to be
provided as part of the request. For HW algorithms supporting these
features, the current acomp api's would need to be extended.
- Currently acomp supports operations only in one go, are there plans
to extend acomp beyond this? For hardware algos supporting partial
ops, we will need to add fields like bytes consumed, flush params,ctx
parameter etc.and export to  user.

Thanks,
Abed (Cavium)


On Sat, Apr 22, 2017 at 2:24 AM, Giovanni Cabiddu
 wrote:
> Add scomp backend for zlib-deflate compression algorithm.
> This backend outputs data using the format defined in rfc1950
> (raw deflate surrounded by zlib header and footer).
>
> Signed-off-by: Giovanni Cabiddu 
> ---
>  crypto/deflate.c | 61 -
>  crypto/testmgr.c | 10 
>  crypto/testmgr.h | 75 
> 
>  3 files changed, 129 insertions(+), 17 deletions(-)
>
> diff --git a/crypto/deflate.c b/crypto/deflate.c
> index f942cb3..94ec3b3 100644
> --- a/crypto/deflate.c
> +++ b/crypto/deflate.c
> @@ -43,20 +43,24 @@ struct deflate_ctx {
> struct z_stream_s decomp_stream;
>  };
>
> -static int deflate_comp_init(struct deflate_ctx *ctx)
> +static int deflate_comp_init(struct deflate_ctx *ctx, int format)
>  {
> int ret = 0;
> struct z_stream_s *stream = >comp_stream;
>
> stream->workspace = vzalloc(zlib_deflate_workspacesize(
> -   -DEFLATE_DEF_WINBITS, DEFLATE_DEF_MEMLEVEL));
> +   MAX_WBITS, MAX_MEM_LEVEL));
> if (!stream->workspace) {
> ret = -ENOMEM;
> goto out;
> }
> -   ret = zlib_deflateInit2(stream, DEFLATE_DEF_LEVEL, Z_DEFLATED,
> -   -DEFLATE_DEF_WINBITS, DEFLATE_DEF_MEMLEVEL,
> -   Z_DEFAULT_STRATEGY);
> +   if (format)
> +   ret = zlib_deflateInit(stream, 3);
> +   else
> +   ret = zlib_deflateInit2(stream, DEFLATE_DEF_LEVEL, Z_DEFLATED,
> +   -DEFLATE_DEF_WINBITS,
> +   DEFLATE_DEF_MEMLEVEL,
> +   Z_DEFAULT_STRATEGY);
> if (ret != Z_OK) {
> ret = -EINVAL;
> goto out_free;
> @@ -68,7 +72,7 @@ static int deflate_comp_init(struct deflate_ctx *ctx)
> goto out;
>  }
>
> -static int deflate_decomp_init(struct deflate_ctx *ctx)
> +static int deflate_decomp_init(struct deflate_ctx *ctx, int format)
>  {
> int ret = 0;
> struct z_stream_s *stream = >decomp_stream;
> @@ -78,7 +82,10 @@ static int deflate_decomp_init(struct deflate_ctx *ctx)
> ret = -ENOMEM;
> goto out;
> }
> -   ret = zlib_inflateInit2(stream, -DEFLATE_DEF_WINBITS);
> +   if (format)
> +   ret = zlib_inflateInit(stream);
> +   else
> +   ret = zlib_inflateInit2(stream, -DEFLATE_DEF_WINBITS);
> if (ret != Z_OK) {
> ret = -EINVAL;
> goto out_free;
> @@ -102,21 +109,21 @@ static void deflate_decomp_exit(struct deflate_ctx *ctx)
> vfree(ctx->decomp_stream.workspace);
>  }
>
> -static int __deflate_init(void *ctx)
> +static int __deflate_init(void *ctx, int format)
>  {
> int ret;
>
> -   ret = deflate_comp_init(ctx);
> +   ret = deflate_comp_init(ctx, format);
> if (ret)
> goto out;
> -   ret = deflate_decomp_init(ctx);
> +   ret = deflate_decomp_init(ctx, format);
> if (ret)
> deflate_comp_exit(ctx);
>  out:
> return ret;
>  }
>
> -static void *deflate_alloc_ctx(struct crypto_scomp *tfm)
> +static void *gen_deflate_alloc_ctx(struct crypto_scomp *tfm, int format)
>  {
> struct deflate_ctx *ctx;
> int ret;
> @@ -125,7 +132,7 @@ static void *deflate_alloc_ctx(struct crypto_scomp *tfm)
> if (!ctx)
> return ERR_PTR(-ENOMEM);
>
> -   ret = __deflate_init(ctx);
> +   ret = __deflate_init(ctx, format);
> if (ret) {
> kfree(ctx);
> return ERR_PTR(ret);
> @@ -134,11 +141,21 @@ static void *deflate_alloc_ctx(struct crypto_scomp *tfm)
> return ctx;
>  }
>
> +static void *deflate_alloc_ctx(struct crypto_scomp *tfm)
> +{
> +   return gen_deflate_alloc_ctx(tfm, 0);
> +}
> +
> 

Re: [PATCH v11 4/5] LRNG - enable compile (fwd)

2017-05-15 Thread Stephan Müller
Am Montag, 15. Mai 2017, 12:54:38 CEST schrieb Julia Lawall:

Hi Julia,

> Hello,
> 
> I received the following report from kbuild about some coccinelle detected
> errors.  I wasn't sure what to look at at the URL to check them.  I
> already forwarded the patch for the last case.
> 
> julia
> 
> -- Forwarded message --
> Date: Mon, 15 May 2017 14:09:39 +0800
> From: kbuild test robot 
> To: kbu...@01.org
> Cc: Julia Lawall 
> Subject: Re: [PATCH v11 4/5] LRNG - enable compile
> 
> CC: kbuild-...@01.org
> In-Reply-To: <2619717.m11260e...@positron.chronox.de>
> TO: "Stephan Müller" 
> CC: linux-ker...@vger.kernel.org
> CC: linux-crypto@vger.kernel.org, "Jason A. Donenfeld" 
> 
> Hi Stephan,
> 
> [auto build test WARNING on char-misc/char-misc-testing]
> [also build test WARNING on v4.12-rc1 next-20170512]
> [if your patch is applied to the wrong git tree, please drop us a note to
> help improve the system]
> 
> url:   
> https://github.com/0day-ci/linux/commits/Stephan-M-ller/dev-random-a-new-ap
> proach/20170514-223633
> :: branch date: 16 hours ago
> :: commit date: 16 hours ago
> >> 
> >> drivers/char/lrng_base.c:2243:5-25: duplicated argument to && or ||

I am not sure about this one: I think the code is clean and this hint is not 
applicable here. Both arguments to the || condition are different as they are 
function calls.
> 
> --
> 
> >> drivers/char/lrng_base.c:1245:7-11: ERROR: iterator variable bound on
> >> line 1236 cannot be NULL

Fixed.
> --
> 
> >> drivers/char/lrng_base.c:1509:19-24: ERROR: reference preceded by free on
> >> line 1453

Fixed, pdrbg set to NULL after free.
> --
> 
> >> drivers/char/lrng_base.c:1461:1-11: alloc with no test, possible model on
> >> line 1466

I think the code is clean because kcalloc was invoked with GFP_NOFAIL. Thus, 
if the code returns we know we have allocated memory.
> --
> 
> >> drivers/char/lrng_base.c:1526:1-3: WARNING: PTR_ERR_OR_ZERO can be used
> 
> Please review and possibly fold the followup patch.

This is already fixed as mentioned in other email.

Thanks a lot for the help.

Ciao
Stephan


Re: [PATCH] fix ptr_ret.cocci warnings

2017-05-15 Thread Stephan Müller
Am Montag, 15. Mai 2017, 12:52:11 CEST schrieb Julia Lawall:

Hi Julia,

> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> 
> Generated by: scripts/coccinelle/api/ptr_ret.cocci

Thank you, included -- it will be present in the next release.

Ciao
Stephan


Re: [PATCH v11 4/5] LRNG - enable compile (fwd)

2017-05-15 Thread Julia Lawall
Hello,

I received the following report from kbuild about some coccinelle detected
errors.  I wasn't sure what to look at at the URL to check them.  I
already forwarded the patch for the last case.

julia

-- Forwarded message --
Date: Mon, 15 May 2017 14:09:39 +0800
From: kbuild test robot 
To: kbu...@01.org
Cc: Julia Lawall 
Subject: Re: [PATCH v11 4/5] LRNG - enable compile

CC: kbuild-...@01.org
In-Reply-To: <2619717.m11260e...@positron.chronox.de>
TO: "Stephan Müller" 
CC: linux-ker...@vger.kernel.org
CC: linux-crypto@vger.kernel.org, "Jason A. Donenfeld" 

Hi Stephan,

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on v4.12-rc1 next-20170512]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stephan-M-ller/dev-random-a-new-approach/20170514-223633
:: branch date: 16 hours ago
:: commit date: 16 hours ago

>> drivers/char/lrng_base.c:2243:5-25: duplicated argument to && or ||
--
>> drivers/char/lrng_base.c:1245:7-11: ERROR: iterator variable bound on line 
>> 1236 cannot be NULL
--
>> drivers/char/lrng_base.c:1509:19-24: ERROR: reference preceded by free on 
>> line 1453
--
>> drivers/char/lrng_base.c:1461:1-11: alloc with no test, possible model on 
>> line 1466
--
>> drivers/char/lrng_base.c:1526:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation

[PATCH] fix ptr_ret.cocci warnings

2017-05-15 Thread Julia Lawall
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

CC: Stephan Müller 
Signed-off-by: Julia Lawall 
Signed-off-by: Fengguang Wu 
---

Not very important, but the code can be a little simpler.

 lrng_base.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/drivers/char/lrng_base.c
+++ b/drivers/char/lrng_base.c
@@ -1523,10 +1523,7 @@ static int lrng_alloc(void)
lrng_init_rng(key, sizeof(key));
lrng_pool.lrng_hash = lrng_hash_alloc(LRNG_HASH_NAME, key, sizeof(key));
memzero_explicit(key, sizeof(key));
-   if (IS_ERR(lrng_pool.lrng_hash))
-   return PTR_ERR(lrng_pool.lrng_hash);
-
-   return 0;
+   return PTR_ERR_OR_ZERO(lrng_pool.lrng_hash);
 }

 /** LRNG kernel interfaces ***/

[PATCH v1] hw_random : omap3-rom-rng:- Handle return value of clk_prepare_enable

2017-05-15 Thread Arvind Yadav
Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Signed-off-by: Arvind Yadav 
---
 drivers/char/hw_random/omap3-rom-rng.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/omap3-rom-rng.c 
b/drivers/char/hw_random/omap3-rom-rng.c
index 37a58d7..38b7190 100644
--- a/drivers/char/hw_random/omap3-rom-rng.c
+++ b/drivers/char/hw_random/omap3-rom-rng.c
@@ -53,7 +53,10 @@ static int omap3_rom_rng_get_random(void *buf, unsigned int 
count)
 
cancel_delayed_work_sync(_work);
if (rng_idle) {
-   clk_prepare_enable(rng_clk);
+   r = clk_prepare_enable(rng_clk);
+   if (r)
+   return r;
+
r = omap3_rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT);
if (r != 0) {
clk_disable_unprepare(rng_clk);
@@ -88,6 +91,8 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, 
size_t max, bool w)
 
 static int omap3_rom_rng_probe(struct platform_device *pdev)
 {
+   int ret = 0;
+
pr_info("initializing\n");
 
omap3_rom_rng_call = pdev->dev.platform_data;
@@ -104,7 +109,9 @@ static int omap3_rom_rng_probe(struct platform_device *pdev)
}
 
/* Leave the RNG in reset state. */
-   clk_prepare_enable(rng_clk);
+   ret = clk_prepare_enable(rng_clk);
+   if (ret)
+   return ret;
omap3_rom_rng_idle(0);
 
return hwrng_register(_rom_rng_ops);
-- 
1.9.1