diff mbox series

[net-next,1/2] mlxsw: spectrum_kvdl: use div_u64() for 64-bit division

Message ID 20180223131540.1065413-1-arnd@arndb.de
State Accepted
Commit b89c7695b14f58686ac89d5add861f1f6d3fd4da
Headers show
Series [net-next,1/2] mlxsw: spectrum_kvdl: use div_u64() for 64-bit division | expand

Commit Message

Arnd Bergmann Feb. 23, 2018, 1:15 p.m. UTC
Calculating the number of entries now uses 64-bit arithmetic that
causes a link error on 32-bit architectures:

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.o: In function `mlxsw_sp_kvdl_init':
spectrum_kvdl.c:(.text+0x51c): undefined reference to `__aeabi_uldivmod'

We could probably use a 32-bit division here as before, but since this is
not in a performance critical path, div_u64() seems cleaner here.

Fixes: 887839e6960d ("mlxsw: spectrum_kvdl: Add support for dynamic partition set")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.9.0

Comments

Arkadi Sharshevsky Feb. 25, 2018, 10:04 a.m. UTC | #1
On 02/23/2018 03:15 PM, Arnd Bergmann wrote:
> Calculating the number of entries now uses 64-bit arithmetic that

> causes a link error on 32-bit architectures:

> 

> drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.o: In function `mlxsw_sp_kvdl_init':

> spectrum_kvdl.c:(.text+0x51c): undefined reference to `__aeabi_uldivmod'

> 

> We could probably use a 32-bit division here as before, but since this is

> not in a performance critical path, div_u64() seems cleaner here.

> 

> Fixes: 887839e6960d ("mlxsw: spectrum_kvdl: Add support for dynamic partition set")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c

> index d27fa57ad3c3..6fd701db90c9 100644

> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c

> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c

> @@ -278,7 +278,7 @@ static int mlxsw_sp_kvdl_part_init(struct mlxsw_sp *mlxsw_sp,

>  		resource_size = info->end_index - info->start_index + 1;

>  	}

>  

> -	nr_entries = resource_size / info->alloc_size;

> +	nr_entries = div_u64(resource_size, info->alloc_size);

>  	usage_size = BITS_TO_LONGS(nr_entries) * sizeof(unsigned long);

>  	part = kzalloc(sizeof(*part) + usage_size, GFP_KERNEL);

>  	if (!part)

> 


Acked-by: Arkadi Sharshevsky <arkadis@mellanox.com>
David Miller Feb. 26, 2018, 4:33 p.m. UTC | #2
From: Arnd Bergmann <arnd@arndb.de>

Date: Fri, 23 Feb 2018 14:15:31 +0100

> Calculating the number of entries now uses 64-bit arithmetic that

> causes a link error on 32-bit architectures:

> 

> drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.o: In function `mlxsw_sp_kvdl_init':

> spectrum_kvdl.c:(.text+0x51c): undefined reference to `__aeabi_uldivmod'

> 

> We could probably use a 32-bit division here as before, but since this is

> not in a performance critical path, div_u64() seems cleaner here.

> 

> Fixes: 887839e6960d ("mlxsw: spectrum_kvdl: Add support for dynamic partition set")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Applied.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
index d27fa57ad3c3..6fd701db90c9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
@@ -278,7 +278,7 @@  static int mlxsw_sp_kvdl_part_init(struct mlxsw_sp *mlxsw_sp,
 		resource_size = info->end_index - info->start_index + 1;
 	}
 
-	nr_entries = resource_size / info->alloc_size;
+	nr_entries = div_u64(resource_size, info->alloc_size);
 	usage_size = BITS_TO_LONGS(nr_entries) * sizeof(unsigned long);
 	part = kzalloc(sizeof(*part) + usage_size, GFP_KERNEL);
 	if (!part)