From patchwork Tue May 17 08:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ng, Adrian Ho Yin" X-Patchwork-Id: 12852121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1DE1C433FE for ; Tue, 17 May 2022 08:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243687AbiEQIlc (ORCPT ); Tue, 17 May 2022 04:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243845AbiEQIl3 (ORCPT ); Tue, 17 May 2022 04:41:29 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DD52AE1; Tue, 17 May 2022 01:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652776888; x=1684312888; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UQpWUmGLp4Oj7CWq7C8ttsNpIWRrZDf0YaCaJl29o50=; b=Ad/ng89cSCo5i62a9AIRvL2lZRUJYqAtRGSP4YvoIJ9XOxnnZpNRj3Hf ym+qsQJ7YccWcIuZbcjk8N7rHCRAfvbzewyC9I5NgiYjfNRnR4kd/3xAC E0uajdU9B71jCMJ1jTpRhcfb8sZyUdXAvEHChq00/otmO2O0rTM9YXrWv yYLu4qhVt9KA3SsRmEP3eVrJAUSX4DUggABk9CfkF7hNNJxwHjJXEza7M uvbaRU3UwHaxcTvkOBYVsciVwSsPXyMixz/rrzywJRORswxN7WJQBeq+/ CJ7EA14cSlBluFOozAzTkCbhTQZ9ecUDNnGuQdwQJy9exxAaHGQbmLoeC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="296388698" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="296388698" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 01:41:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="555677538" Received: from pglc1026.png.intel.com ([172.30.19.132]) by orsmga002.jf.intel.com with ESMTP; 17 May 2022 01:41:24 -0700 From: adrian.ho.yin.ng@intel.com To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, Adrian Ng Ho Yin , Alan Tull Subject: [PATCH 1/3] fpga: Implement DebugFS for FPGA Manager Framework Date: Tue, 17 May 2022 16:41:22 +0800 Message-Id: <20220517084122.2605-1-adrian.ho.yin.ng@intel.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Adrian Ng Ho Yin Implement DebugFS for the FPGA Manager Framework. Each FPGA gets its own directory such as /fpga_manager/fpga0 and three files: * [RW] flags = flags as defined in fpga-mgr.h * [RW] firmware_name = write/read back name of FPGA image firmware file to program * [WO] image = write-only file for directly writing fpga image w/o firmware layer Enabled by CONFIG_FPGA_MGR_DEBUG_FS Signed-off-by: Alan Tull Signed-off-by: Adrian Ng Ho Yin --- drivers/fpga/Kconfig | 7 ++ drivers/fpga/Makefile | 1 + drivers/fpga/fpga-mgr-debugfs.c | 183 ++++++++++++++++++++++++++++++++ drivers/fpga/fpga-mgr-debugfs.h | 32 ++++++ drivers/fpga/fpga-mgr.c | 8 ++ include/linux/fpga/fpga-mgr.h | 3 + 6 files changed, 234 insertions(+) create mode 100644 drivers/fpga/fpga-mgr-debugfs.c create mode 100644 drivers/fpga/fpga-mgr-debugfs.h diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 991b3f361ec9..dd6bf04dadc2 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -10,6 +10,13 @@ menuconfig FPGA kernel. The FPGA framework adds an FPGA manager class and FPGA manager drivers. +config FPGA_MGR_DEBUG_FS + bool "FPGA Manager DebugFS" + depends on FPGA && DEBUG_FS + help + Say Y here if you want to expose a DebugFS interface for the + FPGA Manager Framework. + if FPGA config FPGA_MGR_SOCFPGA diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 0bff783d1b61..e896554010da 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -5,6 +5,7 @@ # Core FPGA Manager Framework obj-$(CONFIG_FPGA) += fpga-mgr.o +obj-$(CONFIG_FPGA_MGR_DEBUG_FS) += fpga-mgr-debugfs.o # FPGA Manager Drivers obj-$(CONFIG_FPGA_MGR_ALTERA_CVP) += altera-cvp.o diff --git a/drivers/fpga/fpga-mgr-debugfs.c b/drivers/fpga/fpga-mgr-debugfs.c new file mode 100644 index 000000000000..30af59b92bf3 --- /dev/null +++ b/drivers/fpga/fpga-mgr-debugfs.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FPGA Manager DebugFS + * + * Copyright (C) 2016 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#include +#include +#include +#include + +static struct dentry *fpga_mgr_debugfs_root; + +struct fpga_mgr_debugfs { + struct dentry *debugfs_dir; + char *firmware_name; + struct fpga_image_info info; +}; + +static ssize_t fpga_mgr_firmware_write_file(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct fpga_manager *mgr = file->private_data; + struct fpga_mgr_debugfs *debugfs = mgr->debugfs; + char *buf; + int ret; + + buf = kzalloc(count, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (copy_from_user(buf, user_buf, count)) + return -EFAULT; + + buf[count] = 0; + if (buf[count - 1] == '\n') + buf[count - 1] = 0; + + kfree(debugfs->firmware_name); + debugfs->firmware_name = buf; + + ret = fpga_mgr_firmware_load(mgr, &debugfs->info, buf); + if (ret) + dev_err(&mgr->dev, + "fpga_mgr_firmware_load returned with value %d\n", ret); + + return count; +} + +static ssize_t fpga_mgr_firmware_read_file(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct fpga_manager *mgr = file->private_data; + struct fpga_mgr_debugfs *debugfs = mgr->debugfs; + char *buf; + int ret; + + if (debugfs->firmware_name == NULL) + return 0; + + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + ret = snprintf(buf, PAGE_SIZE, "%s\n", debugfs->firmware_name); + if (ret < 0) { + kfree(buf); + return ret; + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); + kfree(buf); + + return ret; +} + +static const struct file_operations fpga_mgr_firmware_fops = { + .open = simple_open, + .read = fpga_mgr_firmware_read_file, + .write = fpga_mgr_firmware_write_file, + .llseek = default_llseek, +}; + +static ssize_t fpga_mgr_image_write_file(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct fpga_manager *mgr = file->private_data; + struct fpga_mgr_debugfs *debugfs = mgr->debugfs; + char *buf; + int ret; + + dev_info(&mgr->dev, "writing %d bytes to %s\n", count, mgr->name); + + buf = kzalloc(count, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (copy_from_user(buf, user_buf, count)) + return -EFAULT; + + /* If firmware interface was previously used, forget it. */ + kfree(debugfs->firmware_name); + debugfs->firmware_name = NULL; + + ret = fpga_mgr_buf_load(mgr, &debugfs->info, buf, count); + if (ret) + dev_err(&mgr->dev, + "fpga_mgr_buf_load returned with value %d\n", ret); + + return count; +} + +static const struct file_operations fpga_mgr_image_fops = { + .open = simple_open, + .write = fpga_mgr_image_write_file, + .llseek = default_llseek, +}; + +void fpga_mgr_debugfs_add(struct fpga_manager *mgr) +{ + struct fpga_mgr_debugfs *debugfs; + struct fpga_image_info *info; + + if (!fpga_mgr_debugfs_root) + return; + + debugfs = kzalloc(sizeof(*debugfs), GFP_KERNEL); + if (!debugfs) + return; + + debugfs->debugfs_dir = debugfs_create_dir(dev_name(&mgr->dev), + fpga_mgr_debugfs_root); + + debugfs_create_file("firmware_name", 0600, debugfs->debugfs_dir, mgr, + &fpga_mgr_firmware_fops); + + debugfs_create_file("image", 0200, debugfs->debugfs_dir, mgr, + &fpga_mgr_image_fops); + + info = &debugfs->info; + debugfs_create_u32("flags", 0600, debugfs->debugfs_dir, &info->flags); + + mgr->debugfs = debugfs; +} + +void fpga_mgr_debugfs_remove(struct fpga_manager *mgr) +{ + struct fpga_mgr_debugfs *debugfs = mgr->debugfs; + + if (!fpga_mgr_debugfs_root) + return; + + debugfs_remove_recursive(debugfs->debugfs_dir); + kfree(debugfs->firmware_name); + kfree(debugfs); +} + +void fpga_mgr_debugfs_init(void) +{ + fpga_mgr_debugfs_root = debugfs_create_dir("fpga_manager", NULL); + if (!fpga_mgr_debugfs_root) + pr_warn("fpga_mgr: Failed to create debugfs root\n"); +} + +void fpga_mgr_debugfs_uninit(void) +{ + debugfs_remove_recursive(fpga_mgr_debugfs_root); +} diff --git a/drivers/fpga/fpga-mgr-debugfs.h b/drivers/fpga/fpga-mgr-debugfs.h new file mode 100644 index 000000000000..394da0c62237 --- /dev/null +++ b/drivers/fpga/fpga-mgr-debugfs.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 + * FPGA Manager DebugFS + * + * Copyright (C) 2016 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#ifdef CONFIG_FPGA_MGR_DEBUG_FS + +void fpga_mgr_debugfs_add(struct fpga_manager *mgr); +void fpga_mgr_debugfs_remove(struct fpga_manager *mgr); +void fpga_mgr_debugfs_init(void); +void fpga_mgr_debugfs_uninit(void); + +#else + +void fpga_mgr_debugfs_add(struct fpga_manager *mgr) {} +void fpga_mgr_debugfs_remove(struct fpga_manager *mgr) {} +void fpga_mgr_debugfs_init(void) {} +void fpga_mgr_debugfs_uninit(void) {} + +#endif /* CONFIG_FPGA_MGR_DEBUG_FS */ diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index d49a9ce34568..9e9c1f2ebf2b 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -17,6 +17,7 @@ #include #include #include +#include "fpga-mgr-debugfs.h" static DEFINE_IDA(fpga_mgr_ida); static struct class *fpga_mgr_class; @@ -658,6 +659,8 @@ fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *in return ERR_PTR(ret); } + fpga_mgr_debugfs_add(mgr); + return mgr; error_device: @@ -708,6 +711,8 @@ void fpga_mgr_unregister(struct fpga_manager *mgr) { dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name); + fpga_mgr_debugfs_remove(mgr); + /* * If the low level driver provides a method for putting fpga into * a desired state upon unregister, do it. @@ -800,11 +805,14 @@ static int __init fpga_mgr_class_init(void) fpga_mgr_class->dev_groups = fpga_mgr_groups; fpga_mgr_class->dev_release = fpga_mgr_dev_release; + fpga_mgr_debugfs_init(); + return 0; } static void __exit fpga_mgr_class_exit(void) { + fpga_mgr_debugfs_uninit(); class_destroy(fpga_mgr_class); ida_destroy(&fpga_mgr_ida); } diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 0f9468771bb9..ef7a4fa1448c 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -191,6 +191,9 @@ struct fpga_manager { struct fpga_compat_id *compat_id; const struct fpga_manager_ops *mops; void *priv; +#ifdef CONFIG_FPGA_MGR_DEBUG_FS + void *debugfs; +#endif }; #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) From patchwork Tue May 17 08:41:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ng, Adrian Ho Yin" X-Patchwork-Id: 12852123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3E0C433EF for ; Tue, 17 May 2022 08:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243690AbiEQIl7 (ORCPT ); Tue, 17 May 2022 04:41:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243745AbiEQIl6 (ORCPT ); Tue, 17 May 2022 04:41:58 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10180403E8; Tue, 17 May 2022 01:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652776917; x=1684312917; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QnPlWtkqhfDOYWo6Q0LECnG3DaeXR6oPXcnQW5GxBe8=; b=FvAIMf6+dWpdifdeQRiY7xwu9onfgxIGsTj8NEYMnqg9tGplwFqiOjK2 jTO5hn4tV9ktsl29fdaxNE2YRjpIrviQH0KfchnaRWpLQ6TC0FgNswmGa lxkDjPbI/dFMfp4/v6Tujh6VABCh5DD+yUJkXfs1PQ7KjIG4POOJULhht 6WUn7UM47XiSPLEK1mmSjdccEV+3UGVbNzH5vn9ncpwLMv/ksTAq3/W8Y /HGlCBDHzQ07cqGEepp6fYHVm+t0dvN9E1JRQtYZBCfdh7U6RnHpvxig0 Dg1KraOKg9LnXVGhlPGz1W9neosxs7NwAZNyiKJZh5o5Oveu8cLwnPulU w==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="271235583" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="271235583" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 01:41:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="660517186" Received: from pglc1026.png.intel.com ([172.30.19.132]) by FMSMGA003.fm.intel.com with ESMTP; 17 May 2022 01:41:38 -0700 From: adrian.ho.yin.ng@intel.com To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, Alan Tull Subject: [PATCH 2/3] fpga: doc: documentation for FPGA debugfs Date: Tue, 17 May 2022 16:41:36 +0800 Message-Id: <20220517084136.3529-1-adrian.ho.yin.ng@intel.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Alan Tull Document the DebugFS interface for the core FPGA Manager framework. Signed-off-by: Alan Tull --- Documentation/fpga/debugfs.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/fpga/debugfs.txt diff --git a/Documentation/fpga/debugfs.txt b/Documentation/fpga/debugfs.txt new file mode 100644 index 000000000000..1b34d5460d5d --- /dev/null +++ b/Documentation/fpga/debugfs.txt @@ -0,0 +1,33 @@ +FPGA Manager DebugFS interface for FPGA reprogramming. + +Alan Tull 2016 + +Each FPGA gets its own directory such as /fpga_manager/fpga0 and +three files: + + - [RW] flags: flags as defined in fpga-mgr.h. For example: + + $ echo 1 > /sys/kernel/debug/fpga_manager/fpga0/flags + + - [RW] firmware_name: Name of an FPGA image firmware file. Writing initiates + a complete FPGA programming cycle. Note that the image + file must be in a directory on the firmware search path + such as /lib/firmware. + + $ echo image.rbf > /sys/kernel/debug/fpga_manager/fpga0/firmware_name + + - [WO] image: Raw FPGA image data. Writing the FPGA image data will + initiate a complete FPGA programming cycle. Data must + be written in one chunk, for example: + + $ dd bs=10M if=./image.rbf of=/sys/kernel/debug/fpga_manager/fpga0/image + (where image.rbf < 10M) + +To program the FPGA, write the flags (if needed), then use either the +firmware_name or image file to program. + +This interface does not handle bridges or loading/unloading of soft IP device +drivers. This makes it really easy to mess things up by doing things like +reprogramming the hardware out from under a driver or reprogramming while a +bridge is enabled, causing gunk to go out on a cpu bus. It should go without +saying that this interface is for debug only. Not intended for production use. From patchwork Tue May 17 08:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ng, Adrian Ho Yin" X-Patchwork-Id: 12852122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C69BC433F5 for ; Tue, 17 May 2022 08:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236683AbiEQIlx (ORCPT ); Tue, 17 May 2022 04:41:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243751AbiEQIlw (ORCPT ); Tue, 17 May 2022 04:41:52 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E4C343386; Tue, 17 May 2022 01:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652776912; x=1684312912; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=re/TqJfiXB30NBiMpSKQEhgi6oL5bPlUI1K2WqBpPyI=; b=FkvIYFUHXiUo8qs49/a4zPzp1LyXe46v3vEIoITARqT0bwV27quXPLG6 2wxcACdsyrW1Uz0Vf9pLIjt0/B2BcR+snDSnRVr0KOMlmx4OKDUuVvcZW tPYoNvpyQSHJuHArusgTt1nVnS2MXq6yVLLiKkiYp1Dvyk7y3gH27cct8 nrxGahKNM7Ccilv+mzHHQDWW80uYQRLM7n/4vCS6+1GaAVXX0mzaiqtFx yE4FgAY0RRpJ3XrYUO7RCR8sHZ/WiOyG9bvwac9QFFWEcOVyMSrHrVfHr pmTdFoyWZYkClwRZYgCmq/1UqrFnjQYq6YhXFLKvrAFhjOAJZ3iaRIfrk g==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="251626293" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="251626293" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 01:41:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="626371481" Received: from pglc1026.png.intel.com ([172.30.19.132]) by fmsmga008.fm.intel.com with ESMTP; 17 May 2022 01:41:48 -0700 From: adrian.ho.yin.ng@intel.com To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, Matthew Gerlach , Matthew Gerlach Subject: [PATCH 3/3] add debugfs interface for fpga config complete timeout Date: Tue, 17 May 2022 16:41:46 +0800 Message-Id: <20220517084146.4510-1-adrian.ho.yin.ng@intel.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Matthew Gerlach Add debugfs interface and documentation for setting the maximum time in microseconds for the FPGA to go to the operating state after the region has been programmed. Signed-off-by: Matthew Gerlach --- Documentation/fpga/debugfs.txt | 6 ++++++ drivers/fpga/fpga-mgr-debugfs.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/fpga/debugfs.txt b/Documentation/fpga/debugfs.txt index 1b34d5460d5d..b01950f76e20 100644 --- a/Documentation/fpga/debugfs.txt +++ b/Documentation/fpga/debugfs.txt @@ -9,6 +9,12 @@ three files: $ echo 1 > /sys/kernel/debug/fpga_manager/fpga0/flags + - [RW] config_complete_timeout_us: time out in microseconds to wait for + FPGA to go to operating state after + region has been programmed. + + $ echo 4 > /sys/kernel/debug/fpga_manager/fpga0/config_complete_timeout_us + - [RW] firmware_name: Name of an FPGA image firmware file. Writing initiates a complete FPGA programming cycle. Note that the image file must be in a directory on the firmware search path diff --git a/drivers/fpga/fpga-mgr-debugfs.c b/drivers/fpga/fpga-mgr-debugfs.c index 30af59b92bf3..83b712d4eb14 100644 --- a/drivers/fpga/fpga-mgr-debugfs.c +++ b/drivers/fpga/fpga-mgr-debugfs.c @@ -153,8 +153,13 @@ void fpga_mgr_debugfs_add(struct fpga_manager *mgr) &fpga_mgr_image_fops); info = &debugfs->info; + debugfs_create_u32("flags", 0600, debugfs->debugfs_dir, &info->flags); + debugfs_create_u32("config_complete_timeout_us", 0600, + debugfs->debugfs_dir, + &info->config_complete_timeout_us); + mgr->debugfs = debugfs; }