Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6538871rwl; Wed, 22 Mar 2023 11:54:08 -0700 (PDT) X-Google-Smtp-Source: AK7set+JomauvR1bz5+9gWR9agxpbjITND+Nsizdahg/jNfRUciLwc46mgwzQhAAzUMj3T2FpMYU X-Received: by 2002:a05:6a20:1aa1:b0:d9:dd69:47e3 with SMTP id ci33-20020a056a201aa100b000d9dd6947e3mr435859pzb.23.1679511247831; Wed, 22 Mar 2023 11:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679511247; cv=none; d=google.com; s=arc-20160816; b=QHcvfaS4Rsaqr/ZIC9T10IKBI/kZVQ4+hPVEahqs88gAHn0Uy41xOHqc/GGfcyjHCR JcNGIf2iZzCjKDmKYHIg/oB7hS7DAYA5wbejxGZDcrVorMnn9Pwe0BkqiBPil1FtQcA6 UFLX22lhzHlaiFxiX1BiXX+pmovgcYOCSmL/dKS+MvBaDQwVjnY6isea5fIJeKOM7evp kKT/aKgEF9rifC02SNyhcHEKv2Vcsp9wpTbEz36durkQpwNTC0vRA1Y2o2/VErYYFsw4 YHbh0A/A/0UzKIaJgXLdJXpKAsQF8mERg++RtZCiQx5nlo3a3U/xqlJ17l4Tbnxhd685 SCnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EHttEh6yxXxrUIBWgzA5oiNvBxxBhZB9e9/4ov+LfDc=; b=fk+KW+SmmW2KS/PKDzoaeH7nhc7ckyl253PupetW+HQbF8/PLaYMauKD9p0o7ZcFes MstWSQej5CuP2jzcIXQqxWDwQ8Sq5MgszJWzSwMQnJJxFMHrm8btLOBvBslpJSHfyTpg cpClRZ67yyxc9MQPBjdleHPwtGRGH6DNy3oqjTFhEtJATQMJlxBmFI+ZY5HOVkAgC018 TJAz+AhWeGo+wic8kEXpdS+3e8irUznG2uSPbKxGuqAkXzyk3t+o5+5i2+GCHb17v0OP EecRnpHxWEw9R54QHiHM3fIcuVSQOeJ5cquDL5AiYwLmutC0J+JuwmIpJwdI4CiyNvEP jyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfRKFEKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a63f508000000b00502d6f5fb2dsi17358972pgh.805.2023.03.22.11.53.55; Wed, 22 Mar 2023 11:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfRKFEKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjCVSvs (ORCPT + 99 others); Wed, 22 Mar 2023 14:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjCVSvq (ORCPT ); Wed, 22 Mar 2023 14:51:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56DD75DCA5; Wed, 22 Mar 2023 11:51:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E1C6E621BD; Wed, 22 Mar 2023 18:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2A73C433D2; Wed, 22 Mar 2023 18:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679511102; bh=EHttEh6yxXxrUIBWgzA5oiNvBxxBhZB9e9/4ov+LfDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XfRKFEKfrThqNiROTnBwKYHtw+Fpi6ugZRRZqG3l1x/fsRsdC4gXQ33/0aESDhYl8 CBuXEtk2+egbzEbgirKSFs0rfp7LJfzwOtPL2Q8vg6u60nFQ3PQGEt7NJ1LNP3kS3n ul3Uh3mtrVxqtDoddE9RsRJuwkqAT8RvXvQT5GVHgaeUu7Dxh/ni3uKyMqNLlqntC8 Hsi94Di5ZJZkr3Hf+yKdOiCo4Zigu+V3oFask4ZwtYr7Mp/aKZ0ajNPyDa2MT16+bV 95MHYaGWDAURaiFaFk4Q+oTWLOuFdpjVC3EGR75OaJRiN3D5r35VEFmAAhDW1WnR2E h2ewgpQ52AWzQ== Date: Wed, 22 Mar 2023 18:51:37 +0000 From: Conor Dooley To: Russ Weight Cc: Conor Dooley , Xu Yilun , Daire McNamara , Rob Herring , Krzysztof Kozlowski , Moritz Fischer , Wu Hao , Tom Rix , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: Re: [PATCH v1 0/6] PolarFire SoC Auto Update Support Message-ID: References: <20230217164023.14255-1-conor@kernel.org> <21bebf9d-eb27-5607-b0a9-274c46ef8aa3@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FgRuE+/bPgbqLyAD" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --FgRuE+/bPgbqLyAD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Russ, On Mon, Feb 27, 2023 at 10:56:07PM +0000, Conor Dooley wrote: > On Mon, Feb 27, 2023 at 02:42:30PM -0800, Russ Weight wrote: > > On 2/27/23 14:16, Conor Dooley wrote: > > > On Mon, Feb 27, 2023 at 02:04:36PM -0800, Russ Weight wrote: > > >> On 2/24/23 00:28, Conor Dooley wrote: > > >>> On Fri, Feb 24, 2023 at 03:57:09PM +0800, Xu Yilun wrote: > > >>>> On 2023-02-17 at 16:40:17 +0000, Conor Dooley wrote: > > >>>>> This patchset adds support for the "Auto Update" feature on Polar= Fire > > >>>>> SoC that allows for writing an FPGA bistream to the SPI flash con= nected > > >>>>> to the system controller. > > >>>> I haven't fully checked the patches yet, just some quick comments: > > >>>> > > >>>> Since this feature is just to R/W the flash, and would not affect = the > > >>>> runtime FPGA region, I don't think an FPGA manager is actually nee= ded. > > >>>> Why not just use the MTD uAPI? There is a set of exsiting MTD uAPI= & > > >>>> MTD tool if I remember correctly. > > >>> A lack of interest in opening up the system controller to userspace! > > >>> You're right in that the writing of the image can be done that way,= and > > >>> while I was testing I used the userspace bits of mtd along the way = - but > > >>> for validating that the image we are writing we rely on the system > > >>> controller. > > >>> I'm really not interested in exposing the system controller's > > >>> functionality, especially the bitstream manipulation parts, to user= space > > >>> due to the risk of input validation bugs, so at least that side of > > >>> things should remain in the kernel. > > >>> I suppose I could implement something custom in drivers/soc that do= es > > >>> the validation only, and push the rest out to userspace. Just seemed > > >>> fitting to do the whole lot in drivers/fpga. > > >> In case you haven't already looked at the new firmware-upload > > >> support in the firmware-loader, I'll give you some references > > >> here to see if it fit you needs. This would only support the > > >> write (not the read) but it would allow the controller to do > > >> validation on the write. > > >> > > >> The is the cover letter which shows a usage example: > > >> https://lore.kernel.org/lkml/20220421212204.36052-1-russell.h.weight= @intel.com/ > > >> > > >> And this is a pointer to the latest documentation for it: > > >> https://docs.kernel.org/driver-api/firmware/fw_upload.html > > >> > > >> The only current user is: drivers/fpga/intel-m10-bmc-sec-update.c > > > Sounds interesting, I shall go and take a look. Just quickly, when you > > > say it wouldn't support the read, what exactly do you mean? > > > The only read that I am really interested in doing is reading the fir= st > > > 1K of flash as I need to RMW it, but I don't think that that's what y= ou > > > mean. > > > Do you mean that I would not be able to dump the firmware using your > > > fw_upload interface? If so, that's an acceptable constraint IMO. > >=20 > > Yes - I mean that you couldn't dump the firmware image from userspace > > using the fw_upload interface. The sysfs interface allows you to read > > and write a temporary buffer, but once you "echo 0 > loading", there > > is no sysfs interface associated with the firmware-loader that would > > allow you to read the image from flash. Your controller actually does > > the writes, so RMW in that context is fine. >=20 > Ahh cool. I don't really care about dumping the firmware via such a > mechanism, so that sounds good to me. > I'll check out your approach, the immediate thought is that it sounds > suitable to my use case, so thanks! Taken me a while to get around to it, but thanks for your suggestion. Looks like it is suitable for what I am trying to do, so in the middle of working on another version of this using fw_upload. The enum return codes from write are a little clumsy, but oh well, could be worse I suppose. Just one thing I noted (although I rarely pay much attention to/rely on the driver-api docs when recent drivers exist as usable examples) is that the docs for this stuff is a wee bit out of date due to some API changes. In the code example in this document: https://docs.kernel.org/driver-api/firmware/fw_upload.html firmware_upload_register() has fewer arguments than it does when you look at the signature of the function in the documentation right below it. Cheers, Conor. --FgRuE+/bPgbqLyAD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZBtOOQAKCRB4tDGHoIJi 0vEbAQDSmfFT1DQ/Pk7auDVcWj4C5E1dtcFcY5Al+msb3ok9JwD/RuO6ZvqpZ+fx 2BDz3ttFebCLxjpRK9+HxVOXaeDD0wk= =Vitx -----END PGP SIGNATURE----- --FgRuE+/bPgbqLyAD--