Skip to contentSkip to conversation

FSI device driver implementation

PATCH Superseded Christopher Bostic 3 participants 29 messages May 11, 2017 – Jun 5, 2017

Subsystems (5)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover FSI device driver implementation

Implementation of the IBM 'Flexible Support Interface' (FSI) bus device driver. FSI is a high fan out serial bus consisting of a clock and a serial data line capable of running at speeds up to 166 MHz.

This set provides the basic framework to add FSI extensions to the Linux bus and device models. Master specific implementations are defined to utilize the core FSI function.

In Linux, we have a core FSI "bus type", along with drivers for FSI masters and engines.

The FSI master drivers expose a read/write interface to the bus address space. The master drivers are under drivers/fsi/fsi-master-*.c.

The core handles probing and discovery of slaves and slave engines, using those read/write interfaces. It is responsible for creating the endpoint Linux devices corresponding to the discovered engines on each slave.

Slave engines are identified by an 'engine' type, and an optional version. Engine, a.k.a. client, drivers are matched and bound to these engines during discovery.

This patch set does not include extended FSI function such as:

    *  Cascaded master support
    *  Application layer hot plug notification
    *  Application layer FSI bus status interface

Common FSI terminology:

* Master
Controller of the FSI bus. Only the master is allowed to control the clock line and is the initiator of all transactions on a bus.

* Slave
The receiver or target of a master initiated transaction. The slave cannot initiate communications on a bus and must respond to any master requests for data.

* CFAM
Stands for Common Field replaceable unit Access Macro. A CFAM is an ASIC residing in any device requiring FSI communications. CFAMs consist of an array of hardware 'engines' used for various purposes. I2C masters, UARTs, General Purpose IO hardware are common types of these engines.

* Configuration Space / Table
A table contained at the beginning of each CFAM address space. This table lists information such as the CFAM's ID, which engine types and versions it has available, as well as its addressing range.

* FSI Engine driver
A device driver that registers with the FSI core so that it can access devices it owns on an FSI bus.

* Hub
An FSI master that connects to an upstream 'primary' master allowing high fanout of target devices.

----
Changes in v7:
- Use GENMASK for bitmask definitions
- Move instances of dev_info to dev_dbg
- Add missing return code checks
- Add API details for fsi_device_read/write/peek()
- GPIO master: Unscan when unregistering master
- Document ABI sysfs files raw, term, break, rescan
- GPIO master: move global spinlock into struct fsi_master_gpio
- GPIO master: remove redundant checks for valid pin descriptors

Changes in v6:
- Remove redundant 'depends on' specifiers in Kconfig for SCOM GPIO master and Hub masters.

Changes in v5:
- Remove explicit kfree of struct fsi_master in fsi_master_gpio.
- Remove Palmetto and Romulus dts device tree file udates for FSI gpio master

Changes in v4:
- endianness: the _read() and _write() APIs are now all *bus endian*, so will be the same on all platforms (the previous fsi patches exposed as (BMC/FSP) CPU endian, which is variable).
- device tree: Remove the "ibm," prefix for the fsi core and GPIO master compatibility strings, as they're not describing IBM-specific
- device model: Create separate struct devices for each FSI master, which fits better with the Linux device model, and allows addition of sysfs attributes that are implemented by the fsi core
- sysfs: there are now sysfs facilities for break and term. Raw file supports reads and writes of arbitrary sizes.
- GPIO master: split the xfer() logic out a little, so that the response handling & DPOLL retry mechanism is more obvious
- GPIO master: simplifications for message construction
- GPIO master: fixes for some CRC calculations
- GPIO master: issue TERM in response to DPOLL busy-loops
- Error handling: rather than handle errors on (potentially) an entire cascaded read or write, the error handling is now down on a per-slave basis, where we try to reestablish communication in a more "gradual" manner, rather than sending a break immediately. May need to add a hook to percolate error recovery up to a slave's master but no need seen for that at present.
- Hub master: this is now implemented as a fsi engine driver, as the fsi_slave_{read,write}() functions are exported (and the port count is available in the hMFSI configuration register)
This means we need fewer special-cases in the fsi core.
- Tracepoints: Add tracepoints for FSI core read & write, and another set for low-level GPIO in/out operations.

Changes in v3:
- Patch set contained an invalid 18/18 test patch not meant for community review, corrected.

Changes in v2:
- Change from atomic global for master number to ida simple interface.
- Add valid pointer checks on register and unregister utils.
- Move CRC calculation utilities out of driver to lib path.
- Clean up white space issues.
- Remove added list management of master devices and use instead the device_for_each_child method available in the bus.
- Add new patch to document FSI bus functionality.
- Add new patch documenting FSI gpio master.
- Rearrage patch set to have documentation earlier than code implementing it.
- Document all compatible strings used in device tree bindings.
- Elaborate documentation definition of FSI GPIO master.
- Describe in more detail what each GPIO FSI master pin is for.
- Re-order compatible strings in example binding so that most specific device comes first.
- Indicate proper activation order of all FSI GPIO master pins.
- Fix an unmatched '>' bracket in the example for binding.
- Bracket each element of the example bindings individually.
- Add new patch documenting sysfs-bus-fsi attributes.
- Merge FSI GPIO master init into probe function.
- Set pin initial values at time of pin request.
- Assign value of master->master.dev at probe time.
- Use get_optional interface for all optional GPIO pins.

Christopher Bostic (9):
drivers/fsi: Document FSI master sysfs files in ABI drivers/fsi: Set up links for slave communication drivers/fsi: Set slave SMODE to init communication drivers/fsi: Add master unscan
drivers/fsi: Add documentation for GPIO bindings drivers/fsi: Add client driver register utilities drivers/fsi: Add GPIO based FSI master drivers/fsi: Add SCOM FSI client device driver drivers/fsi: Add hub master support

Jeremy Kerr (14):
drivers/fsi: Add fsi master definition drivers/fsi: Add slave definition
drivers/fsi: Add empty master scan
lib: Add crc4 module
drivers/fsi: Add slave & master read/write APIs drivers/fsi: Implement slave initialisation drivers/fsi: scan slaves & register devices drivers/fsi: Add device read/write/peek API drivers/fsi: Add sysfs files for FSI master & slave accesses drivers/fsi: expose direct-access slave API drivers/fsi: Add tracepoints for low-level operations drivers/fsi: Add error handling for slave drivers/fsi/gpio: Add tracepoints for GPIO master drivers/fsi: Use asynchronous slave mode

 Documentation/ABI/testing/sysfs-bus-fsi            |  38 +
 .../devicetree/bindings/fsi/fsi-master-gpio.txt    |  24 +
 drivers/fsi/Kconfig                                |  26 +
 drivers/fsi/Makefile                               |   3 +
 drivers/fsi/fsi-core.c                             | 836 +++++++++++++++++++++
 drivers/fsi/fsi-master-gpio.c                      | 604 +++++++++++++++
 drivers/fsi/fsi-master-hub.c                       | 327 ++++++++
 drivers/fsi/fsi-master.h                           |  43 ++
 drivers/fsi/fsi-scom.c                             | 263 +++++++
 include/linux/crc4.h                               |   8 +
 include/linux/fsi.h                                |  35 +-
 include/trace/events/fsi.h                         | 127 ++++
 include/trace/events/fsi_master_gpio.h             |  68 ++
 lib/Kconfig                                        |   8 +
 lib/Makefile                                       |   1 +
 lib/crc4.c                                         |  46 ++
 16 files changed, 2456 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi
 create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt
 create mode 100644 drivers/fsi/fsi-master-gpio.c
 create mode 100644 drivers/fsi/fsi-master-hub.c
 create mode 100644 drivers/fsi/fsi-master.h
 create mode 100644 drivers/fsi/fsi-scom.c
 create mode 100644 include/linux/crc4.h
 create mode 100644 include/trace/events/fsi.h
 create mode 100644 include/trace/events/fsi_master_gpio.h
 create mode 100644 lib/crc4.c
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH v7 1/23 drivers/fsi: Add fsi master definition

From: Jeremy Kerr <[email protected]>

Add a struct fsi_master to represent a FSI master controller.

FSI master drivers register one of these structs to provide device-specific of the standard operations: read/write/term/break and link control.

Includes changes from Edward A. James <[email protected]> & Jeremy Kerr <[email protected]>.

---
 drivers/fsi/fsi-core.c   | 35 +++++++++++++++++++++++++++++++++++
 drivers/fsi/fsi-master.h | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100644 drivers/fsi/fsi-master.h
drivers/fsi/fsi-core.c +35 -0
index 3d55bd5..ca02913 100644
@@ -15,8 +15,43 @@
 
 #include <linux/device.h>
 #include <linux/fsi.h>
+#include <linux/idr.h>
 #include <linux/module.h>
 
+#include "fsi-master.h"
+
+static DEFINE_IDA(master_ida);
+
+/* FSI master support */
+int fsi_master_register(struct fsi_master *master)
+{
+	int rc;
+
+	if (!master)
+		return -EINVAL;
+
+	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
+	dev_set_name(&master->dev, "fsi%d", master->idx);
+
+	rc = device_register(&master->dev);
+	if (rc)
+		ida_simple_remove(&master_ida, master->idx);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(fsi_master_register);
+
+void fsi_master_unregister(struct fsi_master *master)
+{
+	if (master->idx >= 0) {
+		ida_simple_remove(&master_ida, master->idx);
+		master->idx = -1;
+	}
+
+	device_unregister(&master->dev);
+}
+EXPORT_SYMBOL_GPL(fsi_master_unregister);
+
 /* FSI core & Linux bus type definitions */
 
 static int fsi_bus_match(struct device *dev, struct device_driver *drv)
drivers/fsi/fsi-master.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#2 lore raw

PATCH v7 2/23 drivers/fsi: Add slave definition

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Add the initial fsi slave device, which is private to the core code. This will be a child of the master, and parent to endpoint devices.

---
 drivers/fsi/fsi-core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/fsi/fsi-core.c +10 -0
index ca02913..2f19509 100644
@@ -22,6 +22,16 @@
 
 static DEFINE_IDA(master_ida);
 
+struct fsi_slave {
+	struct device		dev;
+	struct fsi_master	*master;
+	int			id;
+	int			link;
+	uint32_t		size;	/* size of slave address space */
+};
+
+#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
+
 /* FSI master support */
 int fsi_master_register(struct fsi_master *master)
 {
Signature · 1 line
1.8.2.2
#3 lore raw

PATCH v7 3/23 drivers/fsi: Add empty master scan

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

When a new fsi master is added, we will need to scan its links, and slaves attached to those links. This change introduces a little shell to iterate the links, which we will populate with the actual slave scan in a later change.

---
 drivers/fsi/fsi-core.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +23 -2
index 2f19509..e90d45d 100644
@@ -32,7 +32,25 @@ struct fsi_slave {
 
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+/* FSI slave support */
+static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
+{
+	/* todo: initialise slave device, perform engine scan */
+
+	return -ENODEV;
+}
+
 /* FSI master support */
+static int fsi_master_scan(struct fsi_master *master)
+{
+	int link;
+
+	for (link = 0; link < master->n_links; link++)
+		fsi_slave_init(master, link, 0);
+
+	return 0;
+}
+
 int fsi_master_register(struct fsi_master *master)
 {
 	int rc;
@@ -44,10 +62,13 @@ int fsi_master_register(struct fsi_master *master)
 	dev_set_name(&master->dev, "fsi%d", master->idx);
 
 	rc = device_register(&master->dev);
-	if (rc)
+	if (rc) {
 		ida_simple_remove(&master_ida, master->idx);
+		return rc;
+	}
 
-	return rc;
+	fsi_master_scan(master);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(fsi_master_register);
 
Signature · 1 line
1.8.2.2
#4 lore raw

PATCH v7 4/23 lib: Add crc4 module

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Add a little helper for crc4 calculations. This works 4-bits-at-a-time, using a simple table approach.

We will need this in the FSI core code, as well as any master implementations that need to calculate CRCs in software.

---
 include/linux/crc4.h |  8 ++++++++
 lib/Kconfig          |  8 ++++++++
 lib/Makefile         |  1 +
 lib/crc4.c           | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+)
 create mode 100644 include/linux/crc4.h
 create mode 100644 lib/crc4.c
include/linux/crc4.h new file +8 -0
new file mode 100644
index 0000000..8f739f1
@@ -0,0 +1,8 @@
+#ifndef _LINUX_CRC4_H
+#define _LINUX_CRC4_H
+
+#include <linux/types.h>
+
+extern uint8_t crc4(uint8_t c, uint64_t x, int bits);
+
+#endif /* _LINUX_CRC4_H */
lib/Kconfig +8 -0
index 0c8b78a..d2fd262 100644
@@ -158,6 +158,14 @@ config CRC32_BIT
 
 endchoice
 
+config CRC4
+	tristate "CRC4 functions"
+	help
+	  This option is provided for the case where no in-kernel-tree
+	  modules require CRC4 functions, but a module built outside
+	  the kernel tree does. Such modules that use library CRC4
+	  functions require M here.
+
 config CRC7
 	tristate "CRC7 functions"
 	help
lib/Makefile +1 -0
index 320ac46a..63b3c28 100644
@@ -98,6 +98,7 @@ obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
 obj-$(CONFIG_CRC_ITU_T)	+= crc-itu-t.o
 obj-$(CONFIG_CRC32)	+= crc32.o
 obj-$(CONFIG_CRC32_SELFTEST)	+= crc32test.o
+obj-$(CONFIG_CRC4)	+= crc4.o
 obj-$(CONFIG_CRC7)	+= crc7.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
 obj-$(CONFIG_CRC8)	+= crc8.o
lib/crc4.c new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#5 lore raw

PATCH v7 5/23 drivers/fsi: Add slave & master read/write APIs

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Introduce functions to perform reads/writes on the slave address space; these simply pass the request on the slave's master with the correct link and slave ID.

We implement these on top of similar helpers for the master.

---
 drivers/fsi/fsi-core.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
drivers/fsi/fsi-core.c +92 -0
index e90d45d..1ec9790 100644
@@ -32,7 +32,64 @@ struct fsi_slave {
 
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+static int fsi_master_read(struct fsi_master *master, int link,
+		uint8_t slave_id, uint32_t addr, void *val, size_t size);
+static int fsi_master_write(struct fsi_master *master, int link,
+		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
+
 /* FSI slave support */
+static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp,
+		uint8_t *idp)
+{
+	uint32_t addr = *addrp;
+	uint8_t id = *idp;
+
+	if (addr > slave->size)
+		return -EINVAL;
+
+	/* For 23 bit addressing, we encode the extra two bits in the slave
+	 * id (and the slave's actual ID needs to be 0).
+	 */
+	if (addr > 0x1fffff) {
+		if (slave->id != 0)
+			return -EINVAL;
+		id = (addr >> 21) & 0x3;
+		addr &= 0x1fffff;
+	}
+
+	*addrp = addr;
+	*idp = id;
+	return 0;
+}
+
+static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
+			void *val, size_t size)
+{
+	uint8_t id = slave->id;
+	int rc;
+
+	rc = fsi_slave_calc_addr(slave, &addr, &id);
+	if (rc)
+		return rc;
+
+	return fsi_master_read(slave->master, slave->link, id,
+			addr, val, size);
+}
+
+static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
+			const void *val, size_t size)
+{
+	uint8_t id = slave->id;
+	int rc;
+
+	rc = fsi_slave_calc_addr(slave, &addr, &id);
+	if (rc)
+		return rc;
+
+	return fsi_master_write(slave->master, slave->link, id,
+			addr, val, size);
+}
+
 static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 {
 	/* todo: initialise slave device, perform engine scan */
@@ -41,6 +98,41 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 }
 
 /* FSI master support */
+static int fsi_check_access(uint32_t addr, size_t size)
+{
+	if (size != 1 && size != 2 && size != 4)
+		return -EINVAL;
+
+	if ((addr & 0x3) != (size & 0x3))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int fsi_master_read(struct fsi_master *master, int link,
+		uint8_t slave_id, uint32_t addr, void *val, size_t size)
+{
+	int rc;
+
+	rc = fsi_check_access(addr, size);
+	if (rc)
+		return rc;
+
+	return master->read(master, link, slave_id, addr, val, size);
+}
+
+static int fsi_master_write(struct fsi_master *master, int link,
+		uint8_t slave_id, uint32_t addr, const void *val, size_t size)
+{
+	int rc;
+
+	rc = fsi_check_access(addr, size);
+	if (rc)
+		return rc;
+
+	return master->write(master, link, slave_id, addr, val, size);
+}
+
 static int fsi_master_scan(struct fsi_master *master)
 {
 	int link;
Signature · 1 line
1.8.2.2
#6 lore raw

PATCH v7 6/23 drivers/fsi: Set up links for slave communication

In reply to Christopher Bostic

Enable each link and send a break command, and try to detect a slave by reading from the SMODE register.

---
 drivers/fsi/fsi-core.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +35 -2
index 1ec9790..235f17a 100644
@@ -133,12 +133,45 @@ static int fsi_master_write(struct fsi_master *master, int link,
 	return master->write(master, link, slave_id, addr, val, size);
 }
 
+static int fsi_master_link_enable(struct fsi_master *master, int link)
+{
+	if (master->link_enable)
+		return master->link_enable(master, link);
+
+	return 0;
+}
+
+/*
+ * Issue a break command on this link
+ */
+static int fsi_master_break(struct fsi_master *master, int link)
+{
+	if (master->send_break)
+		return master->send_break(master, link);
+
+	return 0;
+}
+
 static int fsi_master_scan(struct fsi_master *master)
 {
-	int link;
+	int link, rc;
+
+	for (link = 0; link < master->n_links; link++) {
+		rc = fsi_master_link_enable(master, link);
+		if (rc) {
+			dev_dbg(&master->dev,
+				"enable link %d failed: %d\n", link, rc);
+			continue;
+		}
+		rc = fsi_master_break(master, link);
+		if (rc) {
+			dev_dbg(&master->dev,
+				"break to link %d failed: %d\n", link, rc);
+			continue;
+		}
 
-	for (link = 0; link < master->n_links; link++)
 		fsi_slave_init(master, link, 0);
+	}
 
 	return 0;
 }
Signature · 1 line
1.8.2.2
#7 lore raw

PATCH v7 7/23 drivers/fsi: Implement slave initialisation

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Implement fsi_slave_init: if we can read a chip ID, create fsi_slave devices and register with the driver core.

Includes changes from Christopher Bostic <[email protected]>.

---
v7 - Change warning message to debug type when can't read slave

---
 drivers/fsi/Kconfig    |  1 +
 drivers/fsi/fsi-core.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 2 deletions(-)
drivers/fsi/Kconfig +1 -0
index 04c1a0e..e1006c6 100644
@@ -6,6 +6,7 @@ menu "FSI support"
 
 config FSI
 	tristate "FSI support"
+	select CRC4
 	---help---
 	  FSI - the FRU Support Interface - is a simple bus for low-level
 	  access to POWER-based hardware.
drivers/fsi/fsi-core.c +65 -2

89 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#8 lore raw

PATCH v7 8/23 drivers/fsi: Set slave SMODE to init communication

In reply to Christopher Bostic

Set CFAM to appropriate ID so that the controlling master can manage link memory ranges. Add slave engine register definitions.

Includes changes from Jeremy Kerr <[email protected]>.

---
 drivers/fsi/fsi-core.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
drivers/fsi/fsi-core.c +75 -0
index 9d9adc1..04795f2 100644
@@ -22,6 +22,27 @@
 
 #include "fsi-master.h"
 
+#define FSI_SLAVE_BASE			0x800
+
+/*
+ * FSI slave engine control register offsets
+ */
+#define FSI_SMODE			0x0	/* R/W: Mode register */
+
+/*
+ * SMODE fields
+ */
+#define FSI_SMODE_WSC		0x80000000	/* Warm start done */
+#define FSI_SMODE_ECRC		0x20000000	/* Hw CRC check */
+#define FSI_SMODE_SID_SHIFT	24		/* ID shift */
+#define FSI_SMODE_SID_MASK	3		/* ID Mask */
+#define FSI_SMODE_ED_SHIFT	20		/* Echo delay shift */
+#define FSI_SMODE_ED_MASK	0xf		/* Echo delay mask */
+#define FSI_SMODE_SD_SHIFT	16		/* Send delay shift */
+#define FSI_SMODE_SD_MASK	0xf		/* Send delay mask */
+#define FSI_SMODE_LBCRR_SHIFT	8		/* Clk ratio shift */
+#define FSI_SMODE_LBCRR_MASK	0xf		/* Clk ratio mask */
+
 #define FSI_SLAVE_SIZE_23b		0x800000
 
 static DEFINE_IDA(master_ida);
@@ -94,6 +115,52 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 			addr, val, size);
 }
 
+/* Encode slave local bus echo delay */
+static inline uint32_t fsi_smode_echodly(int x)
+{
+	return (x & FSI_SMODE_ED_MASK) << FSI_SMODE_ED_SHIFT;
+}
+
+/* Encode slave local bus send delay */
+static inline uint32_t fsi_smode_senddly(int x)
+{
+	return (x & FSI_SMODE_SD_MASK) << FSI_SMODE_SD_SHIFT;
+}
+
+/* Encode slave local bus clock rate ratio */
+static inline uint32_t fsi_smode_lbcrr(int x)
+{
+	return (x & FSI_SMODE_LBCRR_MASK) << FSI_SMODE_LBCRR_SHIFT;
+}
+
+/* Encode slave ID */
+static inline uint32_t fsi_smode_sid(int x)
+{
+	return (x & FSI_SMODE_SID_MASK) << FSI_SMODE_SID_SHIFT;
+}
+
+static const uint32_t fsi_slave_smode(int id)
+{
+	return FSI_SMODE_WSC | FSI_SMODE_ECRC
+		| fsi_smode_sid(id)
+		| fsi_smode_echodly(0xf) | fsi_smode_senddly(0xf)
+		| fsi_smode_lbcrr(0x8);
+}
+
+static int fsi_slave_set_smode(struct fsi_master *master, int link, int id)
+{
+	uint32_t smode;
+
+	/* set our smode register with the slave ID field to 0; this enables
+	 * extended slave addressing
+	 */
+	smode = fsi_slave_smode(id);
+	smode = cpu_to_be32(smode);
+
+	return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SMODE,
+			&smode, sizeof(smode));
+}
+
 static void fsi_slave_release(struct device *dev)
 {
 	struct fsi_slave *slave = to_fsi_slave(dev);
@@ -132,6 +199,14 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 	dev_info(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n",
 			chip_id, master->idx, link, id);
 
+	rc = fsi_slave_set_smode(master, link, id);
+	if (rc) {
+		dev_warn(&master->dev,
+				"can't set smode on slave:%02x:%02x %d\n",
+				link, id, rc);
+		return -ENODEV;
+	}
+
 	/* We can communicate with a slave; create the slave device and
 	 * register.
 	 */
Signature · 1 line
1.8.2.2
#9 lore raw

PATCH v7 9/23 drivers/fsi: scan slaves & register devices

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Now that we have fsi_slave devices, scan each for endpoints, and register them on the fsi bus.

Includes contributions from Christopher Bostic
<[email protected]>.

---
v7 - Use GEN_MASK for bitmask definitions
- check return code from fsi_slave_scan()
- change dev_info() to dev_dbg() to reduce console spam

---
 drivers/fsi/fsi-core.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fsi.h    |   4 ++
 2 files changed, 131 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +127 -1
index 04795f2..eac0bc4 100644
@@ -19,9 +19,23 @@
 #include <linux/idr.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/bitops.h>
 
 #include "fsi-master.h"
 
+#define FSI_SLAVE_CONF_NEXT_MASK	GENMASK(31, 31)
+#define FSI_SLAVE_CONF_SLOTS_MASK	GENMASK(23, 16)
+#define FSI_SLAVE_CONF_SLOTS_SHIFT	16
+#define FSI_SLAVE_CONF_VERSION_MASK	GENMASK(15, 12)
+#define FSI_SLAVE_CONF_VERSION_SHIFT	12
+#define FSI_SLAVE_CONF_TYPE_MASK	GENMASK(11, 4)
+#define FSI_SLAVE_CONF_TYPE_SHIFT	4
+#define FSI_SLAVE_CONF_CRC_SHIFT	4
+#define FSI_SLAVE_CONF_CRC_MASK		GENMASK(3, 0)
+#define FSI_SLAVE_CONF_DATA_BITS	28
+
+static const int engine_page_size = 0x400;
+
 #define FSI_SLAVE_BASE			0x800
 
 /*
@@ -62,6 +76,30 @@ static int fsi_master_read(struct fsi_master *master, int link,
 static int fsi_master_write(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
 
+/* FSI endpoint-device support */
+
+static void fsi_device_release(struct device *_device)
+{
+	struct fsi_device *device = to_fsi_dev(_device);
+
+	kfree(device);
+}
+
+static struct fsi_device *fsi_create_device(struct fsi_slave *slave)
+{
+	struct fsi_device *dev;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	dev->dev.parent = &slave->dev;
+	dev->dev.bus = &fsi_bus_type;
+	dev->dev.release = fsi_device_release;
+
+	return dev;
+}
+
 /* FSI slave support */
 static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp,
 		uint8_t *idp)
@@ -115,6 +153,91 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 			addr, val, size);
 }
 
+static int fsi_slave_scan(struct fsi_slave *slave)
+{
+	uint32_t engine_addr;
+	uint32_t conf;
+	int rc, i;
+
+	/*
+	 * scan engines
+	 *
+	 * We keep the peek mode and slave engines for the core; so start
+	 * at the third slot in the configuration table. We also need to
+	 * skip the chip ID entry at the start of the address space.
+	 */
+	engine_addr = engine_page_size * 3;
+	for (i = 2; i < engine_page_size / sizeof(uint32_t); i++) {
+		uint8_t slots, version, type, crc;
+		struct fsi_device *dev;
+
+		rc = fsi_slave_read(slave, (i + 1) * sizeof(conf),
+				&conf, sizeof(conf));
+		if (rc) {
+			dev_warn(&slave->dev,
+				"error reading slave registers\n");
+			return -1;
+		}
+		conf = be32_to_cpu(conf);
+
+		crc = crc4(0, conf, 32);
+		if (crc) {
+			dev_warn(&slave->dev,
+				"crc error in slave register at 0x%04x\n",
+				i);
+			return -1;
+		}
+
+		slots = (conf & FSI_SLAVE_CONF_SLOTS_MASK)
+			>> FSI_SLAVE_CONF_SLOTS_SHIFT;
+		version = (conf & FSI_SLAVE_CONF_VERSION_MASK)
+			>> FSI_SLAVE_CONF_VERSION_SHIFT;
+		type = (conf & FSI_SLAVE_CONF_TYPE_MASK)
+			>> FSI_SLAVE_CONF_TYPE_SHIFT;
+
+		/*
+		 * Unused address areas are marked by a zero type value; this
+		 * skips the defined address areas
+		 */
+		if (type != 0 && slots != 0) {
+
+			/* create device */
+			dev = fsi_create_device(slave);
+			if (!dev)
+				return -ENOMEM;
+
+			dev->slave = slave;
+			dev->engine_type = type;
+			dev->version = version;
+			dev->unit = i;
+			dev->addr = engine_addr;
+			dev->size = slots * engine_page_size;
+
+			dev_dbg(&slave->dev,
+			"engine[%i]: type %x, version %x, addr %x size %x\n",
+					dev->unit, dev->engine_type, version,
+					dev->addr, dev->size);
+
+			dev_set_name(&dev->dev, "%02x:%02x:%02x:%02x",
+					slave->master->idx, slave->link,
+					slave->id, i - 2);
+
+			rc = device_register(&dev->dev);
+			if (rc) {
+				dev_warn(&slave->dev, "add failed: %d\n", rc);
+				put_device(&dev->dev);
+			}
+		}
+
+		engine_addr += slots * engine_page_size;
+
+		if (!(conf & FSI_SLAVE_CONF_NEXT_MASK))
+			break;
+	}
+
+	return 0;
+}
+
 /* Encode slave local bus echo delay */
 static inline uint32_t fsi_smode_echodly(int x)
 {
@@ -230,7 +353,10 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 		return rc;
 	}
 
-	/* todo: perform engine scan */
+	rc = fsi_slave_scan(slave);
+	if (rc)
+		dev_dbg(&master->dev, "failed during slave scan with: %d\n",
+				rc);
 
 	return rc;
 }
include/linux/fsi.h +4 -0
index 273cbf6..efa55ba 100644
@@ -21,6 +21,10 @@ struct fsi_device {
 	struct device		dev;
 	u8			engine_type;
 	u8			version;
+	u8			unit;
+	struct fsi_slave	*slave;
+	uint32_t		addr;
+	uint32_t		size;
 };
 
 struct fsi_device_id {
Signature · 1 line
1.8.2.2
#10 lore raw

PATCH v7 10/23 drivers/fsi: Add device read/write/peek API

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

This change introduces the fsi device API: simple read, write and peek accessors for the devices' address spaces.

Includes contributions from Christopher Bostic <[email protected]> and Edward A. James <[email protected]>.

---
v7 - Add API details for fsi_device_read/write/peek().

---
 drivers/fsi/fsi-core.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fsi.h    |  7 ++++++-
 2 files changed, 55 insertions(+), 2 deletions(-)
drivers/fsi/fsi-core.c +49 -1
index eac0bc4..d7a6e76 100644
@@ -34,6 +34,8 @@
 #define FSI_SLAVE_CONF_CRC_MASK		GENMASK(3, 0)
 #define FSI_SLAVE_CONF_DATA_BITS	28
 
+#define FSI_PEEK_BASE			0x410
+
 static const int engine_page_size = 0x400;
 
 #define FSI_SLAVE_BASE			0x800
@@ -75,8 +77,54 @@ static int fsi_master_read(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, void *val, size_t size);
 static int fsi_master_write(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
+static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
+		void *val, size_t size);
+static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
+		const void *val, size_t size);
+
+/*
+ * fsi_device_read() / fsi_device_write() / fsi_device_peek()
+ *
+ * FSI endpoint-device support
+ *
+ * Read / write / peek accessors for a client
+ *
+ * Parameters:
+ * dev:  Structure passed to FSI client device drivers on probe().
+ * addr: FSI address of given device.  Client should pass in its base address
+ *       plus desired offset to access its register space.
+ * val:  For read/peek this is the value read at the specified address. For
+ *       write this is value to write to the specified address.
+ *       The data in val must be FSI bus endian (big endian).
+ * size: Size in bytes of the operation.  Sizes supported are 1, 2 and 4 bytes.
+ *       Addresses must be aligned on size boundaries or an error will result.
+ */
+int fsi_device_read(struct fsi_device *dev, uint32_t addr, void *val,
+		size_t size)
+{
+	if (addr > dev->size || size > dev->size || addr > dev->size - size)
+		return -EINVAL;
 
-/* FSI endpoint-device support */
+	return fsi_slave_read(dev->slave, dev->addr + addr, val, size);
+}
+EXPORT_SYMBOL_GPL(fsi_device_read);
+
+int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val,
+		size_t size)
+{
+	if (addr > dev->size || size > dev->size || addr > dev->size - size)
+		return -EINVAL;
+
+	return fsi_slave_write(dev->slave, dev->addr + addr, val, size);
+}
+EXPORT_SYMBOL_GPL(fsi_device_write);
+
+int fsi_device_peek(struct fsi_device *dev, void *val)
+{
+	uint32_t addr = FSI_PEEK_BASE + ((dev->unit - 2) * sizeof(uint32_t));
+
+	return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t));
+}
 
 static void fsi_device_release(struct device *_device)
 {
include/linux/fsi.h +6 -1
index efa55ba..66bce48 100644
@@ -27,6 +27,12 @@ struct fsi_device {
 	uint32_t		size;
 };
 
+extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
+		void *val, size_t size);
+extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
+		const void *val, size_t size);
+extern int fsi_device_peek(struct fsi_device *dev, void *val);
+
 struct fsi_device_id {
 	u8	engine_type;
 	u8	version;
@@ -40,7 +46,6 @@ struct fsi_device_id {
 #define FSI_DEVICE_VERSIONED(t, v) \
 	.engine_type = (t), .version = (v),
 
-
 struct fsi_driver {
 	struct device_driver		drv;
 	const struct fsi_device_id	*id_table;
Signature · 1 line
1.8.2.2
#11 lore raw

PATCH v7 11/23 drivers/fsi: Add master unscan

In reply to Christopher Bostic

Allow a master to undo a previous scan. Should a master scan a bus twice it will need to ensure it doesn't double register any previously detected device.

----
v7 - Unscan when unregistering master
- Remove leading '__'s from function names
- Return fail state for sysfs rescan file

---
 drivers/fsi/fsi-core.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/fsi/fsi-core.c +44 -0
index d7a6e76..fcb0c81 100644
@@ -71,6 +71,7 @@ struct fsi_slave {
 	uint32_t		size;	/* size of slave address space */
 };
 
+#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
 static int fsi_master_read(struct fsi_master *master, int link,
@@ -488,6 +489,40 @@ static int fsi_master_scan(struct fsi_master *master)
 	return 0;
 }
 
+static int fsi_slave_remove_device(struct device *dev, void *arg)
+{
+	device_unregister(dev);
+	return 0;
+}
+
+static int fsi_master_remove_slave(struct device *dev, void *arg)
+{
+	device_for_each_child(dev, NULL, fsi_slave_remove_device);
+	device_unregister(dev);
+	return 0;
+}
+
+static void fsi_master_unscan(struct fsi_master *master)
+{
+	device_for_each_child(&master->dev, NULL, fsi_master_remove_slave);
+}
+
+static ssize_t master_rescan_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct fsi_master *master = to_fsi_master(dev);
+	int rc;
+
+	fsi_master_unscan(master);
+	rc = fsi_master_scan(master);
+	if (rc < 0)
+		return rc;
+
+	return count;
+}
+
+static DEVICE_ATTR(rescan, 0200, NULL, master_rescan_store);
+
 int fsi_master_register(struct fsi_master *master)
 {
 	int rc;
@@ -504,7 +539,15 @@ int fsi_master_register(struct fsi_master *master)
 		return rc;
 	}
 
+	rc = device_create_file(&master->dev, &dev_attr_rescan);
+	if (rc) {
+		device_unregister(&master->dev);
+		ida_simple_remove(&master_ida, master->idx);
+		return rc;
+	}
+
 	fsi_master_scan(master);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fsi_master_register);
@@ -516,6 +559,7 @@ void fsi_master_unregister(struct fsi_master *master)
 		master->idx = -1;
 	}
 
+	fsi_master_unscan(master);
 	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
Signature · 1 line
1.8.2.2
#12 lore raw

PATCH v7 12/23 drivers/fsi: Add documentation for GPIO bindings

In reply to Christopher Bostic

Add fsi master gpio device tree binding documentation.

Includes changes from Jeremy Kerr <[email protected]>.

---
 .../devicetree/bindings/fsi/fsi-master-gpio.txt    | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt
Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt new file +24 -0
new file mode 100644
index 0000000..a767259
@@ -0,0 +1,24 @@
+Device-tree bindings for gpio-based FSI master driver
+-----------------------------------------------------
+
+Required properties:
+ - compatible = "fsi-master-gpio";
+ - clock-gpios = <gpio-descriptor>;	: GPIO for FSI clock
+ - data-gpios = <gpio-descriptor>;	: GPIO for FSI data signal
+
+Optional properties:
+ - enable-gpios = <gpio-descriptor>;	: GPIO for enable signal
+ - trans-gpios = <gpio-descriptor>;	: GPIO for voltage translator enable
+ - mux-gpios = <gpio-descriptor>;	: GPIO for pin multiplexing with other
+                                          functions (eg, external FSI masters)
+
+Examples:
+
+    fsi-master {
+        compatible = "fsi-master-gpio", "fsi-master";
+        clock-gpios = <&gpio 0>;
+        data-gpios = <&gpio 1>;
+        enable-gpios = <&gpio 2>;
+        trans-gpios = <&gpio 3>;
+        mux-gpios = <&gpio 4>;
+    }
Signature · 1 line
1.8.2.2
#13 lore raw

PATCH v7 13/23 drivers/fsi: Add client driver register utilities

In reply to Christopher Bostic

Add driver_register and driver_unregister wrappers for FSI.

---
 drivers/fsi/fsi-core.c | 17 +++++++++++++++++
 include/linux/fsi.h    | 12 ++++++++++++
 2 files changed, 29 insertions(+)
drivers/fsi/fsi-core.c +17 -0
index fcb0c81..e9fbd9f 100644
@@ -586,6 +586,23 @@ static int fsi_bus_match(struct device *dev, struct device_driver *drv)
 	return 0;
 }
 
+int fsi_driver_register(struct fsi_driver *fsi_drv)
+{
+	if (!fsi_drv)
+		return -EINVAL;
+	if (!fsi_drv->id_table)
+		return -EINVAL;
+
+	return driver_register(&fsi_drv->drv);
+}
+EXPORT_SYMBOL_GPL(fsi_driver_register);
+
+void fsi_driver_unregister(struct fsi_driver *fsi_drv)
+{
+	driver_unregister(&fsi_drv->drv);
+}
+EXPORT_SYMBOL_GPL(fsi_driver_unregister);
+
 struct bus_type fsi_bus_type = {
 	.name		= "fsi",
 	.match		= fsi_bus_match,
include/linux/fsi.h +12 -0
index 66bce48..34f1e9a 100644
@@ -54,6 +54,18 @@ struct fsi_driver {
 #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev)
 #define to_fsi_drv(drvp) container_of(drvp, struct fsi_driver, drv)
 
+extern int fsi_driver_register(struct fsi_driver *fsi_drv);
+extern void fsi_driver_unregister(struct fsi_driver *fsi_drv);
+
+/* module_fsi_driver() - Helper macro for drivers that don't do
+ * anything special in module init/exit.  This eliminates a lot of
+ * boilerplate.  Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit()
+ */
+#define module_fsi_driver(__fsi_driver) \
+		module_driver(__fsi_driver, fsi_driver_register, \
+				fsi_driver_unregister)
+
 extern struct bus_type fsi_bus_type;
 
 #endif /* LINUX_FSI_H */
Signature · 1 line
1.8.2.2
#14 lore raw

PATCH v7 14/23 drivers/fsi: Add sysfs files for FSI master & slave accesses

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

This change adds a 'raw' file for reads & writes, and a 'term' file for the TERM command, and a 'break' file for issuing a BREAK.

---
 drivers/fsi/fsi-core.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
drivers/fsi/fsi-core.c +116 -0
index e9fbd9f..626cc06 100644
@@ -287,6 +287,95 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 	return 0;
 }
 
+static ssize_t fsi_slave_sysfs_raw_read(struct file *file,
+		struct kobject *kobj, struct bin_attribute *attr, char *buf,
+		loff_t off, size_t count)
+{
+	struct fsi_slave *slave = to_fsi_slave(kobj_to_dev(kobj));
+	size_t total_len, read_len;
+	int rc;
+
+	if (off < 0)
+		return -EINVAL;
+
+	if (off > 0xffffffff || count > 0xffffffff || off + count > 0xffffffff)
+		return -EINVAL;
+
+	for (total_len = 0; total_len < count; total_len += read_len) {
+		read_len = min_t(size_t, count, 4);
+		read_len -= off & 0x3;
+
+		rc = fsi_slave_read(slave, off, buf + total_len, read_len);
+		if (rc)
+			return rc;
+
+		off += read_len;
+	}
+
+	return count;
+}
+
+static ssize_t fsi_slave_sysfs_raw_write(struct file *file,
+		struct kobject *kobj, struct bin_attribute *attr,
+		char *buf, loff_t off, size_t count)
+{
+	struct fsi_slave *slave = to_fsi_slave(kobj_to_dev(kobj));
+	size_t total_len, write_len;
+	int rc;
+
+	if (off < 0)
+		return -EINVAL;
+
+	if (off > 0xffffffff || count > 0xffffffff || off + count > 0xffffffff)
+		return -EINVAL;
+
+	for (total_len = 0; total_len < count; total_len += write_len) {
+		write_len = min_t(size_t, count, 4);
+		write_len -= off & 0x3;
+
+		rc = fsi_slave_write(slave, off, buf + total_len, write_len);
+		if (rc)
+			return rc;
+
+		off += write_len;
+	}
+
+	return count;
+}
+
+static struct bin_attribute fsi_slave_raw_attr = {
+	.attr = {
+		.name = "raw",
+		.mode = 0600,
+	},
+	.size = 0,
+	.read = fsi_slave_sysfs_raw_read,
+	.write = fsi_slave_sysfs_raw_write,
+};
+
+static ssize_t fsi_slave_sysfs_term_write(struct file *file,
+		struct kobject *kobj, struct bin_attribute *attr,
+		char *buf, loff_t off, size_t count)
+{
+	struct fsi_slave *slave = to_fsi_slave(kobj_to_dev(kobj));
+	struct fsi_master *master = slave->master;
+
+	if (!master->term)
+		return -ENODEV;
+
+	master->term(master, slave->link, slave->id);
+	return count;
+}
+
+static struct bin_attribute fsi_slave_term_attr = {
+	.attr = {
+		.name = "term",
+		.mode = 0200,
+	},
+	.size = 0,
+	.write = fsi_slave_sysfs_term_write,
+};
+
 /* Encode slave local bus echo delay */
 static inline uint32_t fsi_smode_echodly(int x)
 {
@@ -402,6 +491,14 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 		return rc;
 	}
 
+	rc = device_create_bin_file(&slave->dev, &fsi_slave_raw_attr);
+	if (rc)
+		dev_warn(&slave->dev, "failed to create raw attr: %d\n", rc);
+
+	rc = device_create_bin_file(&slave->dev, &fsi_slave_term_attr);
+	if (rc)
+		dev_warn(&slave->dev, "failed to create term attr: %d\n", rc);
+
 	rc = fsi_slave_scan(slave);
 	if (rc)
 		dev_dbg(&master->dev, "failed during slave scan with: %d\n",
@@ -523,6 +620,18 @@ static ssize_t master_rescan_store(struct device *dev,
 
 static DEVICE_ATTR(rescan, 0200, NULL, master_rescan_store);
 
+static ssize_t master_break_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct fsi_master *master = to_fsi_master(dev);
+
+	fsi_master_break(master, 0);
+
+	return count;
+}
+
+static DEVICE_ATTR(break, 0200, NULL, master_break_store);
+
 int fsi_master_register(struct fsi_master *master)
 {
 	int rc;
@@ -546,6 +655,13 @@ int fsi_master_register(struct fsi_master *master)
 		return rc;
 	}
 
+	rc = device_create_file(&master->dev, &dev_attr_break);
+	if (rc) {
+		device_unregister(&master->dev);
+		ida_simple_remove(&master_ida, master->idx);
+		return rc;
+	}
+
 	fsi_master_scan(master);
 
 	return 0;
Signature · 1 line
1.8.2.2
#15 lore raw

PATCH v7 15/23 drivers/fsi: expose direct-access slave API

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Allow drivers to access the slave address ranges.

---
 drivers/fsi/fsi-core.c | 26 ++++++++++++++++++++------
 include/linux/fsi.h    | 12 ++++++++++++
 2 files changed, 32 insertions(+), 6 deletions(-)
drivers/fsi/fsi-core.c +20 -6
index 626cc06..d319f67 100644
@@ -78,10 +78,6 @@ static int fsi_master_read(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, void *val, size_t size);
 static int fsi_master_write(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
-static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
-		void *val, size_t size);
-static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
-		const void *val, size_t size);
 
 /*
  * fsi_device_read() / fsi_device_write() / fsi_device_peek()
@@ -174,7 +170,7 @@ static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp,
 	return 0;
 }
 
-static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
+int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 			void *val, size_t size)
 {
 	uint8_t id = slave->id;
@@ -188,7 +184,7 @@ static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 			addr, val, size);
 }
 
-static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
+int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 			const void *val, size_t size)
 {
 	uint8_t id = slave->id;
@@ -202,6 +198,24 @@ static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 			addr, val, size);
 }
 
+extern int fsi_slave_claim_range(struct fsi_slave *slave,
+		uint32_t addr, uint32_t size)
+{
+	if (addr + size < addr)
+		return -EINVAL;
+
+	if (addr + size > slave->size)
+		return -EINVAL;
+
+	/* todo: check for overlapping claims */
+	return 0;
+}
+
+extern void fsi_slave_release_range(struct fsi_slave *slave,
+		uint32_t addr, uint32_t size)
+{
+}
+
 static int fsi_slave_scan(struct fsi_slave *slave)
 {
 	uint32_t engine_addr;
include/linux/fsi.h +12 -0
index 34f1e9a..141fd38 100644
@@ -66,6 +66,18 @@ struct fsi_driver {
 		module_driver(__fsi_driver, fsi_driver_register, \
 				fsi_driver_unregister)
 
+/* direct slave API */
+extern int fsi_slave_claim_range(struct fsi_slave *slave,
+		uint32_t addr, uint32_t size);
+extern void fsi_slave_release_range(struct fsi_slave *slave,
+		uint32_t addr, uint32_t size);
+extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
+		void *val, size_t size);
+extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
+		const void *val, size_t size);
+
+
+
 extern struct bus_type fsi_bus_type;
 
 #endif /* LINUX_FSI_H */
Signature · 1 line
1.8.2.2
#16 lore raw

PATCH v7 16/23 drivers/fsi: Add tracepoints for low-level operations

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Trace low level read and write FSI bus operations.

---
 drivers/fsi/fsi-core.c     |  27 +++++++---
 include/trace/events/fsi.h | 127 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 6 deletions(-)
 create mode 100644 include/trace/events/fsi.h
drivers/fsi/fsi-core.c +21 -6
index d319f67..bc73f13 100644
@@ -23,6 +23,9 @@
 
 #include "fsi-master.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/fsi.h>
+
 #define FSI_SLAVE_CONF_NEXT_MASK	GENMASK(31, 31)
 #define FSI_SLAVE_CONF_SLOTS_MASK	GENMASK(23, 16)
 #define FSI_SLAVE_CONF_SLOTS_SHIFT	16
@@ -538,11 +541,16 @@ static int fsi_master_read(struct fsi_master *master, int link,
 {
 	int rc;
 
+	trace_fsi_master_read(master, link, slave_id, addr, size);
+
 	rc = fsi_check_access(addr, size);
-	if (rc)
-		return rc;
+	if (!rc)
+		rc = master->read(master, link, slave_id, addr, val, size);
+
+	trace_fsi_master_rw_result(master, link, slave_id, addr, size,
+			false, val, rc);
 
-	return master->read(master, link, slave_id, addr, val, size);
+	return rc;
 }
 
 static int fsi_master_write(struct fsi_master *master, int link,
@@ -550,11 +558,16 @@ static int fsi_master_write(struct fsi_master *master, int link,
 {
 	int rc;
 
+	trace_fsi_master_write(master, link, slave_id, addr, size, val);
+
 	rc = fsi_check_access(addr, size);
-	if (rc)
-		return rc;
+	if (!rc)
+		rc = master->write(master, link, slave_id, addr, val, size);
 
-	return master->write(master, link, slave_id, addr, val, size);
+	trace_fsi_master_rw_result(master, link, slave_id, addr, size,
+			true, val, rc);
+
+	return rc;
 }
 
 static int fsi_master_link_enable(struct fsi_master *master, int link)
@@ -570,6 +583,8 @@ static int fsi_master_link_enable(struct fsi_master *master, int link)
  */
 static int fsi_master_break(struct fsi_master *master, int link)
 {
+	trace_fsi_master_break(master, link);
+
 	if (master->send_break)
 		return master->send_break(master, link);
 
include/trace/events/fsi.h new file +127 -0

127 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#17 lore raw

PATCH v7 17/23 drivers/fsi: Add error handling for slave

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

This change implements error handling in the FSI core, by cleaning up and retrying failed operations, using the SISC, TERM and BREAK facilities.

---
 drivers/fsi/fsi-core.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 114 insertions(+), 7 deletions(-)
drivers/fsi/fsi-core.c +114 -7
index bc73f13..6e7d778 100644
@@ -46,7 +46,9 @@
 /*
  * FSI slave engine control register offsets
  */
-#define FSI_SMODE			0x0	/* R/W: Mode register */
+#define FSI_SMODE		0x0	/* R/W: Mode register */
+#define FSI_SISC		0x8	/* R/W: Interrupt condition */
+#define FSI_SSTAT		0x14	/* R  : Slave status */
 
 /*
  * SMODE fields
@@ -77,10 +79,14 @@ struct fsi_slave {
 #define to_fsi_master(d) container_of(d, struct fsi_master, dev)
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+static const int slave_retries = 2;
+static int discard_errors;
+
 static int fsi_master_read(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, void *val, size_t size);
 static int fsi_master_write(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
+static int fsi_master_break(struct fsi_master *master, int link);
 
 /*
  * fsi_device_read() / fsi_device_write() / fsi_device_peek()
@@ -173,32 +179,131 @@ static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp,
 	return 0;
 }
 
+int fsi_slave_report_and_clear_errors(struct fsi_slave *slave)
+{
+	struct fsi_master *master = slave->master;
+	uint32_t irq, stat;
+	int rc, link;
+	uint8_t id;
+
+	link = slave->link;
+	id = slave->id;
+
+	rc = fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SISC,
+			&irq, sizeof(irq));
+	if (rc)
+		return rc;
+
+	rc =  fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SSTAT,
+			&stat, sizeof(stat));
+	if (rc)
+		return rc;
+
+	dev_info(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n",
+			be32_to_cpu(stat), be32_to_cpu(irq));
+
+	/* clear interrupts */
+	return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC,
+			&irq, sizeof(irq));
+}
+
+static int fsi_slave_set_smode(struct fsi_master *master, int link, int id);
+
+int fsi_slave_handle_error(struct fsi_slave *slave, bool write, uint32_t addr,
+		size_t size)
+{
+	struct fsi_master *master = slave->master;
+	int rc, link;
+	uint32_t reg;
+	uint8_t id;
+
+	if (discard_errors)
+		return -1;
+
+	link = slave->link;
+	id = slave->id;
+
+	dev_dbg(&slave->dev, "handling error on %s to 0x%08x[%zd]",
+			write ? "write" : "read", addr, size);
+
+	/* try a simple clear of error conditions, which may fail if we've lost
+	 * communication with the slave
+	 */
+	rc = fsi_slave_report_and_clear_errors(slave);
+	if (!rc)
+		return 0;
+
+	/* send a TERM and retry */
+	if (master->term) {
+		rc = master->term(master, link, id);
+		if (!rc) {
+			rc = fsi_master_read(master, link, id, 0,
+					&reg, sizeof(reg));
+			if (!rc)
+				rc = fsi_slave_report_and_clear_errors(slave);
+			if (!rc)
+				return 0;
+		}
+	}
+
+	/* getting serious, reset the slave via BREAK */
+	rc = fsi_master_break(master, link);
+	if (rc)
+		return rc;
+
+	rc = fsi_slave_set_smode(master, link, id);
+	if (rc)
+		return rc;
+
+	return fsi_slave_report_and_clear_errors(slave);
+}
+
 int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 			void *val, size_t size)
 {
 	uint8_t id = slave->id;
-	int rc;
+	int rc, err_rc, i;
 
 	rc = fsi_slave_calc_addr(slave, &addr, &id);
 	if (rc)
 		return rc;
 
-	return fsi_master_read(slave->master, slave->link, id,
-			addr, val, size);
+	for (i = 0; i < slave_retries; i++) {
+		rc = fsi_master_read(slave->master, slave->link,
+				id, addr, val, size);
+		if (!rc)
+			break;
+
+		err_rc = fsi_slave_handle_error(slave, false, addr, size);
+		if (err_rc)
+			break;
+	}
+
+	return rc;
 }
 
 int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 			const void *val, size_t size)
 {
 	uint8_t id = slave->id;
-	int rc;
+	int rc, err_rc, i;
 
 	rc = fsi_slave_calc_addr(slave, &addr, &id);
 	if (rc)
 		return rc;
 
-	return fsi_master_write(slave->master, slave->link, id,
-			addr, val, size);
+	for (i = 0; i < slave_retries; i++) {
+		rc = fsi_master_write(slave->master, slave->link,
+				id, addr, val, size);
+		if (!rc)
+			break;
+
+		err_rc = fsi_slave_handle_error(slave, true, addr, size);
+		if (err_rc)
+			break;
+	}
+
+	return rc;
 }
 
 extern int fsi_slave_claim_range(struct fsi_slave *slave,
@@ -766,3 +871,5 @@ static void fsi_exit(void)
 
 module_init(fsi_init);
 module_exit(fsi_exit);
+module_param(discard_errors, int, 0664);
+MODULE_PARM_DESC(discard_errors, "Don't invoke error handling on bus accesses");
Signature · 1 line
1.8.2.2
#18 lore raw

PATCH v7 18/23 drivers/fsi: Document FSI master sysfs files in ABI

In reply to Christopher Bostic

From: Chris Bostic <[email protected]>

Add info for sysfs scan file in Documentaiton ABI/testing

---
v7 - Rename scan file to 'rescan'
- Add 'raw' file details
- Add 'term' file details
- Add 'break' file details
- Update kernel version for each file to 4.12

---
 Documentation/ABI/testing/sysfs-bus-fsi | 38 +++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi
Documentation/ABI/testing/sysfs-bus-fsi new file +38 -0
new file mode 100644
index 0000000..57c8063
@@ -0,0 +1,38 @@
+What:           /sys/bus/platform/devices/fsi-master/rescan
+Date:		May 2017
+KernelVersion:  4.12
+Contact:        cbostic at linux.vnet.ibm.com
+Description:
+                Initiates a FSI master scan for all connected slave devices
+		on its links.
+
+What:           /sys/bus/platform/devices/fsi-master/break
+Date:		May 2017
+KernelVersion:  4.12
+Contact:        cbostic at linux.vnet.ibm.com
+Description:
+		Sends an FSI BREAK command on a master's communication
+		link to any connnected slaves.  A BREAK resets connected
+		device's logic and preps it to receive further commands
+		from the master.
+
+What:           /sys/bus/platform/devices/fsi-master/slave at 00:00/term
+Date:		May 2017
+KernelVersion:  4.12
+Contact:        cbostic at linux.vnet.ibm.com
+Description:
+		Sends an FSI terminate command from the master to its
+		connected slave. A terminate resets the slave's state machines
+		that control access to the internally connected engines.  In
+		addition the slave freezes its internal error register for
+		debugging purposes.  This command is also needed to abort any
+		ongoing operation in case of an expired 'Master Time Out'
+		timer.
+
+What:           /sys/bus/platform/devices/fsi-master/slave at 00:00/raw
+Date:		May 2017
+KernelVersion:  4.12
+Contact:        cbostic at linux.vnet.ibm.com
+Description:
+		Provides a means of reading/writing a 32 bit value from/to a
+		specified FSI bus address.
Signature · 1 line
1.8.2.2
#19 lore raw

PATCH v7 19/23 drivers/fsi: Add GPIO based FSI master

In reply to Christopher Bostic

Implement a FSI master using GPIO. Will generate FSI protocol for read and write commands to particular addresses. Sends master command and waits for and decodes a slave response.

Includes changes from Edward A. James <[email protected]> and Jeremy Kerr <[email protected]>.

---
v7 - Move global spinlock to struct fsi_master_gpio
- Remove redundant checks for valid gpio descriptors
- Clarify 'active low' comments
- More descriptive comments for build_abs_ar_command()
- Test MTOE count with == instead of >=
- Clean up multi line and redundant comments
- Check for negative return codes in issue_term()
- Simplify input data processing in poll_for_response()
- Remove empty function fsi_master_gpio_release()
- Check return code for fsi_master_register()

v6 - Kconfig: remove 'depends on FSI' for GPIO master
- Remove explicit kfree of devm_kzalloc master struct

---
 drivers/fsi/Kconfig           |  12 +
 drivers/fsi/Makefile          |   1 +
 drivers/fsi/fsi-master-gpio.c | 594 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 607 insertions(+)
 create mode 100644 drivers/fsi/fsi-master-gpio.c
drivers/fsi/Kconfig +12 -0
index e1006c6..ba16637 100644
@@ -10,4 +10,16 @@ config FSI
 	---help---
 	  FSI - the FRU Support Interface - is a simple bus for low-level
 	  access to POWER-based hardware.
+
+if FSI
+
+config FSI_MASTER_GPIO
+	tristate "GPIO-based FSI master"
+	depends on GPIOLIB
+	select CRC4
+	---help---
+	This option enables a FSI master driver using GPIO lines.
+
+endif
+
 endmenu
drivers/fsi/Makefile +1 -0
index db0e5e7..ed28ac0 100644
@@ -1,2 +1,3 @@
 
 obj-$(CONFIG_FSI) += fsi-core.o
+obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
drivers/fsi/fsi-master-gpio.c new file +594 -0

594 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#20 lore raw

PATCH v7 20/23 drivers/fsi/gpio: Add tracepoints for GPIO master

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

Trace low level input/output GPIO operations.

---
 drivers/fsi/fsi-master-gpio.c          |  9 +++++
 include/trace/events/fsi_master_gpio.h | 68 ++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 include/trace/events/fsi_master_gpio.h
drivers/fsi/fsi-master-gpio.c +9 -0
index d467e61..a5d6e70 100644
@@ -61,6 +61,9 @@ struct fsi_master_gpio {
 	struct gpio_desc	*gpio_mux;	/* Mux control */
 };
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/fsi_master_gpio.h>
+
 #define to_fsi_master_gpio(m) container_of(m, struct fsi_master_gpio, master)
 
 struct fsi_gpio_msg {
@@ -126,6 +129,8 @@ static void serial_in(struct fsi_master_gpio *master, struct fsi_gpio_msg *msg,
 		msg->msg |= ~in_bit & 0x1;	/* Data is active low */
 	}
 	msg->bits += num_bits;
+
+	trace_fsi_master_gpio_in(master, num_bits, msg->msg);
 }
 
 static void serial_out(struct fsi_master_gpio *master,
@@ -137,6 +142,8 @@ static void serial_out(struct fsi_master_gpio *master,
 	uint64_t last_bit = ~0;
 	int next_bit;
 
+	trace_fsi_master_gpio_out(master, cmd->bits, cmd->msg);
+
 	if (!cmd->bits) {
 		dev_warn(master->dev, "trying to output 0 bits\n");
 		return;
@@ -458,6 +465,8 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link)
 	if (link != 0)
 		return -ENODEV;
 
+	trace_fsi_master_gpio_break(master);
+
 	set_sda_output(master, 1);
 	sda_out(master, 1);
 	clock_toggle(master, FSI_PRE_BREAK_CLOCKS);
include/trace/events/fsi_master_gpio.h new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#21 lore raw

PATCH v7 21/23 drivers/fsi: Add SCOM FSI client device driver

In reply to Christopher Bostic

Create a simple SCOM engine device driver that reads and writes its control registers via an FSI bus.

Includes changes from Edward A. James <[email protected]>.

---
 drivers/fsi/Kconfig    |   5 +
 drivers/fsi/Makefile   |   1 +
 drivers/fsi/fsi-scom.c | 263 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 269 insertions(+)
 create mode 100644 drivers/fsi/fsi-scom.c
drivers/fsi/Kconfig +5 -0
index ba16637..5582523 100644
@@ -20,6 +20,11 @@ config FSI_MASTER_GPIO
 	---help---
 	This option enables a FSI master driver using GPIO lines.
 
+config FSI_SCOM
+	tristate "SCOM FSI client device driver"
+	---help---
+	This option enables an FSI based SCOM device driver.
+
 endif
 
 endmenu
drivers/fsi/Makefile +1 -0
index ed28ac0..3466f08 100644
@@ -1,3 +1,4 @@
 
 obj-$(CONFIG_FSI) += fsi-core.o
 obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
+obj-$(CONFIG_FSI_SCOM) += fsi-scom.o
drivers/fsi/fsi-scom.c new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#22 lore raw

PATCH v7 22/23 drivers/fsi: Add hub master support

In reply to Christopher Bostic

Add an engine driver to expose a "hub" FSI master - which has a set of control registers in the engine address space, and uses a chunk of the slave address space for actual FSI communication.

Additional changes from Jeremy Kerr <[email protected]>.

---
 drivers/fsi/Kconfig          |   8 ++
 drivers/fsi/Makefile         |   1 +
 drivers/fsi/fsi-master-hub.c | 327 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 336 insertions(+)
 create mode 100644 drivers/fsi/fsi-master-hub.c
drivers/fsi/Kconfig +8 -0
index 5582523..6821ed0 100644
@@ -20,6 +20,14 @@ config FSI_MASTER_GPIO
 	---help---
 	This option enables a FSI master driver using GPIO lines.
 
+config FSI_MASTER_HUB
+	tristate "FSI hub master"
+	---help---
+	This option enables a FSI hub master driver.  Hub is a type of FSI
+	master that is connected to the upstream master via a slave.  Hubs
+	allow chaining of FSI links to an arbitrary depth.  This allows for
+	a high target device fanout.
+
 config FSI_SCOM
 	tristate "SCOM FSI client device driver"
 	---help---
drivers/fsi/Makefile +1 -0
index 3466f08..65eb99d 100644
@@ -1,4 +1,5 @@
 
 obj-$(CONFIG_FSI) += fsi-core.o
+obj-$(CONFIG_FSI_MASTER_HUB) += fsi-master-hub.o
 obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
 obj-$(CONFIG_FSI_SCOM) += fsi-scom.o
drivers/fsi/fsi-master-hub.c new file +327 -0

327 lines not on this page · raw message

Signature · 1 line
1.8.2.2
#23 lore raw

PATCH v7 23/23 drivers/fsi: Use asynchronous slave mode

In reply to Christopher Bostic

From: Jeremy Kerr <[email protected]>

For slaves that are behind a software-clocked master, we want FSI CFAMs to run asynchronously to the FSI clock, so set up our slaves to be in async mode.

---
 drivers/fsi/fsi-core.c        | 22 +++++++++++++++++++++-
 drivers/fsi/fsi-master-gpio.c |  1 +
 drivers/fsi/fsi-master.h      |  2 ++
 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +21 -1
index 6e7d778..f19f87a 100644
@@ -49,6 +49,7 @@
 #define FSI_SMODE		0x0	/* R/W: Mode register */
 #define FSI_SISC		0x8	/* R/W: Interrupt condition */
 #define FSI_SSTAT		0x14	/* R  : Slave status */
+#define FSI_LLMODE		0x100	/* R/W: Link layer mode register */
 
 /*
  * SMODE fields
@@ -64,6 +65,11 @@
 #define FSI_SMODE_LBCRR_SHIFT	8		/* Clk ratio shift */
 #define FSI_SMODE_LBCRR_MASK	0xf		/* Clk ratio mask */
 
+/*
+ * LLMODE fields
+ */
+#define FSI_LLMODE_ASYNC	0x1
+
 #define FSI_SLAVE_SIZE_23b		0x800000
 
 static DEFINE_IDA(master_ida);
@@ -553,8 +559,8 @@ static void fsi_slave_release(struct device *dev)
 
 static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 {
+	uint32_t chip_id, llmode;
 	struct fsi_slave *slave;
-	uint32_t chip_id;
 	uint8_t crc;
 	int rc;
 
@@ -590,6 +596,20 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 		return -ENODEV;
 	}
 
+	/* If we're behind a master that doesn't provide a self-running bus
+	 * clock, put the slave into async mode
+	 */
+	if (master->flags & FSI_MASTER_FLAG_SWCLOCK) {
+		llmode = cpu_to_be32(FSI_LLMODE_ASYNC);
+		rc = fsi_master_write(master, link, id,
+				FSI_SLAVE_BASE + FSI_LLMODE,
+				&llmode, sizeof(llmode));
+		if (rc)
+			dev_warn(&master->dev,
+				"can't set llmode on slave:%02x:%02x %d\n",
+				link, id, rc);
+	}
+
 	/* We can communicate with a slave; create the slave device and
 	 * register.
 	 */
drivers/fsi/fsi-master-gpio.c +1 -0
index a5d6e70..ae26187 100644
@@ -554,6 +554,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
 	master->gpio_mux = gpio;
 
 	master->master.n_links = 1;
+	master->master.flags = FSI_MASTER_FLAG_SWCLOCK;
 	master->master.read = fsi_master_gpio_read;
 	master->master.write = fsi_master_gpio_write;
 	master->master.term = fsi_master_gpio_term;
drivers/fsi/fsi-master.h +2 -0
index 7764b00..12f7b11 100644
@@ -19,6 +19,8 @@
 
 #include <linux/device.h>
 
+#define FSI_MASTER_FLAG_SWCLOCK		0x1
+
 struct fsi_master {
 	struct device	dev;
 	int		idx;
Signature · 1 line
1.8.2.2
#24 lore raw
In reply to Christopher Bostic

Hi Greg,

Are there any further changes you require for this patch set? This has been extensively tested internally and all is working as expected. Would it be possible to move forward with integration in the near
future? Any input would be appreciated.

Thanks,
Chris

Quoted 195 lines · Christopher Bostic

Implementation of the IBM 'Flexible Support Interface' (FSI) bus device driver. FSI is a high fan out serial bus consisting of a clock and a serial data line capable of running at speeds up to 166 MHz.

This set provides the basic framework to add FSI extensions to the Linux bus and device models. Master specific implementations are defined to utilize the core FSI function.

In Linux, we have a core FSI "bus type", along with drivers for FSI masters and engines.

The FSI master drivers expose a read/write interface to the bus address space. The master drivers are under drivers/fsi/fsi-master-*.c.

The core handles probing and discovery of slaves and slave engines, using those read/write interfaces. It is responsible for creating the endpoint Linux devices corresponding to the discovered engines on each slave.

Slave engines are identified by an 'engine' type, and an optional version. Engine, a.k.a. client, drivers are matched and bound to these engines during discovery.

This patch set does not include extended FSI function such as:

     *  Cascaded master support
     *  Application layer hot plug notification
     *  Application layer FSI bus status interface

Common FSI terminology:

* Master
Controller of the FSI bus. Only the master is allowed to control the clock line and is the initiator of all transactions on a bus.

* Slave
The receiver or target of a master initiated transaction. The slave cannot initiate communications on a bus and must respond to any master requests for data.

* CFAM
Stands for Common Field replaceable unit Access Macro. A CFAM is an ASIC residing in any device requiring FSI communications. CFAMs consist of an array of hardware 'engines' used for various purposes. I2C masters, UARTs, General Purpose IO hardware are common types of these engines.

* Configuration Space / Table
A table contained at the beginning of each CFAM address space. This table lists information such as the CFAM's ID, which engine types and versions it has available, as well as its addressing range.

* FSI Engine driver
A device driver that registers with the FSI core so that it can access devices it owns on an FSI bus.

* Hub
An FSI master that connects to an upstream 'primary' master allowing high fanout of target devices.

----
Changes in v7:
- Use GENMASK for bitmask definitions
- Move instances of dev_info to dev_dbg
- Add missing return code checks
- Add API details for fsi_device_read/write/peek()
- GPIO master: Unscan when unregistering master
- Document ABI sysfs files raw, term, break, rescan
- GPIO master: move global spinlock into struct fsi_master_gpio
- GPIO master: remove redundant checks for valid pin descriptors

Changes in v6:
- Remove redundant 'depends on' specifiers in Kconfig for SCOM GPIO master and Hub masters.

Changes in v5:
- Remove explicit kfree of struct fsi_master in fsi_master_gpio.
- Remove Palmetto and Romulus dts device tree file udates for FSI gpio master

Changes in v4:
- endianness: the _read() and _write() APIs are now all *bus endian*, so will be the same on all platforms (the previous fsi patches exposed as (BMC/FSP) CPU endian, which is variable).
- device tree: Remove the "ibm," prefix for the fsi core and GPIO master compatibility strings, as they're not describing IBM-specific
- device model: Create separate struct devices for each FSI master, which fits better with the Linux device model, and allows addition of sysfs attributes that are implemented by the fsi core
- sysfs: there are now sysfs facilities for break and term. Raw file supports reads and writes of arbitrary sizes.
- GPIO master: split the xfer() logic out a little, so that the response handling & DPOLL retry mechanism is more obvious
- GPIO master: simplifications for message construction
- GPIO master: fixes for some CRC calculations
- GPIO master: issue TERM in response to DPOLL busy-loops
- Error handling: rather than handle errors on (potentially) an entire cascaded read or write, the error handling is now down on a per-slave basis, where we try to reestablish communication in a more "gradual" manner, rather than sending a break immediately. May need to add a hook to percolate error recovery up to a slave's master but no need seen for that at present.
- Hub master: this is now implemented as a fsi engine driver, as the fsi_slave_{read,write}() functions are exported (and the port count is available in the hMFSI configuration register)
This means we need fewer special-cases in the fsi core.
- Tracepoints: Add tracepoints for FSI core read & write, and another set for low-level GPIO in/out operations.

Changes in v3:
- Patch set contained an invalid 18/18 test patch not meant for community review, corrected.

Changes in v2:
- Change from atomic global for master number to ida simple interface.
- Add valid pointer checks on register and unregister utils.
- Move CRC calculation utilities out of driver to lib path.
- Clean up white space issues.
- Remove added list management of master devices and use instead the device_for_each_child method available in the bus.
- Add new patch to document FSI bus functionality.
- Add new patch documenting FSI gpio master.
- Rearrage patch set to have documentation earlier than code implementing it.
- Document all compatible strings used in device tree bindings.
- Elaborate documentation definition of FSI GPIO master.
- Describe in more detail what each GPIO FSI master pin is for.
- Re-order compatible strings in example binding so that most specific device comes first.
- Indicate proper activation order of all FSI GPIO master pins.
- Fix an unmatched '>' bracket in the example for binding.
- Bracket each element of the example bindings individually.
- Add new patch documenting sysfs-bus-fsi attributes.
- Merge FSI GPIO master init into probe function.
- Set pin initial values at time of pin request.
- Assign value of master->master.dev at probe time.
- Use get_optional interface for all optional GPIO pins.

Christopher Bostic (9):
drivers/fsi: Document FSI master sysfs files in ABI drivers/fsi: Set up links for slave communication drivers/fsi: Set slave SMODE to init communication drivers/fsi: Add master unscan drivers/fsi: Add documentation for GPIO bindings drivers/fsi: Add client driver register utilities drivers/fsi: Add GPIO based FSI master drivers/fsi: Add SCOM FSI client device driver drivers/fsi: Add hub master support

Jeremy Kerr (14):
drivers/fsi: Add fsi master definition drivers/fsi: Add slave definition
drivers/fsi: Add empty master scan
lib: Add crc4 module
drivers/fsi: Add slave & master read/write APIs drivers/fsi: Implement slave initialisation drivers/fsi: scan slaves & register devices drivers/fsi: Add device read/write/peek API drivers/fsi: Add sysfs files for FSI master & slave accesses drivers/fsi: expose direct-access slave API drivers/fsi: Add tracepoints for low-level operations drivers/fsi: Add error handling for slave drivers/fsi/gpio: Add tracepoints for GPIO master drivers/fsi: Use asynchronous slave mode

  Documentation/ABI/testing/sysfs-bus-fsi            |  38 +
  .../devicetree/bindings/fsi/fsi-master-gpio.txt    |  24 +
  drivers/fsi/Kconfig                                |  26 +
  drivers/fsi/Makefile                               |   3 +
  drivers/fsi/fsi-core.c                             | 836 +++++++++++++++++++++
  drivers/fsi/fsi-master-gpio.c                      | 604 +++++++++++++++
  drivers/fsi/fsi-master-hub.c                       | 327 ++++++++
  drivers/fsi/fsi-master.h                           |  43 ++
  drivers/fsi/fsi-scom.c                             | 263 +++++++
  include/linux/crc4.h                               |   8 +
  include/linux/fsi.h                                |  35 +-
  include/trace/events/fsi.h                         | 127 ++++
  include/trace/events/fsi_master_gpio.h             |  68 ++
  lib/Kconfig                                        |   8 +
  lib/Makefile                                       |   1 +
  lib/crc4.c                                         |  46 ++
  16 files changed, 2456 insertions(+), 1 deletion(-)

create mode 100644 Documentation/ABI/testing/sysfs-bus-fsi create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-gpio.txt create mode 100644 drivers/fsi/fsi-master-gpio.c
create mode 100644 drivers/fsi/fsi-master-hub.c
create mode 100644 drivers/fsi/fsi-master.h
create mode 100644 drivers/fsi/fsi-scom.c
create mode 100644 include/linux/crc4.h
create mode 100644 include/trace/events/fsi.h
create mode 100644 include/trace/events/fsi_master_gpio.h create mode 100644 lib/crc4.c

#25 lore raw
Quoted 6 lines · Christopher Bostic

Hi Greg,

Are there any further changes you require for this patch set? This has been
extensively tested internally and all is working as expected. Would it be
possible to move forward with integration in the near future? Any input
would be appreciated.

Sorry for the delay. I just tried applying this to my tree, but got the following build warnings, and then errors:

In file included from ./include/trace/define_trace.h:95:0,

                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_write?:
./include/trace/events/fsi.h:58:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 8 has type ?size_t {aka long unsigned int}? [-Wformat=]
  TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
            ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
  trace_seq_printf(s, print);     \
                      ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
         PARAMS(print));         \
         ^~~~~~

./include/trace/events/fsi.h:37:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_write,
^~~~~~~~~~~
./include/trace/events/fsi.h:58:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                 from ./include/trace/define_trace.h:95,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:58:44: note: format string is defined here
  TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
                                           ~^~
In file included from ./include/trace/define_trace.h:95:0,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_rw_resul
?:
./include/trace/events/fsi.h:95:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 9 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",

            ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
  trace_seq_printf(s, print);     \
                      ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
         PARAMS(print));         \
         ^~~~~~

./include/trace/events/fsi.h:68:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_rw_result,
^~~~~~~~~~~
./include/trace/events/fsi.h:95:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d", ^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                 from ./include/trace/define_trace.h:95,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:95:44: note: format string is defined here
  TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",
                                           ~^~
  CHK     include/generated/uapi/linux/version.h
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  CC      arch/x86/boot/version.o
  Building modules, stage 2.
  VOFFSET arch/x86/boot/compressed/../voffset.h
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs
  CC      arch/x86/boot/compressed/kaslr.o
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  CC      arch/x86/boot/compressed/misc.o

MODPOST 476 modules
WARNING: modpost: missing MODULE_LICENSE() in drivers/fsi/fsi-core.o see include/linux/module.h for more information
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
DATAREL arch/x86/boot/compressed/vmlinux
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 17532 bytes (padded to 17920 bytes).
System is 5445 kB
CRC 56d8089d
Kernel: arch/x86/boot/bzImage is ready (#387)
ERROR: "fsi_slave_claim_range" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_read" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_write" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_release_range" [drivers/fsi/fsi-master-hub.ko] undefined! make[1]: *** [scripts/Makefile.modpost:91: __modpost] Error 1
make: *** [Makefile:1214: modules] Error 2

Note, I'm using gcc 7.1.1, which might be what is showing the build warnings, but that doesn't explain the build errors.

So obviously, I can't take this as is :(

thanks,

greg k-h

maintainer
#26 lore raw
Quoted 11 lines · On Sat, 3 Jun 2017 19:05:10 +0900 Greg KH <[email protected]> wrote:
Quoted 6 lines · Christopher Bostic

Hi Greg,

Are there any further changes you require for this patch set? This has been
extensively tested internally and all is working as expected. Would it be
possible to move forward with integration in the near future? Any input
would be appreciated.

Sorry for the delay. I just tried applying this to my tree, but got the following build warnings, and then errors:

Quoted 8 lines

In file included from ./include/trace/define_trace.h:95:0,

                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_write?:
./include/trace/events/fsi.h:58:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 8 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",

From patch 16/23:

+TRACE_EVENT(fsi_master_write,
+ TP_PROTO(const struct fsi_master *master, int link, int id,
+ uint32_t addr, size_t size, const void *data),
+ TP_ARGS(master, link, id, addr, size, data),
+ TP_STRUCT__entry(
+ __field(int, master_idx)
+ __field(int, link)
+ __field(int, id)
+ __field(__u32, addr)
+ __field(size_t, size)
+ __field(__u32, data)
+ ),
+ TP_fast_assign(
+ __entry->master_idx = master->idx;
+ __entry->link = link;
+ __entry->id = id;
+ __entry->addr = addr;
+ __entry->size = size;
+ __entry->data = 0;
+ memcpy(&__entry->data, data, size);
+ ),
+ TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
+ __entry->master_idx,
+ __entry->link,
+ __entry->id,
+ __entry->addr,
+ __entry->size,
+ __entry->size, &__entry->data
+ )
+);

Looks like the second __entry->size, probably needs a type cast.

Would something like:

	__entry->size,
	(int)__entry->size, &__entry->data

work?

I haven't looked at the others, but I'm guessing they are probably similar issues.

-- Steve

Quoted 101 lines
            ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
  trace_seq_printf(s, print);     \
                      ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
         PARAMS(print));         \
         ^~~~~~

./include/trace/events/fsi.h:37:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_write,
^~~~~~~~~~~
./include/trace/events/fsi.h:58:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                 from ./include/trace/define_trace.h:95,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:58:44: note: format string is defined here
  TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
                                           ~^~
In file included from ./include/trace/define_trace.h:95:0,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_rw_resul
?:
./include/trace/events/fsi.h:95:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 9 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",

            ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
  trace_seq_printf(s, print);     \
                      ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
         PARAMS(print));         \
         ^~~~~~

./include/trace/events/fsi.h:68:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_rw_result,
^~~~~~~~~~~
./include/trace/events/fsi.h:95:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d", ^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                 from ./include/trace/define_trace.h:95,
                 from ./include/trace/events/fsi.h:127,
                 from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:95:44: note: format string is defined here
  TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",
                                           ~^~
  CHK     include/generated/uapi/linux/version.h
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  CC      arch/x86/boot/version.o
  Building modules, stage 2.
  VOFFSET arch/x86/boot/compressed/../voffset.h
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs
  CC      arch/x86/boot/compressed/kaslr.o
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  CC      arch/x86/boot/compressed/misc.o

MODPOST 476 modules
WARNING: modpost: missing MODULE_LICENSE() in drivers/fsi/fsi-core.o see include/linux/module.h for more information
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
DATAREL arch/x86/boot/compressed/vmlinux
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 17532 bytes (padded to 17920 bytes).
System is 5445 kB
CRC 56d8089d
Kernel: arch/x86/boot/bzImage is ready (#387)
ERROR: "fsi_slave_claim_range" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_read" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_write" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_release_range" [drivers/fsi/fsi-master-hub.ko] undefined! make[1]: *** [scripts/Makefile.modpost:91: __modpost] Error 1
make: *** [Makefile:1214: modules] Error 2

Note, I'm using gcc 7.1.1, which might be what is showing the build warnings, but that doesn't explain the build errors.

So obviously, I can't take this as is :(

thanks,

greg k-h

#27 lore raw
Quoted 52 lines · Steven Rostedt
Quoted 10 lines · On Sat, 3 Jun 2017 19:05:10 +0900 Greg KH <[email protected]> wrote:
Quoted 6 lines · Christopher Bostic

Hi Greg,

Are there any further changes you require for this patch set? This has been
extensively tested internally and all is working as expected. Would it be
possible to move forward with integration in the near future? Any input
would be appreciated.

Sorry for the delay. I just tried applying this to my tree, but got the following build warnings, and then errors:

Quoted 6 lines

In file included from ./include/trace/define_trace.h:95:0,

                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_write?:
./include/trace/events/fsi.h:58:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 8 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",

From patch 16/23:

(quoted diff) +30 -0
+TRACE_EVENT(fsi_master_write,
+	TP_PROTO(const struct fsi_master *master, int link, int id,
+			uint32_t addr, size_t size, const void *data),
+	TP_ARGS(master, link, id, addr, size, data),
+	TP_STRUCT__entry(
+		__field(int,	master_idx)
+		__field(int,	link)
+		__field(int,	id)
+		__field(__u32,	addr)
+		__field(size_t,	size)
+		__field(__u32,	data)
+	),
+	TP_fast_assign(
+		__entry->master_idx = master->idx;
+		__entry->link = link;
+		__entry->id = id;
+		__entry->addr = addr;
+		__entry->size = size;
+		__entry->data = 0;
+		memcpy(&__entry->data, data, size);
+	),
+	TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
+		__entry->master_idx,
+		__entry->link,
+		__entry->id,
+		__entry->addr,
+		__entry->size,
+		__entry->size, &__entry->data
+	)
+);
Quoted 8 lines

