Fix broken usage of the mlx4_read_clock() function:

- return value has too small width
 - cycle_t is unsigned and cannot be less than zero

Sponsored by:	Mellanox Technologies
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2017-07-31 09:15:15 +00:00
parent 401b97316c
commit b0259ad374
3 changed files with 6 additions and 6 deletions

View File

@ -1337,7 +1337,7 @@ int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id, u
int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, u32 max_range_qpn);
int mlx4_read_clock(struct mlx4_dev *dev);
s64 mlx4_read_clock(struct mlx4_dev *dev);
int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
struct mlx4_clock_params *params);

View File

@ -1793,10 +1793,10 @@ static void unmap_bf_area(struct mlx4_dev *dev)
io_mapping_free(mlx4_priv(dev)->bf_mapping);
}
int mlx4_read_clock(struct mlx4_dev *dev)
s64 mlx4_read_clock(struct mlx4_dev *dev)
{
u32 clockhi, clocklo, clockhi1;
cycle_t cycles;
s64 cycles;
int i;
struct mlx4_priv *priv = mlx4_priv(dev);
@ -1813,7 +1813,7 @@ int mlx4_read_clock(struct mlx4_dev *dev)
cycles = (u64) clockhi << 32 | (u64) clocklo;
return cycles;
return cycles & CORE_CLOCK_MASK;
}
EXPORT_SYMBOL_GPL(mlx4_read_clock);

View File

@ -877,12 +877,12 @@ static int mlx4_ib_query_values(struct ib_device *device, int q_values,
struct ib_device_values *values)
{
struct mlx4_ib_dev *dev = to_mdev(device);
cycle_t cycles;
s64 cycles;
values->values_mask = 0;
if (q_values & IBV_VALUES_HW_CLOCK) {
cycles = mlx4_read_clock(dev->dev);
if (cycles < 0) {
if (cycles >= 0) {
values->hwclock = cycles & CORE_CLOCK_MASK;
values->values_mask |= IBV_VALUES_HW_CLOCK;
}