From patchwork Thu Jun 24 21:17:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12343245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F37E4C49EA6 for ; Thu, 24 Jun 2021 21:17:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D50DD6124C for ; Thu, 24 Jun 2021 21:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232663AbhFXVUN (ORCPT ); Thu, 24 Jun 2021 17:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39022 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbhFXVUL (ORCPT ); Thu, 24 Jun 2021 17:20:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PriZzvosAz19zM08cUettXNufWgy2eBON80n4DDrzSo=; b=O5WoSGDww5YQsbJh6GY73tdkydeVbsxKOmp46LRiUMc9i1UuWpNiQJz1G+Xi3tjw7RLKYs LweP16j3pUljC5ZFKH/rQwOO+TALjEmQFj+UrdF67QWBodZrR67ircScNw2MBD2AY8O2iI gg7m3jP2gPYnKx4ZzcXc//x5WnNX0OI= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-cTv-Hr8DMviZfq7DmFEOVQ-1; Thu, 24 Jun 2021 17:17:49 -0400 X-MC-Unique: cTv-Hr8DMviZfq7DmFEOVQ-1 Received: by mail-oo1-f70.google.com with SMTP id d12-20020a4aeb8c0000b029023bbaaddcbbso4495345ooj.13 for ; Thu, 24 Jun 2021 14:17:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PriZzvosAz19zM08cUettXNufWgy2eBON80n4DDrzSo=; b=q1t4T1T/3QX1eSPsjK2g2zg/YrKOs9nO+PmrEpLQGeJyx5ykYlhqTjbPtigf+Sl2Xj J299x9pXtJhADsbJ/UFlUmR0mPiHCo3iWsQ+Z1nRV8sLOlMOy4vQ7R8aept1oruHERrW feo43eHCJ7L6bJGqkdYoSw808Itl1pis4SZ+3zpm6JSVp0WM7YtF0PF6x7uDgW+8S2Xm Uop1vFs3VJay2EDVdHzOa3CuXqBihoyCICMRi0BepZS8oR/OSoJ7NjGd8zrcxqM9Y+43 WaOpfu/8mqbrkMjZXbXyWEowte1RaIzgBgE4UZGBUblAyvCwtZ722fX+nzlDfEwtwgR/ pWRw== X-Gm-Message-State: AOAM5332fj+1N+C8kDalxpRLKMbGSt0fkWrI5RAm2fHMRxOSV/Pbl1DQ n7uFhI468kjYX0cnS0Gxp4yN5KuPDDs4Ml3ydMbbR4NWNWdIqfVCY61aMpUuCZQcxgPq6YJCBJO r8WchN5gFOHlCDY8BaXqVPA== X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr5594672oic.139.1624569467700; Thu, 24 Jun 2021 14:17:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEQx5/Asy9JFkHb7vsUS+fvzP33VQHlWESeEuO9GNT9+5TPvbx+prnMxSKR5IjbiYtXYe96w== X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr5594658oic.139.1624569467433; Thu, 24 Jun 2021 14:17:47 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 94sm915513otj.33.2021.06.24.14.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 14:17:45 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, hao.wu@intel.com, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 1/5] fpga: generalize updating the card Date: Thu, 24 Jun 2021 14:17:23 -0700 Message-Id: <20210624211727.501019-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210624211727.501019-1-trix@redhat.com> References: <20210624211727.501019-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix There is a need to update the whole card. An fpga can contain non-fpga components whose firmware needs to be updated at the same time as the fpga rtl images and may need to be handled differently from the existing fpga reconfiguration in the fpga manager. Move the write_* ops out of fpga_manager_ops and into a new fpga_manager_update_ops struct. Add two update_ops back to fpga_manager_ops, reconfig for the exiting functionality and reimage for the new functionity. Rewire fpga devs to use reconfig ops Signed-off-by: Tom Rix --- drivers/fpga/altera-cvp.c | 8 ++++---- drivers/fpga/altera-pr-ip-core.c | 8 ++++---- drivers/fpga/altera-ps-spi.c | 8 ++++---- drivers/fpga/dfl-fme-mgr.c | 8 ++++---- drivers/fpga/fpga-mgr.c | 18 +++++++++--------- drivers/fpga/ice40-spi.c | 8 ++++---- drivers/fpga/machxo2-spi.c | 8 ++++---- drivers/fpga/socfpga-a10.c | 10 +++++----- drivers/fpga/socfpga.c | 8 ++++---- drivers/fpga/stratix10-soc.c | 6 +++--- drivers/fpga/ts73xx-fpga.c | 6 +++--- drivers/fpga/xilinx-spi.c | 8 ++++---- drivers/fpga/zynq-fpga.c | 10 +++++----- drivers/fpga/zynqmp-fpga.c | 6 +++--- include/linux/fpga/fpga-mgr.h | 32 +++++++++++++++++++++----------- 15 files changed, 81 insertions(+), 71 deletions(-) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index ccf4546eff297..9363353798bc9 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -516,10 +516,10 @@ static int altera_cvp_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops altera_cvp_ops = { - .state = altera_cvp_state, - .write_init = altera_cvp_write_init, - .write = altera_cvp_write, - .write_complete = altera_cvp_write_complete, + .state = altera_cvp_state, + .reconfig.write_init = altera_cvp_write_init, + .reconfig.write = altera_cvp_write, + .reconfig.write_complete = altera_cvp_write_complete, }; static const struct cvp_priv cvp_priv_v1 = { diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c index dfdf21ed34c4e..30c7b534df95b 100644 --- a/drivers/fpga/altera-pr-ip-core.c +++ b/drivers/fpga/altera-pr-ip-core.c @@ -167,10 +167,10 @@ static int alt_pr_fpga_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops alt_pr_ops = { - .state = alt_pr_fpga_state, - .write_init = alt_pr_fpga_write_init, - .write = alt_pr_fpga_write, - .write_complete = alt_pr_fpga_write_complete, + .state = alt_pr_fpga_state, + .reconfig.write_init = alt_pr_fpga_write_init, + .reconfig.write = alt_pr_fpga_write, + .reconfig.write_complete = alt_pr_fpga_write_complete, }; int alt_pr_register(struct device *dev, void __iomem *reg_base) diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c index 23bfd4d1ad0f7..2b01a3c53d374 100644 --- a/drivers/fpga/altera-ps-spi.c +++ b/drivers/fpga/altera-ps-spi.c @@ -231,10 +231,10 @@ static int altera_ps_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops altera_ps_ops = { - .state = altera_ps_state, - .write_init = altera_ps_write_init, - .write = altera_ps_write, - .write_complete = altera_ps_write_complete, + .state = altera_ps_state, + .reconfig.write_init = altera_ps_write_init, + .reconfig.write = altera_ps_write, + .reconfig.write_complete = altera_ps_write_complete, }; static const struct altera_ps_data *id_to_data(const struct spi_device_id *id) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index 313420405d5e8..a6d2ed399e580 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -260,10 +260,10 @@ static u64 fme_mgr_status(struct fpga_manager *mgr) } static const struct fpga_manager_ops fme_mgr_ops = { - .write_init = fme_mgr_write_init, - .write = fme_mgr_write, - .write_complete = fme_mgr_write_complete, - .status = fme_mgr_status, + .status = fme_mgr_status, + .reconfig.write_init = fme_mgr_write_init, + .reconfig.write = fme_mgr_write, + .reconfig.write_complete = fme_mgr_write_complete, }; static void fme_mgr_get_compat_id(void __iomem *fme_pr, diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 000fa89fda99d..9d17779cac7e3 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -44,15 +44,15 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr, struct fpga_image_info *info, const char *buf, size_t count) { - if (mgr->mops && mgr->mops->write_init) - return mgr->mops->write_init(mgr, info, buf, count); + if (mgr->mops && mgr->mops->reconfig.write_init) + return mgr->mops->reconfig.write_init(mgr, info, buf, count); return 0; } static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) { - if (mgr->mops && mgr->mops->write) - return mgr->mops->write(mgr, buf, count); + if (mgr->mops && mgr->mops->reconfig.write) + return mgr->mops->reconfig.write(mgr, buf, count); return -EOPNOTSUPP; } @@ -66,8 +66,8 @@ static inline int fpga_mgr_write_complete(struct fpga_manager *mgr, int ret = 0; mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - if (mgr->mops && mgr->mops->write_complete) - ret = mgr->mops->write_complete(mgr, info); + if (mgr->mops && mgr->mops->reconfig.write_complete) + ret = mgr->mops->reconfig.write_complete(mgr, info); if (ret) { dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; @@ -225,8 +225,8 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, /* Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; - if (mgr->mops->write_sg) { - ret = mgr->mops->write_sg(mgr, sgt); + if (mgr->mops->reconfig.write_sg) { + ret = mgr->mops->reconfig.write_sg(mgr, sgt); } else { struct sg_mapping_iter miter; @@ -302,7 +302,7 @@ static int fpga_mgr_buf_load(struct fpga_manager *mgr, * contiguous kernel buffer and the driver doesn't require SG, non-SG * drivers will still work on the slow path. */ - if (mgr->mops->write) + if (mgr->mops->reconfig.write) return fpga_mgr_buf_load_mapped(mgr, info, buf, count); /* diff --git a/drivers/fpga/ice40-spi.c b/drivers/fpga/ice40-spi.c index 69dec5af23c36..3bdc3fe8ece97 100644 --- a/drivers/fpga/ice40-spi.c +++ b/drivers/fpga/ice40-spi.c @@ -126,10 +126,10 @@ static int ice40_fpga_ops_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops ice40_fpga_ops = { - .state = ice40_fpga_ops_state, - .write_init = ice40_fpga_ops_write_init, - .write = ice40_fpga_ops_write, - .write_complete = ice40_fpga_ops_write_complete, + .state = ice40_fpga_ops_state, + .reconfig.write_init = ice40_fpga_ops_write_init, + .reconfig.write = ice40_fpga_ops_write, + .reconfig.write_complete = ice40_fpga_ops_write_complete, }; static int ice40_fpga_probe(struct spi_device *spi) diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c index 114a64d2b7a4d..8b860e9a19c92 100644 --- a/drivers/fpga/machxo2-spi.c +++ b/drivers/fpga/machxo2-spi.c @@ -350,10 +350,10 @@ static int machxo2_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops machxo2_ops = { - .state = machxo2_spi_state, - .write_init = machxo2_write_init, - .write = machxo2_write, - .write_complete = machxo2_write_complete, + .state = machxo2_spi_state, + .reconfig.write_init = machxo2_write_init, + .reconfig.write = machxo2_write, + .reconfig.write_complete = machxo2_write_complete, }; static int machxo2_spi_probe(struct spi_device *spi) diff --git a/drivers/fpga/socfpga-a10.c b/drivers/fpga/socfpga-a10.c index 573d88bdf7307..e60bf844b4c40 100644 --- a/drivers/fpga/socfpga-a10.c +++ b/drivers/fpga/socfpga-a10.c @@ -458,11 +458,11 @@ static enum fpga_mgr_states socfpga_a10_fpga_state(struct fpga_manager *mgr) } static const struct fpga_manager_ops socfpga_a10_fpga_mgr_ops = { - .initial_header_size = (RBF_DECOMPRESS_OFFSET + 1) * 4, - .state = socfpga_a10_fpga_state, - .write_init = socfpga_a10_fpga_write_init, - .write = socfpga_a10_fpga_write, - .write_complete = socfpga_a10_fpga_write_complete, + .initial_header_size = (RBF_DECOMPRESS_OFFSET + 1) * 4, + .state = socfpga_a10_fpga_state, + .reconfig.write_init = socfpga_a10_fpga_write_init, + .reconfig.write = socfpga_a10_fpga_write, + .reconfig.write_complete = socfpga_a10_fpga_write_complete, }; static int socfpga_a10_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c index 1f467173fc1f3..cc752a3f742c2 100644 --- a/drivers/fpga/socfpga.c +++ b/drivers/fpga/socfpga.c @@ -534,10 +534,10 @@ static enum fpga_mgr_states socfpga_fpga_ops_state(struct fpga_manager *mgr) } static const struct fpga_manager_ops socfpga_fpga_ops = { - .state = socfpga_fpga_ops_state, - .write_init = socfpga_fpga_ops_configure_init, - .write = socfpga_fpga_ops_configure_write, - .write_complete = socfpga_fpga_ops_configure_complete, + .state = socfpga_fpga_ops_state, + .reconfig.write_init = socfpga_fpga_ops_configure_init, + .reconfig.write = socfpga_fpga_ops_configure_write, + .reconfig.write_complete = socfpga_fpga_ops_configure_complete, }; static int socfpga_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index 047fd7f237069..ab1941d92cf60 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -389,9 +389,9 @@ static int s10_ops_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops s10_ops = { - .write_init = s10_ops_write_init, - .write = s10_ops_write, - .write_complete = s10_ops_write_complete, + .reconfig.write_init = s10_ops_write_init, + .reconfig.write = s10_ops_write, + .reconfig.write_complete = s10_ops_write_complete, }; static int s10_probe(struct platform_device *pdev) diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c index 167abb0b08d40..cbbc6dec56856 100644 --- a/drivers/fpga/ts73xx-fpga.c +++ b/drivers/fpga/ts73xx-fpga.c @@ -93,9 +93,9 @@ static int ts73xx_fpga_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops ts73xx_fpga_ops = { - .write_init = ts73xx_fpga_write_init, - .write = ts73xx_fpga_write, - .write_complete = ts73xx_fpga_write_complete, + .reconfig.write_init = ts73xx_fpga_write_init, + .reconfig.write = ts73xx_fpga_write, + .reconfig.write_complete = ts73xx_fpga_write_complete, }; static int ts73xx_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index fee4d0abf6bfe..4d092f30bf700 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -214,10 +214,10 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops xilinx_spi_ops = { - .state = xilinx_spi_state, - .write_init = xilinx_spi_write_init, - .write = xilinx_spi_write, - .write_complete = xilinx_spi_write_complete, + .state = xilinx_spi_state, + .reconfig.write_init = xilinx_spi_write_init, + .reconfig.write = xilinx_spi_write, + .reconfig.write_complete = xilinx_spi_write_complete, }; static int xilinx_spi_probe(struct spi_device *spi) diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c index 9b75bd4f93d8e..bdfc257740cff 100644 --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c @@ -543,11 +543,11 @@ 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, - .write_init = zynq_fpga_ops_write_init, - .write_sg = zynq_fpga_ops_write, - .write_complete = zynq_fpga_ops_write_complete, + .initial_header_size = 128, + .state = zynq_fpga_ops_state, + .reconfig.write_init = zynq_fpga_ops_write_init, + .reconfig.write_sg = zynq_fpga_ops_write, + .reconfig.write_complete = zynq_fpga_ops_write_complete, }; static int zynq_fpga_probe(struct platform_device *pdev) diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index 9efbd70aa6864..fbb66c1f9c871 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -78,9 +78,9 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) } static const struct fpga_manager_ops zynqmp_fpga_ops = { - .state = zynqmp_fpga_ops_state, - .write_init = zynqmp_fpga_ops_write_init, - .write = zynqmp_fpga_ops_write, + .state = zynqmp_fpga_ops_state, + .reconfig.write_init = zynqmp_fpga_ops_write_init, + .reconfig.write = zynqmp_fpga_ops_write, }; static int zynqmp_fpga_probe(struct platform_device *pdev) diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 474c1f5063070..53f9402d6aa17 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -106,14 +106,29 @@ struct fpga_image_info { }; /** - * struct fpga_manager_ops - ops for low level fpga manager drivers - * @initial_header_size: Maximum number of bytes that should be passed into write_init - * @state: returns an enum value of the FPGA's state - * @status: returns status of the FPGA, including reconfiguration error code + * struct fpga_manager_update_ops - ops updating fpga * @write_init: prepare the FPGA to receive configuration data * @write: write count bytes of configuration data to the FPGA * @write_sg: write the scatter list of configuration data to the FPGA * @write_complete: set FPGA to operating state after writing is done + */ +struct fpga_manager_update_ops { + int (*write_init)(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count); + int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); + int (*write_sg)(struct fpga_manager *mgr, struct sg_table *sgt); + int (*write_complete)(struct fpga_manager *mgr, + struct fpga_image_info *info); +}; + +/** + * struct fpga_manager_ops - ops for low level fpga manager drivers + * @initial_header_size: Maximum number of bytes that should be passed into write_init + * @state: returns an enum value of the FPGA's state + * @status: returns status of the FPGA, including reconfiguration error code + * @partial_update: ops for doing partial reconfiguration + * @full_update: ops for doing a full card update, user,shell,fw ie. the works * @fpga_remove: optional: Set FPGA into a specific state during driver remove * @groups: optional attribute groups. * @@ -125,13 +140,8 @@ struct fpga_manager_ops { size_t initial_header_size; enum fpga_mgr_states (*state)(struct fpga_manager *mgr); u64 (*status)(struct fpga_manager *mgr); - int (*write_init)(struct fpga_manager *mgr, - struct fpga_image_info *info, - const char *buf, size_t count); - int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); - int (*write_sg)(struct fpga_manager *mgr, struct sg_table *sgt); - int (*write_complete)(struct fpga_manager *mgr, - struct fpga_image_info *info); + struct fpga_manager_update_ops reconfig; + struct fpga_manager_update_ops reimage; void (*fpga_remove)(struct fpga_manager *mgr); const struct attribute_group **groups; }; From patchwork Thu Jun 24 21:17:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12343243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671B9C49EA5 for ; Thu, 24 Jun 2021 21:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D692613D6 for ; Thu, 24 Jun 2021 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232650AbhFXVUO (ORCPT ); Thu, 24 Jun 2021 17:20:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51967 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbhFXVUN (ORCPT ); Thu, 24 Jun 2021 17:20:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569473; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=06yao2CDsis15QoJOXCwwfY4/53M6JaTIu7lUfBh14M=; b=KCHwwo+P2gSAkS8St5aVdMhZbMI2t7N0SL8vtxV8SGZqztEjWbA889jerCJFkZgoxuX3Ts Rza2jLsP4AK8mPohF+jyZeR42P6gwujx7wWKhMTblaaxNVyyEEOBD69GN2xmaT9MTvDWit iMU15utuLqq9OS+JYUPU5LxVEPM254Q= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-F7be4wlaMqKnnzPPauAe0Q-1; Thu, 24 Jun 2021 17:17:52 -0400 X-MC-Unique: F7be4wlaMqKnnzPPauAe0Q-1 Received: by mail-oo1-f70.google.com with SMTP id q3-20020a4aa3030000b029024b18087470so4514816ool.5 for ; Thu, 24 Jun 2021 14:17:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=06yao2CDsis15QoJOXCwwfY4/53M6JaTIu7lUfBh14M=; b=oQ+MDTZCgqBMCls3a4/as6jmURujxkMCgbB9U8wD18ClEPOp/667Pl4+dKHkaxmA4D sOoLZjbhrvIBz4OiOwHWd7aNFa3b9lEEQKcac8AS0O68NBg6xJvwqMf4yxctR2g4nCiq kExz0izqX6GoT71WQMhtzwf6EaHRZSanrKmpbJkV1+7H4KGsxcf2dvBHjvlfmOhKeCcO MRKzYl65XuWjXE+x7zA6pUfn8Tz4nKeOMXJ2eFq2+fIis18Fp+rhhoZFWIc+edArit31 vsjZefgg3sPe+3IxeMmvKVQ7SuRTJtoMXVmqAIcIfU8VoZRGdxTurhXeMu0I1Oz3QGq+ YC6A== X-Gm-Message-State: AOAM530qWYf0vy2OPj2TQvN7wh73xU+i2YvIV3fVo48XqVXPftr4HQfJ En0sOhSe/swc24e5Jrp9q4kchg8gR7lzjZVVnFWtyvq6V0BPb2KzKfC1pgrPx3ZK/bfN2VzPa7Q 1t0WK7NS7wzxxBN0KL41eXg== X-Received: by 2002:a4a:41d2:: with SMTP id x201mr2732000ooa.35.1624569471624; Thu, 24 Jun 2021 14:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwipQ+FG1zdbSHi5cUqqClnF72jO5dbxM0s0OMGyT/NJe/wW8gpvlxwYtX9N8bXPmn34b+0Kg== X-Received: by 2002:a4a:41d2:: with SMTP id x201mr2731989ooa.35.1624569471466; Thu, 24 Jun 2021 14:17:51 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 94sm915513otj.33.2021.06.24.14.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 14:17:49 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, hao.wu@intel.com, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 2/5] fpga: add FPGA_MGR_REIMAGE flag Date: Thu, 24 Jun 2021 14:17:24 -0700 Message-Id: <20210624211727.501019-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210624211727.501019-1-trix@redhat.com> References: <20210624211727.501019-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix If this flag is set the reimage ops will be used otherwise the reconfig ops will be used to write the image Signed-off-by: Tom Rix --- include/linux/fpga/fpga-mgr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 53f9402d6aa17..0791e22b07f88 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -67,12 +67,15 @@ enum fpga_mgr_states { * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first * * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed + * + * %FPGA_MGR_REIMAGE: Reimage the whole card, fpga bs and other device fw */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) #define FPGA_MGR_EXTERNAL_CONFIG BIT(1) #define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2) #define FPGA_MGR_BITSTREAM_LSB_FIRST BIT(3) #define FPGA_MGR_COMPRESSED_BITSTREAM BIT(4) +#define FPGA_MGR_REIMAGE BIT(5) /** * struct fpga_image_info - information specific to an FPGA image From patchwork Thu Jun 24 21:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12343249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A67C8C49EA5 for ; Thu, 24 Jun 2021 21:18:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 872C1613D6 for ; Thu, 24 Jun 2021 21:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbhFXVUU (ORCPT ); Thu, 24 Jun 2021 17:20:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25208 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232695AbhFXVUR (ORCPT ); Thu, 24 Jun 2021 17:20:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569477; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dvny/Z8JO1gF6YOzXRWiGKmJY7imlNZkUp/yYJtEF1w=; b=BAxadA1F2y3ExErYQJ1QD5DPg17hQB/qmkOl52gtkLGaZAKkyiRb0ihnPbvnYJiAaWeFv9 c4vojHAF9p21UgVzppM7CxnZARDzs/psZcQE9j+lIh9KGlaUdbbJ2gvlMfj+dohtH49czr kH5JZ+FQri1Lcu6LHyCBZ/Mxv/EGfQs= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-108--rbVrmE3PnGh123xFO-TyA-1; Thu, 24 Jun 2021 17:17:56 -0400 X-MC-Unique: -rbVrmE3PnGh123xFO-TyA-1 Received: by mail-ot1-f69.google.com with SMTP id e24-20020a9d63d80000b029045ea018532dso4297544otl.9 for ; Thu, 24 Jun 2021 14:17:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dvny/Z8JO1gF6YOzXRWiGKmJY7imlNZkUp/yYJtEF1w=; b=LXm/AhYwKstbb+9kTUu/PXklk0kRc+QURXse3dwIGaKw6fP+i2YSKY31WXnmJtQKmQ EQmcXGLKA5HET49Csp2FPDjBDv0d8EN/XkrpHBb/rF5cDSlkfDxbZPy3spOb1J8C4yLo zJ6A1rDn21wuLic4y0fvYRI/00HmawfSmJCxxA5D9Q9A3TD7lchBYPEHpQRojDIEBstI GLvBCceGV1ui4UEF9H66vnwP1+uUBNcdbSNJgEQ46Df7UtHSqlplXHBGhmeWP1Vwlnru ewAnSjd8297vc9rW7kiEHXSR7069PfAtOdoO6S91n3q81YsjSqqRlfvrbWWdK3AWu7/N d1IQ== X-Gm-Message-State: AOAM532red0NaSGWBJ9la844JfKN0qRYYwJY6xvPUGFrw6OWiqghZb4s jaakrPEvmZ09jVDwG0bYs0zSpXSgitLQPB0Neu5X003q+Pz9IziTxwkXwIwwVdpbJ0p+wikrzib p4FyToT5d8LBgStFRmrF2mA== X-Received: by 2002:a05:6830:1598:: with SMTP id i24mr6482135otr.52.1624569475275; Thu, 24 Jun 2021 14:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIAj1zRYvZi/2zh/ImgA6QnOGx0FLivp52DXK6MEzD+rDyJnMSz3qaflcHdOfoIDyNuEYFJA== X-Received: by 2002:a05:6830:1598:: with SMTP id i24mr6482115otr.52.1624569475077; Thu, 24 Jun 2021 14:17:55 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 94sm915513otj.33.2021.06.24.14.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 14:17:54 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, hao.wu@intel.com, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 3/5] fpga: pass fpga_manager_update_ops to the fpga_manager_write functions Date: Thu, 24 Jun 2021 14:17:25 -0700 Message-Id: <20210624211727.501019-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210624211727.501019-1-trix@redhat.com> References: <20210624211727.501019-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix Refactor fpga_manager_write* functions for reimaging, pass the update_ops as a parameter. Continue the passing of the update_ops to the write wrapper functions. Only do the reconfig ops. Add a wrapper for write_sg, so the update ops are handled consistently. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 94 ++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 35 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 9d17779cac7e3..a785b7dc5dba0 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -42,17 +42,29 @@ static inline u64 fpga_mgr_status(struct fpga_manager *mgr) static inline int fpga_mgr_write_init(struct fpga_manager *mgr, struct fpga_image_info *info, - const char *buf, size_t count) + const char *buf, size_t count, + const struct fpga_manager_update_ops *uops) { - if (mgr->mops && mgr->mops->reconfig.write_init) - return mgr->mops->reconfig.write_init(mgr, info, buf, count); + if (uops && uops->write_init) + return uops->write_init(mgr, info, buf, count); return 0; } -static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +static inline int fpga_mgr_write(struct fpga_manager *mgr, + const char *buf, size_t count, + const struct fpga_manager_update_ops *uops) { - if (mgr->mops && mgr->mops->reconfig.write) - return mgr->mops->reconfig.write(mgr, buf, count); + if (uops && uops->write) + return uops->write(mgr, buf, count); + return -EOPNOTSUPP; +} + +static inline int fpga_mgr_write_sg(struct fpga_manager *mgr, + struct sg_table *sgt, + const struct fpga_manager_update_ops *uops) +{ + if (uops && uops->write_sg) + return uops->write_sg(mgr, sgt); return -EOPNOTSUPP; } @@ -61,13 +73,14 @@ static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size * finish and set the FPGA into operating mode. */ static inline int fpga_mgr_write_complete(struct fpga_manager *mgr, - struct fpga_image_info *info) + struct fpga_image_info *info, + const struct fpga_manager_update_ops *uops) { int ret = 0; mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - if (mgr->mops && mgr->mops->reconfig.write_complete) - ret = mgr->mops->reconfig.write_complete(mgr, info); + if (uops && uops->write_complete) + ret = uops->write_complete(mgr, info); if (ret) { dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; @@ -136,16 +149,17 @@ EXPORT_SYMBOL_GPL(fpga_image_info_free); */ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr, struct fpga_image_info *info, - const char *buf, size_t count) + const char *buf, size_t count, + const struct fpga_manager_update_ops *uops) { int ret; mgr->state = FPGA_MGR_STATE_WRITE_INIT; if (!mgr->mops->initial_header_size) - ret = fpga_mgr_write_init(mgr, info, NULL, 0); + ret = fpga_mgr_write_init(mgr, info, NULL, 0, uops); else ret = fpga_mgr_write_init( - mgr, info, buf, min(mgr->mops->initial_header_size, count)); + mgr, info, buf, min(mgr->mops->initial_header_size, count), uops); if (ret) { dev_err(&mgr->dev, "Error preparing FPGA for writing\n"); @@ -158,7 +172,8 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr, static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, struct fpga_image_info *info, - struct sg_table *sgt) + struct sg_table *sgt, + const struct fpga_manager_update_ops *uops) { struct sg_mapping_iter miter; size_t len; @@ -166,7 +181,7 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, int ret; if (!mgr->mops->initial_header_size) - return fpga_mgr_write_init_buf(mgr, info, NULL, 0); + return fpga_mgr_write_init_buf(mgr, info, NULL, 0, uops); /* * First try to use miter to map the first fragment to access the @@ -176,7 +191,7 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, if (sg_miter_next(&miter) && miter.length >= mgr->mops->initial_header_size) { ret = fpga_mgr_write_init_buf(mgr, info, miter.addr, - miter.length); + miter.length, uops); sg_miter_stop(&miter); return ret; } @@ -189,7 +204,7 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, len = sg_copy_to_buffer(sgt->sgl, sgt->nents, buf, mgr->mops->initial_header_size); - ret = fpga_mgr_write_init_buf(mgr, info, buf, len); + ret = fpga_mgr_write_init_buf(mgr, info, buf, len, uops); kfree(buf); @@ -201,6 +216,7 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, * @mgr: fpga manager * @info: fpga image specific information * @sgt: scatterlist table + * @uops: which update ops to use * * Step the low level fpga manager through the device-specific steps of getting * an FPGA ready to be configured, writing the image to it, then doing whatever @@ -215,24 +231,25 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, */ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, struct fpga_image_info *info, - struct sg_table *sgt) + struct sg_table *sgt, + const struct fpga_manager_update_ops *uops) { int ret; - ret = fpga_mgr_write_init_sg(mgr, info, sgt); + ret = fpga_mgr_write_init_sg(mgr, info, sgt, uops); if (ret) return ret; /* Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; - if (mgr->mops->reconfig.write_sg) { - ret = mgr->mops->reconfig.write_sg(mgr, sgt); + if (uops->write_sg) { + ret = fpga_mgr_write_sg(mgr, sgt, uops); } else { struct sg_mapping_iter miter; sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG); while (sg_miter_next(&miter)) { - ret = fpga_mgr_write(mgr, miter.addr, miter.length); + ret = fpga_mgr_write(mgr, miter.addr, miter.length, uops); if (ret) break; } @@ -245,16 +262,17 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, return ret; } - return fpga_mgr_write_complete(mgr, info); + return fpga_mgr_write_complete(mgr, info, uops); } static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, struct fpga_image_info *info, - const char *buf, size_t count) + const char *buf, size_t count, + const struct fpga_manager_update_ops *uops) { int ret; - ret = fpga_mgr_write_init_buf(mgr, info, buf, count); + ret = fpga_mgr_write_init_buf(mgr, info, buf, count, uops); if (ret) return ret; @@ -262,14 +280,14 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, * Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; - ret = fpga_mgr_write(mgr, buf, count); + ret = fpga_mgr_write(mgr, buf, count, uops); if (ret) { dev_err(&mgr->dev, "Error while writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_ERR; return ret; } - return fpga_mgr_write_complete(mgr, info); + return fpga_mgr_write_complete(mgr, info, uops); } /** @@ -278,6 +296,7 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, * @info: fpga image info * @buf: buffer contain fpga image * @count: byte count of buf + * @uops: which update ops to use * * Step the low level fpga manager through the device-specific steps of getting * an FPGA ready to be configured, writing the image to it, then doing whatever @@ -288,7 +307,8 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, */ static int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, - const char *buf, size_t count) + const char *buf, size_t count, + const struct fpga_manager_update_ops *uops) { struct page **pages; struct sg_table sgt; @@ -302,8 +322,8 @@ static int fpga_mgr_buf_load(struct fpga_manager *mgr, * contiguous kernel buffer and the driver doesn't require SG, non-SG * drivers will still work on the slow path. */ - if (mgr->mops->reconfig.write) - return fpga_mgr_buf_load_mapped(mgr, info, buf, count); + if (uops && uops->write) + return fpga_mgr_buf_load_mapped(mgr, info, buf, count, uops); /* * Convert the linear kernel pointer into a sg_table of pages for use @@ -338,7 +358,7 @@ static int fpga_mgr_buf_load(struct fpga_manager *mgr, if (rc) return rc; - rc = fpga_mgr_buf_load_sg(mgr, info, &sgt); + rc = fpga_mgr_buf_load_sg(mgr, info, &sgt, uops); sg_free_table(&sgt); return rc; @@ -349,6 +369,7 @@ static int fpga_mgr_buf_load(struct fpga_manager *mgr, * @mgr: fpga manager * @info: fpga image specific information * @image_name: name of image file on the firmware search path + * @uops: which update ops to use * * Request an FPGA image using the firmware class, then write out to the FPGA. * Update the state before each step to provide info on what step failed if @@ -360,7 +381,8 @@ static int fpga_mgr_buf_load(struct fpga_manager *mgr, */ static int fpga_mgr_firmware_load(struct fpga_manager *mgr, struct fpga_image_info *info, - const char *image_name) + const char *image_name, + const struct fpga_manager_update_ops *uops) { struct device *dev = &mgr->dev; const struct firmware *fw; @@ -377,7 +399,7 @@ static int fpga_mgr_firmware_load(struct fpga_manager *mgr, return ret; } - ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size); + ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size, uops); release_firmware(fw); @@ -396,12 +418,14 @@ static int fpga_mgr_firmware_load(struct fpga_manager *mgr, */ int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info) { + const struct fpga_manager_update_ops *uops = &mgr->mops->reconfig; + if (info->sgt) - return fpga_mgr_buf_load_sg(mgr, info, info->sgt); + return fpga_mgr_buf_load_sg(mgr, info, info->sgt, uops); if (info->buf && info->count) - return fpga_mgr_buf_load(mgr, info, info->buf, info->count); + return fpga_mgr_buf_load(mgr, info, info->buf, info->count, uops); if (info->firmware_name) - return fpga_mgr_firmware_load(mgr, info, info->firmware_name); + return fpga_mgr_firmware_load(mgr, info, info->firmware_name, uops); return -EINVAL; } EXPORT_SYMBOL_GPL(fpga_mgr_load); From patchwork Thu Jun 24 21:17:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12343247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA880C49EA7 for ; Thu, 24 Jun 2021 21:18:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2275613D6 for ; Thu, 24 Jun 2021 21:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbhFXVUW (ORCPT ); Thu, 24 Jun 2021 17:20:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28789 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbhFXVUU (ORCPT ); Thu, 24 Jun 2021 17:20:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mFedRc0xrO8oseMlvLubEPJS4VuKtnhUf95dNVhDdKc=; b=RCb9gVyh1IFz5l+P9UsIv88Jbt+0dSBZV9nUMxObyupZ2CKWYCdGv6sgOcZtHt1lW3vTMV R1RhrHBFxB5FAN/F9Z+v6+ykfY6PkYu76XcYHSEfSTe5jojwk7NeSO1GLvHkwSDk+DjmrH zzY/+XK2QBlJFz3crujbXWFc0QAk11o= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-93-292cKPmQOquz-YKJIl7qAw-1; Thu, 24 Jun 2021 17:17:58 -0400 X-MC-Unique: 292cKPmQOquz-YKJIl7qAw-1 Received: by mail-ot1-f69.google.com with SMTP id y21-20020a0568301d95b029044f7b7f3047so4281391oti.5 for ; Thu, 24 Jun 2021 14:17:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mFedRc0xrO8oseMlvLubEPJS4VuKtnhUf95dNVhDdKc=; b=psmu6gfhVZdOv2KqBCexa93H9f2i4ixSxMdLc6JbcYQZl0pV164IJSmIDrNbVQvQDs 2dSMm1Gi9LHnXXDCNapISzS9+CwJxu/mJiZ5LeC4qgfsoE7MDHxNgj1Deg3A1T01W1TM 63FML4YlJg8mFMOMtPbL5dmeE17gPKRtos+tErZxWXhhSQByho7vGQhxtYDkcljGeX6H skEADeWd4dKqdOvwiEGxVDziNsY4kvJnbniob8Pa92MnG2w+z8HPygN/ewBBgCVwz3va +Emfr8ohpdHNWH8G1JVwBMIxSMS4EkYJnHflEOm+WZv3Ume8eMBOZkY99S1NVFEB9Bqm m8Ig== X-Gm-Message-State: AOAM532FOd+HDkHVzoQATOa0gdgq6P+pSgOlXn0qTwxk9G0NNunMEekI yht77IkOtjxzgjK39pTUg5qMZe3/olox0VZdOXp2ltXEGsIfWOAju8gbwxR93bNxpvLRkiOPB5a Mun+ErTGrSlvRExSzRu3z8A== X-Received: by 2002:a05:6830:1ac4:: with SMTP id r4mr6259372otc.36.1624569478212; Thu, 24 Jun 2021 14:17:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymkYtjbDACtIBCrlWJa04+yJJF5DcY75EP2JsqstF7I/shhvTHBjE5r+wDrfOsOzapIRL9Aw== X-Received: by 2002:a05:6830:1ac4:: with SMTP id r4mr6259359otc.36.1624569478058; Thu, 24 Jun 2021 14:17:58 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 94sm915513otj.33.2021.06.24.14.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 14:17:57 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, hao.wu@intel.com, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 4/5] fpga: use reimage ops in fpga_mgr_load() Date: Thu, 24 Jun 2021 14:17:26 -0700 Message-Id: <20210624211727.501019-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210624211727.501019-1-trix@redhat.com> References: <20210624211727.501019-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix If the fpga_image_info flags FPGA_MGR_REIMAGE bit is set swap out the reconfig ops for the reimage ops and do the load. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index a785b7dc5dba0..2abb7043858dc 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -420,6 +420,9 @@ int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info) { const struct fpga_manager_update_ops *uops = &mgr->mops->reconfig; + if (info->flags & FPGA_MGR_REIMAGE) + uops = &mgr->mops->reimage; + if (info->sgt) return fpga_mgr_buf_load_sg(mgr, info, info->sgt, uops); if (info->buf && info->count) From patchwork Thu Jun 24 21:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12343251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 184C1C49EA6 for ; Thu, 24 Jun 2021 21:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05848613CB for ; Thu, 24 Jun 2021 21:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232760AbhFXVU1 (ORCPT ); Thu, 24 Jun 2021 17:20:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36197 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232732AbhFXVU0 (ORCPT ); Thu, 24 Jun 2021 17:20:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEL5AZ4mSr0YqB6XpyjJsxT+Qv98DMEzNJZysot2Lnw=; b=ZwiE+HjbygU4UT7UJqDB+kuXKYSD0docsyNbPgzNRfuNoEbFAfrMJs1t8qLaMhxfAdpcEk 7ZdVQR6JUrixw/0CuD0qJG7RdAFClzkKc+VrU75Z5Bv9RluteZf7mTR9FN4AU3Lo854Q4E ncN1GTGXg1Sv1dcM9TGcFBZtCvtDRZE= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-8QNwk_Y_Mjyi-l_2TlV2DQ-1; Thu, 24 Jun 2021 17:18:02 -0400 X-MC-Unique: 8QNwk_Y_Mjyi-l_2TlV2DQ-1 Received: by mail-oi1-f197.google.com with SMTP id v142-20020acaac940000b02901f80189ca30so4543546oie.22 for ; Thu, 24 Jun 2021 14:18:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QEL5AZ4mSr0YqB6XpyjJsxT+Qv98DMEzNJZysot2Lnw=; b=WMbL0BWJ94Vzk+yarMntFHTMQfvij80+S4mrmSIzXGPGIc3iks4fcVywv1xY4LdwWM XqM6xvhceKrS5v9nwpL781J7PRYAsTwFSImyLZ5Ef6Oqqd6JrbvCA/hGkCb35Jvz3UxP HVddh7NHUqvvLjLRTDbDpD9yTgwRwaVattg5Jbd/J8CfujcThu6ry/Povh/kmNfyu9il fRAcyOfitfyJVxC6fou7zGpCQlmJPqDygKYf7eS5VCqPOOSwwuZgYgodd5G/F2zil1yK nbCiJ9zHzn6v6Uk4bsVtwXceniIhLvb6Lk7SVBM0KaHhlDyffJYltwKKfgijDFbFAF2g KOoA== X-Gm-Message-State: AOAM531EH/nCeZM28DQRow2rPgpsFX7HAFmUBx7Gdfuy9afJRVIQMtw6 cwbYTYwdRmPYHpP3CvRdP/Zx63qg0mJbBuf8bevy3SrAfLOpTdnrhMmom2WJszu4hBa8rutkymd icV0xDdoAkoJccm7LBWWjGA== X-Received: by 2002:a05:6830:270b:: with SMTP id j11mr6370723otu.161.1624569481796; Thu, 24 Jun 2021 14:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOtcE8iHvqrMnsAhoUJeiWnBz2O5EA2IJu/b1p2L7kvKl5sId+fviItFlU87dzuMw8Y+u/bg== X-Received: by 2002:a05:6830:270b:: with SMTP id j11mr6370708otu.161.1624569481664; Thu, 24 Jun 2021 14:18:01 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 94sm915513otj.33.2021.06.24.14.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 14:18:00 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, hao.wu@intel.com, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 5/5] fpga: fpga-mgr: simplify mops check in wrappers Date: Thu, 24 Jun 2021 14:17:27 -0700 Message-Id: <20210624211727.501019-7-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210624211727.501019-1-trix@redhat.com> References: <20210624211727.501019-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The mops value is checked in fpga_mgr_create, do not check it twice. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 2abb7043858dc..21b4fd34b1dbf 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -28,14 +28,14 @@ struct fpga_mgr_devres { /* mops wrappers */ static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) { - if (mgr->mops && mgr->mops->state) + if (mgr->mops->state) return mgr->mops->state(mgr); return FPGA_MGR_STATE_UNKNOWN; } static inline u64 fpga_mgr_status(struct fpga_manager *mgr) { - if (mgr->mops && mgr->mops->status) + if (mgr->mops->status) return mgr->mops->status(mgr); return 0; } @@ -93,7 +93,7 @@ static inline int fpga_mgr_write_complete(struct fpga_manager *mgr, static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr) { - if (mgr->mops && mgr->mops->fpga_remove) + if (mgr->mops->fpga_remove) mgr->mops->fpga_remove(mgr); }