From patchwork Tue Jul 3 08:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Appana Durga Kedareswara rao X-Patchwork-Id: 10503461 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 2025160532 for ; Tue, 3 Jul 2018 08:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DACF2897B for ; Tue, 3 Jul 2018 08:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 014732899B; Tue, 3 Jul 2018 08:52:14 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 037F32897B for ; Tue, 3 Jul 2018 08:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9JVpSwkYiCDSg7ZaP/aWg7vfSVL3K1ta8I6uO7PYlRU=; b=AqU1tmHCPYsPPR 7q0JCgT+4466W/sJYA8ddBucx55mzRiEj2q/WjEuXINFb4wRxyYjcYW0Q1IcWl/nsGr/rTPB0wk0q 4nbHLmRuE1Jhkup3bq05cwmYHkFlMslA2q78v5Xm12sQ50wYy7OVvj545bXDRkql2PmqmEmDMBZEu fuhr6RrxwYPC1FGkOA9IfFV98qLd/AFBMYmK7xpHhh4gsmqUwTfTbMyB9pKTcWekvlVg8Q+9XLrZS FZwo6PMaNZNMzPFba0uQ0ktYKwQndVNMKKSA8BE4e/T3cn/WqAd9DBZhUTasHoOAtZbswff1PkSFG w8BD7Mrvcq2bFBqXUMnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1faH2i-0001Lv-7v; Tue, 03 Jul 2018 08:52:12 +0000 Received: from mail-bl2nam02on0066.outbound.protection.outlook.com ([104.47.38.66] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1faGvg-0005DT-M4 for linux-arm-kernel@lists.infradead.org; Tue, 03 Jul 2018 08:45:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FHlMcp56oPlJ9o/2FEQLD19Gj+dFvZX/t9lIt5Iu0Uk=; b=E4yB+sJW+lQ5AZZR7cZYQVSUvUuNcUYiFhztY6F7MVPAnYSewaUnPYwJZqwHKyHlL0tT+2OrkngFLqrlljz0+rkTQp9CK2a6GgLcjP6yPxWrWUNY8YxbH77eF/4FcvF0J9puri2MC6W9GsRV/dKhPQ5Hf5nU3ATG2stprOgUpwg= Received: from MWHPR0201CA0037.namprd02.prod.outlook.com (2603:10b6:301:73::14) by BYAPR02MB4455.namprd02.prod.outlook.com (2603:10b6:a03:57::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.25; Tue, 3 Jul 2018 08:44:42 +0000 Received: from SN1NAM02FT062.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::209) by MWHPR0201CA0037.outlook.office365.com (2603:10b6:301:73::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.906.24 via Frontend Transport; Tue, 3 Jul 2018 08:44:42 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT062.mail.protection.outlook.com (10.152.72.208) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.906.15 via Frontend Transport; Tue, 3 Jul 2018 08:44:41 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1faGvR-0004Q2-FG; Tue, 03 Jul 2018 01:44:41 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1faGvM-00024V-Bp; Tue, 03 Jul 2018 01:44:36 -0700 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w638iS6m032364; Tue, 3 Jul 2018 01:44:28 -0700 Received: from [172.23.37.94] (helo=xhdappanad40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1faGvE-00023i-3D; Tue, 03 Jul 2018 01:44:28 -0700 From: Appana Durga Kedareswara rao To: , , , Subject: [RFC PATCH 1/2] fpga: fpga-mgr: Add readback support Date: Tue, 3 Jul 2018 14:14:23 +0530 Message-ID: <1530607463-6287-1-git-send-email-appana.durga.rao@xilinx.com> X-Mailer: git-send-email 2.7.4 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(136003)(39860400002)(346002)(376002)(396003)(2980300002)(438002)(199004)(189003)(426003)(77096007)(8936002)(36756003)(26005)(2616005)(356003)(8676002)(14444005)(81166006)(81156014)(186003)(107886003)(476003)(106466001)(6666003)(336012)(4326008)(50466002)(48376002)(36386004)(305945005)(63266004)(9786002)(106002)(50226002)(486006)(2906002)(47776003)(5660300001)(7696005)(126002)(51416003)(478600001)(2201001)(316002)(6636002)(16586007)(110136005)(54906003)(107986001)(217873001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR02MB4455; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT062; 1:oIVGZoJ50JQYwAlrvX+h4ivPeOu+ov2T9ZjjsOcMcz4wx3Bz8jux8BKx7+o6cUDMUrS2Go7blP79agAXorGfzrq/nBvliuOFK1VODUxqpZ8MWKtpRRyy7v2KV4CwyfQt MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b7eabda-8437-494b-01e2-08d5e0c13848 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:BYAPR02MB4455; X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4455; 3:a3lbZpvoJZVW4eJ9ifrMG/07tMJ4ZneG7pJj1JuTrBQ7jSHS7j/va8vvXZduNRlbE7CLwunwzRn8Z/Z+6TcnU62hQvnDTjVWPi002LHXweOCgk9QPxChaj5skqELgz1VkIgMqa9DxrhOT0I8Q3ZrdBLvwNlje8ygtReYMVOq//GAiqkSpMcr3EWGapThgC3h9LYgKdOsxNyyYGynf9ucV8OZH94aN1MBJzDG8Pbd7DI8zH/KmMm6PTg0WJ4saiCXitvdGoNG00iMBjWCUklZNCxRU86M+wi6l+YXHdpxiDq/kvpupUanBBrIgm3YLd1Qpjdn2hM1yg4neY6D0sUJofE9QUbvUcTLDSiXx1508Rg=; 25:MF7w8KN219KUj7nOS83my7nBP0ckUnGCUY+hZADwVa5wUyUFmkHTvmCdDh0rl3SVfEGJ81OLzFZYMeEnBAYqHe6+2ESy4vbhRynVQq32Z2Z9+LnvnhzBo8rk+vq+AdZIoxHKXutvNPmxmiUSEcnaY/lIN+VC+THLlTfK2RywTTkM+RnGfCyWmn0a4odiAKVJOqiHPLMrCEYbmq3FMygxYII8Ooci7s2RVzgd09Ne9dzuOecddmWd6TOJaHiPa5rdoKVzsTlGjA6OW78cRE2Z/bJmbzdtyjaY9S6EO64r4oJr1ahGFQWINWRIVtytEQACaKBpSgiilzb7068i4Lq3mw== X-MS-TrafficTypeDiagnostic: BYAPR02MB4455: X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4455; 31:/QlwcqPj8NUlIPQsG5hd9geOaCZGDizQ/MlJLHXfaaLZ6p7Kz8vZDgFXgSA+jx0uK2bo2lFF+X+h5v3fS03x8EZIhIW/2OL89NDie6xxdYsCV+hDOmXG3g/sxf4d7TsTeZkAoArH8qtcTIK83lQ6eqX/TbK7QI0hsvfP65MMeyiZC0lrMn0sjsI+BsMZb9oXF5On2ziXm4z7bwhj3aumKQlnJTIFlkaOtBdWpDMg2n4=; 20:Ln+/dleVdPh5wgjpoRwXhhhGijI/dxs992cnlJXc3GJAIxMVsBa9kZiGYYJHBjrnNs3VpPWoXl0QCJUEkRittt148qjOQXYzn/PisKHWHSJaV4eyi+2aFUEXoXWbULG57zRViA8YGeTgjCclLl9PIBxrtG++WWJIyKvlPVg5R4hf3NrKHr8fPxpOKrL5fOgsqw0YtujT+UbqP7fxODGVnxWuIhyEVNzIDEDcf+7WsP+H1UtrlUeHmPboFe3lCLYFjDbqYezU4D0jMe33TgNBTUBqs38omcP4uKFXxvfHZqkeioCeQTkj1sFxQCE/hzK/rSrKQLH/qtowSA0cryGKOPhBlXdd/xksDaQ7sMec53zMugYHQ7GycM7yd1PJAwTChmdFNMP7PDNL5MA//aohp1SJiZKkYYWKMlLuuPmyFahd/xPBzvYDXqpx5X2jnI3XgKaKpJRZyyAoH7cjCDs+eG+4akKmKR+BfXX0pwrzn9JtVI0J//NAg+zxOUvOI8yt X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93004095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BYAPR02MB4455; BCL:0; PCL:0; RULEID:; SRVR:BYAPR02MB4455; X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4455; 4:CK1JxMNKyF4/0xCJk8ubOyHfx0j9Qxc8kHia164dwrSdowSc1YVSYGz5aLVcRuKyfcfHcSyd0JXj+GonkM6f3K/EwBsm2t8vefVfsnJ5L2kUIfQ3OgN9l7aSRL9yGyI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?pJPVj8Nd+N0xTiR3raGtq7FlLT99HPUAWSjz4JRK1mfd7B/pG9NNXXqB7cuK?= =?us-ascii?Q?HMbwl7FcfONEmOVwcPZbUEqKNKvC7cS5MY3M318W7R5ivPnLe6R7A2phQCEr?= =?us-ascii?Q?yCbFyofRGtA6OY6wszIOz+3uZe/aQ0VFQbMaTRg43R9u+xn7PUCPpFen+g1a?= =?us-ascii?Q?HQXmOHnYNZU+wu1822WDNn72sdWaMo68COEt7xFZMi/eWVRnfGdK0VQo9BbX?= =?us-ascii?Q?JQKq8u/WrB2qtbM3GAvpg0CDlK0vakqv94qhnbmGLXST8iPWZkeLXtn5RKIq?= =?us-ascii?Q?UVylCHu9Gm+N5XgrVPHO1CKbi4io824qSBX6OLViOvHl1Goq+Y4XTHgEsnJX?= =?us-ascii?Q?5VSsLt4rPJO3v1EBM/csGZ2du2K1EmkxyuCg1onN1gJDiV1zFdRk9NNTfGjO?= =?us-ascii?Q?gJtXGy+FpOLKG2VQkWnb7urGat2/kniifrn6IX0M8gqOcGzkOVHBq14ZqAaF?= =?us-ascii?Q?YKkOx+8irk2tovshEvpWd7yQrdJnhn5?= X-Microsoft-Antispam-Message-Info: yqj/Hu33nKN6ZI7/0C2D6H3FI1m0yIgIHNBDMacn3mBUdiTVkFS5kF0sVxjMGMNuxFJvoZs1E/c5CblUzMrBX0cisQMqK77fzEJEHaNL4pGpUPgKEOa4NVficCga1ftYaIstMWydfvulvlmFG9xdr5JizlO7QOi+CQpb4EKvnYp7ihqLfuyIduyOnGGJLvTH5SFpDH+NMJG/nDWP06Ef2LKxJqcgxdGN7rSKd112Esfb0SpwagwKVLCDUlCWdX/kJKo5sl0hzl4FF1LJmVIP8SFh8QXJ4OtKyDDV0cUVxDQTZhAJ2IWj9ciEoILFO2BQq4bI2359BYsyN+NOHUiERypaxJD/KkWcsuh0Ewj1quA= X-Microsoft-Exchange-Diagnostics: 1; BYAPR02MB4455; 6:36qxWoaN2TWGi24HySXN3GNamoJcjmFGGxid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exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 08:44:41.7846 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b7eabda-8437-494b-01e2-08d5e0c13848 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4455 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180703_014457_278257_AD678EB2 X-CRM114-Status: GOOD ( 14.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fpga@vger.kernel.org, Appana Durga Kedareswara rao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Inorder to debug issues with fpga's users would like to read the fpga configuration information. This patch adds readback support for fpga configuration data in the framework through debugfs interface. Usage: cat /sys/kernel/debug/fpga/readback Signed-off-by: Appana Durga Kedareswara rao --- drivers/fpga/fpga-mgr.c | 52 +++++++++++++++++++++++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 6 +++++ 2 files changed, 58 insertions(+) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 9939d2c..7a9fd7c 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -484,6 +484,39 @@ void fpga_mgr_put(struct fpga_manager *mgr) } EXPORT_SYMBOL_GPL(fpga_mgr_put); +#ifdef CONFIG_DEBUG_FS +#include + +static int fpga_mgr_read(struct seq_file *s, void *data) +{ + struct fpga_manager *mgr = (struct fpga_manager *)s->private; + int ret = 0; + + if (mgr->state != FPGA_MGR_STATE_OPERATING) + return -EBUSY; + + /* Read the FPGA configuration data from the fabric */ + ret = mgr->mops->read(mgr, s); + if (ret) { + dev_err(&mgr->dev, "Error while reading configuration data from FPGA\n"); + return ret; + } + + return ret; +} + +static int fpga_mgr_read_open(struct inode *inode, struct file *file) +{ + return single_open(file, fpga_mgr_read, inode->i_private); +} + +static const struct file_operations fpga_mgr_debugops = { + .owner = THIS_MODULE, + .open = fpga_mgr_read_open, + .read = seq_read, +}; +#endif + /** * fpga_mgr_lock - Lock FPGA manager for exclusive use * @mgr: fpga manager @@ -581,6 +614,21 @@ int fpga_mgr_register(struct device *dev, const char *name, if (ret) goto error_device; +#ifdef CONFIG_DEBUG_FS + mgr->dir = debugfs_create_dir("fpga", NULL); + if (!mgr->dir) + goto error_device; + + mgr->parent = mgr->dir; + mgr->dir = debugfs_create_file("readback", 0644, mgr->parent, mgr, + &fpga_mgr_debugops); + if (!mgr->dir) { + debugfs_remove_recursive(mgr->parent); + mgr->parent = NULL; + goto error_device; + } +#endif + dev_info(&mgr->dev, "%s registered\n", mgr->name); return 0; @@ -604,6 +652,10 @@ void fpga_mgr_unregister(struct device *dev) dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name); +#ifdef CONFIG_DEBUG_FS + debugfs_remove_recursive(mgr->parent); + mgr->parent = NULL; +#endif /* * If the low level driver provides a method for putting fpga into * a desired state upon unregister, do it. diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 3c6de23..6013809 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -114,6 +114,7 @@ struct fpga_image_info { * @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 + * @read: read FPGA configuration information * @fpga_remove: optional: Set FPGA into a specific state during driver remove * @groups: optional attribute groups. * @@ -131,6 +132,7 @@ struct fpga_manager_ops { int (*write_sg)(struct fpga_manager *mgr, struct sg_table *sgt); int (*write_complete)(struct fpga_manager *mgr, struct fpga_image_info *info); + int (*read)(struct fpga_manager *mgr, struct seq_file *s); void (*fpga_remove)(struct fpga_manager *mgr); const struct attribute_group **groups; }; @@ -151,6 +153,10 @@ struct fpga_manager { enum fpga_mgr_states state; const struct fpga_manager_ops *mops; void *priv; +#ifdef CONFIG_DEBUG_FS + struct dentry *dir; + struct dentry *parent; +#endif }; #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev)