* [PATCH 0/2] mcb: export FPGA information via sysfs
@ 2016-03-18 13:49 Johannes Thumshirn
2016-03-18 13:49 ` [PATCH 1/2] mcb: Correctly initialize the bus's device Johannes Thumshirn
2016-03-18 13:49 ` [PATCH 2/2] mcb: export bus information via sysfs Johannes Thumshirn
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2016-03-18 13:49 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Andreas Werner, linux-kernel
The following series adds a way to obtain information about a MCB FPGA via
sysfs. This is viable i.e. for a field technician to check if the latest FPGA
bitstream version is applied to the hardware.
The first patch layes the foundation in order to get sysfs correctly working
with MCB and the second patch exports the bus information into sysfs.
Johannes Thumshirn (2):
mcb: Correctly initialize the bus's device
mcb: export bus information via sysfs
Documentation/ABI/testing/sysfs-bus-mcb | 29 ++++++++++++
drivers/mcb/mcb-core.c | 79 +++++++++++++++++++++++++++++++--
drivers/mcb/mcb-internal.h | 1 -
drivers/mcb/mcb-parse.c | 15 +++----
include/linux/mcb.h | 14 ++++--
5 files changed, 121 insertions(+), 17 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-mcb
--
2.7.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] mcb: Correctly initialize the bus's device
2016-03-18 13:49 [PATCH 0/2] mcb: export FPGA information via sysfs Johannes Thumshirn
@ 2016-03-18 13:49 ` Johannes Thumshirn
2016-03-18 14:04 ` kbuild test robot
2016-03-18 13:49 ` [PATCH 2/2] mcb: export bus information via sysfs Johannes Thumshirn
1 sibling, 1 reply; 4+ messages in thread
From: Johannes Thumshirn @ 2016-03-18 13:49 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Andreas Werner, linux-kernel
The mcb bus' device member wasn't correctly initialized and thus wasn't placed
correctly into the driver model.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
---
drivers/mcb/mcb-core.c | 20 +++++++++++++++++---
include/linux/mcb.h | 5 ++---
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index a4be451..2633a6b 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -187,6 +187,7 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
{
struct mcb_bus *bus;
int bus_nr;
+ int rc;
bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL);
if (!bus)
@@ -194,14 +195,27 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
if (bus_nr < 0) {
- kfree(bus);
- return ERR_PTR(bus_nr);
+ rc = bus_nr;
+ goto err_free;
}
- INIT_LIST_HEAD(&bus->children);
bus->bus_nr = bus_nr;
bus->carrier = carrier;
+
+ device_initialize(&bus->dev);
+ bus->dev.parent = carrier;
+ bus->dev.bus = &mcb_bus_type;
+ bus->dev.type = &mcb_carrier_device_type;
+
+ dev_set_name(&bus->dev, "mcb:%d", bus_nr);
+ rc = device_add(&bus->dev);
+ if (rc)
+ goto err_free;
+
return bus;
+err_free:
+ kfree(bus);
+ return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(mcb_alloc_bus);
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ed06e15..3efafbc 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -21,13 +21,12 @@ struct mcb_device;
/**
* struct mcb_bus - MEN Chameleon Bus
*
- * @dev: pointer to carrier device
- * @children: the child busses
+ * @dev: bus device
+ * @carrier: pointer to carrier device
* @bus_nr: mcb bus number
* @get_irq: callback to get IRQ number
*/
struct mcb_bus {
- struct list_head children;
struct device dev;
struct device *carrier;
int bus_nr;
--
2.7.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] mcb: export bus information via sysfs
2016-03-18 13:49 [PATCH 0/2] mcb: export FPGA information via sysfs Johannes Thumshirn
2016-03-18 13:49 ` [PATCH 1/2] mcb: Correctly initialize the bus's device Johannes Thumshirn
@ 2016-03-18 13:49 ` Johannes Thumshirn
1 sibling, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2016-03-18 13:49 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Andreas Werner, linux-kernel
Export information about the bus stored in the FPGA's header to userspace via
sysfs, instead of hiding it in pr_debug()s from everyone.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
---
Documentation/ABI/testing/sysfs-bus-mcb | 29 ++++++++++++++++
drivers/mcb/mcb-core.c | 59 +++++++++++++++++++++++++++++++++
drivers/mcb/mcb-internal.h | 1 -
drivers/mcb/mcb-parse.c | 15 +++------
include/linux/mcb.h | 9 +++++
5 files changed, 102 insertions(+), 11 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-mcb
diff --git a/Documentation/ABI/testing/sysfs-bus-mcb b/Documentation/ABI/testing/sysfs-bus-mcb
new file mode 100644
index 0000000..77947c5
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-mcb
@@ -0,0 +1,29 @@
+What: /sys/bus/mcb/devices/mcb:X
+Date: March 2016
+KernelVersion: 4.7
+Contact: Johannes Thumshirn <jth@kernel.org>
+Description: Hardware chip or device hosting the MEN chameleon bus
+
+What: /sys/bus/mcb/devices/mcb:X/revision
+Date: March 2016
+KernelVersion: 4.7
+Contact: Johannes Thumshirn <jth@kernel.org>
+Description: The FPGA's revision number
+
+What: /sys/bus/mcb/devices/mcb:X/minor
+Date: March 2016
+KernelVersion: 4.7
+Contact: Johannes Thumshirn <jth@kernel.org>
+Description: The FPGA's minor number
+
+What: /sys/bus/mcb/devices/mcb:X/model
+Date: March 2016
+KernelVersion: 4.7
+Contact: Johannes Thumshirn <jth@kernel.org>
+Description: The FPGA's model number
+
+What: /sys/bus/mcb/devices/mcb:X/name
+Date: March 2016
+KernelVersion: 4.7
+Contact: Johannes Thumshirn <jth@kernel.org>
+Description: The FPGA's name
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 2633a6b..9ae4d15 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -90,6 +90,60 @@ static void mcb_shutdown(struct device *dev)
mdrv->shutdown(mdev);
}
+static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct mcb_bus *bus = to_mcb_bus(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n", bus->revision);
+}
+static DEVICE_ATTR_RO(revision);
+
+static ssize_t model_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct mcb_bus *bus = to_mcb_bus(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%c\n", bus->model);
+}
+static DEVICE_ATTR_RO(model);
+
+static ssize_t minor_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct mcb_bus *bus = to_mcb_bus(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n", bus->minor);
+}
+static DEVICE_ATTR_RO(minor);
+
+static ssize_t name_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct mcb_bus *bus = to_mcb_bus(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", bus->name);
+}
+static DEVICE_ATTR_RO(name);
+
+static struct attribute *mcb_bus_attrs[] = {
+ &dev_attr_revision.attr,
+ &dev_attr_model.attr,
+ &dev_attr_minor.attr,
+ &dev_attr_name.attr,
+ NULL,
+};
+
+static const struct attribute_group mcb_carrier_group = {
+ .attrs = mcb_bus_attrs,
+};
+
+static const struct attribute_group *mcb_carrier_groups[] = {
+ &mcb_carrier_group,
+ NULL,
+};
+
+
static struct bus_type mcb_bus_type = {
.name = "mcb",
.match = mcb_match,
@@ -99,6 +153,11 @@ static struct bus_type mcb_bus_type = {
.shutdown = mcb_shutdown,
};
+static struct device_type mcb_carrier_device_type = {
+ .name = "mcb-carrier",
+ .groups = mcb_carrier_groups,
+};
+
/**
* __mcb_register_driver() - Register a @mcb_driver at the system
* @drv: The @mcb_driver
diff --git a/drivers/mcb/mcb-internal.h b/drivers/mcb/mcb-internal.h
index fb7493d..5254e02 100644
--- a/drivers/mcb/mcb-internal.h
+++ b/drivers/mcb/mcb-internal.h
@@ -5,7 +5,6 @@
#define PCI_VENDOR_ID_MEN 0x1a88
#define PCI_DEVICE_ID_MEN_CHAMELEON 0x4d45
-#define CHAMELEON_FILENAME_LEN 12
#define CHAMELEONV2_MAGIC 0xabce
#define CHAM_HEADER_SIZE 0x200
diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 0049269..35f385b 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -113,16 +113,11 @@ int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
}
p += hsize;
- pr_debug("header->revision = %d\n", header->revision);
- pr_debug("header->model = 0x%x ('%c')\n", header->model,
- header->model);
- pr_debug("header->minor = %d\n", header->minor);
- pr_debug("header->bus_type = 0x%x\n", header->bus_type);
-
-
- pr_debug("header->magic = 0x%x\n", header->magic);
- pr_debug("header->filename = \"%.*s\"\n", CHAMELEON_FILENAME_LEN,
- header->filename);
+ bus->revision = header->revision;
+ bus->model = header->model;
+ bus->minor = header->minor;
+ snprintf(bus->name, CHAMELEON_FILENAME_LEN + 1, "%s",
+ header->filename);
for_each_chameleon_cell(dtype, p) {
switch (dtype) {
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index 3efafbc..ead13d2 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -15,6 +15,8 @@
#include <linux/device.h>
#include <linux/irqreturn.h>
+#define CHAMELEON_FILENAME_LEN 12
+
struct mcb_driver;
struct mcb_device;
@@ -25,11 +27,18 @@ struct mcb_device;
* @carrier: pointer to carrier device
* @bus_nr: mcb bus number
* @get_irq: callback to get IRQ number
+ * @revision: the FPGA's revision number
+ * @model: the FPGA's model number
+ * @filename: the FPGA's name
*/
struct mcb_bus {
struct device dev;
struct device *carrier;
int bus_nr;
+ u8 revision;
+ char model;
+ u8 minor;
+ char name[CHAMELEON_FILENAME_LEN + 1];
int (*get_irq)(struct mcb_device *dev);
};
#define to_mcb_bus(b) container_of((b), struct mcb_bus, dev)
--
2.7.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mcb: Correctly initialize the bus's device
2016-03-18 13:49 ` [PATCH 1/2] mcb: Correctly initialize the bus's device Johannes Thumshirn
@ 2016-03-18 14:04 ` kbuild test robot
0 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2016-03-18 14:04 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: kbuild-all, Johannes Thumshirn, Andreas Werner, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1601 bytes --]
Hi Johannes,
[auto build test ERROR on v4.5-rc7]
[also build test ERROR on next-20160318]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/mcb-export-FPGA-information-via-sysfs/20160318-215254
config: x86_64-randconfig-x001-201611 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
Note: the linux-review/Johannes-Thumshirn/mcb-export-FPGA-information-via-sysfs/20160318-215254 HEAD c6d1aabc2067586d00c2b367c36e8b0df9a151ce builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/mcb/mcb-core.c: In function 'mcb_alloc_bus':
>> drivers/mcb/mcb-core.c:208:19: error: 'mcb_carrier_device_type' undeclared (first use in this function)
bus->dev.type = &mcb_carrier_device_type;
^
drivers/mcb/mcb-core.c:208:19: note: each undeclared identifier is reported only once for each function it appears in
vim +/mcb_carrier_device_type +208 drivers/mcb/mcb-core.c
202 bus->bus_nr = bus_nr;
203 bus->carrier = carrier;
204
205 device_initialize(&bus->dev);
206 bus->dev.parent = carrier;
207 bus->dev.bus = &mcb_bus_type;
> 208 bus->dev.type = &mcb_carrier_device_type;
209
210 dev_set_name(&bus->dev, "mcb:%d", bus_nr);
211 rc = device_add(&bus->dev);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 19137 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-18 14:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 13:49 [PATCH 0/2] mcb: export FPGA information via sysfs Johannes Thumshirn
2016-03-18 13:49 ` [PATCH 1/2] mcb: Correctly initialize the bus's device Johannes Thumshirn
2016-03-18 14:04 ` kbuild test robot
2016-03-18 13:49 ` [PATCH 2/2] mcb: export bus information via sysfs Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®