[PATCH] hw/misc/sifive_u_otp: handling the fails of blk_pread and blk_pwrite

2020-11-04 Thread Green Wan
Fix code coverage issues by checking return value and handling fail case of blk_pread() and blk_pwrite(). Return default value 0xff if read fails. Signed-off-by: Green Wan --- hw/misc/sifive_u_otp.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff

Re: [PULL 12/12] hw/misc/sifive_u_otp: Add backend drive support

2020-11-04 Thread Green Wan
OK, let me do it. I'll send it soon. On Tue, Nov 3, 2020 at 11:53 PM Alistair Francis wrote: > > On Mon, Nov 2, 2020 at 9:49 AM Peter Maydell wrote: > > > > On Fri, 23 Oct 2020 at 16:27, Alistair Francis > > wrote: > > > > > > From: Green Wan

[PATCH v8 0/2] Add file-backed and write-once features to OTP

2020-10-19 Thread Green Wan
ite to same bit of the OTP memory. - Second patch is to add file-backed implementation to allow users to use '-drive' to assign an OTP raw image file. OTP image file must be bigger than 16K. For example, '-drive if=none,format=raw,file=otp.img' Testing

[PATCH v8 2/2] hw/misc/sifive_u_otp: Add backend drive support

2020-10-19 Thread Green Wan
five/fu540/firmware/fw_payload.elf \ -d guest_errors -drive if=none,format=raw,file=otp.img Signed-off-by: Green Wan Reviewed-by: Bin Meng Tested-by: Bin Meng --- hw/misc/sifive_u_otp.c | 65 ++ include/hw/misc/sifive_u_otp.h | 2 ++ 2 files changed, 67

