All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
To: u-boot@lists.denx.de
Cc: Adrian Fiergolski <adrian.fiergolski@fastree3d.com>,
	Jorge Ramirez-Ortiz <jorge@foundries.io>,
	Michal Simek <michal.simek@xilinx.com>,
	Ricardo Salveti <ricardo@foundries.io>,
	Igor Opaniuk <igor.opaniuk@foundries.io>,
	Oleksandr Suvorov <oleksandr.suvorov@foundries.io>,
	Michal Simek <michal.simek@amd.com>
Subject: [PATCH v9 11/13] fpga: zynqmp: add bitstream compatible checking
Date: Wed,  1 Jun 2022 11:46:21 +0300	[thread overview]
Message-ID: <20220601084623.16006-12-oleksandr.suvorov@foundries.io> (raw)
In-Reply-To: <20220601084623.16006-11-oleksandr.suvorov@foundries.io>

Check whether the FPGA ZynqMP driver supports the given bitstream
image type.

Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
---

(no changes since v1)

 drivers/fpga/zynqmppl.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
index 6959b8ae97e..3dacb10e11f 100644
--- a/drivers/fpga/zynqmppl.c
+++ b/drivers/fpga/zynqmppl.c
@@ -199,6 +199,28 @@ static int zynqmp_validate_bitstream(xilinx_desc *desc, const void *buf,
 	return 0;
 }
 
+static int zynqmp_check_compatible(xilinx_desc *desc, int flags)
+{
+	/* If no flags set, the image is legacy */
+	if (!flags)
+		return 0;
+
+	/* For legacy bitstream images no need other methods exist */
+	if ((flags & desc->flags) && flags == FPGA_LEGACY)
+		return 0;
+
+	/*
+	 * Other images are handled in secure callback loads(). Check
+	 * callback existence besides image type support.
+	 */
+	if (CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) &&
+	    desc->operations->loads &&
+	    (flags & desc->flags))
+		return 0;
+
+	return FPGA_FAIL;
+}
+
 static int zynqmp_load(xilinx_desc *desc, const void *buf,
 		       size_t bsize, bitstream_type bstype,
 		       int flags)
@@ -213,6 +235,11 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf,
 
 	debug("%s called!\n", __func__);
 
+	if (zynqmp_check_compatible(desc, flags)) {
+		puts("Missing loads operation or unsupported bitstream type\n");
+		return FPGA_FAIL;
+	}
+
 	if (zynqmp_firmware_version() <= PMUFW_V1_0) {
 		puts("WARN: PMUFW v1.0 or less is detected\n");
 		puts("WARN: Not all bitstream formats are supported\n");
-- 
2.36.1


  reply	other threads:[~2022-06-01  8:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  8:46 [PATCH v9 00/13] fpga: zynqmp: Adding support of loading authenticated images Oleksandr Suvorov
2022-06-01  8:46 ` [PATCH v9 01/13] fpga: add option for loading FPGA secure bitstreams Oleksandr Suvorov
2022-06-01  8:46   ` [PATCH v9 02/13] fpga: xilinx: add missed identifier names Oleksandr Suvorov
2022-06-01  8:46     ` [PATCH v9 03/13] fpga: xilinx: add bitstream flags to driver desc Oleksandr Suvorov
2022-06-01  8:46       ` [PATCH v9 04/13] fpga: zynqmp: add str2flags call Oleksandr Suvorov
2022-06-01  8:46         ` [PATCH v9 05/13] fpga: add fpga_compatible2flag Oleksandr Suvorov
2022-06-01  8:46           ` [PATCH v9 06/13] fpga: xilinx: pass compatible flags to xilinx_load() Oleksandr Suvorov
2022-06-01  8:46             ` [PATCH v9 07/13] fpga: pass compatible flags to fpga_load() Oleksandr Suvorov
2022-06-01  8:46               ` [PATCH v9 08/13] spl: fit: pass real " Oleksandr Suvorov
2022-06-01  8:46                 ` [PATCH v9 09/13] fpga: xilinx: pass compatible flags to load() callback Oleksandr Suvorov
2022-06-01  8:46                   ` [PATCH v9 10/13] fpga: zynqmp: optimize zynqmppl_load() code Oleksandr Suvorov
2022-06-01  8:46                     ` Oleksandr Suvorov [this message]
2022-06-01  8:46                       ` [PATCH v9 12/13] fpga: zynqmp: support loading authenticated images Oleksandr Suvorov
2022-06-01  8:46                         ` [PATCH v9 13/13] fpga: zynqmp: support loading encrypted bitfiles Oleksandr Suvorov
2022-06-07 12:44                         ` [PATCH v9 12/13] fpga: zynqmp: support loading authenticated images Michal Simek
2022-06-07 12:14                 ` [PATCH v9 08/13] spl: fit: pass real compatible flags to fpga_load() Michal Simek
2022-06-07 12:11           ` [PATCH v9 05/13] fpga: add fpga_compatible2flag Michal Simek
2022-06-07 13:14             ` Oleksandr Suvorov
2022-06-07 11:31       ` [PATCH v9 03/13] fpga: xilinx: add bitstream flags to driver desc Michal Simek
2022-06-07 11:37         ` Oleksandr Suvorov
2022-06-07 12:46           ` Michal Simek
2022-06-07 13:03             ` Oleksandr Suvorov
2022-06-07 11:54       ` Michal Simek
2022-06-02 15:11 ` [PATCH v9 00/13] fpga: zynqmp: Adding support of loading authenticated images Oleksandr Suvorov
2022-06-07 13:01   ` Adrian Fiergolski
2022-06-07 13:11     ` Oleksandr Suvorov

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=20220601084623.16006-12-oleksandr.suvorov@foundries.io \
    --to=oleksandr.suvorov@foundries.io \
    --cc=adrian.fiergolski@fastree3d.com \
    --cc=igor.opaniuk@foundries.io \
    --cc=jorge@foundries.io \
    --cc=michal.simek@amd.com \
    --cc=michal.simek@xilinx.com \
    --cc=ricardo@foundries.io \
    --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.