Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2019-05-20 12:52:22 +0200
committerMichal Kubecek <mkubecek@suse.cz>2019-05-20 12:53:18 +0200
commit89c5a47c94c790e2c5897b23db5a694aeb8d2755 (patch)
tree0215651211be50582cdaa7b8a61ed5afa181559f
parentc8b11014c4d661b98b7d0997654bb7a4daadac33 (diff)
mlx5: avoid 64-bit division.
Fix i386 build.
-rw-r--r--patches.rpmify/mlx5-avoid-64-bit-division.patch76
-rw-r--r--series.conf1
2 files changed, 77 insertions, 0 deletions
diff --git a/patches.rpmify/mlx5-avoid-64-bit-division.patch b/patches.rpmify/mlx5-avoid-64-bit-division.patch
new file mode 100644
index 0000000000..c32c050661
--- /dev/null
+++ b/patches.rpmify/mlx5-avoid-64-bit-division.patch
@@ -0,0 +1,76 @@
+From: Michal Kubecek <mkubecek@suse.cz>
+Subject: mlx5: avoid 64-bit division
+To: Leon Romanovsky <leon@kernel.org>
+Cc: Doug Ledford <dledford@redhat.com>,
+ Jason Gunthorpe <jgg@ziepe.ca>,
+ linux-rdma@vger.kernel.org,
+ linux-kernel@vger.kernel.org
+Patch-mainline: Submitted - 2019-05-20
+References: none
+
+Commit 25c13324d03d ("IB/mlx5: Add steering SW ICM device memory type")
+breaks i386 build by introducing three 64-bit divisions. As the divisor
+is MLX5_SW_ICM_BLOCK_SIZE() which is always a power of 2, we can replace
+the division with bit operations.
+
+Fixes: 25c13324d03d ("IB/mlx5: Add steering SW ICM device memory type")
+Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
+---
+ drivers/infiniband/hw/mlx5/cmd.c | 9 +++++++--
+ drivers/infiniband/hw/mlx5/main.c | 2 +-
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+--- a/drivers/infiniband/hw/mlx5/cmd.c
++++ b/drivers/infiniband/hw/mlx5/cmd.c
+@@ -190,12 +190,12 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length,
+ u16 uid, phys_addr_t *addr, u32 *obj_id)
+ {
+ struct mlx5_core_dev *dev = dm->dev;
+- u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev));
+ u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
+ u32 in[MLX5_ST_SZ_DW(create_sw_icm_in)] = {};
+ unsigned long *block_map;
+ u64 icm_start_addr;
+ u32 log_icm_size;
++ u32 num_blocks;
+ u32 max_blocks;
+ u64 block_idx;
+ void *sw_icm;
+@@ -224,6 +224,8 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length,
+ return -EINVAL;
+ }
+
++ num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >>
++ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev);
+ max_blocks = BIT(log_icm_size - MLX5_LOG_SW_ICM_BLOCK_SIZE(dev));
+ spin_lock(&dm->lock);
+ block_idx = bitmap_find_next_zero_area(block_map,
+@@ -266,13 +268,16 @@ int mlx5_cmd_dealloc_sw_icm(struct mlx5_dm *dm, int type, u64 length,
+ u16 uid, phys_addr_t addr, u32 obj_id)
+ {
+ struct mlx5_core_dev *dev = dm->dev;
+- u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev));
+ u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
+ u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {};
+ unsigned long *block_map;
++ u32 num_blocks;
+ u64 start_idx;
+ int err;
+
++ num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >>
++ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev);
++
+ switch (type) {
+ case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
+ start_idx =
+--- a/drivers/infiniband/hw/mlx5/main.c
++++ b/drivers/infiniband/hw/mlx5/main.c
+@@ -2344,7 +2344,7 @@ static int handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
+ /* Allocation size must a multiple of the basic block size
+ * and a power of 2.
+ */
+- act_size = roundup(attr->length, MLX5_SW_ICM_BLOCK_SIZE(dm_db->dev));
++ act_size = round_up(attr->length, MLX5_SW_ICM_BLOCK_SIZE(dm_db->dev));
+ act_size = roundup_pow_of_two(act_size);
+
+ dm->size = act_size;
diff --git a/series.conf b/series.conf
index 7c9372c4dc..2ebad47eba 100644
--- a/series.conf
+++ b/series.conf
@@ -39,6 +39,7 @@
patches.rpmify/Revert-kconfig-only-write-CONFIG_FOO-is-not-set-for-.patch
patches.rpmify/powerpc-boot-Fix-missing-crc32poly.h-when-building-w.patch
patches.rpmify/scripts-mkmakefile-honor-second-argument.patch
+ patches.rpmify/mlx5-avoid-64-bit-division.patch
########################################################
# kABI consistency patches