Received: by 10.223.185.116 with SMTP id b49csp3387192wrg; Tue, 13 Feb 2018 01:36:42 -0800 (PST) X-Google-Smtp-Source: AH8x226xEMNlJgjwdSkTeA/2yue4TRzvjmNppqNR/oj94yKt7TGncNJHPgwumyYD5qExMUVszCAG X-Received: by 2002:a17:902:2f03:: with SMTP id s3-v6mr591048plb.112.1518514602152; Tue, 13 Feb 2018 01:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518514602; cv=none; d=google.com; s=arc-20160816; b=iJx8fZC0q1PJe1QMYKAYQnh0eZbOK42evdvCljT5XoL6M13es37Li1bY56KeRG6i9k 3LWJqCBpv7vscQQvXZGLZgCmuG+UiuK4an6+1kwjBiZqWiFFm2YCKxvjeH2mT5drrWdQ ClN1o8+5ZNI3B8HIemUNg8Oj+LItSrzPAT0795mRjKjNcHIWSwAdbrbxOpzwef4A1RdI NK6N1fRraGBWLtHVHSS8m5UU6BlnSXrbNaSuIrLT1NStMGWmUw39HSMkX3p4fNmPcUeo mf+V/aMtV2xsiYiCTEO+/F8RkkQgYxGn4zzihGhvD36AsiZQpZ3gd9OqHe+kSBDnu8fy Ux6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uSR7ybWxgVucFAmP3jWaBlZhOPLitYJMmjVplLVN6Uk=; b=d8iSxWS0fPwku1mK/LTLKG9OoQ+XCmMDSVbB/7Xfz6kJrhiFShj41UmUqiOyspdbT0 sAVdcX1RGuuceYQqf5H04DPlJoRuI2Xw4ljPZ4crl0YANRs1JSj+f/3PBp4cb1eyZSKs iv1Dz1KWsnbBquz8gW9cSZzETrfEFyx0ME+Ab3QnUL0gYmUZh92AXhtqIxOEPpKaaKog gl3UG4641GC/SGGJMoNxyLErN9LOBlGYUtc3fvmJWUlQoRdXaeVZmQqjJcQ0XyLo8won H2qeAFANmfEmWmlc+Pxp4knlpwZ7ZwgOY11vDXqFNHYFzZsP+KGs1QT0pA1O1ihzlKdy K7ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si7683947pff.157.2018.02.13.01.36.27; Tue, 13 Feb 2018 01:36:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934682AbeBMJf2 (ORCPT + 99 others); Tue, 13 Feb 2018 04:35:28 -0500 Received: from mga03.intel.com ([134.134.136.65]:27114 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934645AbeBMJfU (ORCPT ); Tue, 13 Feb 2018 04:35:20 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 01:35:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,507,1511856000"; d="scan'208";a="26889491" Received: from hao-dev.bj.intel.com ([10.238.157.61]) by FMSMGA003.fm.intel.com with ESMTP; 13 Feb 2018 01:35:18 -0800 From: Wu Hao To: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, luwei.kang@intel.com, yi.z.zhang@intel.com, hao.wu@intel.com Subject: [PATCH v4 03/24] fpga: mgr: add status for fpga-manager Date: Tue, 13 Feb 2018 17:24:32 +0800 Message-Id: <1518513893-4719-4-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518513893-4719-1-git-send-email-hao.wu@intel.com> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds status to fpga-manager data structure, to allow driver to store full/partial reconfiguration errors and other status information, and adds one status callback to fpga_manager_ops to allow fpga_manager to collect latest status when failures are detected. The following sysfs file is created: * /sys/class/fpga_manager//status Return status of fpga manager, including reconfiguration errors. Signed-off-by: Wu Hao --- v3: add one line description for status add status callback function to fpga_manager_ops update fpga-mgr status if any failure or during initialization s/INCOMPATIBLE_BS_ERR/INCOMPATIBLE_IMAGE_ERR/ v4: simply code per suggestion from Alan. add supported status strings (and descriptions) in sysfs document. remove unused error code (SECURE_LOAD_ERR). --- Documentation/ABI/testing/sysfs-class-fpga-manager | 24 +++++++++++++++++++ drivers/fpga/fpga-mgr.c | 28 ++++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 9 +++++++ 3 files changed, 61 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-fpga-manager b/Documentation/ABI/testing/sysfs-class-fpga-manager index 23056c5..60db277 100644 --- a/Documentation/ABI/testing/sysfs-class-fpga-manager +++ b/Documentation/ABI/testing/sysfs-class-fpga-manager @@ -35,3 +35,27 @@ Description: Read fpga manager state as a string. * write complete = Doing post programming steps * write complete error = Error while doing post programming * operating = FPGA is programmed and operating + +What: /sys/class/fpga_manager//status +Date: February 2018 +KernelVersion: 4.16 +Contact: Wu Hao +Description: Read fpga manager status as a string. + If FPGA programming operation fails, it could be caused by crc + error or incompatible bitstream image. The intent of this + interface is to provide more detailed information for FPGA + programming errors to userspace. This is a list of strings for + the supported status. + + * reconfig operation error - invalid operations detected by + reconfiguration hardware. + e.g start reconfiguration + with errors not cleared + * reconfig CRC error - CRC error detected by + reconfiguration hardware. + * reconfig incompatible image - reconfiguration image is + incompatible with hardware + * reconfig IP protocol error - protocol errors detected by + reconfiguration hardware + * reconfig fifo overflow error - FIFO overflow detected by + reconfiguration hardware diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 245e7a6..50b7396 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -397,12 +397,40 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } +static ssize_t status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fpga_manager *mgr = to_fpga_manager(dev); + u64 status; + int len = 0; + + if (!mgr->mops->status) + return -ENOENT; + + status = mgr->mops->status(mgr); + + if (status & FPGA_MGR_STATUS_OPERATION_ERR) + len += sprintf(buf + len, "reconfig operation error\n"); + if (status & FPGA_MGR_STATUS_CRC_ERR) + len += sprintf(buf + len, "reconfig CRC error\n"); + if (status & FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR) + len += sprintf(buf + len, "reconfig incompatible image\n"); + if (status & FPGA_MGR_STATUS_IP_PROTOCOL_ERR) + len += sprintf(buf + len, "reconfig IP protocol error\n"); + if (status & FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR) + len += sprintf(buf + len, "reconfig fifo overflow error\n"); + + return len; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(state); +static DEVICE_ATTR_RO(status); static struct attribute *fpga_mgr_attrs[] = { &dev_attr_name.attr, &dev_attr_state.attr, + &dev_attr_status.attr, NULL, }; ATTRIBUTE_GROUPS(fpga_mgr); diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 6e98b66..6c79183 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -112,6 +112,7 @@ 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 * @write_init: prepare the FPGA to receive confuration data * @write: write count bytes of configuration data to the FPGA * @write_sg: write the scatter list of configuration data to the FPGA @@ -126,6 +127,7 @@ struct fpga_image_info { 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); @@ -137,6 +139,13 @@ struct fpga_manager_ops { const struct attribute_group **groups; }; +/* FPGA manager status: Partial/Full Reconfiguration errors */ +#define FPGA_MGR_STATUS_OPERATION_ERR BIT(0) +#define FPGA_MGR_STATUS_CRC_ERR BIT(1) +#define FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR BIT(2) +#define FPGA_MGR_STATUS_IP_PROTOCOL_ERR BIT(3) +#define FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR BIT(4) + /** * struct fpga_manager - fpga manager structure * @name: name of low level fpga manager -- 2.7.4