All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
To: oleksandr.suvorov@foundries.io
Cc: ricardo@foundries.io, igor.opaniuk@foundries.io,
	jorge@foundries.io, mr.nuke.me@gmail.com, bmeng.cn@gmail.com,
	hs@denx.de, jagan@amarulasolutions.com, klaus@linux.vnet.ibm.com,
	seanga2@gmail.com, sjg@chromium.org,
	jaeckel-floss@eyet-services.de,
	Michal Simek <michal.simek@xilinx.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v7 2/7] fpga: add fit_fpga_load function
Date: Wed, 4 May 2022 16:28:14 +0200	[thread overview]
Message-ID: <49817a87-7de5-811a-131f-a22a6f4c0299@fastree3d.com> (raw)
In-Reply-To: <3929af10-3e4e-82bb-b5dc-d75e8d3a27d9@xilinx.com>

Hi Oleksandr,

On 03.05.2022 09:42, Michal Simek wrote:
>
>
> On 4/11/22 20:00, Adrian Fiergolski wrote:
>> From: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
>>
>> Introduce a function which passes an fpga compatible string from
>> FIT images to FPGA drivers. This lets the different implementations
>> decide how to handle it.
>>
>> Some code of Jorge Ramirez-Ortiz <jorge@foundries.io> is reused.
>>
>> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
>> Tested-by: Ricardo Salveti <ricardo@foundries.io>
>> Co-developed-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
>> Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>
>> ---
>>   common/spl/spl_fit.c |  6 ++----
>>   drivers/fpga/fpga.c  | 23 ++++++++++++++++++++++-
>>   include/fpga.h       |  4 ++++
>>   3 files changed, 28 insertions(+), 5 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index 1bbf824684..0e3c2a94b6 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -588,11 +588,9 @@ static int spl_fit_upload_fpga(struct 
>> spl_fit_info *ctx, int node,
>>       compatible = fdt_getprop(ctx->fit, node, "compatible", NULL);
>>       if (!compatible)
>>           warn_deprecated("'fpga' image without 'compatible' property");
>> -    else if (strcmp(compatible, "u-boot,fpga-legacy"))
>> -        printf("Ignoring compatible = %s property\n", compatible);
>>   -    ret = fpga_load(0, (void *)fpga_image->load_addr, 
>> fpga_image->size,
>> -            BIT_FULL);
>> +    ret = fit_fpga_load(0, (void *)fpga_image->load_addr, 
>> fpga_image->size,
>> +                BIT_FULL, compatible);
>>       if (ret) {
>>           printf("%s: Cannot load the image to the FPGA\n", __func__);
>>           return ret;
>> diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
>> index 3b0a44b242..a306dd81f9 100644
>> --- a/drivers/fpga/fpga.c
>> +++ b/drivers/fpga/fpga.c
>> @@ -249,8 +249,23 @@ int fpga_loads(int devnum, const void *buf, 
>> size_t size,
>>   }
>>   #endif
>>   +int fit_fpga_load(int devnum, const void *buf, size_t bsize,
>> +          bitstream_type bstype, const char *compatible)
>> +{
>> +    fpga_desc *desc = fpga_get_desc(devnum);
>
> this generates warning which you should fix.
>
> +  fpga_desc *desc = fpga_get_desc(devnum);
> +                    ^~~~~~~~~~~~~
> w+../drivers/fpga/fpga.c: In function ‘fit_fpga_load’:
> w+../drivers/fpga/fpga.c:255:20: warning: initialization discards 
> ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

As it's your patch, could you address it?

The 'compatible' field can't be set here, as fpga_get_desc returns 
'const fpga_desc * const'. The descriptors table is populated (fpga_add) 
in board_init. At that stage, I am afraid, we don't have access to the 
fit image information yet to set a proper 'compatible' (would need to 
check the code more carefully). Moreover, IMHO it's not the cleanest way 
to change the 'compatible' field after the driver's initialisation.

>
>
>> +
>> +    /*
>> +     * Store the compatible string to proceed it in underlying
>> +     * functions
>> +     */
>> +    desc->compatible = (char *)compatible;
>> +
>> +    return fpga_load(devnum, buf, bsize, bstype);
>> +}
>> +
>>   /*
>> - * Generic multiplexing code
>> + * Generic multiplexing code:
>> + * Each architecture must handle the mandatory FPGA DT compatible 
>> property.
>>    */
>>   int fpga_load(int devnum, const void *buf, size_t bsize, 
>> bitstream_type bstype)
>>   {
>> @@ -270,6 +285,9 @@ int fpga_load(int devnum, const void *buf, size_t 
>> bsize, bitstream_type bstype)
>>               break;
>>           case fpga_altera:
>>   #if defined(CONFIG_FPGA_ALTERA)
>> +            if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18))
>> +                printf("Ignoring compatible = %s property\n",
>> +                       desc->compatible);
>>               ret_val = altera_load(desc->devdesc, buf, bsize);
>>   #else
>>               fpga_no_sup((char *)__func__, "Altera devices");
>> @@ -277,6 +295,9 @@ int fpga_load(int devnum, const void *buf, size_t 
>> bsize, bitstream_type bstype)
>>               break;
>>           case fpga_lattice:
>>   #if defined(CONFIG_FPGA_LATTICE)
>> +            if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18))
>> +                printf("Ignoring compatible = %s property\n",
>> +                       desc->compatible);
>>               ret_val = lattice_load(desc->devdesc, buf, bsize);
>>   #else
>>               fpga_no_sup((char *)__func__, "Lattice devices");
>> diff --git a/include/fpga.h b/include/fpga.h
>> index ec5144334d..2891f32106 100644
>> --- a/include/fpga.h
>> +++ b/include/fpga.h
>> @@ -35,6 +35,7 @@ typedef enum {            /* typedef fpga_type */
>>   typedef struct {        /* typedef fpga_desc */
>>       fpga_type devtype;    /* switch value to select sub-functions */
>>       void *devdesc;        /* real device descriptor */
>> +    char *compatible;    /* device compatible string */
>>   } fpga_desc;            /* end, typedef fpga_desc */
>>     typedef struct {                /* typedef fpga_desc */
>> @@ -63,6 +64,9 @@ int fpga_add(fpga_type devtype, void *desc);
>>   int fpga_count(void);
>>   const fpga_desc *const fpga_get_desc(int devnum);
>>   int fpga_is_partial_data(int devnum, size_t img_len);
>> +/* the DT compatible property must be handled by the different FPGA 
>> archs */
>> +int fit_fpga_load(int devnum, const void *buf, size_t bsize,
>> +          bitstream_type bstype, const char *compatible);
>>   int fpga_load(int devnum, const void *buf, size_t bsize,
>>             bitstream_type bstype);
>>   int fpga_fsload(int devnum, const void *buf, size_t size,
>
> M
Adrian

  reply	other threads:[~2022-05-04 14:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 18:00 [PATCH v7 0/7] fpga: zynqmp: Adding support of loading authenticated images Adrian Fiergolski
2022-04-11 18:00 ` [PATCH v7 1/7] fpga: add option for loading FPGA secure bitstreams Adrian Fiergolski
2022-04-11 18:00 ` [PATCH v7 2/7] fpga: add fit_fpga_load function Adrian Fiergolski
2022-05-03  7:42   ` Michal Simek
2022-05-04 14:28     ` Adrian Fiergolski [this message]
2022-05-04 18:26       ` Oleksandr Suvorov
2022-05-09 10:30         ` Adrian Fiergolski
2022-05-09 11:41           ` Oleksandr Suvorov
2022-05-09 11:02       ` Oleksandr Suvorov
2022-05-09 11:35         ` Adrian Fiergolski
2022-05-09 13:28           ` Oleksandr Suvorov
2022-05-09 13:34             ` Adrian Fiergolski
2022-05-16 14:25               ` Michal Simek
2022-05-18  8:47                 ` Oleksandr Suvorov
2022-05-31 23:17                 ` Oleksandr Suvorov
2022-04-11 18:00 ` [PATCH v7 3/7] fpga: xilinx: pass an address of xilinx_desc in fpga_desc Adrian Fiergolski
2022-04-11 18:00 ` [PATCH v7 4/7] fpga: xilinx: add missed identifier names Adrian Fiergolski
2022-05-03  7:43   ` Michal Simek
2022-04-11 18:00 ` [PATCH v7 5/7] fpga: xilinx: pass xilinx_desc pointer address into load() ops Adrian Fiergolski
2022-05-03  7:44   ` Michal Simek
2022-04-11 18:00 ` [PATCH v7 6/7] fpga: zynqmp: support loading authenticated images Adrian Fiergolski
2022-05-03  7:55   ` Michal Simek
2022-05-07 22:19     ` Oleksandr Suvorov
2022-04-11 18:00 ` [PATCH v7 7/7] fpga: zynqmp: support loading encrypted bitfiles Adrian Fiergolski
2022-05-03  7:56 ` [PATCH v7 0/7] fpga: zynqmp: Adding support of loading authenticated images Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49817a87-7de5-811a-131f-a22a6f4c0299@fastree3d.com \
    --to=adrian.fiergolski@fastree3d.com \
    --cc=bmeng.cn@gmail.com \
    --cc=hs@denx.de \
    --cc=igor.opaniuk@foundries.io \
    --cc=jaeckel-floss@eyet-services.de \
    --cc=jagan@amarulasolutions.com \
    --cc=jorge@foundries.io \
    --cc=klaus@linux.vnet.ibm.com \
    --cc=michal.simek@xilinx.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=oleksandr.suvorov@foundries.io \
    --cc=ricardo@foundries.io \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.