2010-12-10 20:45:45

by Bounine, Alexandre

[permalink] [raw]
Subject: [PATCH -mm 0/4] RapidIO: Misc updates

The following four patches are follow-up to two RapidIO patches
that are in the -mm tree now.

Alexandre Bounine (4):
RapidIO: Add definitions of Component Tag fields
RapidIO: Add device object linking into discovery
RapidIO: Use Component Tag for unified switch identification
RapidIO: Add new sysfs attributes

drivers/rapidio/rio-scan.c | 21 ++++++++++++---------
drivers/rapidio/rio-sysfs.c | 39 ++++++++++++++++++++++++++++++++++++++-
drivers/rapidio/rio.c | 2 +-
include/linux/rio.h | 10 ++++++++++
4 files changed, 61 insertions(+), 11 deletions(-)

--
1.7.3.1


2010-12-10 20:45:51

by Bounine, Alexandre

[permalink] [raw]
Subject: [PATCH -mm 1/4] RapidIO: Add definitions of Component Tag fields

Add definition of the unique device identifier field in the component tag.
RIO_CTAG_UDEVID does not take all 32 bits of the component tag value to
allow future extensions to the component tag use.

Selected size of the RIO_CTAG_UDEVID field (17 bits) is sufficient to accommodate
maximum number of endpoints in large RIO network (16-bit id) plus switches.

Signed-off-by: Alexandre Bounine <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Li Yang <[email protected]>
Cc: Thomas Moll <[email protected]>
Cc: Micha Nelissen <[email protected]>
---
drivers/rapidio/rio.c | 2 +-
include/linux/rio.h | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index c13289e..cc2a3b7 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -710,7 +710,7 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
u32 err_status, em_perrdet, em_ltlerrdet;
int rc, portnum;

- rdev = rio_get_comptag(pw_msg->em.comptag, NULL);
+ rdev = rio_get_comptag((pw_msg->em.comptag & RIO_CTAG_UDEVID), NULL);
if (rdev == NULL) {
/* Device removed or enumeration error */
pr_debug("RIO: %s No matching device for CTag 0x%08x\n",
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 9b55885..ff681eb 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -66,6 +66,16 @@

#define RIO_PW_MSG_SIZE 64

+/*
+ * A component tag value (stored in the component tag CSR) is used as device's
+ * unique identifier assigned during enumeration. Besides being used for
+ * identifying switches (which do not have device ID register), it also is used
+ * by error management notification and therefore has to be assigned
+ * to endpoints as well.
+ */
+#define RIO_CTAG_RESRVD 0xfffe0000 /* Reserved */
+#define RIO_CTAG_UDEVID 0x0001ffff /* Unique device identifier */
+
extern struct bus_type rio_bus_type;
extern struct device rio_bus;
extern struct list_head rio_devices; /* list of all devices */
--
1.7.3.1

2010-12-10 20:45:55

by Bounine, Alexandre

[permalink] [raw]
Subject: [PATCH -mm 2/4] RapidIO: Add device object linking into discovery

Add setting links between rio_dev objects into the discovery process.
This needed to report device connections on agent (non-host) processors
that perform RIO discovery. Originally, these links have been introduced
for enumerating host only to support error management.

Signed-off-by: Alexandre Bounine <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Li Yang <[email protected]>
Cc: Thomas Moll <[email protected]>
Cc: Micha Nelissen <[email protected]>
---
drivers/rapidio/rio-scan.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 45d14cd..e655756 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -947,7 +947,7 @@ static int rio_enum_complete(struct rio_mport *port)
*/
static int __devinit
rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
- u8 hopcount)
+ u8 hopcount, struct rio_dev *prev, int prev_port)
{
u8 port_num, route_port;
struct rio_dev *rdev;
@@ -957,6 +957,9 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
if ((rdev = rio_setup_device(net, port, destid, hopcount, 0))) {
/* Add device to the global and bus/net specific list. */
list_add_tail(&rdev->net_list, &net->devices);
+ rdev->prev = prev;
+ if (prev && rio_is_switch(prev))
+ prev->rswitch->nextdev[prev_port] = rdev;
} else
return -1;

@@ -998,8 +1001,8 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
if (ndestid == RIO_ANY_DESTID(port->sys_size))
continue;
rio_unlock_device(port, destid, hopcount);
- if (rio_disc_peer
- (net, port, ndestid, hopcount + 1) < 0)
+ if (rio_disc_peer(net, port, ndestid,
+ hopcount + 1, rdev, port_num) < 0)
return -1;
}
}
@@ -1291,7 +1294,7 @@ int __devinit rio_disc_mport(struct rio_mport *mport)
mport->host_deviceid);

if (rio_disc_peer(net, mport, RIO_ANY_DESTID(mport->sys_size),
- 0) < 0) {
+ 0, NULL, 0) < 0) {
printk(KERN_INFO
"RIO: master port %d device has failed discovery\n",
mport->id);
--
1.7.3.1

2010-12-10 20:46:01

by Bounine, Alexandre

[permalink] [raw]
Subject: [PATCH -mm 3/4] RapidIO: Use Component Tag for unified switch identification

Change the way how switchid value is set. Local counter variable does not
provide unified way to identify switch devices in a system with multiple
processors. Using local counter leads to the situation when the same RIO
switch has different switch ID for each processor. Replacing local counter
with unique portion of the Component Tag provides unified reference to the
switch by every processor in the system.

Signed-off-by: Alexandre Bounine <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Li Yang <[email protected]>
Cc: Thomas Moll <[email protected]>
Cc: Micha Nelissen <[email protected]>
---
drivers/rapidio/rio-scan.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index e655756..467e82b 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -46,7 +46,6 @@ static void rio_init_em(struct rio_dev *rdev);
DEFINE_SPINLOCK(rio_global_list_lock);

static int next_destid = 0;
-static int next_switchid = 0;
static int next_net = 0;
static int next_comptag = 1;

@@ -438,6 +437,10 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
rio_mport_write_config_32(port, destid, hopcount,
RIO_COMPONENT_TAG_CSR, next_comptag);
rdev->comp_tag = next_comptag++;
+ } else {
+ rio_mport_read_config_32(port, destid, hopcount,
+ RIO_COMPONENT_TAG_CSR,
+ &rdev->comp_tag);
}

if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) {
@@ -461,7 +464,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
/* If a PE has both switch and other functions, show it as a switch */
if (rio_is_switch(rdev)) {
rswitch = rdev->rswitch;
- rswitch->switchid = next_switchid;
+ rswitch->switchid = rdev->comp_tag & RIO_CTAG_UDEVID;
rswitch->port_ok = 0;
rswitch->route_table = kzalloc(sizeof(u8)*
RIO_MAX_ROUTE_ENTRIES(port->sys_size),
@@ -816,7 +819,6 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
return -1;

if (rio_is_switch(rdev)) {
- next_switchid++;
sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo);
rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
port->host_deviceid, sw_inport, 0);
@@ -964,8 +966,6 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
return -1;

if (rio_is_switch(rdev)) {
- next_switchid++;
-
/* Associated destid is how we accessed this switch */
rdev->destid = destid;

--
1.7.3.1

2010-12-10 20:46:04

by Bounine, Alexandre

[permalink] [raw]
Subject: [PATCH -mm 4/4] RapidIO: Add new sysfs attributes

Add new sysfs attributes.

1. Routing information required to to reach the RIO device:
destid - device destination ID (real for for endpoint, route for switch)
hopcount - hopcount for maintenance requests (switches only)

2. device linking information:
lprev - name of device that precedes the given device in the enumeration
or discovery order (displayed along with of the port to which it
is attached).
lnext - names of devices (with corresponding port numbers) that are
attached to the given device as next in the enumeration or
discovery order (switches only)

Signed-off-by: Alexandre Bounine <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Li Yang <[email protected]>
Cc: Thomas Moll <[email protected]>
Cc: Micha Nelissen <[email protected]>
---
drivers/rapidio/rio-sysfs.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 76b4185..b8d9eaf 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -33,6 +33,8 @@ rio_config_attr(device_rev, "0x%08x\n");
rio_config_attr(asm_did, "0x%04x\n");
rio_config_attr(asm_vid, "0x%04x\n");
rio_config_attr(asm_rev, "0x%04x\n");
+rio_config_attr(destid, "0x%04x\n");
+rio_config_attr(hopcount, "0x%02x\n");

static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -52,6 +54,33 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch
return (str - buf);
}

+static ssize_t lprev_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct rio_dev *rdev = to_rio_dev(dev);
+
+ return sprintf(buf, "%02d %s\n", RIO_GET_PORT_NUM(rdev->swpinfo),
+ (rdev->prev) ? rio_name(rdev->prev) : "host");
+}
+
+static ssize_t lnext_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct rio_dev *rdev = to_rio_dev(dev);
+ char *str = buf;
+ int i;
+
+ if (rdev->pef & RIO_PEF_SWITCH) {
+ for (i = 0; i < RIO_GET_TOTAL_PORTS(rdev->swpinfo); i++) {
+ if (rdev->rswitch->nextdev[i])
+ str += sprintf(str, "%02d %s\n", i,
+ rio_name(rdev->rswitch->nextdev[i]));
+ }
+ }
+
+ return str - buf;
+}
+
struct device_attribute rio_dev_attrs[] = {
__ATTR_RO(did),
__ATTR_RO(vid),
@@ -59,10 +88,14 @@ struct device_attribute rio_dev_attrs[] = {
__ATTR_RO(asm_did),
__ATTR_RO(asm_vid),
__ATTR_RO(asm_rev),
+ __ATTR_RO(lprev),
+ __ATTR_RO(destid),
__ATTR_NULL,
};

static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL);
+static DEVICE_ATTR(lnext, S_IRUGO, lnext_show, NULL);
+static DEVICE_ATTR(hopcount, S_IRUGO, hopcount_show, NULL);

static ssize_t
rio_read_config(struct file *filp, struct kobject *kobj,
@@ -218,7 +251,9 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev)
err = device_create_bin_file(&rdev->dev, &rio_config_attr);

if (!err && (rdev->pef & RIO_PEF_SWITCH)) {
- err = device_create_file(&rdev->dev, &dev_attr_routes);
+ err |= device_create_file(&rdev->dev, &dev_attr_routes);
+ err |= device_create_file(&rdev->dev, &dev_attr_lnext);
+ err |= device_create_file(&rdev->dev, &dev_attr_hopcount);
if (!err && rdev->rswitch->sw_sysfs)
err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE);
}
@@ -241,6 +276,8 @@ void rio_remove_sysfs_dev_files(struct rio_dev *rdev)
device_remove_bin_file(&rdev->dev, &rio_config_attr);
if (rdev->pef & RIO_PEF_SWITCH) {
device_remove_file(&rdev->dev, &dev_attr_routes);
+ device_remove_file(&rdev->dev, &dev_attr_lnext);
+ device_remove_file(&rdev->dev, &dev_attr_hopcount);
if (rdev->rswitch->sw_sysfs)
rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE);
}
--
1.7.3.1

2010-12-10 23:20:01

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH -mm 0/4] RapidIO: Misc updates

On Fri, 10 Dec 2010 15:38:14 -0500
Alexandre Bounine <[email protected]> wrote:

> The following four patches are follow-up to two RapidIO patches
> that are in the -mm tree now.
>
> Alexandre Bounine (4):
> RapidIO: Add definitions of Component Tag fields
> RapidIO: Add device object linking into discovery
> RapidIO: Use Component Tag for unified switch identification
> RapidIO: Add new sysfs attributes
>

I held
rapidio-use-common-destid-storage-for-endpoints-and-switches.patch and
rapidio-integrate-rio_switch-into-rio_dev.patch back from 2.6.37 due to
ongoing discussion. What is the situation now?

2010-12-10 23:22:59

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH -mm 4/4] RapidIO: Add new sysfs attributes

On Fri, 10 Dec 2010 15:38:18 -0500
Alexandre Bounine <[email protected]> wrote:

> Add new sysfs attributes.

One would like to see documentation updates along with sysfs API
updates. But one fears that this entire interface wasn't documented
anyway :(

Please at least fully describe the proposed interface in the changelog
so others can review the proposal.

The proposed new sysfs files appear to break the
one-value-per-sysfs-file rule.

2010-12-12 19:02:08

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH -mm 4/4] RapidIO: Add new sysfs attributes

On Fri, Dec 10, 2010 at 03:38:18PM -0500, Alexandre Bounine wrote:
> Add new sysfs attributes.

Like Andrew pointed out, all sysfs files are required to have entries in
Documentation/ABI. If the existing rapidio sysfs files are not
documented, please document them in there _before_ adding new ones.

thanks,

greg k-h

2010-12-13 13:56:30

by Bounine, Alexandre

[permalink] [raw]
Subject: RE: [PATCH -mm 4/4] RapidIO: Add new sysfs attributes

Greg KH wrote:
>
> Like Andrew pointed out, all sysfs files are required to have entries
in
> Documentation/ABI. If the existing rapidio sysfs files are not
> documented, please document them in there _before_ adding new ones.
>
I included RapidIO documentation update into my plan for next set of
RapidIO patches. Until than this patch may be safely dropped without
affecting other patches in this set.

Alex.