| @@ -1579,6 +1579,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, · 1578 unmodified lines |
| 1579 | 1579 | struct mlx5_ib_dev *dev = to_mdev(ibdev); |
| 1580 | 1580 | struct mlx5_ib_alloc_ucontext_req_v2 req = {}; |
| 1581 | 1581 | struct mlx5_ib_alloc_ucontext_resp resp = {}; |
| 1582 | + struct mlx5_core_dev *mdev = dev->mdev; |
| 1582 | 1583 | struct mlx5_ib_ucontext *context; |
| 1583 | 1584 | struct mlx5_bfreg_info *bfregi; |
| 1584 | 1585 | int ver; |
| @@ -1706,6 +1707,12 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, · 121 unmodified lines |
| 1706 | 1707 | resp.response_length += sizeof(resp.eth_min_inline); |
| 1707 | 1708 | } |
| 1708 | 1709 | |
| 1710 | + if (field_avail(typeof(resp), clock_info_versions, udata->outlen)) { |
| 1711 | + if (mdev->clock_info) |
| 1712 | + resp.clock_info_versions = BIT(MLX5_IB_CLOCK_INFO_V1); |
| 1713 | + resp.response_length += sizeof(resp.clock_info_versions); |
| 1714 | + } |
| 1715 | + |
| 1709 | 1716 | /* |
| 1710 | 1717 | * We don't want to expose information from the PCI bar that is located |
| 1711 | 1718 | * after 4096 bytes, so if the arch only supports larger pages, let's |
| @@ -1719,8 +1726,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, · 7 unmodified lines |
| 1719 | 1726 | resp.hca_core_clock_offset = |
| 1720 | 1727 | offsetof(struct mlx5_init_seg, internal_timer_h) % PAGE_SIZE; |
| 1721 | 1728 | } |
| 1722 | | − resp.response_length += sizeof(resp.hca_core_clock_offset) + |
| 1723 | | − sizeof(resp.reserved2); |
| 1729 | + resp.response_length += sizeof(resp.hca_core_clock_offset); |
| 1724 | 1730 | } |
| 1725 | 1731 | |
| 1726 | 1732 | if (field_avail(typeof(resp), log_uar_size, udata->outlen)) |
| @@ -1959,6 +1965,38 @@ static inline char *mmap_cmd2str(enum mlx5_ib_mmap_cmd cmd) · 232 unmodified lines |
| 1959 | 1965 | } |
| 1960 | 1966 | } |
| 1961 | 1967 | |
| 1968 | +static int mlx5_ib_mmap_clock_info_page(struct mlx5_ib_dev *dev, |
| 1969 | + struct vm_area_struct *vma, |
| 1970 | + struct mlx5_ib_ucontext *context) |
| 1971 | +{ |
| 1972 | + phys_addr_t pfn; |
| 1973 | + int err; |
| 1974 | + |
| 1975 | + if (vma->vm_end - vma->vm_start != PAGE_SIZE) |
| 1976 | + return -EINVAL; |
| 1977 | + |
| 1978 | + if (get_index(vma->vm_pgoff) != MLX5_IB_CLOCK_INFO_V1) |
| 1979 | + return -EOPNOTSUPP; |
| 1980 | + |
| 1981 | + if (vma->vm_flags & VM_WRITE) |
| 1982 | + return -EPERM; |
| 1983 | + |
| 1984 | + if (!dev->mdev->clock_info_page) |
| 1985 | + return -EOPNOTSUPP; |
| 1986 | + |
| 1987 | + pfn = page_to_pfn(dev->mdev->clock_info_page); |
| 1988 | + err = remap_pfn_range(vma, vma->vm_start, pfn, PAGE_SIZE, |
| 1989 | + vma->vm_page_prot); |
| 1990 | + if (err) |
| 1991 | + return err; |
| 1992 | + |
| 1993 | + mlx5_ib_dbg(dev, "mapped clock info at 0x%lx, PA 0x%llx\n", |
| 1994 | + vma->vm_start, |
| 1995 | + (unsigned long long)pfn << PAGE_SHIFT); |
| 1996 | + |
| 1997 | + return mlx5_ib_set_vma_data(vma, context); |
| 1998 | +} |
| 1999 | + |
| 1962 | 2000 | static int uar_mmap(struct mlx5_ib_dev *dev, enum mlx5_ib_mmap_cmd cmd, |
| 1963 | 2001 | struct vm_area_struct *vma, |
| 1964 | 2002 | struct mlx5_ib_ucontext *context) |
| @@ -2121,6 +2159,8 @@ static int mlx5_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vm · 156 unmodified lines |
| 2121 | 2159 | vma->vm_start, |
| 2122 | 2160 | (unsigned long long)pfn << PAGE_SHIFT); |
| 2123 | 2161 | break; |
| 2162 | + case MLX5_IB_MMAP_CLOCK_INFO: |
| 2163 | + return mlx5_ib_mmap_clock_info_page(dev, vma, context); |
| 2124 | 2164 | |
| 2125 | 2165 | default: |
| 2126 | 2166 | return -EINVAL; |