drivers/net/ethernet/aquantia/atlantic/aq_ring.c:80:21: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value

From: kernel test robot
Date: Mon Mar 01 2021 - 10:27:45 EST


Hi Léo,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
commit: 9b22fece786ed641909988da4810bfa8e5d2e592 atlantic: remove architecture depends
date: 9 weeks ago
config: mips-randconfig-r011-20210301 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project b077d82b00d81934c7c27ac89dd8b0e7f448bded)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b22fece786ed641909988da4810bfa8e5d2e592
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 9b22fece786ed641909988da4810bfa8e5d2e592
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:10:
In file included from include/linux/gfp.h:6:
In file included from include/linux/mmzone.h:8:
In file included from include/linux/spinlock.h:59:
In file included from include/linux/lockdep.h:27:
include/linux/debug_locks.h:17:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
return xchg(&debug_locks, 0);
^
arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:202:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
cmpxchg64(&buddy->pte, 0, _PAGE_GLOBAL);
^
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:202:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/net/checksum.h:22:
arch/mips/include/asm/checksum.h:161:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
: "0" ((__force unsigned long)daddr),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:21:
include/linux/netdevice.h:560:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
} while (cmpxchg(&n->state, val, new) != val);
^
arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_ring.h:13:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:21:
include/linux/netdevice.h:560:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
>> drivers/net/ethernet/aquantia/atlantic/aq_ring.c:80:21: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
aq_free_rxpage(&rxbuf->rxdata,
^~~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:95:24: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
ret = aq_get_rxpage(&rxbuf->rxdata, order,
^~~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:427:23: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
aq_buf_vaddr(&buff->rxdata),
^~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:433:23: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
aq_buf_vaddr(&buff->rxdata),
^~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:436:49: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
memcpy(__skb_put(skb, hdr_len), aq_buf_vaddr(&buff->rxdata),
^~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:543:28: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
buff->pa = aq_buf_daddr(&buff->rxdata);
^~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:560:19: warning: taking address of packed member '' of class or structure 'aq_ring_buff_s' may result in an unaligned pointer value [-Waddress-of-packed-member]
aq_free_rxpage(&buff->rxdata, aq_nic_get_dev(self->aq_nic));
^~~~~~~~~~~~
21 warnings and 1 error generated.
--
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:10:
In file included from include/linux/gfp.h:6:
In file included from include/linux/mmzone.h:8:
In file included from include/linux/spinlock.h:59:
In file included from include/linux/lockdep.h:27:
include/linux/debug_locks.h:17:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
return xchg(&debug_locks, 0);
^
arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:202:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
cmpxchg64(&buddy->pte, 0, _PAGE_GLOBAL);
^
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:14:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:202:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/net/checksum.h:22:
arch/mips/include/asm/checksum.h:161:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
: "0" ((__force unsigned long)daddr),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:21:
include/linux/netdevice.h:560:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
} while (cmpxchg(&n->state, val, new) != val);
^
arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:10:
In file included from drivers/net/ethernet/aquantia/atlantic/hw_atl/../aq_hw.h:15:
In file included from drivers/net/ethernet/aquantia/atlantic/aq_common.h:13:
In file included from include/linux/etherdevice.h:21:
include/linux/netdevice.h:560:11: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
>> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:1323:7: warning: taking address of packed member 'ns_mac' of class or structure 'hw_fw_request_ptp_adj_freq' may result in an unaligned pointer value [-Waddress-of-packed-member]
&fwreq.ptp_adj_freq.ns_mac,
^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:1324:7: warning: taking address of packed member 'fns_mac' of class or structure 'hw_fw_request_ptp_adj_freq' may result in an unaligned pointer value [-Waddress-of-packed-member]
&fwreq.ptp_adj_freq.fns_mac);
^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:1326:7: warning: taking address of packed member 'ns_phy' of class or structure 'hw_fw_request_ptp_adj_freq' may result in an unaligned pointer value [-Waddress-of-packed-member]
&fwreq.ptp_adj_freq.ns_phy,
^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c:1327:7: warning: taking address of packed member 'fns_phy' of class or structure 'hw_fw_request_ptp_adj_freq' may result in an unaligned pointer value [-Waddress-of-packed-member]
&fwreq.ptp_adj_freq.fns_phy);
^~~~~~~~~~~~~~~~~~~~~~~~~~
18 warnings and 1 error generated.


vim +80 drivers/net/ethernet/aquantia/atlantic/aq_ring.c

