Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2698785ybd; Thu, 27 Jun 2019 17:51:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnWy7JS7N4OhlYMPMrQAM8+HpIPc7Ljmf22UNG2m+/bvpjLh7dP5T/UQbzhxECdzzhtFIQ X-Received: by 2002:a65:510c:: with SMTP id f12mr6336741pgq.92.1561683086984; Thu, 27 Jun 2019 17:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561683086; cv=none; d=google.com; s=arc-20160816; b=ZEF9OjT01KZvkgKZN+rreFzU86gve/S9RsoUYBvJhvSXVi+ljH6sVQWGqhzUmw6J96 LlHmVgI0x5KNrknhMY8B5vRhmOZyFFWSiWBQjolmRZp9ehoqXZXsF6YAAve69KlVRflL nyVghSsWDBG/UHgfier7BNRl9NE9p4r5+0IFRoOJVhOjLlYaXhcaG//nf9YcChlBSwiX Bra8r3YSwfvgNSRF3tgLrL+RHU07gc4CyUUbG9eTs3wEGpZYyRdGKpsebeuU57NNgsDS BdCKdum/z+ZnYblE1b0gJdXHnc4NcZzLqNMmWfUmgkeRA5Z7mPC4Gxl0ESAw/DbZSnIn 7guA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3QsqgjppNoRqVMVUzDD6R+n+xqC7gpGu6izDLvFjBzc=; b=HnMZurERlh6zY+Ukx4Hm9mTqkve/e1Klrg8XrSl3qoTBjKdJ2dVO9XxbpdWOotOnZn 0VoMaqND2e2RqIXfq2RU1RCJFoi4oftvOXyy2cCWPEboAfeJVYvuPzzsVKQbXbV2cfTA /XJPCCuHl2xe5Q/L/33nvHoeH2MmDleigfKHnMJtkoUDftORP7hNy0I6Z7FpEK6bYBS5 CX5Cliu+PF5ayv2m1BunXjuBw/wmIwazdvz73yTO37mm4NriYaYDYmfzYhJRcEKTjVxX ykT04wiqvI+ssp5Q854tiOz5Nc8idO6p+bZRTDCcZuvdU0BT/OiwDR5naEHYuy5T+B6t Tffw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n185si739432pfn.16.2019.06.27.17.51.11; Thu, 27 Jun 2019 17:51:26 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfF1Aus (ORCPT + 99 others); Thu, 27 Jun 2019 20:50:48 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45054 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726966AbfF1Aur (ORCPT ); Thu, 27 Jun 2019 20:50:47 -0400 Received: by mail-pf1-f194.google.com with SMTP id t16so2047994pfe.11 for ; Thu, 27 Jun 2019 17:50:46 -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=3QsqgjppNoRqVMVUzDD6R+n+xqC7gpGu6izDLvFjBzc=; b=rvqd2I4F/URvaNy/MI3wHh45g9ZvPB3Ne3eKzJYPa5SyYU5CIjAD1cYpDeGzHaDYhW WZdECtDpTUjL23WyibRYgXiw7jRsbL2RsJLEgbX+3veyDu4s4WlY/KZbLmCISOdBENxZ F3K7KnDk1osllv6ij5/HwqVxC4Um2N59iAz8Jhd2shro7RVQ9VCjuWmofMrT369f3ykI s90q4NSr8K0LTeujuKcmNAbYFpObWbaYxbUI9PuD6HqywGqYIrjjgLb2hDMYOCc0mkKf I4chNmOg0nPJ5P86ocOg3cP8sO49vx0K4bGNJqhVvnposYmsaiCgiwFrJo3ZXlTILIM1 apzQ== X-Gm-Message-State: APjAAAU70pkgetSR5zZ11wKuFXVfyWu6iQ6IL46n6tQdaZuS2XeoZNtP EGMk9dbC/7qEagjvOER8KIG75g== X-Received: by 2002:a17:90a:30e4:: with SMTP id h91mr9188812pjb.37.1561683046125; Thu, 27 Jun 2019 17:50:46 -0700 (PDT) Received: from localhost (c-76-21-109-208.hsd1.ca.comcast.net. [76.21.109.208]) by smtp.gmail.com with ESMTPSA id 25sm273021pfp.76.2019.06.27.17.50.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 17:50:44 -0700 (PDT) From: Moritz Fischer To: linux-fpga@vger.kernel.org, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Wu Hao , Luwei Kang , Xu Yilun , Alan Tull , Moritz Fischer Subject: [PATCH 14/15] fpga: dfl: fme: add capability sysfs interfaces Date: Thu, 27 Jun 2019 17:49:50 -0700 Message-Id: <20190628004951.6202-15-mdf@kernel.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190628004951.6202-1-mdf@kernel.org> References: <20190628004951.6202-1-mdf@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wu Hao This patch adds 3 read-only sysfs interfaces for FPGA Management Engine (FME) block for capabilities including cache_size, fabric_version and socket_id. Signed-off-by: Luwei Kang Signed-off-by: Xu Yilun Signed-off-by: Wu Hao Acked-by: Alan Tull Signed-off-by: Moritz Fischer --- .../ABI/testing/sysfs-platform-dfl-fme | 23 +++++++++ drivers/fpga/dfl-fme-main.c | 48 +++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme b/Documentation/ABI/testing/sysfs-platform-dfl-fme index 8fa4febfa4b2..99cd3b2acff5 100644 --- a/Documentation/ABI/testing/sysfs-platform-dfl-fme +++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme @@ -21,3 +21,26 @@ Contact: Wu Hao Description: Read-only. It returns Bitstream (static FPGA region) meta data, which includes the synthesis date, seed and other information of this static FPGA region. + +What: /sys/bus/platform/devices/dfl-fme.0/cache_size +Date: June 2019 +KernelVersion: 5.3 +Contact: Wu Hao +Description: Read-only. It returns cache size of this FPGA device. + +What: /sys/bus/platform/devices/dfl-fme.0/fabric_version +Date: June 2019 +KernelVersion: 5.3 +Contact: Wu Hao +Description: Read-only. It returns fabric version of this FPGA device. + Userspace applications need this information to select + best data channels per different fabric design. + +What: /sys/bus/platform/devices/dfl-fme.0/socket_id +Date: June 2019 +KernelVersion: 5.3 +Contact: Wu Hao +Description: Read-only. It returns socket_id to indicate which socket + this FPGA belongs to, only valid for integrated solution. + User only needs this information, in case standard numa node + can't provide correct information. diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c index 38c6342e1865..2d69b8fd0137 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -75,10 +75,58 @@ static ssize_t bitstream_metadata_show(struct device *dev, } static DEVICE_ATTR_RO(bitstream_metadata); +static ssize_t cache_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_CACHE_SIZE, v)); +} +static DEVICE_ATTR_RO(cache_size); + +static ssize_t fabric_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_FABRIC_VERID, v)); +} +static DEVICE_ATTR_RO(fabric_version); + +static ssize_t socket_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_SOCKET_ID, v)); +} +static DEVICE_ATTR_RO(socket_id); + static const struct attribute *fme_hdr_attrs[] = { &dev_attr_ports_num.attr, &dev_attr_bitstream_id.attr, &dev_attr_bitstream_metadata.attr, + &dev_attr_cache_size.attr, + &dev_attr_fabric_version.attr, + &dev_attr_socket_id.attr, NULL, }; -- 2.22.0