From owner-svn-src-all@freebsd.org Mon Jul 29 09:26:57 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 126CDA3E63; Mon, 29 Jul 2019 09:26:57 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E6D2170263; Mon, 29 Jul 2019 09:26:56 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B26B02619A; Mon, 29 Jul 2019 09:26:56 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6T9Qu56000785; Mon, 29 Jul 2019 09:26:56 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6T9Quod000782; Mon, 29 Jul 2019 09:26:56 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201907290926.x6T9Quod000782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Mon, 29 Jul 2019 09:26:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350406 - stable/12/sys/dev/sfxge/common X-SVN-Group: stable-12 X-SVN-Commit-Author: arybchik X-SVN-Commit-Paths: stable/12/sys/dev/sfxge/common X-SVN-Commit-Revision: 350406 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E6D2170263 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; NEURAL_HAM_SHORT(-0.95)[-0.954,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2019 09:26:57 -0000 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 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;