[Skiboot] [PATCH V2 7/7] libffs: init with ecc protection at blocklevel level

Alistair Popple alistair at popple.id.au
Mon Jun 22 19:28:19 AEST 2015


Likewise,

Reviewed-By: Alistair Popple <alistair at popple.id.au>

On Tue, 16 Jun 2015 19:01:10 Cyril Bur wrote:
> Passing a flag on libffs init will register all regions of the flash with
> ecc (as per the libffs partition information) as being ecc protected (or
> not).
> 
> This saves the consumer needing to know or care about the presence of ecc.
> 
> Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
> ---
>  core/flash.c             |  4 ++--
>  external/pflash/pflash.c |  4 ++--
>  libflash/libffs.c        | 14 ++++++++++++--
>  libflash/libffs.h        |  2 +-
>  4 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/core/flash.c b/core/flash.c
> index c65aefa..873a0f8 100644
> --- a/core/flash.c
> +++ b/core/flash.c
> @@ -261,7 +261,7 @@ int flash_register(struct blocklevel_device *bl, bool is_system_flash)
>  		return OPAL_RESOURCE;
>  	}
>  
> -	rc = ffs_init(0, flash->size, bl, &ffs);
> +	rc = ffs_init(0, flash->size, bl, &ffs, 0);
>  	if (rc) {
>  		prlog(PR_WARNING, "FLASH: No ffs info; "
>  				"using raw device only\n");
> @@ -541,7 +541,7 @@ static int flash_load_resource(enum resource_id id, uint32_t subid,
>  		goto out_unlock;
>  	}
>  
> -	rc = ffs_init(0, flash->size, flash->bl, &ffs);
> +	rc = ffs_init(0, flash->size, flash->bl, &ffs, 0);
>  	if (rc) {
>  		prerror("FLASH: Can't open ffs handle\n");
>  		goto out_unlock;
> diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
> index 9244570..fac4199 100644
> --- a/external/pflash/pflash.c
> +++ b/external/pflash/pflash.c
> @@ -80,7 +80,7 @@ static void print_ffs_info(uint32_t toc_offset)
>  	int rc;
>  	uint32_t i;
>  
> -	rc = ffs_init(toc_offset, fl_total_size, bl, &ffs_handle);
> +	rc = ffs_init(toc_offset, fl_total_size, bl, &ffs_handle, 0);
>  	if (rc) {
>  		fprintf(stderr, "Error %d opening ffs !\n", rc);
>  		return;
> @@ -140,7 +140,7 @@ static int open_partition(const char *name)
>  
>  	/* Open libffs if needed */
>  	if (!ffsh) {
> -		rc = ffs_init(ffs_toc, fl_total_size, bl, &ffsh);
> +		rc = ffs_init(ffs_toc, fl_total_size, bl, &ffsh, 0);
>  		if (rc) {
>  			fprintf(stderr, "Error %d opening ffs !\n", rc);
>  			if (ffs_toc)
> diff --git a/libflash/libffs.c b/libflash/libffs.c
> index c03c56a..f4aafd8 100644
> --- a/libflash/libffs.c
> +++ b/libflash/libffs.c
> @@ -73,12 +73,12 @@ static int ffs_check_convert_header(struct ffs_hdr *dst, struct ffs_hdr *src)
>  }
>  
>  int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
> -		struct ffs_handle **ffs)
> +		struct ffs_handle **ffs, int mark_ecc)
>  {
>  	struct ffs_hdr hdr;
>  	struct ffs_handle *f;
>  	uint32_t total_size;
> -	int rc;
> +	int rc, i;
>  
>  	if (!ffs || !bl)
>  		return FLASH_ERR_PARM_ERROR;
> @@ -140,6 +140,16 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
>  		goto out;
>  	}
>  
> +	if (mark_ecc) {
> +		uint32_t start, total_size;
> +		bool ecc;
> +		for (i = 0; i < f->hdr.entry_count; i++) {
> +			ffs_part_info(f, i, NULL, &start, &total_size, NULL, &ecc);
> +			if (ecc)
> +				blocklevel_ecc_protect(bl, start, total_size);
> +		}
> +	}
> +
>  out:
>  	if (rc == 0)
>  		*ffs = f;
> diff --git a/libflash/libffs.h b/libflash/libffs.h
> index a0040e9..ddf3793 100644
> --- a/libflash/libffs.h
> +++ b/libflash/libffs.h
> @@ -38,7 +38,7 @@ struct ffs_handle;
>  /* Init */
>  
>  int ffs_init(uint32_t offset, uint32_t max_size,
> -		struct blocklevel_device *bl, struct ffs_handle **ffs);
> +		struct blocklevel_device *bl, struct ffs_handle **ffs, int mark_ecc);
>  
>  /* ffs_open_image is Linux only as it uses lseek, which skiboot does not
>   * implement */
> 



More information about the Skiboot mailing list