Looks like the second __entry->size, probably needs a type cast.

Would something like:

	__entry->size,
	(int)__entry->size, &__entry->data

work?

Steven,

Yes that did the trick. Thanks for the input

-Chris

Quoted 107 lines

I haven't looked at the others, but I'm guessing they are probably similar issues.

-- Steve

Quoted 101 lines
             ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
   trace_seq_printf(s, print);     \
                       ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
          PARAMS(print));         \
          ^~~~~~

./include/trace/events/fsi.h:37:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_write,
^~~~~~~~~~~
./include/trace/events/fsi.h:58:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                  from ./include/trace/define_trace.h:95,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:58:44: note: format string is defined here
   TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
                                            ~^~
In file included from ./include/trace/define_trace.h:95:0,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_rw_resul
?:
./include/trace/events/fsi.h:95:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 9 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",

             ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
   trace_seq_printf(s, print);     \
                       ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
          PARAMS(print));         \
          ^~~~~~

./include/trace/events/fsi.h:68:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_rw_result,
^~~~~~~~~~~
./include/trace/events/fsi.h:95:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d", ^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                  from ./include/trace/define_trace.h:95,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:95:44: note: format string is defined here
   TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",
                                            ~^~
   CHK     include/generated/uapi/linux/version.h
   GEN     .version
   CHK     include/generated/compile.h
   UPD     include/generated/compile.h
   CC      init/version.o
   LD      init/built-in.o
   LD      vmlinux.o
   MODPOST vmlinux.o
   KSYM    .tmp_kallsyms1.o
   KSYM    .tmp_kallsyms2.o
   LD      vmlinux
   SORTEX  vmlinux
   SYSMAP  System.map
   CC      arch/x86/boot/version.o
   Building modules, stage 2.
   VOFFSET arch/x86/boot/compressed/../voffset.h
   OBJCOPY arch/x86/boot/compressed/vmlinux.bin
   RELOCS  arch/x86/boot/compressed/vmlinux.relocs
   CC      arch/x86/boot/compressed/kaslr.o
   GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
   CC      arch/x86/boot/compressed/misc.o

MODPOST 476 modules
WARNING: modpost: missing MODULE_LICENSE() in drivers/fsi/fsi-core.o see include/linux/module.h for more information
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
DATAREL arch/x86/boot/compressed/vmlinux
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 17532 bytes (padded to 17920 bytes).
System is 5445 kB
CRC 56d8089d
Kernel: arch/x86/boot/bzImage is ready (#387)
ERROR: "fsi_slave_claim_range" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_read" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_write" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_release_range" [drivers/fsi/fsi-master-hub.ko] undefined! make[1]: *** [scripts/Makefile.modpost:91: __modpost] Error 1
make: *** [Makefile:1214: modules] Error 2

Note, I'm using gcc 7.1.1, which might be what is showing the build warnings, but that doesn't explain the build errors.

So obviously, I can't take this as is :(

thanks,

greg k-h

#28 lore raw
In reply to Greg KH
Quoted 99 lines · Greg KH
Quoted 6 lines · Christopher Bostic

Hi Greg,

Are there any further changes you require for this patch set? This has been
extensively tested internally and all is working as expected. Would it be
possible to move forward with integration in the near future? Any input
would be appreciated.

Sorry for the delay. I just tried applying this to my tree, but got the following build warnings, and then errors:

In file included from ./include/trace/define_trace.h:95:0,

                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_write?:
./include/trace/events/fsi.h:58:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 8 has type ?size_t {aka long unsigned int}? [-Wformat=]
   TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
             ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
   trace_seq_printf(s, print);     \
                       ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
          PARAMS(print));         \
          ^~~~~~

./include/trace/events/fsi.h:37:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_write,
^~~~~~~~~~~
./include/trace/events/fsi.h:58:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                  from ./include/trace/define_trace.h:95,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:58:44: note: format string is defined here
   TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}",
                                            ~^~
In file included from ./include/trace/define_trace.h:95:0,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:

./include/trace/events/fsi.h: In function ?trace_raw_output_fsi_master_rw_resul
?:
./include/trace/events/fsi.h:95:12: warning: field width specifier ?*? expects argument of type ?int?, but argument 9 has type ?size_t {aka long unsigned int}? [-Wformat=]
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",

             ^
./include/trace/trace_events.h:343:22: note: in definition of macro ?DECLARE_EVENT_CLASS?
   trace_seq_printf(s, print);     \
                       ^~~~~
./include/trace/trace_events.h:65:9: note: in expansion of macro ?PARAMS?
          PARAMS(print));         \
          ^~~~~~

./include/trace/events/fsi.h:68:1: note: in expansion of macro ?TRACE_EVENT?
TRACE_EVENT(fsi_master_rw_result,
^~~~~~~~~~~
./include/trace/events/fsi.h:95:2: note: in expansion of macro ?TP_printk?
TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d", ^~~~~~~~~
In file included from ./include/trace/trace_events.h:377:0,

                  from ./include/trace/define_trace.h:95,
                  from ./include/trace/events/fsi.h:127,
                  from drivers/fsi/fsi-core.c:27:
./include/trace/events/fsi.h:95:44: note: format string is defined here
   TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d",
                                            ~^~
   CHK     include/generated/uapi/linux/version.h
   GEN     .version
   CHK     include/generated/compile.h
   UPD     include/generated/compile.h
   CC      init/version.o
   LD      init/built-in.o
   LD      vmlinux.o
   MODPOST vmlinux.o
   KSYM    .tmp_kallsyms1.o
   KSYM    .tmp_kallsyms2.o
   LD      vmlinux
   SORTEX  vmlinux
   SYSMAP  System.map
   CC      arch/x86/boot/version.o
   Building modules, stage 2.
   VOFFSET arch/x86/boot/compressed/../voffset.h
   OBJCOPY arch/x86/boot/compressed/vmlinux.bin
   RELOCS  arch/x86/boot/compressed/vmlinux.relocs
   CC      arch/x86/boot/compressed/kaslr.o
   GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
   CC      arch/x86/boot/compressed/misc.o

MODPOST 476 modules
WARNING: modpost: missing MODULE_LICENSE() in drivers/fsi/fsi-core.o see include/linux/module.h for more information
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
DATAREL arch/x86/boot/compressed/vmlinux
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 17532 bytes (padded to 17920 bytes).
System is 5445 kB

Quoted 8 lines

CRC 56d8089d
Kernel: arch/x86/boot/bzImage is ready (#387)
ERROR: "fsi_slave_claim_range" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_read" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_write" [drivers/fsi/fsi-master-hub.ko] undefined!
ERROR: "fsi_slave_release_range" [drivers/fsi/fsi-master-hub.ko] undefined! make[1]: *** [scripts/Makefile.modpost:91: __modpost] Error 1
make: *** [Makefile:1214: modules] Error 2

Hi Greg,

Was missing a few export symbols for module mode... Sorry about that. Will correct the trace warnings as well and get v8 sent out ASAP.

Thanks for the input.
Chris

Quoted 10 lines

Note, I'm using gcc 7.1.1, which might be what is showing the build warnings, but that doesn't explain the build errors.

So obviously, I can't take this as is :(

thanks,

greg k-h