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: 12343231 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 3035BC49EA6 for ; Thu, 24 Jun 2021 21:19:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E9F166124C for ; Thu, 24 Jun 2021 21:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9F166124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GGo2bnJfTEqSRw9qE+6AM1/ZE7fCeTfTfPjFUreYxek=; b=RoEIleWi7zb7mj K93SYQqXnUFHJkAwCeespqaDHQ7PzF7z8a8Qvx6ELdAKsJHTUa6XI7GeS+jCG42YMvSJRS+jdX8mg agUbpYZNBodFOYVW6kg3/8Mj3CA+hrU3XK/3MMOhM9dUOFFVJhqd7O5cPf6rN7l62fZU9BkZHp30a YVMEVBxG2P2zvSSyAw7eyql5SpP0jpdF+pTrAcVUEHs+yT0yAP3USnVG2BdzzaF8pmVVtBk+Say/j JtcUHnZ+egNhlBSnCXfqwVZQdhvJliC3flKSWP+0J50j3MLPLgCsMcU+F0A2WB93o+FQmryDo8kQs gBsIHR9pKYHUozWXJPIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjV-00GKEj-O6; Thu, 24 Jun 2021 21:17:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjQ-00GKDI-93 for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 21:17:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PriZzvosAz19zM08cUettXNufWgy2eBON80n4DDrzSo=; b=XNId9+1dD/yeW/0HdWVaSNThXuW9gmEAVYFYfayGwXfN+I+m34zEhiUDNwhzHlmNG0am/4 Qr6TvMOVv89vNOVl7KsT/bgr3D73z+RaxX2cVTm0QIVtNor7RGS3JXSNMtzLEnsZtz1pDb ckfkFfIJb13w6y1TiRmsvnmmnyLHaO8= 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-309-aE0mewnFPpWi-LBJRVfH0Q-1; Thu, 24 Jun 2021 17:17:50 -0400 X-MC-Unique: aE0mewnFPpWi-LBJRVfH0Q-1 Received: by mail-ot1-f69.google.com with SMTP id l13-20020a9d734d0000b02903db3d2b53faso4268976otk.6 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=nKrVQPFiaIQa86dSG/qOB4105nUY72EhVDRHVbr+ogiSFTHejoxLou9cNe/0WWpT3N sFEfrr7CQM1uojdKsNqNzuq2oy+7T5Bz/R8DsP3nrPQNNiaOCo51xn+Q2VKAafqQvqyF dh4vWWBytbACtQLPQRdA7URYmevUn9AQv586FCP9oNh9ljmrTH1jo9JBJQgErvW0bZZZ 6G1UyT9DXv5Q5otUBQrLbYo+gC73zMsNpmwjZWyLH20ZIz5aEWtLxGXBLAWUxWsa7wf+ TEwYwHPbOdde87fljZGJAodhDyRa9h6m9iLEdmDYwzPt2fSAFQ/W+bIGSE0kPNbmYanp KEUw== X-Gm-Message-State: AOAM530zr1RsgXM7ExPzKuHLY3N5O7ZeLvvwXcVR0RlGVKx3SzLOYp4E NWzDi7y1+U2dWrsLVG1LGpVvtSfV3dHgrZGzYoGJZIvZAUxOmgPn9FmYZPzsahkicTPGqt8TC/2 HrPoyQD/mqgrF/Q3FOzHGYjXv50UN5c2E1cU= X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr5594670oic.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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_141752_555585_7AD2D3AA X-CRM114-Status: GOOD ( 20.39 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: 12343233 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 55AE0C49EA7 for ; Thu, 24 Jun 2021 21:19:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 19F2C6008E for ; Thu, 24 Jun 2021 21:19:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19F2C6008E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iQIsmL2MK/XIQxvjZ76gh3vNpaqeE4F1qGDm6lnmuSo=; b=p8fgrX2D2kBdzU ce1kCMZfvkId91chWbOao89JyB8RVb6qxIusz81D5R9AdmGShADHvCLrf8ImwO7qqQADK85ZMO3YH RsPPohNIeb7e+KjkyZ/UDBtm3wYR+izMXoCPB4HXGfLikp5oRIqn6ho8YLWl40qKPlWAsMNdVH0Pq flMS39YZTjqVAZiCYtoge51k8LjYzYbhltojepxpnv8Zex7U2A5yTxxhDJvAuvf4Bn8UooNU8NjA+ riA52S4ho3NzU9bNBLKkXpsyWxsm9Q6eyJlhLuEtqJCYK532a37eZfuG7hVIhAUEcM0f7Mghzm6x4 ITV1mEMMjxyxe/Q9gsyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjk-00GKHz-LH; Thu, 24 Jun 2021 21:18:12 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjS-00GKE3-Fj for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 21:17:55 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=06yao2CDsis15QoJOXCwwfY4/53M6JaTIu7lUfBh14M=; b=KpvgPGdiue1bDNDyFY+EDTzLkySKJLSWih1DBzl0rno8LLGy1pA44O1Z2ZI/1k5JeG5jP8 wpKcDd6I6KCSU60308AA1T0kgqfs0lAHx6K9X2Q0vU3wCtTanzpuM0BFHlWCNqxE3TDLJf sJc43dEJ2h6c5gevAOBzq2WYbPaq44Q= 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-274-lMR4HX1ZMfyoaFDrh-22aA-1; Thu, 24 Jun 2021 17:17:52 -0400 X-MC-Unique: lMR4HX1ZMfyoaFDrh-22aA-1 Received: by mail-oi1-f197.google.com with SMTP id b12-20020a056808010cb029021dde407eb3so4593264oie.13 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=FkLUsdC4HIuKXmZP9281lpw3Jgyq0o8m+esLckDQJVdXoZMZlh1d5RUHGAA8eTMhYO I1JazF6QFre+9fl1m0hEyx+IQ3DFxOmLPkdXjpNa5AQsz49MlsgxdacU1U/8+DoFN6vm eZcimC5p8WUCM+sFSWDK0ERseEGc0ukmJ66Ime/FLLVt7kJ7ywW/BkHYzVbgGoRJNrZu EMDq/qjmRKj8Pls3sR3DB2QzeVG6rF1v//dZfMWxHKmNPg84o/rLPvZvyuNlbMnScqKM h0o09RjZ0kqbOJZJ+sZRAOQsxgxJy3OdyTnl6ifHLOlu1Gb1TSvZXS67t8FPyIiS7d55 XImw== X-Gm-Message-State: AOAM5305RyKB1xoKuomC0vXff8nCnr559iR6fPdcDC5ECEsy28rpFG8E g3mbZ29gUjcswIw5+gAcri4NW293K5M3S84AvnGS681cX5n/RJYSsDqxBmJczfAkXgT9Jz1GMPZ T2pjMwCnIXR48FNxF2Knb4kGmBdT1GjRDYZw= X-Received: by 2002:a4a:41d2:: with SMTP id x201mr2732003ooa.35.1624569471625; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_141754_631356_301E72A0 X-CRM114-Status: GOOD ( 10.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: 12343235 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 6DA10C49EA6 for ; Thu, 24 Jun 2021 21:20:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 31A986008E for ; Thu, 24 Jun 2021 21:20:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31A986008E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tcfV3l3qKiPIDcySBa1+Q9o20KtlUq+PRH9TGneHTOc=; b=O5VrQ+mrBoU90y dDxnoHik2Mtqx2f/zhdAv0MuhaIIDBjqnGJdUC0HLUKDSnjNrdGIK7cjcU79c1RPUDVG4RdVC9zHS UxJDM2A4/DBnkgNEWYibIBCKbU/J/+albzfcuvKjrhl5sl1xjlAeZRfJuBabr+EnuZnhMoQSZP+DR xQV6gdOahsQQC4ZdEwAUMbeG57NR4dx/9HOGLyVO03zX65lUzHahRkB9jueVkIJib8ejYQmkwakkm XibG9XKI0ORvDiQ05HrpecOmy5NRA7Ny0dWRQCpJ9HbzaYS9igFu6Pgvvg437nZe/KZLycyPMLdLI t7dBVKVPFO9FP+eQe5LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWk1-00GKNM-Eb; Thu, 24 Jun 2021 21:18:29 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjW-00GKEq-Eg for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 21:18:00 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dvny/Z8JO1gF6YOzXRWiGKmJY7imlNZkUp/yYJtEF1w=; b=AXhqKCe6fc5DqbrKRd4qrcsQ+fued4adUVBSRGwdtaZM37scS4rvPtY2cOVjUEE8fWBRrC tEYidG3eCRJj0jD/Ofj5VKPsIi3XJizDlRIFm7GhoxdNT12NoJFdL/W6FEwofHKVkDPalU pKKM8SwUzb4GyWLwflKrD2227PwjPnY= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-kJB2bhF0PryaeLteh4o1QQ-1; Thu, 24 Jun 2021 17:17:56 -0400 X-MC-Unique: kJB2bhF0PryaeLteh4o1QQ-1 Received: by mail-ot1-f72.google.com with SMTP id y21-20020a0568301d95b029044f7b7f3047so4281302oti.5 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=NbPaQW9EIBSEbI2jDvv1HXlB5DNkGdyPEqA7YsJ400lpb3atW0jwxsnXIyzVAdVGL+ lxJ7BCQlnroQuuNdH21J6D9rgWsNEcs56bMDDAR8X+LoLfBDcAckkGBZSPiumgBe2MRK e7cTj8KHrOA5sJLCuyOLCckbjiJbF/4f8KNW69yt0vHaYMwetWJrGERbfmxMB8KM+Lkl fOE76qbRsXPMm1DtYBiRTJG4lY0z5ge0Lq9T0ccbdd/xqDcmpghp+f33AOg4hzoMrJ7M 3RJwHTAI6Iyn2Rc+meHJWY2gfDbKBtYGfOghDWYTOlI5sH6eTrYTAxilrsoTvyBRZpV0 Ot3Q== X-Gm-Message-State: AOAM530v/O9MkxeAwVe3L9p4ATkU/+1dkFowdt739PoPQI4lg4QyJXhv 1Zx2Ed2872fVrOQgxIOJnVaqRaxvSsaWQArjQiVoOEYZaQ569mJF7tNMsqXkONdoRS7Wcn9Hfqs I8QpTnm9BQhCqbUXCxpnZYn1+B555BBdvqYA= X-Received: by 2002:a05:6830:1598:: with SMTP id i24mr6482133otr.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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_141758_648230_0F6A2ECA X-CRM114-Status: GOOD ( 21.35 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: 12343237 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 B0B2DC49EA5 for ; Thu, 24 Jun 2021 21:20:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8164B6124C for ; Thu, 24 Jun 2021 21:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8164B6124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qh2n9SpgWp8yAaV1vUH4cG9R42RVDwINZj5Tf6ZYHsc=; b=OvNTtu6DJTUkS5 2FNsT0TNiAb+YPFp+m/hWNBN2/9ZFnihKN96RZeTB9zYmLyMy8mHXyU5oKEGZs+xTkQKDSKzKRRfk 6+GE6Luy0F1l97Qx+LZzAkBKEhmaA9hxrla4Byzs2nrC3FG4afxlkQsLh1qXP/vpH7Kju5WzzPwn7 0Q1ZGQ7v/Qe8S6LnSU7UiTYOXTJOKvKnAPhSAphyXMOCLmVjhQmLbS/ycWjLTONeCTGOBOGbQrrAf udE0JTlmMDIBGoLcIMEOTWBPuY3+vwhyEQXIqHkwgz2P00XaLvoKk5kcUsMKg8j9mWfln6JZEq/NR Ts7FD9EhyjMVBFFikgHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWkG-00GKRx-Pz; Thu, 24 Jun 2021 21:18:45 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjZ-00GKFU-B3 for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 21:18:02 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mFedRc0xrO8oseMlvLubEPJS4VuKtnhUf95dNVhDdKc=; b=DJosz9AfAWcPgU5QKwPKTSvpUXqhoWjjerYuJvhII0xwXug3vP0TFyldyTYQcElIuSddPk MGNHYeA19xSKwIwdE/HiDvychICTkVi2x5rF4fK2emCCYIaIsiIda3UjjOFXmAbmL1VIP5 kN71W3yizSzMMfzFpuQAuR+MLuQ0X6w= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-rgWcumQuP3afppt13QXc5w-1; Thu, 24 Jun 2021 17:17:58 -0400 X-MC-Unique: rgWcumQuP3afppt13QXc5w-1 Received: by mail-ot1-f71.google.com with SMTP id y6-20020a9d51860000b029046100bd0f34so1594912otg.22 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=PaVgr89YzbhDVTXK3jw4YBzt4udLUiiFTBnVRzaZp/LLOQ3zcCL7bID9oQO6lumdU5 FgHeb37yH9vAnWosSqxlGccaIY7xgMzlnwx+PkWymnCLodF0Xoj02GDBpQi9BSXut04S M95vsPy9E2nYSvVbKxH8liJ9RNTy4t/3AD9dsy9KwysJzEAcxwS8YRT4cWnqzA5grMu9 /sBxJ8elujuMDjWyKoN5yf0btOcld6urZIcJ+yoRkC+vBeevjfnKH0NMaLK6Dlz0WL7y 9AZF6cOLL2rOOdcN2S3S7vHqOXYfhN4iscnUGX4cFPHjAJIGuYQ6GcbFycZMbRRPjUI7 IELw== X-Gm-Message-State: AOAM530fhkcgpmMpEHJhzTgXS1OV268UR8w+jHqsc4W6iNQMEuterj4O +ws4QVTjykG2xsQgCH90OZ+FMNDsNPIfNyJllP7xbE+jyfquPrTvzSBoEkvqCcDrOXCm4tU8RSp Fx95II1TpelvkQ9woxT/eIzkhyDiQSrRD6cg= X-Received: by 2002:a05:6830:1ac4:: with SMTP id r4mr6259373otc.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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_141801_526647_8592CCDE X-CRM114-Status: GOOD ( 10.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: 12343239 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 4543EC49EA7 for ; Thu, 24 Jun 2021 21:20:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 144BC6124C for ; Thu, 24 Jun 2021 21:20:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 144BC6124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u9HotZu8McZpQT9QqC26bY3LlNf3RgzuhbAEGUTPecI=; b=uCYfthEdyQ6HvV i7h/3Bd7nUI3s6v2k8CLwHglvVdBZ+NxIgbuNtJTwidyXCPiUXSJh2jQNTjMGkl2WXKgEVbpg0+v5 8KT5ClzdFOqH0kNLoO8SBKRUh++SnCQs4gFwHKafED0nKroBU+T5prK54UvSI51G7WSjRRjQPDHc6 uVNBRKF6B2WC1SV+S1rhbRiP6ROsdD4gbXiqww1k+9+MEamnnjHPoskWFjChDQj/B7Kbua/h5rUH0 J2v1lhrqcFR6pM8AEZVwnGnLRJz81EUrsm1m0eFrTaIJl3mJQWYVEZc8ynlariOhhSfaMSSDKPLuw +p2qh0F9RJmDF/f7sVVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWkc-00GKZN-AM; Thu, 24 Jun 2021 21:19:06 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwWjd-00GKGG-0m for linux-arm-kernel@lists.infradead.org; Thu, 24 Jun 2021 21:18:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624569484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEL5AZ4mSr0YqB6XpyjJsxT+Qv98DMEzNJZysot2Lnw=; b=FgrcBf7+4gMaY1yGRHkR3kahGHrU+WUqho8AtpqyHizIHHG3JiG2859paaC3Ts7ng7qvpW HY+q/f1uSFa1sypHEBw0ZlEuUU+Fm3En89kme8/WJMfIuFCcAoim7mOe4/BLP+YZ4utm4n Y+saZwxRNWG2i8scZ5SaAQkILW0veRE= 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-587-aE8DJZCaPGqefFbHe_DGgw-1; Thu, 24 Jun 2021 17:18:02 -0400 X-MC-Unique: aE8DJZCaPGqefFbHe_DGgw-1 Received: by mail-oi1-f197.google.com with SMTP id z18-20020a0568080652b029022413cd7d4dso4581626oih.11 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=kfV6z1IPA10bMPtd6kbM5MNS+I8HscyCk7Uj//dpZTGRgx+Kk+bnlKDXNrpsL3Yiee Tc1s2LLQDllOEM7opu4/Jhu9nxVWOWy9UxJQgzndVfJ2BxavorTVKTofI3Ib2+nMM3rg i+qxJPnLq2ErAIGJkGmKeVfJVAYLjdHzlQfN234g4ACF84lh0UMg75Bd8WzGa8aInyZv TZRNchiJ5KPULeAQEK7KwK0U47f1sQeJLCq/076VXIF46aGUuHc3t1u4uQHUAFxvTg/b bRVUhGVoAyiQ3fUGZkc5XDWN9Tk3PgQy60rzrtA4Y8uNNr79d6nG/1wFiUKJ0cfKC45F 44vw== X-Gm-Message-State: AOAM531YS2IhA0LJ/E56OiO2v2SLwoGCygQLu/GPtCL50bTWNBDOKxLQ 7wswOEriQjZwKyN5t3cW7I5frMtWQaSnFTfUzTdOrajCQAxIKeadEDVkbWrq7pWodjV5QSlzttT cN13U4Ykxu0VIAVStJCcgV3zaCu1EQCFdLxM= X-Received: by 2002:a05:6830:270b:: with SMTP id j11mr6370721otu.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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210624_141805_197191_23BD4551 X-CRM114-Status: GOOD ( 12.64 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); }