svn commit: r350406 - stable/12/sys/dev/sfxge/common
Andrew Rybchenko
arybchik at FreeBSD.org
Mon Jul 29 09:26:57 UTC 2019
Author: arybchik
Date: Mon Jul 29 09:26:55 2019
New Revision: 350406
URL: https://svnweb.freebsd.org/changeset/base/350406
Log:
MFC r350370
sfxge(4): fix align to power of 2 when align has smaller type
Substitute driver-defined P2ALIGN() with EFX_P2ALIGN() defined in
libefx.
Cast value and alignment to one specified type to guarantee result
correctness.
Reported by: Andrea Valsania <andrea.valsania at answervad.it>
Sponsored by: Solarflare Communications, Inc.
Modified:
stable/12/sys/dev/sfxge/common/ef10_rx.c
stable/12/sys/dev/sfxge/common/efsys.h
stable/12/sys/dev/sfxge/common/efx.h
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/dev/sfxge/common/ef10_rx.c
==============================================================================
--- stable/12/sys/dev/sfxge/common/ef10_rx.c Mon Jul 29 09:25:16 2019 (r350405)
+++ stable/12/sys/dev/sfxge/common/ef10_rx.c Mon Jul 29 09:26:55 2019 (r350406)
@@ -689,7 +689,7 @@ ef10_rx_qpush(
efx_dword_t dword;
/* Hardware has alignment restriction for WPTR */
- wptr = P2ALIGN(added, EF10_RX_WPTR_ALIGN);
+ wptr = EFX_P2ALIGN(unsigned int, added, EF10_RX_WPTR_ALIGN);
if (pushed == wptr)
return;
Modified: stable/12/sys/dev/sfxge/common/efsys.h
==============================================================================
--- stable/12/sys/dev/sfxge/common/efsys.h Mon Jul 29 09:25:16 2019 (r350405)
+++ stable/12/sys/dev/sfxge/common/efsys.h Mon Jul 29 09:26:55 2019 (r350406)
@@ -93,10 +93,6 @@ extern "C" {
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
#endif
-#ifndef P2ALIGN
-#define P2ALIGN(_x, _a) ((_x) & -(_a))
-#endif
-
#ifndef IS2P
#define ISP2(x) (((x) & ((x) - 1)) == 0)
#endif
Modified: stable/12/sys/dev/sfxge/common/efx.h
==============================================================================
--- stable/12/sys/dev/sfxge/common/efx.h Mon Jul 29 09:25:16 2019 (r350405)
+++ stable/12/sys/dev/sfxge/common/efx.h Mon Jul 29 09:26:55 2019 (r350406)
@@ -56,6 +56,10 @@ extern "C" {
#define EFX_P2ROUNDUP(_type, _value, _align) \
(-(-(_type)(_value) & -(_type)(_align)))
+/* Align value down to the nearest power of two. */
+#define EFX_P2ALIGN(_type, _value, _align) \
+ ((_type)(_value) & -(_type)(_align))
+
/* Return codes */
typedef __success(return == 0) int efx_rc_t;
More information about the svn-src-all
mailing list