[PATCH v8 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection

2020-10-19 Thread Green Wan
- Add write operation to update fuse data bit when PWE bit is on. - Add array, fuse_wo, to store the 'written' status for all bits of OTP to block the write operation. Signed-off-by: Green Wan Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Tested-by: Bin Meng --

Re: [RFC PATCH v7 2/2] hw/misc/sifive_u_otp: Add backend drive support

2020-10-19 Thread Green Wan
Sorry for replying late. I missed this email. I will revise the patch today. Thanks, - Green On Thu, Oct 15, 2020 at 4:01 PM Bin Meng wrote: > > On Thu, Oct 15, 2020 at 12:15 PM Green Wan wrote: > > > > Add '-drive' support to OTP device. Allow users to assign

[RFC PATCH v7 2/2] hw/misc/sifive_u_otp: Add backend drive support

2020-10-14 Thread Green Wan
five/fu540/firmware/fw_payload.elf \ -d guest_errors -drive if=none,format=raw,file=otp.img Signed-off-by: Green Wan --- hw/misc/sifive_u_otp.c | 67 +- include/hw/misc/sifive_u_otp.h | 2 + 2 files changed, 68 insertions(+), 1 deletion(-) diff --git

[RFC PATCH v7 0/2] Add file-backed and write-once features to OTP

2020-10-14 Thread Green Wan
ve' to assign an OTP raw image file. OTP image file must be bigger than 16K. For example, '-drive if=none,format=raw,file=otp.img' Testing - Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/misc/sifive_u_otp: Add write function and write-once protection

[RFC PATCH v7 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection

2020-10-14 Thread Green Wan
- Add write operation to update fuse data bit when PWE bit is on. - Add array, fuse_wo, to store the 'written' status for all bits of OTP to block the write operation. Signed-off-by: Green Wan Reviewed-by: Alistair Francis --- hw/misc/sifive_u_otp.c

Re: [RFC PATCH v5 2/2] hw/riscv: sifive_u: Add backend drive support

2020-10-14 Thread Green Wan
:51 AM Alistair Francis wrote: > > On Wed, Oct 14, 2020 at 8:02 AM Bin Meng wrote: > > > > Hi Alistair, > > > > On Wed, Oct 14, 2020 at 10:46 PM Alistair Francis > > wrote: > > > > > > On Wed, Sep 30, 2020 at 12:10 AM Green Wan wro

Re: [RFC PATCH v6 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection

2020-10-14 Thread Green Wan
On Wed, Oct 14, 2020 at 3:17 PM Bin Meng wrote: > > Hi Green, > > On Wed, Oct 14, 2020 at 3:02 PM Green Wan wrote: > > > > On Wed, Oct 14, 2020 at 1:37 PM Bin Meng wrote: > > > > > > Hi Green, > > > > > > On Mon, Sep 28, 2020 at 6:12

Re: [RFC PATCH v6 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection

2020-10-14 Thread Green Wan
On Wed, Oct 14, 2020 at 1:37 PM Bin Meng wrote: > > Hi Green, > > On Mon, Sep 28, 2020 at 6:12 PM Green Wan wrote: > > > > - Add write operation to update fuse data bit when PWE bit is on. > > - Add array, fuse_wo, to store the 'written' status for a

Re: [RFC PATCH v5 2/2] hw/riscv: sifive_u: Add backend drive support

2020-09-30 Thread Green Wan
On Wed, Sep 30, 2020 at 1:08 AM Alistair Francis wrote: > > On Mon, Sep 28, 2020 at 2:18 AM Green Wan wrote: > > > > Hi Alistair, > > > > Thanks for the review. See the reply inline below. > > > > > > On Sat, Sep 26, 2020 at 5:52 AM Alistair Fran

[RFC PATCH v6 0/2] Add file-backed and write-once features to OTP

2020-09-28 Thread Green Wan
sted on sifive_u for both qemu and u-boot. Green Wan (2): hw/misc/sifive_u_otp: Add write function and write-once protection hw/misc/sifive_u_otp: Add backend drive support hw/misc/sifive_u_otp.c | 81 +- include/hw/misc/sifive_u_otp.h | 5 +++ 2 file

[RFC PATCH v6 1/2] hw/misc/sifive_u_otp: Add write function and write-once protection

2020-09-28 Thread Green Wan
- Add write operation to update fuse data bit when PWE bit is on. - Add array, fuse_wo, to store the 'written' status for all bits of OTP to block the write operation. Signed-off-by: Green Wan Reviewed-by: Alistair Francis --- hw/misc/sifive_u_otp.c

[RFC PATCH v6 2/2] hw/misc/sifive_u_otp: Add backend drive support

2020-09-28 Thread Green Wan
0/firmware/fw_payload.elf \ -d guest_errors -drive if=none,format=raw,file=otp.img Signed-off-by: Green Wan --- hw/misc/sifive_u_otp.c | 51 ++ include/hw/misc/sifive_u_otp.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/hw/misc/sifive_u_otp.c

Re: [RFC PATCH v5 2/2] hw/riscv: sifive_u: Add backend drive support

2020-09-28 Thread Green Wan
Hi Alistair, Thanks for the review. See the reply inline below. On Sat, Sep 26, 2020 at 5:52 AM Alistair Francis wrote: > > On Tue, Sep 1, 2020 at 8:49 AM Green Wan wrote: > > > > Add '-drive' support to OTP device. Allow users to assign a raw file > > as OTP

[RFC PATCH v5 1/2] hw/riscv: sifive_u: Add write operation and write-once protection

2020-09-01 Thread Green Wan
- Add write operation to update fuse data bit when PWE bit is on. - Add array, fuse_wo, to store the 'written' status for all bits of OTP to block the write operation. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 30 +- includ

[RFC PATCH v5 2/2] hw/riscv: sifive_u: Add backend drive support

2020-09-01 Thread Green Wan
Add '-drive' support to OTP device. Allow users to assign a raw file as OTP image. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 50 + include/hw/riscv/sifive_u_otp.h | 2 ++ 2 files changed, 52 insertions(+) diff --git

[RFC PATCH v5 0/2] Add file-backed and write-once features to OTP

2020-09-01 Thread Green Wan
e bigger than 16K. For example, '-drive if=none,format=raw,file=otp.img' Testing - Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv: sifive_u: Add write operation and write-once protection hw/riscv: sifive_u: Add backend drive support hw/ris

Re: [RFC PATCH v4 1/2] hw/riscv: sifive_u: Add backend drive support

2020-09-01 Thread Green Wan
Hi Bin, Thanks for the remindings. I didn't notice the write operation and will add the write functionality based on bit by bit mechanism. Regards, Green On Fri, Aug 28, 2020 at 8:54 PM Bin Meng wrote: > > Hi Green, > > On Thu, Aug 27, 2020 at 3:47 PM Green Wan wrote: &g

[RFC PATCH v4 0/2] Add file-backed and write-once features to OTP

2020-08-27 Thread Green Wan
ting - Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv: sifive_u: Add backend drive support hw/riscv: sifive_u: Add write-once protection hw/riscv/sifive_u_otp.c | 71 + include/hw/riscv/sifive_u_otp.h | 3 ++ 2 files changed, 74 insertions(+) -- 2.17.1

[RFC PATCH v4 1/2] hw/riscv: sifive_u: Add backend drive support

2020-08-27 Thread Green Wan
Add '-drive' support to OTP device. Allow users to assign a raw file as OTP image. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 50 + include/hw/riscv/sifive_u_otp.h | 2 ++ 2 files changed, 52 insertions(+) diff --git

[RFC PATCH v4 2/2] hw/riscv: sifive_u: Add write-once protection

2020-08-27 Thread Green Wan
Add array to store the 'written' status for all bit of OTP to block the write operation to the same bit. Ignore the control register offset from 0x0 to 0x38 of OTP memory mapping. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 21 + includ

[RFC PATCH v3 0/2] Add file-backed and write-once features to OTP

2020-08-18 Thread Green Wan
write to the OTP memory. Only keep the 'written' state for non-control register range from 0x38 to 16KB. Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv: sifive_u: Add backend drive support hw/riscv: sifive_u: Add write-once protection

Re: [RFC PATCH v2 1/2] hw/riscv: sifive_u: Add file-backed OTP.

2020-08-18 Thread Green Wan
Hi Alistair, You're right. I can get drive without -device. Now it looks much better. Sent v3 patch. Thanks a lot, - Green On Fri, Aug 14, 2020 at 5:34 AM Alistair Francis wrote: > On Wed, Aug 12, 2020 at 9:12 PM Green Wan wrote: > > > > Hi Alistair, > > > >

[RFC PATCH v3 2/2] hw/riscv: sifive_u: Add write-once protection.

2020-08-18 Thread Green Wan
Add array to store the 'written' status for all bit of OTP to block the write operation to the same bit. Ignore the control register offset from 0x0 to 0x38 of OTP memory mapping. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 21 + includ

[RFC PATCH v3 1/2] hw/riscv: sifive_u: Add backend drive support

2020-08-18 Thread Green Wan
Add '-drive' support to OTP device. Allow users to assign a raw file as OTP image. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 50 + include/hw/riscv/sifive_u_otp.h | 2 ++ 2 files changed, 52 insertions(+) diff --git

Re: [RFC PATCH v2 1/2] hw/riscv: sifive_u: Add file-backed OTP.

2020-08-12 Thread Green Wan
s for specifying the device? Thanks, - Green On Tue, Aug 11, 2020 at 6:24 AM Alistair Francis wrote: > ,()On Thu, Jul 30, 2020 at 7:49 PM Green Wan wrote: > > > > Add a file-backed implementation for OTP of sifive_u machine. The > > machine property for file-backed is disa

[RFC PATCH v2 1/2] hw/riscv: sifive_u: Add file-backed OTP.

2020-07-30 Thread Green Wan
Add a file-backed implementation for OTP of sifive_u machine. The machine property for file-backed is disabled in default. Do file open, mmap and close for every OTP read/write in case keep the update-to-date snapshot of OTP. Signed-off-by: Green Wan --- hw/riscv/sifive_u.c | 26

[RFC PATCH v2 2/2] hw/riscv: sifive_u: Add write-once protection.

2020-07-30 Thread Green Wan
Add array to store the 'written' status for all bit of OTP to block the write operation to the same bit. Ignore the control register offset from 0x0 to 0x38 of OTP memory mapping. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 20 includ

[RFC PATCH v2 0/2] Add write-once and file-backed features to OTP

2020-07-30 Thread Green Wan
' feature to block second write to the OTP memory. Only keep the 'written' state for non-control register range from 0x38 to 16KB. Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv: sifive_u: Add file-backed OTP. hw/riscv: sifive_u: Add write-once

Re: [RFC PATCH 1/2] hw/riscv: sifive_u: Add file-backed OTP. softmmu/vl: add otp-file to boot option

2020-07-27 Thread Green Wan
def struct SiFiveUOTPState { uint32_t fuse[SIFIVE_U_OTP_NUM_FUSES]; /* config */ uint32_t serial; +char *otp_file; uint32_t fuse_wo[SIFIVE_U_OTP_NUM_FUSES]; } SiFiveUOTPState; Regards, Green On Fri, Jul 24, 2020 at 10:20 PM Bin Meng wrote: > Hi Green, > > On Fri, Jul 2

[RFC PATCH 1/2] hw/riscv: sifive_u: Add file-backed OTP. softmmu/vl: add otp-file to boot option

2020-07-24 Thread Green Wan
Add a file-backed implementation for OTP of sifive_u machine. Use '-boot otp-file=xxx' to enable it. Do file open, mmap and close for every OTP read/write in case keep the update-to-date snapshot of OTP. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c

[RFC PATCH 2/2] hw/riscv: sifive_u: Add write-once protection.

2020-07-24 Thread Green Wan
Add array to store the 'written' status for all bit of OTP to block the write operation to the same bit. Ignore the control register offset from 0x0 to 0x38 of OTP memory mapping. Signed-off-by: Green Wan --- hw/riscv/sifive_u_otp.c | 34 ++---

[RFC PATCH 0/2] Add write-once and file-backed features to OTP

2020-07-24 Thread Green Wan
olves file open, mmap and close operation to the image file. Add write-once feature to block second write operation to the OTP memory. Only keep the 'written' state for non-control register range from 0x38 to 16KB. Tested on sifive_u for both qemu and u-boot. Green Wan (2): hw/riscv