From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF013C74A5B for ; Sat, 18 Mar 2023 10:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eizfYt4gmE1/akzP3WlL10wSYVw1p1kEJJKyERNFpfo=; b=YLSdMFlpTtz1ql E+pk5o19uJfuqoBFsCzRYam8nuLmA5M1ViOplHZTzVPyT1X2d7G9DO287IUT9T6BUUI1ULBCJ6zL6 kC1ra2OIAPT8HH1LhXE4lWjEw/IaaHsiduuEe4ELHDIpvCkiDW+JldGItorhgluqSiGZ6GH79C9RJ 6JA03uONNsSrW0F5zuHX1gpqjS/GqyxszJUxJEkljdaELIbrKAKyiJdUQDT+iYRBWhFxs/vLGv6vF i6eArDVJAOhvaLa+JFbRUMzgWvQL+/eRN/jCaisbewvNw7U5Y4kUCmAZ9iP5Be4Q+QqTB8i12xL7+ Wih86Pbn6PE1hW7lSL3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdTLz-004Yr2-2P; Sat, 18 Mar 2023 09:59:59 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdTLw-004Yqa-13 for linux-arm-kernel@lists.infradead.org; Sat, 18 Mar 2023 09:59:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679133596; x=1710669596; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=rqzxt1VGupOEfYGONcYiToQW8wfRtVs/qcIF0suXze8=; b=lFkLoNuK/hsLj/gmIqo+K5rwmuPoN2AgscJp5oXq7NbH8v4flDXRM820 ei4IhLigx4d3Y5AIFqK6NNofCzrLJFuPxZElF5s8WXWY7IOgljGUU3FwC TDxrHf0G5FTL3vu8nz0LOtSjSp0+qZQLMiZaRxYALKRhi6r0HFlfwcgE+ bUaWwJz6uoleQfFudaptxd00loxyaQw20hf6uvpbgI+pD27HlToGpnO7X Ib2uoxzdOOBXWL7d/v0QYSsYjbfPvQ4KB960zbMVGd60bq71o9uIvkNke WvmA2YvyBcGZtiaqIBKrzmES96hfdD9KtrxtSsf3LcQk3+Jn/XzX1EGkv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10652"; a="326786533" X-IronPort-AV: E=Sophos;i="5.98,271,1673942400"; d="scan'208";a="326786533" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2023 02:59:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10652"; a="804381771" X-IronPort-AV: E=Sophos;i="5.98,271,1673942400"; d="scan'208";a="804381771" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga004.jf.intel.com with ESMTP; 18 Mar 2023 02:59:50 -0700 Date: Sat, 18 Mar 2023 17:48:29 +0800 From: Xu Yilun To: Nava kishore Manne Cc: mdf@kernel.org, hao.wu@intel.com, trix@redhat.com, michal.simek@xilinx.com, linux-fpga@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fpga: zynq: Add parse_header ops support Message-ID: References: <20230314121754.297264-1-nava.kishore.manne@amd.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230314121754.297264-1-nava.kishore.manne@amd.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230318_025956_543009_2C983ACF X-CRM114-Status: GOOD ( 21.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2023-03-14 at 17:47:54 +0530, Nava kishore Manne wrote: > The commit 3cc624beba63 ("fpga: fpga-mgr: support bitstream offset in > image buffer") added a new parse_header ops to handle the header related > stuff in the fpga framework. So moved the header validation logic from > write_init() to parse_header(). > > Signed-off-by: Nava kishore Manne > --- > drivers/fpga/zynq-fpga.c | 23 ++++++++++++++++------- > 1 file changed, 16 insertions(+), 7 deletions(-) > > diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c > index ae0da361e6c6..6e5df0193028 100644 > --- a/drivers/fpga/zynq-fpga.c > +++ b/drivers/fpga/zynq-fpga.c > @@ -248,6 +248,21 @@ static bool zynq_fpga_has_sync(const u8 *buf, size_t count) > return false; > } > > +static int zynq_fpga_ops_parse_header(struct fpga_manager *mgr, > + struct fpga_image_info *info, > + const char *buf, size_t count) > +{ > + if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { > + if (!zynq_fpga_has_sync(buf, count)) { FPGA manager may pass in the whole image if it is already mapped, maybe only info->header_size should be checked? Thanks, Yilun > + dev_err(&mgr->dev, > + "Invalid bitstream, could not find a sync word. Bitstream must be a byte swapped .bin file\n"); > + return -EINVAL; > + } > + } > + > + return 0; > +} > + > static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, > struct fpga_image_info *info, > const char *buf, size_t count) > @@ -275,13 +290,6 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, > > /* don't globally reset PL if we're doing partial reconfig */ > if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { > - if (!zynq_fpga_has_sync(buf, count)) { > - dev_err(&mgr->dev, > - "Invalid bitstream, could not find a sync word. Bitstream must be a byte swapped .bin file\n"); > - err = -EINVAL; > - goto out_err; > - } > - > /* assert AXI interface resets */ > regmap_write(priv->slcr, SLCR_FPGA_RST_CTRL_OFFSET, > FPGA_RST_ALL_MASK); > @@ -545,6 +553,7 @@ static enum fpga_mgr_states zynq_fpga_ops_state(struct fpga_manager *mgr) > static const struct fpga_manager_ops zynq_fpga_ops = { > .initial_header_size = 128, > .state = zynq_fpga_ops_state, > + .parse_header = zynq_fpga_ops_parse_header, > .write_init = zynq_fpga_ops_write_init, > .write_sg = zynq_fpga_ops_write, > .write_complete = zynq_fpga_ops_write_complete, > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel