Commit f549e088 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

Pull infiniband fixes from Roland Dreier:
 "Fix a regression in the /sys/class/infiniband/.../rate attribute --
  old kernels used to just return something, even if the underlying
  value was out-of-bounds, while 3.4-rc1 returned EINVAL to userspace.
  This breaks some applications that check for the error, so go back to
  the old behavior."

* tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
  IB/core: Don't return EINVAL from sysfs rate attribute for invalid speeds
  IB/mlx4: Don't return an invalid speed when a port is down
parents 70f33fa5 0559d8dc
...@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ...@@ -179,7 +179,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
{ {
struct ib_port_attr attr; struct ib_port_attr attr;
char *speed = ""; char *speed = "";
int rate = -1; /* in deci-Gb/sec */ int rate; /* in deci-Gb/sec */
ssize_t ret; ssize_t ret;
ret = ib_query_port(p->ibdev, p->port_num, &attr); ret = ib_query_port(p->ibdev, p->port_num, &attr);
...@@ -187,9 +187,6 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ...@@ -187,9 +187,6 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
return ret; return ret;
switch (attr.active_speed) { switch (attr.active_speed) {
case IB_SPEED_SDR:
rate = 25;
break;
case IB_SPEED_DDR: case IB_SPEED_DDR:
speed = " DDR"; speed = " DDR";
rate = 50; rate = 50;
...@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused, ...@@ -210,6 +207,10 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
speed = " EDR"; speed = " EDR";
rate = 250; rate = 250;
break; break;
case IB_SPEED_SDR:
default: /* default to SDR for invalid rates */
rate = 25;
break;
} }
rate *= ib_width_enum_to_int(attr.active_width); rate *= ib_width_enum_to_int(attr.active_width);
......
...@@ -253,6 +253,11 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port, ...@@ -253,6 +253,11 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
if (out_mad->data[15] & 0x1) if (out_mad->data[15] & 0x1)
props->active_speed = IB_SPEED_FDR10; props->active_speed = IB_SPEED_FDR10;
} }
/* Avoid wrong speed value returned by FW if the IB link is down. */
if (props->state == IB_PORT_DOWN)
props->active_speed = IB_SPEED_SDR;
out: out:
kfree(in_mad); kfree(in_mad);
kfree(out_mad); kfree(out_mad);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment