diff mbox series

[U-Boot,1/2] common: Generic file system firmware loader

Message ID 1509527902-5080-2-git-send-email-tien.fong.chee@intel.com
State Changes Requested
Delegated to: Marek Vasut
Headers show
Series Creating generic file system firmware loader | expand

Commit Message

Chee, Tien Fong Nov. 1, 2017, 9:18 a.m. UTC
From: Tien Fong Chee <tien.fong.chee@intel.com>

Generic firmware loader framework contains some common functionality
which is factored out from splash loader. It is reusable by any
specific driver file system firmware loader. Specific driver file system
firmware loader handling can be defined with both weak function
fsloader_preprocess and fs_loading.

Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
---
 common/Makefile   |   1 +
 common/load_fs.c  | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/load_fs.h |  38 ++++++++++
 3 files changed, 256 insertions(+)
 create mode 100644 common/load_fs.c
 create mode 100644 include/load_fs.h

Comments

Marek Vasut Nov. 1, 2017, 9:26 a.m. UTC | #1
On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:
> From: Tien Fong Chee <tien.fong.chee@intel.com>
> 
> Generic firmware loader framework contains some common functionality
> which is factored out from splash loader. It is reusable by any
> specific driver file system firmware loader. Specific driver file system
> firmware loader handling can be defined with both weak function
> fsloader_preprocess and fs_loading.
> 
> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> ---
>  common/Makefile   |   1 +
>  common/load_fs.c  | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/load_fs.h |  38 ++++++++++
>  3 files changed, 256 insertions(+)
>  create mode 100644 common/load_fs.c
>  create mode 100644 include/load_fs.h
[...]

> +int flash_select_fs_dev(struct flash_location *location)

Why does everything have flash_ prefix ?

I also mentioned the API should copy the linux firmware loader API.

> +{
> +	int res;
> +
> +	switch (location->storage) {
> +	case FLASH_STORAGE_MMC:
> +		res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
> +		break;
> +	case FLASH_STORAGE_USB:
> +		res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
> +		break;
> +	case FLASH_STORAGE_SATA:
> +		res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY);
> +		break;
> +	case FLASH_STORAGE_NAND:
> +		if (location->ubivol != NULL)
> +			res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
> +		else
> +			res = -ENODEV;
> +		break;
> +	default:
> +		error("Error: unsupported location storage.\n");
> +		return -ENODEV;
> +	}
> +
> +	if (res)
> +		error("Error: could not access storage.\n");
> +
> +	return res;
> +}
> +
> +#ifndef CONFIG_SPL_BUILD
> +#ifdef CONFIG_USB_STORAGE

This looks wrong, the USB can be supported in SPL no problem. And this
USB init shouldn't be duplicated here IMO.

> +static int flash_init_usb(void)
> +{
> +	int err;
> +
> +	err = usb_init();
> +	if (err)
> +		return err;
> +
> +#ifndef CONFIG_DM_USB
> +	err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
> +#endif
> +
> +	return err;
> +}
> +#else
> +static inline int flash_init_usb(void)

Don't use inline , the compiler can decide better.

[...]
Chee, Tien Fong Nov. 2, 2017, 8:20 a.m. UTC | #2
On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:
> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:

> > 

> > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > 

> > Generic firmware loader framework contains some common

> > functionality

> > which is factored out from splash loader. It is reusable by any

> > specific driver file system firmware loader. Specific driver file

> > system

> > firmware loader handling can be defined with both weak function

> > fsloader_preprocess and fs_loading.

> > 

> > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

> > ---

> >  common/Makefile   |   1 +

> >  common/load_fs.c  | 217

> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++

> >  include/load_fs.h |  38 ++++++++++

> >  3 files changed, 256 insertions(+)

> >  create mode 100644 common/load_fs.c

> >  create mode 100644 include/load_fs.h

> [...]

> 

> > 

> > +int flash_select_fs_dev(struct flash_location *location)

> Why does everything have flash_ prefix ?

> 

I can remove the flash_ prefix, this generic FS loader should support
for all filesystem instead of flash.

> I also mentioned the API should copy the linux firmware loader API.

> 

If i'm not mistaken, you are referring firmware loader API in this
link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd3b2e9364
fbb32ad28b971/drivers/base/firmware_class.c#L1264.

Actually we have almost same framework in filesystem loader portion,
just different implementation, and Linux firmware loader is more
specific to Linux environment such as hard code path searching in RFS.
The generic FS loader in this patch is much more flexible, let user to
define their own prefer implementation.
 Linux FS firmware loader  <--->   U-Boot FS firmware loader
--------------------------       ---------------------------
1) request_firmware			flash_load_fs
2) _request_firmware_prepare          weak fsloader_preprocess
3) fw_get_filesystem_firmware          weak fs_loading                
         
> > +	int res;

> > +

> > +	switch (location->storage) {

> > +	case FLASH_STORAGE_MMC:

> > +		res = fs_set_blk_dev("mmc", location->devpart,

> > FS_TYPE_ANY);

> > +		break;

> > +	case FLASH_STORAGE_USB:

> > +		res = fs_set_blk_dev("usb", location->devpart,

> > FS_TYPE_ANY);

> > +		break;

> > +	case FLASH_STORAGE_SATA:

> > +		res = fs_set_blk_dev("sata", location->devpart,

> > FS_TYPE_ANY);

> > +		break;

> > +	case FLASH_STORAGE_NAND:

> > +		if (location->ubivol != NULL)

> > +			res = fs_set_blk_dev("ubi", NULL,

> > FS_TYPE_UBIFS);

> > +		else

> > +			res = -ENODEV;

> > +		break;

> > +	default:

> > +		error("Error: unsupported location storage.\n");

> > +		return -ENODEV;

> > +	}

> > +

> > +	if (res)

> > +		error("Error: could not access storage.\n");

> > +

> > +	return res;

> > +}

> > +

> > +#ifndef CONFIG_SPL_BUILD

> > +#ifdef CONFIG_USB_STORAGE

> This looks wrong, the USB can be supported in SPL no problem. And

> this

Technically, USB can be supported in SPL, but the build for USB in SPL
is not supported yet.
> USB init shouldn't be duplicated here IMO.

> 

This is just for the case USB init is not yet started, but loader is
called 1st.
> > 

> > +static int flash_init_usb(void)

> > +{

> > +	int err;

> > +

> > +	err = usb_init();

> > +	if (err)

> > +		return err;

> > +

> > +#ifndef CONFIG_DM_USB

> > +	err = usb_stor_scan(1) < 0 ? -ENODEV : 0;

> > +#endif

> > +

> > +	return err;

> > +}

> > +#else

> > +static inline int flash_init_usb(void)

> Don't use inline , the compiler can decide better.

> 

Okay.
> [...]

> 

>
Marek Vasut Nov. 5, 2017, 4:43 p.m. UTC | #3
On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:
> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:
>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:
>>>
>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>
>>> Generic firmware loader framework contains some common
>>> functionality
>>> which is factored out from splash loader. It is reusable by any
>>> specific driver file system firmware loader. Specific driver file
>>> system
>>> firmware loader handling can be defined with both weak function
>>> fsloader_preprocess and fs_loading.
>>>
>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
>>> ---
>>>  common/Makefile   |   1 +
>>>  common/load_fs.c  | 217
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>  include/load_fs.h |  38 ++++++++++
>>>  3 files changed, 256 insertions(+)
>>>  create mode 100644 common/load_fs.c
>>>  create mode 100644 include/load_fs.h
>> [...]
>>
>>>
>>> +int flash_select_fs_dev(struct flash_location *location)
>> Why does everything have flash_ prefix ?
>>
> I can remove the flash_ prefix, this generic FS loader should support
> for all filesystem instead of flash.
> 
>> I also mentioned the API should copy the linux firmware loader API.
>>
> If i'm not mistaken, you are referring firmware loader API in this
> link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd3b2e9364
> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
> 
> Actually we have almost same framework in filesystem loader portion,
> just different implementation, and Linux firmware loader is more
> specific to Linux environment such as hard code path searching in RFS.
> The generic FS loader in this patch is much more flexible, let user to
> define their own prefer implementation.
>  Linux FS firmware loader  <--->   U-Boot FS firmware loader
> --------------------------       ---------------------------
> 1) request_firmware			flash_load_fs
> 2) _request_firmware_prepare          weak fsloader_preprocess
> 3) fw_get_filesystem_firmware          weak fs_loading                

The API should be the same or very similar to make porting of drivers
from Linux easy and allow people to know only one API, not two.

>>> +	int res;
>>> +
>>> +	switch (location->storage) {
>>> +	case FLASH_STORAGE_MMC:
>>> +		res = fs_set_blk_dev("mmc", location->devpart,
>>> FS_TYPE_ANY);
>>> +		break;
>>> +	case FLASH_STORAGE_USB:
>>> +		res = fs_set_blk_dev("usb", location->devpart,
>>> FS_TYPE_ANY);
>>> +		break;
>>> +	case FLASH_STORAGE_SATA:
>>> +		res = fs_set_blk_dev("sata", location->devpart,
>>> FS_TYPE_ANY);
>>> +		break;
>>> +	case FLASH_STORAGE_NAND:
>>> +		if (location->ubivol != NULL)
>>> +			res = fs_set_blk_dev("ubi", NULL,
>>> FS_TYPE_UBIFS);
>>> +		else
>>> +			res = -ENODEV;
>>> +		break;
>>> +	default:
>>> +		error("Error: unsupported location storage.\n");
>>> +		return -ENODEV;
>>> +	}
>>> +
>>> +	if (res)
>>> +		error("Error: could not access storage.\n");
>>> +
>>> +	return res;
>>> +}
>>> +
>>> +#ifndef CONFIG_SPL_BUILD
>>> +#ifdef CONFIG_USB_STORAGE
>> This looks wrong, the USB can be supported in SPL no problem. And
>> this
> Technically, USB can be supported in SPL, but the build for USB in SPL
> is not supported yet.
>> USB init shouldn't be duplicated here IMO.
>>
> This is just for the case USB init is not yet started, but loader is
> called 1st.
I am not asking WHY this is needed. I suspect we have this code
somewhere already, so it's a duplicate here.
Chee, Tien Fong Nov. 6, 2017, 4:15 a.m. UTC | #4
On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:
> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:

> > 

> > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:

> > > 

> > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:

> > > > 

> > > > 

> > > > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > 

> > > > Generic firmware loader framework contains some common

> > > > functionality

> > > > which is factored out from splash loader. It is reusable by any

> > > > specific driver file system firmware loader. Specific driver

> > > > file

> > > > system

> > > > firmware loader handling can be defined with both weak function

> > > > fsloader_preprocess and fs_loading.

> > > > 

> > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > ---

> > > >  common/Makefile   |   1 +

> > > >  common/load_fs.c  | 217

> > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++

> > > >  include/load_fs.h |  38 ++++++++++

> > > >  3 files changed, 256 insertions(+)

> > > >  create mode 100644 common/load_fs.c

> > > >  create mode 100644 include/load_fs.h

> > > [...]

> > > 

> > > > 

> > > > 

> > > > +int flash_select_fs_dev(struct flash_location *location)

> > > Why does everything have flash_ prefix ?

> > > 

> > I can remove the flash_ prefix, this generic FS loader should

> > support

> > for all filesystem instead of flash.

> > 

> > > 

> > > I also mentioned the API should copy the linux firmware loader

> > > API.

> > > 

> > If i'm not mistaken, you are referring firmware loader API in this

> > link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd3b2e

> > 9364

> > fbb32ad28b971/drivers/base/firmware_class.c#L1264.

> > 

I would like to confirm with you whether we are talking to the same API
above?

> > Actually we have almost same framework in filesystem loader

> > portion,

> > just different implementation, and Linux firmware loader is more

> > specific to Linux environment such as hard code path searching in

> > RFS.

> > The generic FS loader in this patch is much more flexible, let user

> > to

> > define their own prefer implementation.

> >  Linux FS firmware loader  <--->   U-Boot FS firmware loader

> > --------------------------       ---------------------------

> > 1) request_firmware			flash_load_fs

> > 2) _request_firmware_prepare          weak fsloader_preprocess

> > 3) fw_get_filesystem_firmware          weak fs_loading            

> >    

> The API should be the same or very similar to make porting of drivers

> from Linux easy and allow people to know only one API, not two.

> 

> > 

> > > 

> > > > 

> > > > +	int res;

> > > > +

> > > > +	switch (location->storage) {

> > > > +	case FLASH_STORAGE_MMC:

> > > > +		res = fs_set_blk_dev("mmc", location->devpart,

> > > > FS_TYPE_ANY);

> > > > +		break;

> > > > +	case FLASH_STORAGE_USB:

> > > > +		res = fs_set_blk_dev("usb", location->devpart,

> > > > FS_TYPE_ANY);

> > > > +		break;

> > > > +	case FLASH_STORAGE_SATA:

> > > > +		res = fs_set_blk_dev("sata", location-

> > > > >devpart,

> > > > FS_TYPE_ANY);

> > > > +		break;

> > > > +	case FLASH_STORAGE_NAND:

> > > > +		if (location->ubivol != NULL)

> > > > +			res = fs_set_blk_dev("ubi", NULL,

> > > > FS_TYPE_UBIFS);

> > > > +		else

> > > > +			res = -ENODEV;

> > > > +		break;

> > > > +	default:

> > > > +		error("Error: unsupported location

> > > > storage.\n");

> > > > +		return -ENODEV;

> > > > +	}

> > > > +

> > > > +	if (res)

> > > > +		error("Error: could not access storage.\n");

> > > > +

> > > > +	return res;

> > > > +}

> > > > +

> > > > +#ifndef CONFIG_SPL_BUILD

> > > > +#ifdef CONFIG_USB_STORAGE

> > > This looks wrong, the USB can be supported in SPL no problem. And

> > > this

> > Technically, USB can be supported in SPL, but the build for USB in

> > SPL

> > is not supported yet.

> > > 

> > > USB init shouldn't be duplicated here IMO.

> > > 

> > This is just for the case USB init is not yet started, but loader

> > is

> > called 1st.

> I am not asking WHY this is needed. I suspect we have this code

> somewhere already, so it's a duplicate here.

>
Marek Vasut Nov. 6, 2017, 10:56 a.m. UTC | #5
On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:
> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:
>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:
>>>
>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:
>>>>
>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:
>>>>>
>>>>>
>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>
>>>>> Generic firmware loader framework contains some common
>>>>> functionality
>>>>> which is factored out from splash loader. It is reusable by any
>>>>> specific driver file system firmware loader. Specific driver
>>>>> file
>>>>> system
>>>>> firmware loader handling can be defined with both weak function
>>>>> fsloader_preprocess and fs_loading.
>>>>>
>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>> ---
>>>>>  common/Makefile   |   1 +
>>>>>  common/load_fs.c  | 217
>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>  3 files changed, 256 insertions(+)
>>>>>  create mode 100644 common/load_fs.c
>>>>>  create mode 100644 include/load_fs.h
>>>> [...]
>>>>
>>>>>
>>>>>
>>>>> +int flash_select_fs_dev(struct flash_location *location)
>>>> Why does everything have flash_ prefix ?
>>>>
>>> I can remove the flash_ prefix, this generic FS loader should
>>> support
>>> for all filesystem instead of flash.
>>>
>>>>
>>>> I also mentioned the API should copy the linux firmware loader
>>>> API.
>>>>
>>> If i'm not mistaken, you are referring firmware loader API in this
>>> link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd3b2e
>>> 9364
>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
>>>
> I would like to confirm with you whether we are talking to the same API
> above?

https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.html

first link on google btw . You might be able to avoid the firmware
structure.

[...]
Chee, Tien Fong Nov. 7, 2017, 9:03 a.m. UTC | #6
On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:
> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:

> > 

> > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:

> > > 

> > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:

> > > > 

> > > > 

> > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:

> > > > > 

> > > > > 

> > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:

> > > > > > 

> > > > > > 

> > > > > > 

> > > > > > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > > > 

> > > > > > Generic firmware loader framework contains some common

> > > > > > functionality

> > > > > > which is factored out from splash loader. It is reusable by

> > > > > > any

> > > > > > specific driver file system firmware loader. Specific

> > > > > > driver

> > > > > > file

> > > > > > system

> > > > > > firmware loader handling can be defined with both weak

> > > > > > function

> > > > > > fsloader_preprocess and fs_loading.

> > > > > > 

> > > > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > > > ---

> > > > > >  common/Makefile   |   1 +

> > > > > >  common/load_fs.c  | 217

> > > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++

> > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > >  3 files changed, 256 insertions(+)

> > > > > >  create mode 100644 common/load_fs.c

> > > > > >  create mode 100644 include/load_fs.h

> > > > > [...]

> > > > > 

> > > > > > 

> > > > > > 

> > > > > > 

> > > > > > +int flash_select_fs_dev(struct flash_location *location)

> > > > > Why does everything have flash_ prefix ?

> > > > > 

> > > > I can remove the flash_ prefix, this generic FS loader should

> > > > support

> > > > for all filesystem instead of flash.

> > > > 

> > > > > 

> > > > > 

> > > > > I also mentioned the API should copy the linux firmware

> > > > > loader

> > > > > API.

> > > > > 

> > > > If i'm not mistaken, you are referring firmware loader API in

> > > > this

> > > > link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd

> > > > 3b2e

> > > > 9364

> > > > fbb32ad28b971/drivers/base/firmware_class.c#L1264.

> > > > 

> > I would like to confirm with you whether we are talking to the same

> > API

> > above?

> https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.html

> 

> first link on google btw . You might be able to avoid the firmware

> structure.

> 

After assessment, i found that Linux loader is not suitable for fpga
loader as fpga loader need
1) Able to program FPGA image in SPL chunk bu chunk with small memory
allocatted.
2) Name of FPGA image defined in DTS, and path of FPGA image in FAT and
UBI partition.

Linux loader is strongly designed based on Linux environment, always
assume having RFF, env support(which SPL don't have), sysfs and udev
feature.

Thanks.
> [...]

>
Marek Vasut Nov. 7, 2017, 9:34 a.m. UTC | #7
On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:
> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:
>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:
>>>
>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:
>>>>
>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:
>>>>>
>>>>>
>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:
>>>>>>
>>>>>>
>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>>>
>>>>>>> Generic firmware loader framework contains some common
>>>>>>> functionality
>>>>>>> which is factored out from splash loader. It is reusable by
>>>>>>> any
>>>>>>> specific driver file system firmware loader. Specific
>>>>>>> driver
>>>>>>> file
>>>>>>> system
>>>>>>> firmware loader handling can be defined with both weak
>>>>>>> function
>>>>>>> fsloader_preprocess and fs_loading.
>>>>>>>
>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>>> ---
>>>>>>>  common/Makefile   |   1 +
>>>>>>>  common/load_fs.c  | 217
>>>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>>>  3 files changed, 256 insertions(+)
>>>>>>>  create mode 100644 common/load_fs.c
>>>>>>>  create mode 100644 include/load_fs.h
>>>>>> [...]
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> +int flash_select_fs_dev(struct flash_location *location)
>>>>>> Why does everything have flash_ prefix ?
>>>>>>
>>>>> I can remove the flash_ prefix, this generic FS loader should
>>>>> support
>>>>> for all filesystem instead of flash.
>>>>>
>>>>>>
>>>>>>
>>>>>> I also mentioned the API should copy the linux firmware
>>>>>> loader
>>>>>> API.
>>>>>>
>>>>> If i'm not mistaken, you are referring firmware loader API in
>>>>> this
>>>>> link https://github.com/torvalds/linux/blob/f007cad159e99fa2acd
>>>>> 3b2e
>>>>> 9364
>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
>>>>>
>>> I would like to confirm with you whether we are talking to the same
>>> API
>>> above?
>> https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.html
>>
>> first link on google btw . You might be able to avoid the firmware
>> structure.
>>
> After assessment, i found that Linux loader is not suitable for fpga
> loader as fpga loader need
> 1) Able to program FPGA image in SPL chunk bu chunk with small memory
> allocatted.
> 2) Name of FPGA image defined in DTS, and path of FPGA image in FAT and
> UBI partition.
> 
> Linux loader is strongly designed based on Linux environment, always
> assume having RFF, env support(which SPL don't have), sysfs and udev
> feature.

Sigh, you can just have some additional function call to fetch smaller
chunks from a file, I don't think it's that hard of a problem ...
Chee, Tien Fong Nov. 9, 2017, 6:04 a.m. UTC | #8
On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:
> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:

> > 

> > On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:

> > > 

> > > On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:

> > > > 

> > > > 

> > > > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:

> > > > > 

> > > > > 

> > > > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:

> > > > > > 

> > > > > > 

> > > > > > 

> > > > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:

> > > > > > > 

> > > > > > > 

> > > > > > > 

> > > > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > > > > > 

> > > > > > > > Generic firmware loader framework contains some common

> > > > > > > > functionality

> > > > > > > > which is factored out from splash loader. It is

> > > > > > > > reusable by

> > > > > > > > any

> > > > > > > > specific driver file system firmware loader. Specific

> > > > > > > > driver

> > > > > > > > file

> > > > > > > > system

> > > > > > > > firmware loader handling can be defined with both weak

> > > > > > > > function

> > > > > > > > fsloader_preprocess and fs_loading.

> > > > > > > > 

> > > > > > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com

> > > > > > > > >

> > > > > > > > ---

> > > > > > > >  common/Makefile   |   1 +

> > > > > > > >  common/load_fs.c  | 217

> > > > > > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++

> > > > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > > > >  3 files changed, 256 insertions(+)

> > > > > > > >  create mode 100644 common/load_fs.c

> > > > > > > >  create mode 100644 include/load_fs.h

> > > > > > > [...]

> > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > +int flash_select_fs_dev(struct flash_location

> > > > > > > > *location)

> > > > > > > Why does everything have flash_ prefix ?

> > > > > > > 

> > > > > > I can remove the flash_ prefix, this generic FS loader

> > > > > > should

> > > > > > support

> > > > > > for all filesystem instead of flash.

> > > > > > 

> > > > > > > 

> > > > > > > 

> > > > > > > 

> > > > > > > I also mentioned the API should copy the linux firmware

> > > > > > > loader

> > > > > > > API.

> > > > > > > 

> > > > > > If i'm not mistaken, you are referring firmware loader API

> > > > > > in

> > > > > > this

> > > > > > link https://github.com/torvalds/linux/blob/f007cad159e99fa

> > > > > > 2acd

> > > > > > 3b2e

> > > > > > 9364

> > > > > > fbb32ad28b971/drivers/base/firmware_class.c#L1264.

> > > > > > 

> > > > I would like to confirm with you whether we are talking to the

> > > > same

> > > > API

> > > > above?

> > > https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.h

> > > tml

> > > 

> > > first link on google btw . You might be able to avoid the

> > > firmware

> > > structure.

> > > 

> > After assessment, i found that Linux loader is not suitable for

> > fpga

> > loader as fpga loader need

> > 1) Able to program FPGA image in SPL chunk bu chunk with small

> > memory

> > allocatted.

> > 2) Name of FPGA image defined in DTS, and path of FPGA image in FAT

> > and

> > UBI partition.

> > 

> > Linux loader is strongly designed based on Linux environment,

> > always

> > assume having RFF, env support(which SPL don't have), sysfs and

> > udev

> > feature.

> Sigh, you can just have some additional function call to fetch

> smaller

> chunks from a file, I don't think it's that hard of a problem ...

> 

We already have that function to support smaller chunks, and it also
work for single large image when enough memory is available in ver 1
series of fpga loadfs.

Since the Linux loader API is totally not suitable for fpga loadfs, and
also nothing i can leverage from there for fpga loadfs, could you
please consider to accept implementation for this series patches or
implementation for fpga loadfs series ver1?

Thanks.
Marek Vasut Nov. 9, 2017, 7:05 a.m. UTC | #9
On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:
> On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:
>> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:
>>>
>>> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:
>>>>
>>>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:
>>>>>
>>>>>
>>>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:
>>>>>>
>>>>>>
>>>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>>>>>
>>>>>>>>> Generic firmware loader framework contains some common
>>>>>>>>> functionality
>>>>>>>>> which is factored out from splash loader. It is
>>>>>>>>> reusable by
>>>>>>>>> any
>>>>>>>>> specific driver file system firmware loader. Specific
>>>>>>>>> driver
>>>>>>>>> file
>>>>>>>>> system
>>>>>>>>> firmware loader handling can be defined with both weak
>>>>>>>>> function
>>>>>>>>> fsloader_preprocess and fs_loading.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com
>>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>>  common/Makefile   |   1 +
>>>>>>>>>  common/load_fs.c  | 217
>>>>>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>>>>>  3 files changed, 256 insertions(+)
>>>>>>>>>  create mode 100644 common/load_fs.c
>>>>>>>>>  create mode 100644 include/load_fs.h
>>>>>>>> [...]
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> +int flash_select_fs_dev(struct flash_location
>>>>>>>>> *location)
>>>>>>>> Why does everything have flash_ prefix ?
>>>>>>>>
>>>>>>> I can remove the flash_ prefix, this generic FS loader
>>>>>>> should
>>>>>>> support
>>>>>>> for all filesystem instead of flash.
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> I also mentioned the API should copy the linux firmware
>>>>>>>> loader
>>>>>>>> API.
>>>>>>>>
>>>>>>> If i'm not mistaken, you are referring firmware loader API
>>>>>>> in
>>>>>>> this
>>>>>>> link https://github.com/torvalds/linux/blob/f007cad159e99fa
>>>>>>> 2acd
>>>>>>> 3b2e
>>>>>>> 9364
>>>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
>>>>>>>
>>>>> I would like to confirm with you whether we are talking to the
>>>>> same
>>>>> API
>>>>> above?
>>>> https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.h
>>>> tml
>>>>
>>>> first link on google btw . You might be able to avoid the
>>>> firmware
>>>> structure.
>>>>
>>> After assessment, i found that Linux loader is not suitable for
>>> fpga
>>> loader as fpga loader need
>>> 1) Able to program FPGA image in SPL chunk bu chunk with small
>>> memory
>>> allocatted.
>>> 2) Name of FPGA image defined in DTS, and path of FPGA image in FAT
>>> and
>>> UBI partition.
>>>
>>> Linux loader is strongly designed based on Linux environment,
>>> always
>>> assume having RFF, env support(which SPL don't have), sysfs and
>>> udev
>>> feature.
>> Sigh, you can just have some additional function call to fetch
>> smaller
>> chunks from a file, I don't think it's that hard of a problem ...
>>
> We already have that function to support smaller chunks, and it also
> work for single large image when enough memory is available in ver 1
> series of fpga loadfs.
> 
> Since the Linux loader API is totally not suitable for fpga loadfs, and
> also nothing i can leverage from there for fpga loadfs, could you
> please consider to accept implementation for this series patches or
> implementation for fpga loadfs series ver1?

You mean going back to completely custom non-generic altera-only ad-hoc
interface ? I'd like to hear opinion of the others on CC ...
Chee, Tien Fong Nov. 9, 2017, 7:09 a.m. UTC | #10
On Kha, 2017-11-09 at 08:05 +0100, Marek Vasut wrote:
> On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:

> > 

> > On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:

> > > 

> > > On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:

> > > > 

> > > > 

> > > > On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:

> > > > > 

> > > > > 

> > > > > On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:

> > > > > > 

> > > > > > 

> > > > > > 

> > > > > > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:

> > > > > > > 

> > > > > > > 

> > > > > > > 

> > > > > > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.com

> > > > > > > > > wrote:

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > > > > > > > 

> > > > > > > > > > Generic firmware loader framework contains some

> > > > > > > > > > common

> > > > > > > > > > functionality

> > > > > > > > > > which is factored out from splash loader. It is

> > > > > > > > > > reusable by

> > > > > > > > > > any

> > > > > > > > > > specific driver file system firmware loader.

> > > > > > > > > > Specific

> > > > > > > > > > driver

> > > > > > > > > > file

> > > > > > > > > > system

> > > > > > > > > > firmware loader handling can be defined with both

> > > > > > > > > > weak

> > > > > > > > > > function

> > > > > > > > > > fsloader_preprocess and fs_loading.

> > > > > > > > > > 

> > > > > > > > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel

> > > > > > > > > > .com

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > ---

> > > > > > > > > >  common/Makefile   |   1 +

> > > > > > > > > >  common/load_fs.c  | 217

> > > > > > > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++

> > > > > > > > > > +++

> > > > > > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > > > > > >  3 files changed, 256 insertions(+)

> > > > > > > > > >  create mode 100644 common/load_fs.c

> > > > > > > > > >  create mode 100644 include/load_fs.h

> > > > > > > > > [...]

> > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > +int flash_select_fs_dev(struct flash_location

> > > > > > > > > > *location)

> > > > > > > > > Why does everything have flash_ prefix ?

> > > > > > > > > 

> > > > > > > > I can remove the flash_ prefix, this generic FS loader

> > > > > > > > should

> > > > > > > > support

> > > > > > > > for all filesystem instead of flash.

> > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > I also mentioned the API should copy the linux

> > > > > > > > > firmware

> > > > > > > > > loader

> > > > > > > > > API.

> > > > > > > > > 

> > > > > > > > If i'm not mistaken, you are referring firmware loader

> > > > > > > > API

> > > > > > > > in

> > > > > > > > this

> > > > > > > > link https://github.com/torvalds/linux/blob/f007cad159e

> > > > > > > > 99fa

> > > > > > > > 2acd

> > > > > > > > 3b2e

> > > > > > > > 9364

> > > > > > > > fbb32ad28b971/drivers/base/firmware_class.c#L1264.

> > > > > > > > 

> > > > > > I would like to confirm with you whether we are talking to

> > > > > > the

> > > > > > same

> > > > > > API

> > > > > > above?

> > > > > https://www.kernel.org/doc/html/v4.13/driver-api/firmware/ind

> > > > > ex.h

> > > > > tml

> > > > > 

> > > > > first link on google btw . You might be able to avoid the

> > > > > firmware

> > > > > structure.

> > > > > 

> > > > After assessment, i found that Linux loader is not suitable for

> > > > fpga

> > > > loader as fpga loader need

> > > > 1) Able to program FPGA image in SPL chunk bu chunk with small

> > > > memory

> > > > allocatted.

> > > > 2) Name of FPGA image defined in DTS, and path of FPGA image in

> > > > FAT

> > > > and

> > > > UBI partition.

> > > > 

> > > > Linux loader is strongly designed based on Linux environment,

> > > > always

> > > > assume having RFF, env support(which SPL don't have), sysfs and

> > > > udev

> > > > feature.

> > > Sigh, you can just have some additional function call to fetch

> > > smaller

> > > chunks from a file, I don't think it's that hard of a problem ...

> > > 

> > We already have that function to support smaller chunks, and it

> > also

> > work for single large image when enough memory is available in ver

> > 1

> > series of fpga loadfs.

> > 

> > Since the Linux loader API is totally not suitable for fpga loadfs,

> > and

> > also nothing i can leverage from there for fpga loadfs, could you

> > please consider to accept implementation for this series patches or

> > implementation for fpga loadfs series ver1?

> You mean going back to completely custom non-generic altera-only ad-

> hoc

> interface ? I'd like to hear opinion of the others on CC ...

> 

or this patch.
Lukasz Majewski Nov. 9, 2017, 10 a.m. UTC | #11
On Thu, 9 Nov 2017 08:05:18 +0100
Marek Vasut <marex@denx.de> wrote:

> On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:
> > On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  
> >> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  
> >>>
> >>> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  
> >>>>
> >>>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  
> >>>>>
> >>>>>
> >>>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:  
> >>>>>>
> >>>>>>
> >>>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:  
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:  
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
> >>>>>>>>>
> >>>>>>>>> Generic firmware loader framework contains some common
> >>>>>>>>> functionality
> >>>>>>>>> which is factored out from splash loader. It is
> >>>>>>>>> reusable by
> >>>>>>>>> any
> >>>>>>>>> specific driver file system firmware loader. Specific
> >>>>>>>>> driver
> >>>>>>>>> file
> >>>>>>>>> system
> >>>>>>>>> firmware loader handling can be defined with both weak
> >>>>>>>>> function
> >>>>>>>>> fsloader_preprocess and fs_loading.
> >>>>>>>>>
> >>>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com  
> >>>>>>>>>>  
> >>>>>>>>> ---
> >>>>>>>>>  common/Makefile   |   1 +
> >>>>>>>>>  common/load_fs.c  | 217
> >>>>>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>>>>>>>>  include/load_fs.h |  38 ++++++++++
> >>>>>>>>>  3 files changed, 256 insertions(+)
> >>>>>>>>>  create mode 100644 common/load_fs.c
> >>>>>>>>>  create mode 100644 include/load_fs.h  
> >>>>>>>> [...]
> >>>>>>>>  
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> +int flash_select_fs_dev(struct flash_location
> >>>>>>>>> *location)  
> >>>>>>>> Why does everything have flash_ prefix ?
> >>>>>>>>  
> >>>>>>> I can remove the flash_ prefix, this generic FS loader
> >>>>>>> should
> >>>>>>> support
> >>>>>>> for all filesystem instead of flash.
> >>>>>>>  
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> I also mentioned the API should copy the linux firmware
> >>>>>>>> loader
> >>>>>>>> API.
> >>>>>>>>  
> >>>>>>> If i'm not mistaken, you are referring firmware loader API
> >>>>>>> in
> >>>>>>> this
> >>>>>>> link https://github.com/torvalds/linux/blob/f007cad159e99fa
> >>>>>>> 2acd
> >>>>>>> 3b2e
> >>>>>>> 9364
> >>>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
> >>>>>>>  
> >>>>> I would like to confirm with you whether we are talking to the
> >>>>> same
> >>>>> API
> >>>>> above?  
> >>>> https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.h
> >>>> tml
> >>>>
> >>>> first link on google btw . You might be able to avoid the
> >>>> firmware
> >>>> structure.
> >>>>  
> >>> After assessment, i found that Linux loader is not suitable for
> >>> fpga
> >>> loader as fpga loader need
> >>> 1) Able to program FPGA image in SPL chunk bu chunk with small
> >>> memory
> >>> allocatted.
> >>> 2) Name of FPGA image defined in DTS, and path of FPGA image in
> >>> FAT and
> >>> UBI partition.
> >>>
> >>> Linux loader is strongly designed based on Linux environment,
> >>> always
> >>> assume having RFF, env support(which SPL don't have), sysfs and
> >>> udev
> >>> feature.  
> >> Sigh, you can just have some additional function call to fetch
> >> smaller
> >> chunks from a file, I don't think it's that hard of a problem ...
> >>  
> > We already have that function to support smaller chunks, and it also
> > work for single large image when enough memory is available in ver 1
> > series of fpga loadfs.
> > 
> > Since the Linux loader API is totally not suitable for fpga loadfs,
> > and also nothing i can leverage from there for fpga loadfs, could
> > you please consider to accept implementation for this series
> > patches or implementation for fpga loadfs series ver1?  
> 
> You mean going back to completely custom non-generic altera-only
> ad-hoc interface ? I'd like to hear opinion of the others on CC ...
> 

I must admit that I don't know the exact Altera API for loading their
bitstream.

What I would like to have though is a some kind of generic code, which
would allow me to reuse it on other ARM + DSP SoCs.....

If we cannot re-use Linux stuff, then when we add something different
(more customer/industry aligned), please make it reusable for other
solutions (Xilinx, ADI, etc) - that would require a good documentation.

Those are my 2 cents.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Marek Vasut Nov. 9, 2017, 10:31 a.m. UTC | #12
On 11/09/2017 11:00 AM, Lukasz Majewski wrote:
> On Thu, 9 Nov 2017 08:05:18 +0100
> Marek Vasut <marex@denx.de> wrote:
> 
>> On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:
>>> On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  
>>>> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  
>>>>>
>>>>> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  
>>>>>>
>>>>>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  
>>>>>>>
>>>>>>>
>>>>>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:  
>>>>>>>>
>>>>>>>>
>>>>>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut wrote:  
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com wrote:  
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>>>>>>>
>>>>>>>>>>> Generic firmware loader framework contains some common
>>>>>>>>>>> functionality
>>>>>>>>>>> which is factored out from splash loader. It is
>>>>>>>>>>> reusable by
>>>>>>>>>>> any
>>>>>>>>>>> specific driver file system firmware loader. Specific
>>>>>>>>>>> driver
>>>>>>>>>>> file
>>>>>>>>>>> system
>>>>>>>>>>> firmware loader handling can be defined with both weak
>>>>>>>>>>> function
>>>>>>>>>>> fsloader_preprocess and fs_loading.
>>>>>>>>>>>
>>>>>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com  
>>>>>>>>>>>>  
>>>>>>>>>>> ---
>>>>>>>>>>>  common/Makefile   |   1 +
>>>>>>>>>>>  common/load_fs.c  | 217
>>>>>>>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>>>>>>>  3 files changed, 256 insertions(+)
>>>>>>>>>>>  create mode 100644 common/load_fs.c
>>>>>>>>>>>  create mode 100644 include/load_fs.h  
>>>>>>>>>> [...]
>>>>>>>>>>  
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> +int flash_select_fs_dev(struct flash_location
>>>>>>>>>>> *location)  
>>>>>>>>>> Why does everything have flash_ prefix ?
>>>>>>>>>>  
>>>>>>>>> I can remove the flash_ prefix, this generic FS loader
>>>>>>>>> should
>>>>>>>>> support
>>>>>>>>> for all filesystem instead of flash.
>>>>>>>>>  
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I also mentioned the API should copy the linux firmware
>>>>>>>>>> loader
>>>>>>>>>> API.
>>>>>>>>>>  
>>>>>>>>> If i'm not mistaken, you are referring firmware loader API
>>>>>>>>> in
>>>>>>>>> this
>>>>>>>>> link https://github.com/torvalds/linux/blob/f007cad159e99fa
>>>>>>>>> 2acd
>>>>>>>>> 3b2e
>>>>>>>>> 9364
>>>>>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
>>>>>>>>>  
>>>>>>> I would like to confirm with you whether we are talking to the
>>>>>>> same
>>>>>>> API
>>>>>>> above?  
>>>>>> https://www.kernel.org/doc/html/v4.13/driver-api/firmware/index.h
>>>>>> tml
>>>>>>
>>>>>> first link on google btw . You might be able to avoid the
>>>>>> firmware
>>>>>> structure.
>>>>>>  
>>>>> After assessment, i found that Linux loader is not suitable for
>>>>> fpga
>>>>> loader as fpga loader need
>>>>> 1) Able to program FPGA image in SPL chunk bu chunk with small
>>>>> memory
>>>>> allocatted.
>>>>> 2) Name of FPGA image defined in DTS, and path of FPGA image in
>>>>> FAT and
>>>>> UBI partition.
>>>>>
>>>>> Linux loader is strongly designed based on Linux environment,
>>>>> always
>>>>> assume having RFF, env support(which SPL don't have), sysfs and
>>>>> udev
>>>>> feature.  
>>>> Sigh, you can just have some additional function call to fetch
>>>> smaller
>>>> chunks from a file, I don't think it's that hard of a problem ...
>>>>  
>>> We already have that function to support smaller chunks, and it also
>>> work for single large image when enough memory is available in ver 1
>>> series of fpga loadfs.
>>>
>>> Since the Linux loader API is totally not suitable for fpga loadfs,
>>> and also nothing i can leverage from there for fpga loadfs, could
>>> you please consider to accept implementation for this series
>>> patches or implementation for fpga loadfs series ver1?  
>>
>> You mean going back to completely custom non-generic altera-only
>> ad-hoc interface ? I'd like to hear opinion of the others on CC ...
>>
> 
> I must admit that I don't know the exact Altera API for loading their
> bitstream.

That's irrelevant for a generic loader. The loader should provide a file
or ability to read chunks of file if needed, that's all. The consumer
driver would then use that API to program whatever, ie. the FPGA.

> What I would like to have though is a some kind of generic code, which
> would allow me to reuse it on other ARM + DSP SoCs.....

... on other platforms in general.

> If we cannot re-use Linux stuff, then when we add something different
> (more customer/industry aligned), please make it reusable for other
> solutions (Xilinx, ADI, etc) - that would require a good documentation.
And what is the problem with the Linux API ? I am not saying to reuse
the Linux code, but the API is quite well fleshed out.
Chee, Tien Fong Nov. 10, 2017, 9:05 a.m. UTC | #13
On Kha, 2017-11-09 at 11:31 +0100, Marek Vasut wrote:
> On 11/09/2017 11:00 AM, Lukasz Majewski wrote:

> > 

> > On Thu, 9 Nov 2017 08:05:18 +0100

> > Marek Vasut <marex@denx.de> wrote:

> > 

> > > 

> > > On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:

> > > > 

> > > > On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  

> > > > > 

> > > > > On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  

> > > > > > 

> > > > > > 

> > > > > > On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  

> > > > > > > 

> > > > > > > 

> > > > > > > On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:  

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut

> > > > > > > > > > wrote:  

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.com

> > > > > > > > > > > wrote:  

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > From: Tien Fong Chee <tien.fong.chee@intel.com>

> > > > > > > > > > > > 

> > > > > > > > > > > > Generic firmware loader framework contains some

> > > > > > > > > > > > common

> > > > > > > > > > > > functionality

> > > > > > > > > > > > which is factored out from splash loader. It is

> > > > > > > > > > > > reusable by

> > > > > > > > > > > > any

> > > > > > > > > > > > specific driver file system firmware loader.

> > > > > > > > > > > > Specific

> > > > > > > > > > > > driver

> > > > > > > > > > > > file

> > > > > > > > > > > > system

> > > > > > > > > > > > firmware loader handling can be defined with

> > > > > > > > > > > > both weak

> > > > > > > > > > > > function

> > > > > > > > > > > > fsloader_preprocess and fs_loading.

> > > > > > > > > > > > 

> > > > > > > > > > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@i

> > > > > > > > > > > > ntel.com  

> > > > > > > > > > > > > 

> > > > > > > > > > > > >  

> > > > > > > > > > > > ---

> > > > > > > > > > > >  common/Makefile   |   1 +

> > > > > > > > > > > >  common/load_fs.c  | 217

> > > > > > > > > > > > +++++++++++++++++++++++++++++++++++++++++++++++

> > > > > > > > > > > > +++++++

> > > > > > > > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > > > > > > > >  3 files changed, 256 insertions(+)

> > > > > > > > > > > >  create mode 100644 common/load_fs.c

> > > > > > > > > > > >  create mode 100644 include/load_fs.h  

> > > > > > > > > > > [...]

> > > > > > > > > > >  

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > +int flash_select_fs_dev(struct flash_location

> > > > > > > > > > > > *location)  

> > > > > > > > > > > Why does everything have flash_ prefix ?

> > > > > > > > > > >  

> > > > > > > > > > I can remove the flash_ prefix, this generic FS

> > > > > > > > > > loader

> > > > > > > > > > should

> > > > > > > > > > support

> > > > > > > > > > for all filesystem instead of flash.

> > > > > > > > > >  

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > I also mentioned the API should copy the linux

> > > > > > > > > > > firmware

> > > > > > > > > > > loader

> > > > > > > > > > > API.

> > > > > > > > > > >  

> > > > > > > > > > If i'm not mistaken, you are referring firmware

> > > > > > > > > > loader API

> > > > > > > > > > in

> > > > > > > > > > this

> > > > > > > > > > link https://github.com/torvalds/linux/blob/f007cad

> > > > > > > > > > 159e99fa

> > > > > > > > > > 2acd

> > > > > > > > > > 3b2e

> > > > > > > > > > 9364

> > > > > > > > > > fbb32ad28b971/drivers/base/firmware_class.c#L1264.

> > > > > > > > > >  

> > > > > > > > I would like to confirm with you whether we are talking

> > > > > > > > to the

> > > > > > > > same

> > > > > > > > API

> > > > > > > > above?  

> > > > > > > https://www.kernel.org/doc/html/v4.13/driver-api/firmware

> > > > > > > /index.h

> > > > > > > tml

> > > > > > > 

> > > > > > > first link on google btw . You might be able to avoid the

> > > > > > > firmware

> > > > > > > structure.

> > > > > > >  

> > > > > > After assessment, i found that Linux loader is not suitable

> > > > > > for

> > > > > > fpga

> > > > > > loader as fpga loader need

> > > > > > 1) Able to program FPGA image in SPL chunk bu chunk with

> > > > > > small

> > > > > > memory

> > > > > > allocatted.

> > > > > > 2) Name of FPGA image defined in DTS, and path of FPGA

> > > > > > image in

> > > > > > FAT and

> > > > > > UBI partition.

> > > > > > 

> > > > > > Linux loader is strongly designed based on Linux

> > > > > > environment,

> > > > > > always

> > > > > > assume having RFF, env support(which SPL don't have), sysfs

> > > > > > and

> > > > > > udev

> > > > > > feature.  

> > > > > Sigh, you can just have some additional function call to

> > > > > fetch

> > > > > smaller

> > > > > chunks from a file, I don't think it's that hard of a problem

> > > > > ...

> > > > >  

> > > > We already have that function to support smaller chunks, and it

> > > > also

> > > > work for single large image when enough memory is available in

> > > > ver 1

> > > > series of fpga loadfs.

> > > > 

> > > > Since the Linux loader API is totally not suitable for fpga

> > > > loadfs,

> > > > and also nothing i can leverage from there for fpga loadfs,

> > > > could

> > > > you please consider to accept implementation for this series

> > > > patches or implementation for fpga loadfs series ver1?  

> > > You mean going back to completely custom non-generic altera-only

> > > ad-hoc interface ? I'd like to hear opinion of the others on CC

> > > ...

> > > 

> > I must admit that I don't know the exact Altera API for loading

> > their

> > bitstream.

> That's irrelevant for a generic loader. The loader should provide a

> file

> or ability to read chunks of file if needed, that's all. The consumer

> driver would then use that API to program whatever, ie. the FPGA.

> 

> > 

> > What I would like to have though is a some kind of generic code,

> > which

> > would allow me to reuse it on other ARM + DSP SoCs.....

> ... on other platforms in general.

> 

> > 

> > If we cannot re-use Linux stuff, then when we add something

> > different

> > (more customer/industry aligned), please make it reusable for other

> > solutions (Xilinx, ADI, etc) - that would require a good

> > documentation.

> And what is the problem with the Linux API ? I am not saying to reuse

> the Linux code, but the API is quite well fleshed out.

> 

I found there is one function called "request_firmware_into_buf" from
Linux firmware loader API which can be used for reading a file, or
ability to read chunks of file.

So, how about we just go ahead with this function implemented in U-
Boot?

Thanks.
Marek Vasut Nov. 10, 2017, 10:04 a.m. UTC | #14
On 11/10/2017 10:05 AM, Chee, Tien Fong wrote:
> On Kha, 2017-11-09 at 11:31 +0100, Marek Vasut wrote:
>> On 11/09/2017 11:00 AM, Lukasz Majewski wrote:
>>>
>>> On Thu, 9 Nov 2017 08:05:18 +0100
>>> Marek Vasut <marex@denx.de> wrote:
>>>
>>>>
>>>> On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:
>>>>>
>>>>> On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  
>>>>>>
>>>>>> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  
>>>>>>>
>>>>>>>
>>>>>>> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  
>>>>>>>>
>>>>>>>>
>>>>>>>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut wrote:  
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut
>>>>>>>>>>> wrote:  
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.com
>>>>>>>>>>>> wrote:  
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.com>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Generic firmware loader framework contains some
>>>>>>>>>>>>> common
>>>>>>>>>>>>> functionality
>>>>>>>>>>>>> which is factored out from splash loader. It is
>>>>>>>>>>>>> reusable by
>>>>>>>>>>>>> any
>>>>>>>>>>>>> specific driver file system firmware loader.
>>>>>>>>>>>>> Specific
>>>>>>>>>>>>> driver
>>>>>>>>>>>>> file
>>>>>>>>>>>>> system
>>>>>>>>>>>>> firmware loader handling can be defined with
>>>>>>>>>>>>> both weak
>>>>>>>>>>>>> function
>>>>>>>>>>>>> fsloader_preprocess and fs_loading.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.chee@i
>>>>>>>>>>>>> ntel.com  
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  
>>>>>>>>>>>>> ---
>>>>>>>>>>>>>  common/Makefile   |   1 +
>>>>>>>>>>>>>  common/load_fs.c  | 217
>>>>>>>>>>>>> +++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>>>>> +++++++
>>>>>>>>>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>>>>>>>>>  3 files changed, 256 insertions(+)
>>>>>>>>>>>>>  create mode 100644 common/load_fs.c
>>>>>>>>>>>>>  create mode 100644 include/load_fs.h  
>>>>>>>>>>>> [...]
>>>>>>>>>>>>  
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> +int flash_select_fs_dev(struct flash_location
>>>>>>>>>>>>> *location)  
>>>>>>>>>>>> Why does everything have flash_ prefix ?
>>>>>>>>>>>>  
>>>>>>>>>>> I can remove the flash_ prefix, this generic FS
>>>>>>>>>>> loader
>>>>>>>>>>> should
>>>>>>>>>>> support
>>>>>>>>>>> for all filesystem instead of flash.
>>>>>>>>>>>  
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I also mentioned the API should copy the linux
>>>>>>>>>>>> firmware
>>>>>>>>>>>> loader
>>>>>>>>>>>> API.
>>>>>>>>>>>>  
>>>>>>>>>>> If i'm not mistaken, you are referring firmware
>>>>>>>>>>> loader API
>>>>>>>>>>> in
>>>>>>>>>>> this
>>>>>>>>>>> link https://github.com/torvalds/linux/blob/f007cad
>>>>>>>>>>> 159e99fa
>>>>>>>>>>> 2acd
>>>>>>>>>>> 3b2e
>>>>>>>>>>> 9364
>>>>>>>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L1264.
>>>>>>>>>>>  
>>>>>>>>> I would like to confirm with you whether we are talking
>>>>>>>>> to the
>>>>>>>>> same
>>>>>>>>> API
>>>>>>>>> above?  
>>>>>>>> https://www.kernel.org/doc/html/v4.13/driver-api/firmware
>>>>>>>> /index.h
>>>>>>>> tml
>>>>>>>>
>>>>>>>> first link on google btw . You might be able to avoid the
>>>>>>>> firmware
>>>>>>>> structure.
>>>>>>>>  
>>>>>>> After assessment, i found that Linux loader is not suitable
>>>>>>> for
>>>>>>> fpga
>>>>>>> loader as fpga loader need
>>>>>>> 1) Able to program FPGA image in SPL chunk bu chunk with
>>>>>>> small
>>>>>>> memory
>>>>>>> allocatted.
>>>>>>> 2) Name of FPGA image defined in DTS, and path of FPGA
>>>>>>> image in
>>>>>>> FAT and
>>>>>>> UBI partition.
>>>>>>>
>>>>>>> Linux loader is strongly designed based on Linux
>>>>>>> environment,
>>>>>>> always
>>>>>>> assume having RFF, env support(which SPL don't have), sysfs
>>>>>>> and
>>>>>>> udev
>>>>>>> feature.  
>>>>>> Sigh, you can just have some additional function call to
>>>>>> fetch
>>>>>> smaller
>>>>>> chunks from a file, I don't think it's that hard of a problem
>>>>>> ...
>>>>>>  
>>>>> We already have that function to support smaller chunks, and it
>>>>> also
>>>>> work for single large image when enough memory is available in
>>>>> ver 1
>>>>> series of fpga loadfs.
>>>>>
>>>>> Since the Linux loader API is totally not suitable for fpga
>>>>> loadfs,
>>>>> and also nothing i can leverage from there for fpga loadfs,
>>>>> could
>>>>> you please consider to accept implementation for this series
>>>>> patches or implementation for fpga loadfs series ver1?  
>>>> You mean going back to completely custom non-generic altera-only
>>>> ad-hoc interface ? I'd like to hear opinion of the others on CC
>>>> ...
>>>>
>>> I must admit that I don't know the exact Altera API for loading
>>> their
>>> bitstream.
>> That's irrelevant for a generic loader. The loader should provide a
>> file
>> or ability to read chunks of file if needed, that's all. The consumer
>> driver would then use that API to program whatever, ie. the FPGA.
>>
>>>
>>> What I would like to have though is a some kind of generic code,
>>> which
>>> would allow me to reuse it on other ARM + DSP SoCs.....
>> ... on other platforms in general.
>>
>>>
>>> If we cannot re-use Linux stuff, then when we add something
>>> different
>>> (more customer/industry aligned), please make it reusable for other
>>> solutions (Xilinx, ADI, etc) - that would require a good
>>> documentation.
>> And what is the problem with the Linux API ? I am not saying to reuse
>> the Linux code, but the API is quite well fleshed out.
>>
> I found there is one function called "request_firmware_into_buf" from
> Linux firmware loader API which can be used for reading a file, or
> ability to read chunks of file.
> 
> So, how about we just go ahead with this function implemented in U-
> Boot?

You can also have request_firmware_chunk() function, since
request_firmware_into_buf() doesn't have offset. That's fine.
Chee, Tien Fong Nov. 13, 2017, 4:31 a.m. UTC | #15
On Jum, 2017-11-10 at 11:04 +0100, Marek Vasut wrote:
> On 11/10/2017 10:05 AM, Chee, Tien Fong wrote:

> > 

> > On Kha, 2017-11-09 at 11:31 +0100, Marek Vasut wrote:

> > > 

> > > On 11/09/2017 11:00 AM, Lukasz Majewski wrote:

> > > > 

> > > > 

> > > > On Thu, 9 Nov 2017 08:05:18 +0100

> > > > Marek Vasut <marex@denx.de> wrote:

> > > > 

> > > > > 

> > > > > 

> > > > > On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:

> > > > > > 

> > > > > > 

> > > > > > On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  

> > > > > > > 

> > > > > > > 

> > > > > > > On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut

> > > > > > > > > > wrote:  

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut

> > > > > > > > > > > > wrote:  

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.

> > > > > > > > > > > > > com

> > > > > > > > > > > > > wrote:  

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > From: Tien Fong Chee <tien.fong.chee@intel.

> > > > > > > > > > > > > > com>

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > Generic firmware loader framework contains

> > > > > > > > > > > > > > some

> > > > > > > > > > > > > > common

> > > > > > > > > > > > > > functionality

> > > > > > > > > > > > > > which is factored out from splash loader.

> > > > > > > > > > > > > > It is

> > > > > > > > > > > > > > reusable by

> > > > > > > > > > > > > > any

> > > > > > > > > > > > > > specific driver file system firmware

> > > > > > > > > > > > > > loader.

> > > > > > > > > > > > > > Specific

> > > > > > > > > > > > > > driver

> > > > > > > > > > > > > > file

> > > > > > > > > > > > > > system

> > > > > > > > > > > > > > firmware loader handling can be defined

> > > > > > > > > > > > > > with

> > > > > > > > > > > > > > both weak

> > > > > > > > > > > > > > function

> > > > > > > > > > > > > > fsloader_preprocess and fs_loading.

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > Signed-off-by: Tien Fong Chee <tien.fong.ch

> > > > > > > > > > > > > > ee@i

> > > > > > > > > > > > > > ntel.com  

> > > > > > > > > > > > > > > 

> > > > > > > > > > > > > > > 

> > > > > > > > > > > > > > >  

> > > > > > > > > > > > > > ---

> > > > > > > > > > > > > >  common/Makefile   |   1 +

> > > > > > > > > > > > > >  common/load_fs.c  | 217

> > > > > > > > > > > > > > +++++++++++++++++++++++++++++++++++++++++++

> > > > > > > > > > > > > > ++++

> > > > > > > > > > > > > > +++++++

> > > > > > > > > > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > > > > > > > > > >  3 files changed, 256 insertions(+)

> > > > > > > > > > > > > >  create mode 100644 common/load_fs.c

> > > > > > > > > > > > > >  create mode 100644 include/load_fs.h  

> > > > > > > > > > > > > [...]

> > > > > > > > > > > > >  

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > +int flash_select_fs_dev(struct

> > > > > > > > > > > > > > flash_location

> > > > > > > > > > > > > > *location)  

> > > > > > > > > > > > > Why does everything have flash_ prefix ?

> > > > > > > > > > > > >  

> > > > > > > > > > > > I can remove the flash_ prefix, this generic FS

> > > > > > > > > > > > loader

> > > > > > > > > > > > should

> > > > > > > > > > > > support

> > > > > > > > > > > > for all filesystem instead of flash.

> > > > > > > > > > > >  

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > I also mentioned the API should copy the

> > > > > > > > > > > > > linux

> > > > > > > > > > > > > firmware

> > > > > > > > > > > > > loader

> > > > > > > > > > > > > API.

> > > > > > > > > > > > >  

> > > > > > > > > > > > If i'm not mistaken, you are referring firmware

> > > > > > > > > > > > loader API

> > > > > > > > > > > > in

> > > > > > > > > > > > this

> > > > > > > > > > > > link https://github.com/torvalds/linux/blob/f00

> > > > > > > > > > > > 7cad

> > > > > > > > > > > > 159e99fa

> > > > > > > > > > > > 2acd

> > > > > > > > > > > > 3b2e

> > > > > > > > > > > > 9364

> > > > > > > > > > > > fbb32ad28b971/drivers/base/firmware_class.c#L12

> > > > > > > > > > > > 64.

> > > > > > > > > > > >  

> > > > > > > > > > I would like to confirm with you whether we are

> > > > > > > > > > talking

> > > > > > > > > > to the

> > > > > > > > > > same

> > > > > > > > > > API

> > > > > > > > > > above?  

> > > > > > > > > https://www.kernel.org/doc/html/v4.13/driver-api/firm

> > > > > > > > > ware

> > > > > > > > > /index.h

> > > > > > > > > tml

> > > > > > > > > 

> > > > > > > > > first link on google btw . You might be able to avoid

> > > > > > > > > the

> > > > > > > > > firmware

> > > > > > > > > structure.

> > > > > > > > >  

> > > > > > > > After assessment, i found that Linux loader is not

> > > > > > > > suitable

> > > > > > > > for

> > > > > > > > fpga

> > > > > > > > loader as fpga loader need

> > > > > > > > 1) Able to program FPGA image in SPL chunk bu chunk

> > > > > > > > with

> > > > > > > > small

> > > > > > > > memory

> > > > > > > > allocatted.

> > > > > > > > 2) Name of FPGA image defined in DTS, and path of FPGA

> > > > > > > > image in

> > > > > > > > FAT and

> > > > > > > > UBI partition.

> > > > > > > > 

> > > > > > > > Linux loader is strongly designed based on Linux

> > > > > > > > environment,

> > > > > > > > always

> > > > > > > > assume having RFF, env support(which SPL don't have),

> > > > > > > > sysfs

> > > > > > > > and

> > > > > > > > udev

> > > > > > > > feature.  

> > > > > > > Sigh, you can just have some additional function call to

> > > > > > > fetch

> > > > > > > smaller

> > > > > > > chunks from a file, I don't think it's that hard of a

> > > > > > > problem

> > > > > > > ...

> > > > > > >  

> > > > > > We already have that function to support smaller chunks,

> > > > > > and it

> > > > > > also

> > > > > > work for single large image when enough memory is available

> > > > > > in

> > > > > > ver 1

> > > > > > series of fpga loadfs.

> > > > > > 

> > > > > > Since the Linux loader API is totally not suitable for fpga

> > > > > > loadfs,

> > > > > > and also nothing i can leverage from there for fpga loadfs,

> > > > > > could

> > > > > > you please consider to accept implementation for this

> > > > > > series

> > > > > > patches or implementation for fpga loadfs series ver1?  

> > > > > You mean going back to completely custom non-generic altera-

> > > > > only

> > > > > ad-hoc interface ? I'd like to hear opinion of the others on

> > > > > CC

> > > > > ...

> > > > > 

> > > > I must admit that I don't know the exact Altera API for loading

> > > > their

> > > > bitstream.

> > > That's irrelevant for a generic loader. The loader should provide

> > > a

> > > file

> > > or ability to read chunks of file if needed, that's all. The

> > > consumer

> > > driver would then use that API to program whatever, ie. the FPGA.

> > > 

> > > > 

> > > > 

> > > > What I would like to have though is a some kind of generic

> > > > code,

> > > > which

> > > > would allow me to reuse it on other ARM + DSP SoCs.....

> > > ... on other platforms in general.

> > > 

> > > > 

> > > > 

> > > > If we cannot re-use Linux stuff, then when we add something

> > > > different

> > > > (more customer/industry aligned), please make it reusable for

> > > > other

> > > > solutions (Xilinx, ADI, etc) - that would require a good

> > > > documentation.

> > > And what is the problem with the Linux API ? I am not saying to

> > > reuse

> > > the Linux code, but the API is quite well fleshed out.

> > > 

> > I found there is one function called "request_firmware_into_buf"

> > from

> > Linux firmware loader API which can be used for reading a file, or

> > ability to read chunks of file.

> > 

> > So, how about we just go ahead with this function implemented in U-

> > Boot?

> You can also have request_firmware_chunk() function, since

> request_firmware_into_buf() doesn't have offset. That's fine.

> 

Okay.
Chee, Tien Fong Nov. 16, 2017, 8:09 a.m. UTC | #16
On Jum, 2017-11-10 at 11:04 +0100, Marek Vasut wrote:
> On 11/10/2017 10:05 AM, Chee, Tien Fong wrote:

> > 

> > On Kha, 2017-11-09 at 11:31 +0100, Marek Vasut wrote:

> > > 

> > > On 11/09/2017 11:00 AM, Lukasz Majewski wrote:

> > > > 

> > > > 

> > > > On Thu, 9 Nov 2017 08:05:18 +0100

> > > > Marek Vasut <marex@denx.de> wrote:

> > > > 

> > > > > 

> > > > > 

> > > > > On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:

> > > > > > 

> > > > > > 

> > > > > > On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  

> > > > > > > 

> > > > > > > 

> > > > > > > On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  

> > > > > > > > 

> > > > > > > > 

> > > > > > > > 

> > > > > > > > On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > 

> > > > > > > > > On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > 

> > > > > > > > > > On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut

> > > > > > > > > > wrote:  

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > 

> > > > > > > > > > > On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > 

> > > > > > > > > > > > On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut

> > > > > > > > > > > > wrote:  

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > On 11/01/2017 10:18 AM, tien.fong.chee@intel.

> > > > > > > > > > > > > com

> > > > > > > > > > > > > wrote:  

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > From: Tien Fong Chee <tien.fong.chee@intel.

> > > > > > > > > > > > > > com>

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > Generic firmware loader framework contains

> > > > > > > > > > > > > > some

> > > > > > > > > > > > > > common

> > > > > > > > > > > > > > functionality

> > > > > > > > > > > > > > which is factored out from splash loader.

> > > > > > > > > > > > > > It is

> > > > > > > > > > > > > > reusable by

> > > > > > > > > > > > > > any

> > > > > > > > > > > > > > specific driver file system firmware

> > > > > > > > > > > > > > loader.

> > > > > > > > > > > > > > Specific

> > > > > > > > > > > > > > driver

> > > > > > > > > > > > > > file

> > > > > > > > > > > > > > system

> > > > > > > > > > > > > > firmware loader handling can be defined

> > > > > > > > > > > > > > with

> > > > > > > > > > > > > > both weak

> > > > > > > > > > > > > > function

> > > > > > > > > > > > > > fsloader_preprocess and fs_loading.

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > Signed-off-by: Tien Fong Chee <tien.fong.ch

> > > > > > > > > > > > > > ee@i

> > > > > > > > > > > > > > ntel.com  

> > > > > > > > > > > > > > > 

> > > > > > > > > > > > > > > 

> > > > > > > > > > > > > > >  

> > > > > > > > > > > > > > ---

> > > > > > > > > > > > > >  common/Makefile   |   1 +

> > > > > > > > > > > > > >  common/load_fs.c  | 217

> > > > > > > > > > > > > > +++++++++++++++++++++++++++++++++++++++++++

> > > > > > > > > > > > > > ++++

> > > > > > > > > > > > > > +++++++

> > > > > > > > > > > > > >  include/load_fs.h |  38 ++++++++++

> > > > > > > > > > > > > >  3 files changed, 256 insertions(+)

> > > > > > > > > > > > > >  create mode 100644 common/load_fs.c

> > > > > > > > > > > > > >  create mode 100644 include/load_fs.h  

> > > > > > > > > > > > > [...]

> > > > > > > > > > > > >  

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > 

> > > > > > > > > > > > > > +int flash_select_fs_dev(struct

> > > > > > > > > > > > > > flash_location

> > > > > > > > > > > > > > *location)  

> > > > > > > > > > > > > Why does everything have flash_ prefix ?

> > > > > > > > > > > > >  

> > > > > > > > > > > > I can remove the flash_ prefix, this generic FS

> > > > > > > > > > > > loader

> > > > > > > > > > > > should

> > > > > > > > > > > > support

> > > > > > > > > > > > for all filesystem instead of flash.

> > > > > > > > > > > >  

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > 

> > > > > > > > > > > > > I also mentioned the API should copy the

> > > > > > > > > > > > > linux

> > > > > > > > > > > > > firmware

> > > > > > > > > > > > > loader

> > > > > > > > > > > > > API.

> > > > > > > > > > > > >  

> > > > > > > > > > > > If i'm not mistaken, you are referring firmware

> > > > > > > > > > > > loader API

> > > > > > > > > > > > in

> > > > > > > > > > > > this

> > > > > > > > > > > > link https://github.com/torvalds/linux/blob/f00

> > > > > > > > > > > > 7cad

> > > > > > > > > > > > 159e99fa

> > > > > > > > > > > > 2acd

> > > > > > > > > > > > 3b2e

> > > > > > > > > > > > 9364

> > > > > > > > > > > > fbb32ad28b971/drivers/base/firmware_class.c#L12

> > > > > > > > > > > > 64.

> > > > > > > > > > > >  

> > > > > > > > > > I would like to confirm with you whether we are

> > > > > > > > > > talking

> > > > > > > > > > to the

> > > > > > > > > > same

> > > > > > > > > > API

> > > > > > > > > > above?  

> > > > > > > > > https://www.kernel.org/doc/html/v4.13/driver-api/firm

> > > > > > > > > ware

> > > > > > > > > /index.h

> > > > > > > > > tml

> > > > > > > > > 

> > > > > > > > > first link on google btw . You might be able to avoid

> > > > > > > > > the

> > > > > > > > > firmware

> > > > > > > > > structure.

> > > > > > > > >  

> > > > > > > > After assessment, i found that Linux loader is not

> > > > > > > > suitable

> > > > > > > > for

> > > > > > > > fpga

> > > > > > > > loader as fpga loader need

> > > > > > > > 1) Able to program FPGA image in SPL chunk bu chunk

> > > > > > > > with

> > > > > > > > small

> > > > > > > > memory

> > > > > > > > allocatted.

> > > > > > > > 2) Name of FPGA image defined in DTS, and path of FPGA

> > > > > > > > image in

> > > > > > > > FAT and

> > > > > > > > UBI partition.

> > > > > > > > 

> > > > > > > > Linux loader is strongly designed based on Linux

> > > > > > > > environment,

> > > > > > > > always

> > > > > > > > assume having RFF, env support(which SPL don't have),

> > > > > > > > sysfs

> > > > > > > > and

> > > > > > > > udev

> > > > > > > > feature.  

> > > > > > > Sigh, you can just have some additional function call to

> > > > > > > fetch

> > > > > > > smaller

> > > > > > > chunks from a file, I don't think it's that hard of a

> > > > > > > problem

> > > > > > > ...

> > > > > > >  

> > > > > > We already have that function to support smaller chunks,

> > > > > > and it

> > > > > > also

> > > > > > work for single large image when enough memory is available

> > > > > > in

> > > > > > ver 1

> > > > > > series of fpga loadfs.

> > > > > > 

> > > > > > Since the Linux loader API is totally not suitable for fpga

> > > > > > loadfs,

> > > > > > and also nothing i can leverage from there for fpga loadfs,

> > > > > > could

> > > > > > you please consider to accept implementation for this

> > > > > > series

> > > > > > patches or implementation for fpga loadfs series ver1?  

> > > > > You mean going back to completely custom non-generic altera-

> > > > > only

> > > > > ad-hoc interface ? I'd like to hear opinion of the others on

> > > > > CC

> > > > > ...

> > > > > 

> > > > I must admit that I don't know the exact Altera API for loading

> > > > their

> > > > bitstream.

> > > That's irrelevant for a generic loader. The loader should provide

> > > a

> > > file

> > > or ability to read chunks of file if needed, that's all. The

> > > consumer

> > > driver would then use that API to program whatever, ie. the FPGA.

> > > 

> > > > 

> > > > 

> > > > What I would like to have though is a some kind of generic

> > > > code,

> > > > which

> > > > would allow me to reuse it on other ARM + DSP SoCs.....

> > > ... on other platforms in general.

> > > 

> > > > 

> > > > 

> > > > If we cannot re-use Linux stuff, then when we add something

> > > > different

> > > > (more customer/industry aligned), please make it reusable for

> > > > other

> > > > solutions (Xilinx, ADI, etc) - that would require a good

> > > > documentation.

> > > And what is the problem with the Linux API ? I am not saying to

> > > reuse

> > > the Linux code, but the API is quite well fleshed out.

> > > 

> > I found there is one function called "request_firmware_into_buf"

> > from

> > Linux firmware loader API which can be used for reading a file, or

> > ability to read chunks of file.

> > 

> > So, how about we just go ahead with this function implemented in U-

> > Boot?

> You can also have request_firmware_chunk() function, since

> request_firmware_into_buf() doesn't have offset. That's fine.

> 

I think we can having same function request_firmware_into_buf for chunk
reading, because i can add the offset into firmware structure so the
last write location can be stored into offset. Since we know the size
of the buffer, so we can do the calculation outside of the function and
repetitive calling the function with the return offset until whole file
is read. What do you think?

Thanks.
Marek Vasut Nov. 16, 2017, 8:11 a.m. UTC | #17
On 11/16/2017 09:09 AM, Chee, Tien Fong wrote:
> On Jum, 2017-11-10 at 11:04 +0100, Marek Vasut wrote:
>> On 11/10/2017 10:05 AM, Chee, Tien Fong wrote:
>>>
>>> On Kha, 2017-11-09 at 11:31 +0100, Marek Vasut wrote:
>>>>
>>>> On 11/09/2017 11:00 AM, Lukasz Majewski wrote:
>>>>>
>>>>>
>>>>> On Thu, 9 Nov 2017 08:05:18 +0100
>>>>> Marek Vasut <marex@denx.de> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On 11/09/2017 07:04 AM, Chee, Tien Fong wrote:
>>>>>>>
>>>>>>>
>>>>>>> On Sel, 2017-11-07 at 10:34 +0100, Marek Vasut wrote:  
>>>>>>>>
>>>>>>>>
>>>>>>>> On 11/07/2017 10:03 AM, Chee, Tien Fong wrote:  
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Isn, 2017-11-06 at 11:56 +0100, Marek Vasut wrote:  
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 11/06/2017 05:15 AM, Chee, Tien Fong wrote:  
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Ahd, 2017-11-05 at 17:43 +0100, Marek Vasut
>>>>>>>>>>> wrote:  
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 11/02/2017 09:20 AM, Chee, Tien Fong wrote:  
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Rab, 2017-11-01 at 10:26 +0100, Marek Vasut
>>>>>>>>>>>>> wrote:  
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On 11/01/2017 10:18 AM, tien.fong.chee@intel.
>>>>>>>>>>>>>> com
>>>>>>>>>>>>>> wrote:  
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> From: Tien Fong Chee <tien.fong.chee@intel.
>>>>>>>>>>>>>>> com>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Generic firmware loader framework contains
>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>> common
>>>>>>>>>>>>>>> functionality
>>>>>>>>>>>>>>> which is factored out from splash loader.
>>>>>>>>>>>>>>> It is
>>>>>>>>>>>>>>> reusable by
>>>>>>>>>>>>>>> any
>>>>>>>>>>>>>>> specific driver file system firmware
>>>>>>>>>>>>>>> loader.
>>>>>>>>>>>>>>> Specific
>>>>>>>>>>>>>>> driver
>>>>>>>>>>>>>>> file
>>>>>>>>>>>>>>> system
>>>>>>>>>>>>>>> firmware loader handling can be defined
>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>> both weak
>>>>>>>>>>>>>>> function
>>>>>>>>>>>>>>> fsloader_preprocess and fs_loading.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Signed-off-by: Tien Fong Chee <tien.fong.ch
>>>>>>>>>>>>>>> ee@i
>>>>>>>>>>>>>>> ntel.com  
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  
>>>>>>>>>>>>>>> ---
>>>>>>>>>>>>>>>  common/Makefile   |   1 +
>>>>>>>>>>>>>>>  common/load_fs.c  | 217
>>>>>>>>>>>>>>> +++++++++++++++++++++++++++++++++++++++++++
>>>>>>>>>>>>>>> ++++
>>>>>>>>>>>>>>> +++++++
>>>>>>>>>>>>>>>  include/load_fs.h |  38 ++++++++++
>>>>>>>>>>>>>>>  3 files changed, 256 insertions(+)
>>>>>>>>>>>>>>>  create mode 100644 common/load_fs.c
>>>>>>>>>>>>>>>  create mode 100644 include/load_fs.h  
>>>>>>>>>>>>>> [...]
>>>>>>>>>>>>>>  
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> +int flash_select_fs_dev(struct
>>>>>>>>>>>>>>> flash_location
>>>>>>>>>>>>>>> *location)  
>>>>>>>>>>>>>> Why does everything have flash_ prefix ?
>>>>>>>>>>>>>>  
>>>>>>>>>>>>> I can remove the flash_ prefix, this generic FS
>>>>>>>>>>>>> loader
>>>>>>>>>>>>> should
>>>>>>>>>>>>> support
>>>>>>>>>>>>> for all filesystem instead of flash.
>>>>>>>>>>>>>  
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I also mentioned the API should copy the
>>>>>>>>>>>>>> linux
>>>>>>>>>>>>>> firmware
>>>>>>>>>>>>>> loader
>>>>>>>>>>>>>> API.
>>>>>>>>>>>>>>  
>>>>>>>>>>>>> If i'm not mistaken, you are referring firmware
>>>>>>>>>>>>> loader API
>>>>>>>>>>>>> in
>>>>>>>>>>>>> this
>>>>>>>>>>>>> link https://github.com/torvalds/linux/blob/f00
>>>>>>>>>>>>> 7cad
>>>>>>>>>>>>> 159e99fa
>>>>>>>>>>>>> 2acd
>>>>>>>>>>>>> 3b2e
>>>>>>>>>>>>> 9364
>>>>>>>>>>>>> fbb32ad28b971/drivers/base/firmware_class.c#L12
>>>>>>>>>>>>> 64.
>>>>>>>>>>>>>  
>>>>>>>>>>> I would like to confirm with you whether we are
>>>>>>>>>>> talking
>>>>>>>>>>> to the
>>>>>>>>>>> same
>>>>>>>>>>> API
>>>>>>>>>>> above?  
>>>>>>>>>> https://www.kernel.org/doc/html/v4.13/driver-api/firm
>>>>>>>>>> ware
>>>>>>>>>> /index.h
>>>>>>>>>> tml
>>>>>>>>>>
>>>>>>>>>> first link on google btw . You might be able to avoid
>>>>>>>>>> the
>>>>>>>>>> firmware
>>>>>>>>>> structure.
>>>>>>>>>>  
>>>>>>>>> After assessment, i found that Linux loader is not
>>>>>>>>> suitable
>>>>>>>>> for
>>>>>>>>> fpga
>>>>>>>>> loader as fpga loader need
>>>>>>>>> 1) Able to program FPGA image in SPL chunk bu chunk
>>>>>>>>> with
>>>>>>>>> small
>>>>>>>>> memory
>>>>>>>>> allocatted.
>>>>>>>>> 2) Name of FPGA image defined in DTS, and path of FPGA
>>>>>>>>> image in
>>>>>>>>> FAT and
>>>>>>>>> UBI partition.
>>>>>>>>>
>>>>>>>>> Linux loader is strongly designed based on Linux
>>>>>>>>> environment,
>>>>>>>>> always
>>>>>>>>> assume having RFF, env support(which SPL don't have),
>>>>>>>>> sysfs
>>>>>>>>> and
>>>>>>>>> udev
>>>>>>>>> feature.  
>>>>>>>> Sigh, you can just have some additional function call to
>>>>>>>> fetch
>>>>>>>> smaller
>>>>>>>> chunks from a file, I don't think it's that hard of a
>>>>>>>> problem
>>>>>>>> ...
>>>>>>>>  
>>>>>>> We already have that function to support smaller chunks,
>>>>>>> and it
>>>>>>> also
>>>>>>> work for single large image when enough memory is available
>>>>>>> in
>>>>>>> ver 1
>>>>>>> series of fpga loadfs.
>>>>>>>
>>>>>>> Since the Linux loader API is totally not suitable for fpga
>>>>>>> loadfs,
>>>>>>> and also nothing i can leverage from there for fpga loadfs,
>>>>>>> could
>>>>>>> you please consider to accept implementation for this
>>>>>>> series
>>>>>>> patches or implementation for fpga loadfs series ver1?  
>>>>>> You mean going back to completely custom non-generic altera-
>>>>>> only
>>>>>> ad-hoc interface ? I'd like to hear opinion of the others on
>>>>>> CC
>>>>>> ...
>>>>>>
>>>>> I must admit that I don't know the exact Altera API for loading
>>>>> their
>>>>> bitstream.
>>>> That's irrelevant for a generic loader. The loader should provide
>>>> a
>>>> file
>>>> or ability to read chunks of file if needed, that's all. The
>>>> consumer
>>>> driver would then use that API to program whatever, ie. the FPGA.
>>>>
>>>>>
>>>>>
>>>>> What I would like to have though is a some kind of generic
>>>>> code,
>>>>> which
>>>>> would allow me to reuse it on other ARM + DSP SoCs.....
>>>> ... on other platforms in general.
>>>>
>>>>>
>>>>>
>>>>> If we cannot re-use Linux stuff, then when we add something
>>>>> different
>>>>> (more customer/industry aligned), please make it reusable for
>>>>> other
>>>>> solutions (Xilinx, ADI, etc) - that would require a good
>>>>> documentation.
>>>> And what is the problem with the Linux API ? I am not saying to
>>>> reuse
>>>> the Linux code, but the API is quite well fleshed out.
>>>>
>>> I found there is one function called "request_firmware_into_buf"
>>> from
>>> Linux firmware loader API which can be used for reading a file, or
>>> ability to read chunks of file.
>>>
>>> So, how about we just go ahead with this function implemented in U-
>>> Boot?
>> You can also have request_firmware_chunk() function, since
>> request_firmware_into_buf() doesn't have offset. That's fine.
>>
> I think we can having same function request_firmware_into_buf for chunk
> reading, because i can add the offset into firmware structure so the
> last write location can be stored into offset. Since we know the size
> of the buffer, so we can do the calculation outside of the function and
> repetitive calling the function with the return offset until whole file
> is read. What do you think?

Something like that.

> Thanks.
>
diff mbox series

Patch

diff --git a/common/Makefile b/common/Makefile
index 801ea31..89f9365 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -130,3 +130,4 @@  obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
+obj-y += load_fs.o
diff --git a/common/load_fs.c b/common/load_fs.c
new file mode 100644
index 0000000..112b4f6
--- /dev/null
+++ b/common/load_fs.c
@@ -0,0 +1,217 @@ 
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <load_fs.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <usb.h>
+
+int flash_select_fs_dev(struct flash_location *location)
+{
+	int res;
+
+	switch (location->storage) {
+	case FLASH_STORAGE_MMC:
+		res = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
+		break;
+	case FLASH_STORAGE_USB:
+		res = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
+		break;
+	case FLASH_STORAGE_SATA:
+		res = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY);
+		break;
+	case FLASH_STORAGE_NAND:
+		if (location->ubivol != NULL)
+			res = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
+		else
+			res = -ENODEV;
+		break;
+	default:
+		error("Error: unsupported location storage.\n");
+		return -ENODEV;
+	}
+
+	if (res)
+		error("Error: could not access storage.\n");
+
+	return res;
+}
+
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int flash_init_usb(void)
+{
+	int err;
+
+	err = usb_init();
+	if (err)
+		return err;
+
+#ifndef CONFIG_DM_USB
+	err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
+#endif
+
+	return err;
+}
+#else
+static inline int flash_init_usb(void)
+{
+	error("Error: Cannot load flash image: no USB support\n");
+	return -ENOSYS;
+}
+#endif
+#endif
+
+#ifdef CONFIG_SATA
+static int flash_init_sata(void)
+{
+	return sata_probe(0);
+}
+#else
+static inline int flash_init_sata(void)
+{
+	error("Error: Cannot load flash image: no SATA support\n");
+	return -ENOSYS;
+}
+#endif
+
+#ifdef CONFIG_CMD_UBIFS
+static int flash_mount_ubifs(struct flash_location *location)
+{
+	int res;
+	char cmd[32];
+
+	sprintf(cmd, "ubi part %s", location->mtdpart);
+	res = run_command(cmd, 0);
+	if (res)
+		return res;
+
+	sprintf(cmd, "ubifsmount %s", location->ubivol);
+	res = run_command(cmd, 0);
+
+	return res;
+}
+
+static inline int flash_umount_ubifs(void)
+{
+	return run_command("ubifsumount", 0);
+}
+#else
+static inline int flash_mount_ubifs(struct flash_location *location)
+{
+	error("Error: Cannot load flash image: no UBIFS support\n");
+	return -ENOSYS;
+}
+
+static inline int flash_umount_ubifs(void)
+{
+	error("Error: Cannot unmount UBIFS: no UBIFS support\n");
+	return -ENOSYS;
+}
+#endif
+
+/**
+ * fsloader_preprocess - Any prepocessing before calling filesystem loader such
+ *			 getting filename, and flash partition information.
+ *
+ * @locations:		An array of supported flash locations. Contains default
+ *			flash setting for the file image.
+ * @file_info:		Description and attributes to the image.
+ *			Could be structure pointer, and any type pointer.
+ * @filename:		Image filename in flashes. Storing the file image name
+ *			to this pointer after retriving the name from DTB,
+ *			or environment or source code.
+ * @load_addr:		Target location image loaded to.
+ *
+ * @return:		If 0, processing is succesfull. Filename pointer
+ *			contains valid filename.
+ *			If -ve, processing is failed.
+ */
+__weak int fsloader_preprocess(struct flash_location *location,
+			       void *file_info, char **filename,
+			       u32 load_addr)
+{
+	return 0;
+}
+
+/*
+ * fs_loading - Place for implementing whatever specific driver to
+ *		the target HW such as program raw binary file to FPGA.
+ *
+ * @locations:		An array of supported flash locations. Contains default
+ *			flash setting for the file image.
+ * @file_info:		Description and attributes to the image.
+ *			Could be structure pointer, and any type pointer.
+ * @filename:		Image filename in flashes.
+ * @load_addr:		Target location image loaded to.
+ * @bsize:		Size of target location.
+ *
+ * @return:		If 0, loading is succesfull. filename pointer contains
+ *			valid filename.
+ *			If non-zero, loading is failed.
+ */
+__weak int fs_loading(struct flash_location *location, void *file_info,
+		      char *filename, u32 load_addr, size_t bsize)
+{
+	return 0;
+}
+
+/*
+ * flash_load_fs - Generic filesystem firmware loader, this should be called
+ *		   for any loader with filesystem.
+ *
+ * @locations:		An array of supported flash locations. Contains default
+ *			flash setting for the file image.
+ * @file_info:		Description and attributes to the file image.
+ *			Could be structure pointer, and any type pointer.
+ * @load_addr:		Target location file image loaded to.
+ * @bsize:		Size of target location.
+ *
+ * @return:		If 0, loading is succesfull.
+ *			If non-zero, loading is failed.
+ */
+int flash_load_fs(struct flash_location *location, void *file_info,
+		   u32 load_addr, size_t bsize)
+{
+	int res = 0;
+	char *flash_file = NULL;
+
+	res = fsloader_preprocess(location, file_info, &flash_file,
+				  load_addr);
+
+	if (res)
+		goto out;
+
+#ifndef CONFIG_SPL_BUILD
+	/* Loading from USB is not supported yet in SPL */
+	if (location->storage == FLASH_STORAGE_USB)
+		res = flash_init_usb();
+#endif
+
+	if (location->storage == FLASH_STORAGE_SATA)
+		res = flash_init_sata();
+
+	if (location->ubivol != NULL)
+		res = flash_mount_ubifs(location);
+
+	if (res)
+		return res;
+
+	res = fs_loading(location, file_info, flash_file, load_addr,
+			 bsize);
+
+out:
+	if (location->ubivol != NULL)
+		flash_umount_ubifs();
+
+	return res;
+}
+
diff --git a/include/load_fs.h b/include/load_fs.h
new file mode 100644
index 0000000..dbde8d0
--- /dev/null
+++ b/include/load_fs.h
@@ -0,0 +1,38 @@ 
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+
+#ifndef _LOAD_FS_H_
+#define _LOAD_FS_H_
+
+enum flash_storage {
+	FLASH_STORAGE_NAND,
+	FLASH_STORAGE_SF,
+	FLASH_STORAGE_MMC,
+	FLASH_STORAGE_USB,
+	FLASH_STORAGE_SATA,
+};
+
+enum flash_flags {
+	FLASH_STORAGE_RAW, /* Stored in raw memory */
+	FLASH_STORAGE_FS,  /* Stored within a file system */
+	FLASH_STORAGE_FIT, /* Stored inside a FIT image */
+};
+
+struct flash_location {
+	char *name;
+	enum flash_storage storage;
+	enum flash_flags flags;
+	u32 offset;	/* offset from start of storage */
+	char *devpart;  /* Use the load command dev:part conventions */
+	char *mtdpart;	/* MTD partition for ubi part */
+	char *ubivol;	/* UBI volume-name for ubifsmount */
+};
+
+int flash_load_fs(struct flash_location *location, void *file_info,
+		  u32 load_addr, size_t bsize);
+int flash_select_fs_dev(struct flash_location *location);
+#endif