From patchwork Wed Nov 9 22:58:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 9420311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CFA38601C2 for ; Wed, 9 Nov 2016 23:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C127B29103 for ; Wed, 9 Nov 2016 23:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5EA429303; Wed, 9 Nov 2016 23:04:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F0C929103 for ; Wed, 9 Nov 2016 23:04:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4bsu-0004HG-Jx; Wed, 09 Nov 2016 23:02:24 +0000 Received: from quartz.orcorp.ca ([184.70.90.242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4bpu-000130-Sp for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2016 22:59:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=obsidianresearch.com; s=rsa1; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=h3DrtjbuHs3/zbrqty1PfzoT73IxN1WBM+Kn+fwJo+s=; b=HcCfJ28FjlJ/YlidgGXWgczt3LKeivzx7d36pafT8ZCbU8kYR2v4+/PkVQ/yEIexNqxOw/1bZJNvN6e0fXKxeBIhc4zSIbaMWDeJyPFvvInmK2Bn2aj1SDi4o5IZB+cdaWTOuOuIiODqjU58y6nGB73BHQjsVMc3PBp4xcjRofY=; Received: from [10.0.0.151] (helo=jggl.edm.orcorp.ca) by quartz.orcorp.ca with esmtps (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1c4bpG-00011i-KU; Wed, 09 Nov 2016 15:58:38 -0700 From: Jason Gunthorpe To: Alan Tull , Moritz Fischer Subject: [PATCH fpga 9/9] fpga: Remove support for non-sg drivers Date: Wed, 9 Nov 2016 15:58:23 -0700 Message-Id: <1478732303-13718-10-git-send-email-jgunthorpe@obsidianresearch.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1478732303-13718-1-git-send-email-jgunthorpe@obsidianresearch.com> References: <1478732303-13718-1-git-send-email-jgunthorpe@obsidianresearch.com> X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.151 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161109_145919_245110_6FA0B144 X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Looijmans , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , Matthias Brugger , Michal Simek , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP All drivers now use the sg interface so there is no reason to keep the contiguous interface any more. Now that all drivers support this interface we can also export it. Signed-off-by: Jason Gunthorpe --- drivers/fpga/fpga-mgr.c | 62 +++++++------------------------------------ include/linux/fpga/fpga-mgr.h | 7 ++--- 2 files changed, 11 insertions(+), 58 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c2491ffeabd3..4ba22925d9d5 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -47,8 +47,8 @@ static struct class *fpga_mgr_class; * * Return: 0 on success, negative error code otherwise. */ -static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, u32 flags, - struct sg_table *sgt) +int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, u32 flags, + struct sg_table *sgt) { struct device *dev = &mgr->dev; int ret; @@ -92,52 +92,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, u32 flags, return 0; } - -static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, u32 flags, - const char *buf, size_t count) -{ - struct device *dev = &mgr->dev; - int ret; - - /* - * Call the low level driver's write_init function. This will do the - * device-specific things to get the FPGA into the state where it is - * ready to receive an FPGA image. - */ - mgr->state = FPGA_MGR_STATE_WRITE_INIT; - ret = mgr->mops->write_init(mgr, flags, buf, count); - if (ret) { - dev_err(dev, "Error preparing FPGA for writing\n"); - mgr->state = FPGA_MGR_STATE_WRITE_INIT_ERR; - return ret; - } - - /* - * Write the FPGA image to the FPGA. - */ - mgr->state = FPGA_MGR_STATE_WRITE; - ret = mgr->mops->write(mgr, buf, count); - if (ret) { - dev_err(dev, "Error while writing image data to FPGA\n"); - mgr->state = FPGA_MGR_STATE_WRITE_ERR; - return ret; - } - - /* - * After all the FPGA image has been written, do the device specific - * steps to finish and set the FPGA into operating mode. - */ - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - ret = mgr->mops->write_complete(mgr, flags); - if (ret) { - dev_err(dev, "Error after writing image data to FPGA\n"); - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; - return ret; - } - mgr->state = FPGA_MGR_STATE_OPERATING; - - return 0; -} +EXPORT_SYMBOL_GPL(fpga_mgr_buf_load_sg); /** * fpga_mgr_buf_load - load fpga from image in buffer @@ -163,9 +118,6 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf, int index; int rc; - if (!mgr->mops->write_init_sg || !mgr->mops->write_sg) - return fpga_mgr_buf_load_mapped(mgr, flags, buf, count); - /* * Convert the linear kernel pointer into a sg_table of pages for use * by the driver. @@ -226,6 +178,11 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ; + /* + * FIXME: We do not need a vmap, just a page list, but + * request_firmware has no way to give us that, so this needlessly + * consumes vmalloc space. + */ ret = request_firmware(&fw, image_name, dev); if (ret) { mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ_ERR; @@ -369,8 +326,7 @@ int fpga_mgr_register(struct device *dev, const char *name, int id, ret; if (!mops || !mops->write_complete || !mops->state || - ((!mops->write_init || !mops->write) && - (!mops->write_init_sg || !mops->write_sg))) { + !mops->write_init_sg || !mops->write_sg) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); return -EINVAL; } diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 371b30ea60eb..5c698c8fe71b 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -72,8 +72,6 @@ enum fpga_mgr_states { /** * struct fpga_manager_ops - ops for low level fpga manager drivers * @state: returns an enum value of the FPGA's state - * @write_init: prepare the FPGA to receive confuration data (linear memory) - * @write: write count bytes of configuration data to the FPGA * @write_init_sg: prepare the FPGA to receive confuration data (scatter list * table) * @write_sg: write count bytes of configuration data to the FPGA @@ -86,9 +84,6 @@ enum fpga_mgr_states { */ struct fpga_manager_ops { enum fpga_mgr_states (*state)(struct fpga_manager *mgr); - int (*write_init)(struct fpga_manager *mgr, u32 flags, - const char *buf, size_t count); - int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); int (*write_init_sg)(struct fpga_manager *mgr, u32 flags, struct sg_table *sgt); int (*write_sg)(struct fpga_manager *mgr, struct sg_table *sgt); @@ -118,6 +113,8 @@ struct fpga_manager { int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf, size_t count); +int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, u32 flags, + struct sg_table *sgt); int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, const char *image_name);