From: Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Mathieu Poirier
<mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"Xu Wei" <xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
<linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Herbert Xu
<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
<guohanjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v2 2/2] hwrng: hisi: Add support for Hisilicon SoC RNG
Date: Fri, 8 Apr 2016 10:03:14 +0800 [thread overview]
Message-ID: <57071162.908@huawei.com> (raw)
In-Reply-To: <CANLsYkwRGm3oBWaoKki4Ge3A_-temOsdJcwby6ds_X5_XGYZtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 2016/4/7 22:55, Mathieu Poirier wrote:
> On 7 April 2016 at 02:23, Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
>> This adds the Hisilicon Random Number Generator(RNG) support,
>> which is found in Hip04 and Hip05 soc.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/char/hw_random/Kconfig | 13 ++++
>> drivers/char/hw_random/Makefile | 1 +
>> drivers/char/hw_random/hisi-rng.c | 121 ++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 135 insertions(+)
>> create mode 100644 drivers/char/hw_random/hisi-rng.c
[...]
>> +
>> +#define RNG_SEED 0x0
>> +#define RNG_CTRL 0x4
>> + #define RNG_SEED_SEL BIT(2)
>> + #define RNG_RING_EN BIT(1)
>> + #define RNG_EN BIT(0)
>> +#define RNG_RAN_NUM 0x10
>> +#define RNG_PHY_SEED 0x14
>> +#define RNG_RELOAD_ERR 0x84
>> +
>> +#define to_hisi_rng(p) container_of(p, struct hisi_rng, rng)
>> +
>> +static int seed_sel;
>> +module_param(seed_sel, int, S_IRUGO);
>> +MODULE_PARM_DESC(seed_sel, "Auto reload seed. 0, use LFSR(default); 1, use ring oscillator.");
>> +
>> +struct hisi_rng {
>> + void __iomem *base;
>> + struct hwrng rng;
>> +};
>> +
>> +static int hisi_rng_init(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + int val = RNG_EN;
>> + u32 seed;
>> +
>> + /* get a random number as initial seed */
>> + get_random_bytes(&seed, sizeof(seed));
>> +
>> + writel_relaxed(seed, hrng->base + RNG_SEED);
>> +
>> + if (seed_sel == 1)
>> + val |= RNG_RING_EN | RNG_SEED_SEL;
>
> Hello Kefeng,
>
> Please explain what this mode does. Otherwise reviewers have to make
> a guess based on the description of the module parameter.
The seed is reload periodically, there are two choice of seeds, default using
the val from LFSR, seed_sel = 1 will use the val generated by ring oscillator.
>
>> +
>> + writel_relaxed(val, hrng->base + RNG_CTRL);
>> + return 0;
>> +}
>> +
>> +static void hisi_rng_cleanup(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> +
>> + writel_relaxed(0, hrng->base + RNG_CTRL);
>> +}
>> +
>> +static int hisi_rng_read(struct hwrng *rng, void *buf, size_t max,
>> + bool wait)
>
> What are variable 'max' and 'wait' used for? As far as I can tell
> they can be removed.
Ok, will use data_read callback in struct hwrng.
>
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + u32 *data = buf;
>> +
>> + *data = readl_relaxed(hrng->base + RNG_RAN_NUM);
>> + return 4;
>
> Why not simply doing the readl_relaxed() in the the code rather than
> introducing a new function?
Not clear, your mean introduce the data variable?
Will use following data_read, thanks.
static int hisi_rng_data_read(struct hwrng *rng, u32 *data)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
*data = readl_relaxed(hrng->base + RNG_RAN_NUM);
return 4;
}
Thanks,
Kefeng
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: wangkefeng.wang@huawei.com (Kefeng Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/2] hwrng: hisi: Add support for Hisilicon SoC RNG
Date: Fri, 8 Apr 2016 10:03:14 +0800 [thread overview]
Message-ID: <57071162.908@huawei.com> (raw)
In-Reply-To: <CANLsYkwRGm3oBWaoKki4Ge3A_-temOsdJcwby6ds_X5_XGYZtQ@mail.gmail.com>
On 2016/4/7 22:55, Mathieu Poirier wrote:
> On 7 April 2016 at 02:23, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> This adds the Hisilicon Random Number Generator(RNG) support,
>> which is found in Hip04 and Hip05 soc.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> drivers/char/hw_random/Kconfig | 13 ++++
>> drivers/char/hw_random/Makefile | 1 +
>> drivers/char/hw_random/hisi-rng.c | 121 ++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 135 insertions(+)
>> create mode 100644 drivers/char/hw_random/hisi-rng.c
[...]
>> +
>> +#define RNG_SEED 0x0
>> +#define RNG_CTRL 0x4
>> + #define RNG_SEED_SEL BIT(2)
>> + #define RNG_RING_EN BIT(1)
>> + #define RNG_EN BIT(0)
>> +#define RNG_RAN_NUM 0x10
>> +#define RNG_PHY_SEED 0x14
>> +#define RNG_RELOAD_ERR 0x84
>> +
>> +#define to_hisi_rng(p) container_of(p, struct hisi_rng, rng)
>> +
>> +static int seed_sel;
>> +module_param(seed_sel, int, S_IRUGO);
>> +MODULE_PARM_DESC(seed_sel, "Auto reload seed. 0, use LFSR(default); 1, use ring oscillator.");
>> +
>> +struct hisi_rng {
>> + void __iomem *base;
>> + struct hwrng rng;
>> +};
>> +
>> +static int hisi_rng_init(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + int val = RNG_EN;
>> + u32 seed;
>> +
>> + /* get a random number as initial seed */
>> + get_random_bytes(&seed, sizeof(seed));
>> +
>> + writel_relaxed(seed, hrng->base + RNG_SEED);
>> +
>> + if (seed_sel == 1)
>> + val |= RNG_RING_EN | RNG_SEED_SEL;
>
> Hello Kefeng,
>
> Please explain what this mode does. Otherwise reviewers have to make
> a guess based on the description of the module parameter.
The seed is reload periodically, there are two choice of seeds, default using
the val from LFSR, seed_sel = 1 will use the val generated by ring oscillator.
>
>> +
>> + writel_relaxed(val, hrng->base + RNG_CTRL);
>> + return 0;
>> +}
>> +
>> +static void hisi_rng_cleanup(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> +
>> + writel_relaxed(0, hrng->base + RNG_CTRL);
>> +}
>> +
>> +static int hisi_rng_read(struct hwrng *rng, void *buf, size_t max,
>> + bool wait)
>
> What are variable 'max' and 'wait' used for? As far as I can tell
> they can be removed.
Ok, will use data_read callback in struct hwrng.
>
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + u32 *data = buf;
>> +
>> + *data = readl_relaxed(hrng->base + RNG_RAN_NUM);
>> + return 4;
>
> Why not simply doing the readl_relaxed() in the the code rather than
> introducing a new function?
Not clear, your mean introduce the data variable?
Will use following data_read, thanks.
static int hisi_rng_data_read(struct hwrng *rng, u32 *data)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
*data = readl_relaxed(hrng->base + RNG_RAN_NUM);
return 4;
}
Thanks,
Kefeng
WARNING: multiple messages have this Message-ID (diff)
From: Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Mathieu Poirier
<mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Xu Wei <xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Herbert Xu
<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
guohanjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH v2 2/2] hwrng: hisi: Add support for Hisilicon SoC RNG
Date: Fri, 8 Apr 2016 10:03:14 +0800 [thread overview]
Message-ID: <57071162.908@huawei.com> (raw)
In-Reply-To: <CANLsYkwRGm3oBWaoKki4Ge3A_-temOsdJcwby6ds_X5_XGYZtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 2016/4/7 22:55, Mathieu Poirier wrote:
> On 7 April 2016 at 02:23, Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:
>> This adds the Hisilicon Random Number Generator(RNG) support,
>> which is found in Hip04 and Hip05 soc.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/char/hw_random/Kconfig | 13 ++++
>> drivers/char/hw_random/Makefile | 1 +
>> drivers/char/hw_random/hisi-rng.c | 121 ++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 135 insertions(+)
>> create mode 100644 drivers/char/hw_random/hisi-rng.c
[...]
>> +
>> +#define RNG_SEED 0x0
>> +#define RNG_CTRL 0x4
>> + #define RNG_SEED_SEL BIT(2)
>> + #define RNG_RING_EN BIT(1)
>> + #define RNG_EN BIT(0)
>> +#define RNG_RAN_NUM 0x10
>> +#define RNG_PHY_SEED 0x14
>> +#define RNG_RELOAD_ERR 0x84
>> +
>> +#define to_hisi_rng(p) container_of(p, struct hisi_rng, rng)
>> +
>> +static int seed_sel;
>> +module_param(seed_sel, int, S_IRUGO);
>> +MODULE_PARM_DESC(seed_sel, "Auto reload seed. 0, use LFSR(default); 1, use ring oscillator.");
>> +
>> +struct hisi_rng {
>> + void __iomem *base;
>> + struct hwrng rng;
>> +};
>> +
>> +static int hisi_rng_init(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + int val = RNG_EN;
>> + u32 seed;
>> +
>> + /* get a random number as initial seed */
>> + get_random_bytes(&seed, sizeof(seed));
>> +
>> + writel_relaxed(seed, hrng->base + RNG_SEED);
>> +
>> + if (seed_sel == 1)
>> + val |= RNG_RING_EN | RNG_SEED_SEL;
>
> Hello Kefeng,
>
> Please explain what this mode does. Otherwise reviewers have to make
> a guess based on the description of the module parameter.
The seed is reload periodically, there are two choice of seeds, default using
the val from LFSR, seed_sel = 1 will use the val generated by ring oscillator.
>
>> +
>> + writel_relaxed(val, hrng->base + RNG_CTRL);
>> + return 0;
>> +}
>> +
>> +static void hisi_rng_cleanup(struct hwrng *rng)
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> +
>> + writel_relaxed(0, hrng->base + RNG_CTRL);
>> +}
>> +
>> +static int hisi_rng_read(struct hwrng *rng, void *buf, size_t max,
>> + bool wait)
>
> What are variable 'max' and 'wait' used for? As far as I can tell
> they can be removed.
Ok, will use data_read callback in struct hwrng.
>
>> +{
>> + struct hisi_rng *hrng = to_hisi_rng(rng);
>> + u32 *data = buf;
>> +
>> + *data = readl_relaxed(hrng->base + RNG_RAN_NUM);
>> + return 4;
>
> Why not simply doing the readl_relaxed() in the the code rather than
> introducing a new function?
Not clear, your mean introduce the data variable?
Will use following data_read, thanks.
static int hisi_rng_data_read(struct hwrng *rng, u32 *data)
{
struct hisi_rng *hrng = to_hisi_rng(rng);
*data = readl_relaxed(hrng->base + RNG_RAN_NUM);
return 4;
}
Thanks,
Kefeng
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-04-08 2:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 8:23 [PATCH v2 0/2] Add Hisilicon Random Number Generator(RNG) support Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
[not found] ` <1460017397-30996-1-git-send-email-wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-07 8:23 ` [PATCH v2 1/2] dt/bindings: Add bindings for hisilicon random number generator Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
2016-04-11 14:43 ` Rob Herring
2016-04-11 14:43 ` Rob Herring
2016-04-12 1:16 ` Kefeng Wang
2016-04-12 1:16 ` Kefeng Wang
2016-04-12 1:16 ` Kefeng Wang
2016-04-12 13:54 ` Rob Herring
2016-04-12 13:54 ` Rob Herring
[not found] ` <CAL_JsqJv57nX7a89OR8U1=m+MLQKJBCOeuORPWXwGRx_P9XXBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-13 5:58 ` Kefeng Wang
2016-04-13 5:58 ` Kefeng Wang
2016-04-13 5:58 ` Kefeng Wang
2016-04-07 8:23 ` [PATCH v2 2/2] hwrng: hisi: Add support for Hisilicon SoC RNG Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
2016-04-07 8:23 ` Kefeng Wang
[not found] ` <1460017397-30996-3-git-send-email-wangkefeng.wang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-04-07 14:55 ` Mathieu Poirier
2016-04-07 14:55 ` Mathieu Poirier
[not found] ` <CANLsYkwRGm3oBWaoKki4Ge3A_-temOsdJcwby6ds_X5_XGYZtQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-08 2:03 ` Kefeng Wang [this message]
2016-04-08 2:03 ` Kefeng Wang
2016-04-08 2:03 ` Kefeng Wang
2016-04-08 14:35 ` Mathieu Poirier
2016-04-08 14:35 ` Mathieu Poirier
[not found] ` <CANLsYkwm6ABM_SijZWe8X7Y6APqYKMcvmK+n6Uh3784L6nCuGw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-11 1:36 ` Kefeng Wang
2016-04-11 1:36 ` Kefeng Wang
2016-04-11 1:36 ` Kefeng Wang
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=57071162.908@huawei.com \
--to=wangkefeng.wang-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=guohanjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.