linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: Conor Dooley <conor.dooley@microchip.com>
Cc: linux-fpga@vger.kernel.org, conor@kernel.org,
	Daire McNamara <daire.mcnamara@microchip.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Moritz Fischer <mdf@kernel.org>, Wu Hao <hao.wu@intel.com>,
	Tom Rix <trix@redhat.com>,
	linux-riscv@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 6/7] fpga: add PolarFire SoC Auto Update support
Date: Fri, 14 Apr 2023 12:40:38 +0000	[thread overview]
Message-ID: <ZDlJxrybiWy3Mk4Y@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20230411-tinsmith-matchless-af5c7c41d23b@wendy>

On 2023-04-11 at 12:51:34 +0100, Conor Dooley wrote:
> On Sun, Apr 02, 2023 at 06:57:18PM +0800, Xu Yilun wrote:
> > On 2023-03-31 at 08:18:22 +0100, Conor Dooley wrote:
> > > Add support for Auto Update reprogramming of the FPGA fabric on
> > > PolarFire SoC, using the fw_upload mechanism a la the
> > > intel-m10-bmc-sec-update driver.
> > 
> > I'm not an expert of MTD and have several concerns about the mtd
> > writing part:
> > 
> > - This seems a generic case that writing a file content into the
> >   driver restricted offset on mtd.
> 
> Right, writing at an offset is pretty generic.
> 
> > - Seems the firmware update interface could be created for mtd device,
> >   like the nvmem interface?
> 
> I'm not entirely sure what you mean by this one.
> Are you saying that there should be a generic way to do "firmware"
> uploads to mtd devices, based on some sort of structure defined in

Yes, I think if the firmware upload interface could be generic, then add
it to the mtd devices, rather than creating a "virtual mtd management"
device as this patch does.

> devicetree etc?
> And perhaps then, this driver would register as a consumer of that
> interface, pushing all of the direct mtd stuff out to that interface?
> 
> > - I assume the purpose of the fw upload interface is to protect
> >   unexpected writing from user. So how to protect the mtd be
> >   written by other user interfaces like mtdchar/block or nvmem?
> 
> I'm not very good with the security knobs so I don't have an answer for
> you here (yet). But your assumption about the rationale here is correct
> and I would like to block access.
> 
> > For other parts:
> > 
> > - directory block check, fw upload don't touch this block, so why check
> >   it in fw upload process.
> 
> I don't know what you mean. The mtd device could be empty and the
> directory would need to be populated with the image address etc.
> Or, it could previously have been used for something else, and then it
> would be required to reconfigure it correctly for Auto Upgrade.
> 
> Maybe I am misunderstanding you?

This directory block content is unrelated to the firmware image, so
could be written before firmware upload interface is created. The
firmware image uploading could be done without touching directory
blocks. That means directory blocks could be set by driver as
no-touch area for firmware uploading interface.

> 
> > 
> > - image verification, no matter pass or fail, fw upload is actually done,
> >   the flash is written and no way to rollback. So may remove from fw
> >   upload process.
> 
> The FPGA is flash based, so writing to the mtd device is not going to
> actually program the FPGA with this content. The original image/bitstream
> in the mtd device is either going to be a) equivalent to what is already
> programmed in the FPGA, b) not an upgrade over what is current in the
> FPGA, c) something that was uploaded since the last time the device was
> restarted.
> I don't think that overwriting any of those is problematic, as if the
> verification fails, the original bitstream will continue being used
> until an image that does actually pass is provided.
> 
> Without doing the verification though, there's no way to tell for certain
> if the FPGA is actually going to perform an upgrade to this new bitstream
> once it is restarted, so I think there is value in keeping this.

I don't mean to remove the support of verification from driver. I say
remove the verification from MTD firmware upload process. You can
use another interface in your driver to verify if FPGA could load the
content in user block at any time.

In my opinion, generic firmware upload interface for MTD could be used
out of FPGA cases, it just deals with writing the image file to the MTD.
Once you have nothing more to write for the image file, the job for the
interface could be successfully done.

> 
> If you're still very sceptical about whether this belongs in
> drivers/fpga, I can always dump it in drivers/soc instead I guess.

I actually don't think this belongs to FPGA domain. My pereference is a
generic MTD firmware upload interface for MTD domain.

But this is just my opinion. You may talk to MTD or SoC maintainers for
final solution.

Thanks,
Yilun

> 
> Cheers,
> Conor.
> 



  reply	other threads:[~2023-04-14  4:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  7:18 [PATCH v2 0/7] PolarFire SoC Auto Update Support Conor Dooley
2023-03-31  7:18 ` [PATCH v2 1/7] soc: microchip: mpfs: add a prefix to rx_callback() Conor Dooley
2023-03-31  7:18 ` [PATCH v2 2/7] dt-bindings: soc: microchip: add a property for system controller flash Conor Dooley
2023-03-31  7:18 ` [PATCH v2 3/7] soc: microchip: mpfs: enable access to the system controller's flash Conor Dooley
2023-03-31  7:18 ` [PATCH v2 4/7] soc: microchip: mpfs: print service status in warning message Conor Dooley
2023-03-31  7:18 ` [PATCH v2 5/7] soc: microchip: mpfs: add auto-update subdev to system controller Conor Dooley
2023-03-31  7:18 ` [PATCH v2 6/7] fpga: add PolarFire SoC Auto Update support Conor Dooley
2023-04-02 10:57   ` Xu Yilun
2023-04-11 11:51     ` Conor Dooley
2023-04-14 12:40       ` Xu Yilun [this message]
2023-03-31  7:18 ` [PATCH v2 7/7] riscv: dts: microchip: add the mpfs' system controller qspi & associated flash Conor Dooley
2023-04-02  8:00 ` [PATCH v2 0/7] PolarFire SoC Auto Update Support Xu Yilun
2023-04-02  8:23   ` Conor Dooley
2023-04-03 19:34 ` (subset) " Conor Dooley

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=ZDlJxrybiWy3Mk4Y@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@intel.com \
    --cc=conor.dooley@microchip.com \
    --cc=conor@kernel.org \
    --cc=daire.mcnamara@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hao.wu@intel.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mdf@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=trix@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).