46f4c29d9de6e4 Igor Russkikh 2019-03-23 60
46f4c29d9de6e4 Igor Russkikh 2019-03-23 61 static int aq_get_rxpages(struct aq_ring_s *self, struct aq_ring_buff_s *rxbuf,
46f4c29d9de6e4 Igor Russkikh 2019-03-23 62 int order)
46f4c29d9de6e4 Igor Russkikh 2019-03-23 63 {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 64 int ret;
46f4c29d9de6e4 Igor Russkikh 2019-03-23 65
46f4c29d9de6e4 Igor Russkikh 2019-03-23 66 if (rxbuf->rxdata.page) {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 67 /* One means ring is the only user and can reuse */
46f4c29d9de6e4 Igor Russkikh 2019-03-23 68 if (page_ref_count(rxbuf->rxdata.page) > 1) {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 69 /* Try reuse buffer */
46f4c29d9de6e4 Igor Russkikh 2019-03-23 70 rxbuf->rxdata.pg_off += AQ_CFG_RX_FRAME_MAX;
46f4c29d9de6e4 Igor Russkikh 2019-03-23 71 if (rxbuf->rxdata.pg_off + AQ_CFG_RX_FRAME_MAX <=
46f4c29d9de6e4 Igor Russkikh 2019-03-23 72 (PAGE_SIZE << order)) {
d7d8bb9286134b Mark Starovoytov 2020-07-20 73 u64_stats_update_begin(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 74 self->stats.rx.pg_flips++;
d7d8bb9286134b Mark Starovoytov 2020-07-20 75 u64_stats_update_end(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 76 } else {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 77 /* Buffer exhausted. We have other users and
46f4c29d9de6e4 Igor Russkikh 2019-03-23 78 * should release this page and realloc
46f4c29d9de6e4 Igor Russkikh 2019-03-23 79 */
46f4c29d9de6e4 Igor Russkikh 2019-03-23 @80 aq_free_rxpage(&rxbuf->rxdata,
46f4c29d9de6e4 Igor Russkikh 2019-03-23 81 aq_nic_get_dev(self->aq_nic));
d7d8bb9286134b Mark Starovoytov 2020-07-20 82 u64_stats_update_begin(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 83 self->stats.rx.pg_losts++;
d7d8bb9286134b Mark Starovoytov 2020-07-20 84 u64_stats_update_end(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 85 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 86 } else {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 87 rxbuf->rxdata.pg_off = 0;
d7d8bb9286134b Mark Starovoytov 2020-07-20 88 u64_stats_update_begin(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 89 self->stats.rx.pg_reuses++;
d7d8bb9286134b Mark Starovoytov 2020-07-20 90 u64_stats_update_end(&self->stats.rx.syncp);
46f4c29d9de6e4 Igor Russkikh 2019-03-23 91 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 92 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 93
46f4c29d9de6e4 Igor Russkikh 2019-03-23 94 if (!rxbuf->rxdata.page) {
46f4c29d9de6e4 Igor Russkikh 2019-03-23 95 ret = aq_get_rxpage(&rxbuf->rxdata, order,
46f4c29d9de6e4 Igor Russkikh 2019-03-23 96 aq_nic_get_dev(self->aq_nic));
aa7e17a3e35a6e Dmitry Bogdanov 2020-07-20 97 if (ret) {
aa7e17a3e35a6e Dmitry Bogdanov 2020-07-20 98 u64_stats_update_begin(&self->stats.rx.syncp);
aa7e17a3e35a6e Dmitry Bogdanov 2020-07-20 99 self->stats.rx.alloc_fails++;
aa7e17a3e35a6e Dmitry Bogdanov 2020-07-20 100 u64_stats_update_end(&self->stats.rx.syncp);
aa7e17a3e35a6e Dmitry Bogdanov 2020-07-20 101 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 102 return ret;
46f4c29d9de6e4 Igor Russkikh 2019-03-23 103 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 104
46f4c29d9de6e4 Igor Russkikh 2019-03-23 105 return 0;
46f4c29d9de6e4 Igor Russkikh 2019-03-23 106 }
46f4c29d9de6e4 Igor Russkikh 2019-03-23 107

:::::: The code at line 80 was first introduced by commit
:::::: 46f4c29d9de6e4a9d4ed7de9a37dd42501d89f86 net: aquantia: optimize rx performance by page reuse strategy

:::::: TO: Igor Russkikh <Igor.Russkikh@xxxxxxxxxxxx>
:::::: CC: David S. Miller <davem@xxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip