2022-10-31 13:21:08

by Zhang Changzhong

[permalink] [raw]
Subject: [PATCH net] net/sonic: use dma_mapping_error() for error check

The DMA address returned by dma_map_single() should be checked with
dma_mapping_error(). Fix it accordingly.

Fixes: efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update")
Signed-off-by: Zhang Changzhong <[email protected]>
---
drivers/net/ethernet/natsemi/sonic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
index d17d1b4..4050d5b 100644
--- a/drivers/net/ethernet/natsemi/sonic.c
+++ b/drivers/net/ethernet/natsemi/sonic.c
@@ -292,7 +292,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
*/

laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
- if (!laddr) {
+ if (dma_mapping_error(lp->device, laddr))
pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
@@ -509,7 +509,7 @@ static bool sonic_alloc_rb(struct net_device *dev, struct sonic_local *lp,

*new_addr = dma_map_single(lp->device, skb_put(*new_skb, SONIC_RBSIZE),
SONIC_RBSIZE, DMA_FROM_DEVICE);
- if (!*new_addr) {
+ if (dma_mapping_error(lp->device, *new_addr)) {
dev_kfree_skb(*new_skb);
*new_skb = NULL;
return false;
--
2.9.5



2022-11-01 10:23:26

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH net] net/sonic: use dma_mapping_error() for error check

Hi Zhang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]

url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
patch link: https://lore.kernel.org/r/1667221322-8317-1-git-send-email-zhangchangzhong%40huawei.com
patch subject: [PATCH net] net/sonic: use dma_mapping_error() for error check
config: m68k-defconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
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
# https://github.com/intel-lab-lkp/linux/commit/837273d17ba29bbc661c5c82432e83ce4198200a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
git checkout 837273d17ba29bbc661c5c82432e83ce4198200a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from drivers/net/ethernet/natsemi/macsonic.c:533:
drivers/net/ethernet/natsemi/sonic.c: In function 'sonic_send_packet':
drivers/net/ethernet/natsemi/sonic.c:295:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
295 | if (dma_mapping_error(lp->device, laddr))
| ^~
drivers/net/ethernet/natsemi/sonic.c:297:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
297 | dev_kfree_skb_any(skb);
| ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:279:23: warning: unused variable 'flags' [-Wunused-variable]
279 | unsigned long flags;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:278:13: warning: unused variable 'entry' [-Wunused-variable]
278 | int entry;
| ^~~~~
In file included from include/linux/kref.h:16,
from include/linux/mm_types.h:8,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/net/ethernet/natsemi/macsonic.c:36:
drivers/net/ethernet/natsemi/sonic.c: At top level:
include/linux/spinlock.h:379:1: error: expected identifier or '(' before 'do'
379 | do { \
| ^~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock.h:381:3: error: expected identifier or '(' before 'while'
381 | } while (0)
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:303:9: warning: data definition has no type or storage class
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:303:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
drivers/net/ethernet/natsemi/sonic.c:303:18: error: 'lp' undeclared here (not in a function); did you mean 'up'?
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~
| up
drivers/net/ethernet/natsemi/sonic.c:305:34: error: expected ')' before numeric constant
305 | sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:306:34: error: expected ')' before numeric constant
306 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:307:34: error: expected ')' before numeric constant
307 | sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:308:34: error: expected ')' before numeric constant
308 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:309:34: error: expected ')' before numeric constant
309 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:310:34: error: expected ')' before numeric constant
310 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:311:34: error: expected ')' before numeric constant
311 | sonic_tda_put(dev, entry, SONIC_TD_LINK,
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:314:30: error: expected ')' before '->' token
314 | sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
| ^~
| )
In file included from include/linux/skbuff.h:45,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from drivers/net/ethernet/natsemi/macsonic.c:47:
>> include/net/net_debug.h:123:2: error: expected identifier or '(' before '{' token
123 | ({ \
| ^
drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
317 | netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
| ^~~~~~~~~
In file included from arch/m68k/include/asm/io_mm.h:25,
from arch/m68k/include/asm/io.h:8,
from include/linux/io.h:13,
from include/linux/irq.h:20,
from include/asm-generic/hardirq.h:17,
from ./arch/m68k/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from drivers/net/ethernet/natsemi/macsonic.c:40:
arch/m68k/include/asm/raw_io.h:31:27: error: expected identifier or '(' before 'void'
31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
| ^~~~
arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
44 | #define raw_outw(val,port) out_be16((port),(val))
| ^~~~~~~~
arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
13 | #define nubus_writew raw_outw
| ^~~~~~~~
drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
| ^~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
arch/m68k/include/asm/raw_io.h:31:32: error: expected ')' before '(' token
31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
| ^
arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
44 | #define raw_outw(val,port) out_be16((port),(val))
| ^~~~~~~~
arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
13 | #define nubus_writew raw_outw
| ^~~~~~~~
drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
| ^~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:321:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
321 | lp->tx_len[entry] = length;
| ^~
drivers/net/ethernet/natsemi/sonic.c:322:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
322 | lp->tx_laddr[entry] = laddr;
| ^~
drivers/net/ethernet/natsemi/sonic.c:323:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
323 | lp->tx_skb[entry] = skb;
| ^~
drivers/net/ethernet/natsemi/sonic.c:325:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
325 | lp->eol_tx = entry;
| ^~
drivers/net/ethernet/natsemi/sonic.c:327:9: warning: data definition has no type or storage class
327 | entry = (entry + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:327:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
drivers/net/ethernet/natsemi/sonic.c:327:9: error: redefinition of 'entry'
drivers/net/ethernet/natsemi/sonic.c:303:9: note: previous definition of 'entry' with type 'int'
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:327:17: error: initializer element is not constant
327 | entry = (entry + 1) & SONIC_TDS_MASK;
| ^
drivers/net/ethernet/natsemi/sonic.c:328:9: error: expected identifier or '(' before 'if'
328 | if (lp->tx_skb[entry]) {
| ^~
drivers/net/ethernet/natsemi/sonic.c:335:32: error: expected declaration specifiers or '...' before '&' token
335 | spin_unlock_irqrestore(&lp->lock, flags);
| ^
drivers/net/ethernet/natsemi/sonic.c:335:43: error: unknown type name 'flags'
335 | spin_unlock_irqrestore(&lp->lock, flags);
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:337:9: error: expected identifier or '(' before 'return'
337 | return NETDEV_TX_OK;
| ^~~~~~
drivers/net/ethernet/natsemi/sonic.c:338:1: error: expected identifier or '(' before '}' token
338 | }
| ^
cc1: some warnings being treated as errors


vim +123 include/net/net_debug.h

5b87be9e4978fe Eric Dumazet 2022-05-09 95
5b87be9e4978fe Eric Dumazet 2022-05-09 96 #define netif_emerg(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 97 netif_level(emerg, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 98 #define netif_alert(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 99 netif_level(alert, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 100 #define netif_crit(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 101 netif_level(crit, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 102 #define netif_err(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 103 netif_level(err, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 104 #define netif_warn(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 105 netif_level(warn, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 106 #define netif_notice(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 107 netif_level(notice, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 108 #define netif_info(priv, type, dev, fmt, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 109 netif_level(info, priv, type, dev, fmt, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 110
5b87be9e4978fe Eric Dumazet 2022-05-09 111 #if defined(CONFIG_DYNAMIC_DEBUG) || \
5b87be9e4978fe Eric Dumazet 2022-05-09 112 (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
5b87be9e4978fe Eric Dumazet 2022-05-09 113 #define netif_dbg(priv, type, netdev, format, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 114 do { \
5b87be9e4978fe Eric Dumazet 2022-05-09 115 if (netif_msg_##type(priv)) \
5b87be9e4978fe Eric Dumazet 2022-05-09 116 dynamic_netdev_dbg(netdev, format, ##args); \
5b87be9e4978fe Eric Dumazet 2022-05-09 117 } while (0)
5b87be9e4978fe Eric Dumazet 2022-05-09 118 #elif defined(DEBUG)
5b87be9e4978fe Eric Dumazet 2022-05-09 119 #define netif_dbg(priv, type, dev, format, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 120 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
5b87be9e4978fe Eric Dumazet 2022-05-09 121 #else
5b87be9e4978fe Eric Dumazet 2022-05-09 122 #define netif_dbg(priv, type, dev, format, args...) \
5b87be9e4978fe Eric Dumazet 2022-05-09 @123 ({ \
5b87be9e4978fe Eric Dumazet 2022-05-09 124 if (0) \
5b87be9e4978fe Eric Dumazet 2022-05-09 125 netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
5b87be9e4978fe Eric Dumazet 2022-05-09 126 0; \
5b87be9e4978fe Eric Dumazet 2022-05-09 127 })
5b87be9e4978fe Eric Dumazet 2022-05-09 128 #endif
5b87be9e4978fe Eric Dumazet 2022-05-09 129

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (14.36 kB)
config (76.10 kB)
Download all attachments

2022-11-01 23:29:38

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH net] net/sonic: use dma_mapping_error() for error check

Hi Zhang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]

url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
patch link: https://lore.kernel.org/r/1667221322-8317-1-git-send-email-zhangchangzhong%40huawei.com
patch subject: [PATCH net] net/sonic: use dma_mapping_error() for error check
config: mips-jazz_defconfig
compiler: mipsel-linux-gcc (GCC) 12.1.0
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
# https://github.com/intel-lab-lkp/linux/commit/837273d17ba29bbc661c5c82432e83ce4198200a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
git checkout 837273d17ba29bbc661c5c82432e83ce4198200a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from drivers/net/ethernet/natsemi/jazzsonic.c:228:
drivers/net/ethernet/natsemi/sonic.c: In function 'sonic_send_packet':
drivers/net/ethernet/natsemi/sonic.c:295:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
295 | if (dma_mapping_error(lp->device, laddr))
| ^~
drivers/net/ethernet/natsemi/sonic.c:297:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
297 | dev_kfree_skb_any(skb);
| ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:279:23: warning: unused variable 'flags' [-Wunused-variable]
279 | unsigned long flags;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:278:13: warning: unused variable 'entry' [-Wunused-variable]
278 | int entry;
| ^~~~~
In file included from include/linux/kref.h:16,
from include/linux/mm_types.h:8,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/net/ethernet/natsemi/jazzsonic.c:23:
drivers/net/ethernet/natsemi/sonic.c: At top level:
include/linux/spinlock.h:379:1: error: expected identifier or '(' before 'do'
379 | do { \
| ^~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock.h:381:3: error: expected identifier or '(' before 'while'
381 | } while (0)
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:303:9: warning: data definition has no type or storage class
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:303:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
drivers/net/ethernet/natsemi/sonic.c:303:18: error: 'lp' undeclared here (not in a function); did you mean 'up'?
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~
| up
drivers/net/ethernet/natsemi/sonic.c:305:34: error: expected ')' before numeric constant
305 | sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:306:34: error: expected ')' before numeric constant
306 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:307:34: error: expected ')' before numeric constant
307 | sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:308:34: error: expected ')' before numeric constant
308 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:309:34: error: expected ')' before numeric constant
309 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:310:34: error: expected ')' before numeric constant
310 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:311:34: error: expected ')' before numeric constant
311 | sonic_tda_put(dev, entry, SONIC_TD_LINK,
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:314:30: error: expected ')' before '->' token
314 | sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
| ^~
| )
In file included from include/linux/skbuff.h:45,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from drivers/net/ethernet/natsemi/jazzsonic.c:33:
include/net/net_debug.h:123:2: error: expected identifier or '(' before '{' token
123 | ({ \
| ^
drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
317 | netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
| ^~~~~~~~~
>> drivers/net/ethernet/natsemi/jazzsonic.c:59:1: error: expected identifier or '(' before 'do'
59 | do { \
| ^~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
>> drivers/net/ethernet/natsemi/jazzsonic.c:61:3: error: expected identifier or '(' before 'while'
61 | } while (0)
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:321:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
321 | lp->tx_len[entry] = length;
| ^~
drivers/net/ethernet/natsemi/sonic.c:322:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
322 | lp->tx_laddr[entry] = laddr;
| ^~
drivers/net/ethernet/natsemi/sonic.c:323:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
323 | lp->tx_skb[entry] = skb;
| ^~
drivers/net/ethernet/natsemi/sonic.c:325:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
325 | lp->eol_tx = entry;
| ^~
drivers/net/ethernet/natsemi/sonic.c:327:9: warning: data definition has no type or storage class
327 | entry = (entry + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:327:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
drivers/net/ethernet/natsemi/sonic.c:327:9: error: redefinition of 'entry'
drivers/net/ethernet/natsemi/sonic.c:303:9: note: previous definition of 'entry' with type 'int'
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:327:17: error: initializer element is not constant
327 | entry = (entry + 1) & SONIC_TDS_MASK;
| ^
drivers/net/ethernet/natsemi/sonic.c:328:9: error: expected identifier or '(' before 'if'
328 | if (lp->tx_skb[entry]) {
| ^~
drivers/net/ethernet/natsemi/sonic.c:335:32: error: expected declaration specifiers or '...' before '&' token
335 | spin_unlock_irqrestore(&lp->lock, flags);
| ^
drivers/net/ethernet/natsemi/sonic.c:335:43: error: unknown type name 'flags'
335 | spin_unlock_irqrestore(&lp->lock, flags);
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:337:9: error: expected identifier or '(' before 'return'
337 | return NETDEV_TX_OK;
| ^~~~~~
drivers/net/ethernet/natsemi/sonic.c:338:1: error: expected identifier or '(' before '}' token
338 | }
| ^
cc1: some warnings being treated as errors


vim +59 drivers/net/ethernet/natsemi/jazzsonic.c

^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 57
^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 58 #define SONIC_WRITE(reg,val) \
^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 @59 do { \
efcce839360fb3 drivers/net/jazzsonic.c Finn Thain 2005-08-20 60 *((volatile unsigned int *)dev->base_addr+(reg)) = (val); \
^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 @61 } while (0)
^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 62

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (10.29 kB)
config (58.41 kB)
Download all attachments

2022-11-02 09:07:14

by Zhang Changzhong

[permalink] [raw]
Subject: Re: [PATCH net] net/sonic: use dma_mapping_error() for error check

On 2022/11/2 7:04, kernel test robot wrote:
> Hi Zhang,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on net/master]
>

Sorry, my fault! I forgot to check my kernel config when building.

Thanks,
Changzhong

> url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
> patch link: https://lore.kernel.org/r/1667221322-8317-1-git-send-email-zhangchangzhong%40huawei.com
> patch subject: [PATCH net] net/sonic: use dma_mapping_error() for error check
> config: mips-jazz_defconfig
> compiler: mipsel-linux-gcc (GCC) 12.1.0
> 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
> # https://github.com/intel-lab-lkp/linux/commit/837273d17ba29bbc661c5c82432e83ce4198200a
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
> git checkout 837273d17ba29bbc661c5c82432e83ce4198200a
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> In file included from drivers/net/ethernet/natsemi/jazzsonic.c:228:
> drivers/net/ethernet/natsemi/sonic.c: In function 'sonic_send_packet':
> drivers/net/ethernet/natsemi/sonic.c:295:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
> 295 | if (dma_mapping_error(lp->device, laddr))
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:297:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
> 297 | dev_kfree_skb_any(skb);
> | ^~~~~~~~~~~~~~~~~
> drivers/net/ethernet/natsemi/sonic.c:279:23: warning: unused variable 'flags' [-Wunused-variable]
> 279 | unsigned long flags;
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:278:13: warning: unused variable 'entry' [-Wunused-variable]
> 278 | int entry;
> | ^~~~~
> In file included from include/linux/kref.h:16,
> from include/linux/mm_types.h:8,
> from include/linux/buildid.h:5,
> from include/linux/module.h:14,
> from drivers/net/ethernet/natsemi/jazzsonic.c:23:
> drivers/net/ethernet/natsemi/sonic.c: At top level:
> include/linux/spinlock.h:379:1: error: expected identifier or '(' before 'do'
> 379 | do { \
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
> 301 | spin_lock_irqsave(&lp->lock, flags);
> | ^~~~~~~~~~~~~~~~~
> include/linux/spinlock.h:381:3: error: expected identifier or '(' before 'while'
> 381 | } while (0)
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
> 301 | spin_lock_irqsave(&lp->lock, flags);
> | ^~~~~~~~~~~~~~~~~
> drivers/net/ethernet/natsemi/sonic.c:303:9: warning: data definition has no type or storage class
> 303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:303:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
> drivers/net/ethernet/natsemi/sonic.c:303:18: error: 'lp' undeclared here (not in a function); did you mean 'up'?
> 303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
> | ^~
> | up
> drivers/net/ethernet/natsemi/sonic.c:305:34: error: expected ')' before numeric constant
> 305 | sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:306:34: error: expected ')' before numeric constant
> 306 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:307:34: error: expected ')' before numeric constant
> 307 | sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:308:34: error: expected ')' before numeric constant
> 308 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:309:34: error: expected ')' before numeric constant
> 309 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:310:34: error: expected ')' before numeric constant
> 310 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:311:34: error: expected ')' before numeric constant
> 311 | sonic_tda_put(dev, entry, SONIC_TD_LINK,
> | ^
> | )
> drivers/net/ethernet/natsemi/sonic.c:314:30: error: expected ')' before '->' token
> 314 | sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
> | ^~
> | )
> In file included from include/linux/skbuff.h:45,
> from include/net/net_namespace.h:43,
> from include/linux/netdevice.h:38,
> from drivers/net/ethernet/natsemi/jazzsonic.c:33:
> include/net/net_debug.h:123:2: error: expected identifier or '(' before '{' token
> 123 | ({ \
> | ^
> drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
> 317 | netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
> | ^~~~~~~~~
>>> drivers/net/ethernet/natsemi/jazzsonic.c:59:1: error: expected identifier or '(' before 'do'
> 59 | do { \
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
> 319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
> | ^~~~~~~~~~~
>>> drivers/net/ethernet/natsemi/jazzsonic.c:61:3: error: expected identifier or '(' before 'while'
> 61 | } while (0)
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
> 319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
> | ^~~~~~~~~~~
> drivers/net/ethernet/natsemi/sonic.c:321:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
> 321 | lp->tx_len[entry] = length;
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:322:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
> 322 | lp->tx_laddr[entry] = laddr;
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:323:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
> 323 | lp->tx_skb[entry] = skb;
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:325:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
> 325 | lp->eol_tx = entry;
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:327:9: warning: data definition has no type or storage class
> 327 | entry = (entry + 1) & SONIC_TDS_MASK;
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:327:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
> drivers/net/ethernet/natsemi/sonic.c:327:9: error: redefinition of 'entry'
> drivers/net/ethernet/natsemi/sonic.c:303:9: note: previous definition of 'entry' with type 'int'
> 303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:327:17: error: initializer element is not constant
> 327 | entry = (entry + 1) & SONIC_TDS_MASK;
> | ^
> drivers/net/ethernet/natsemi/sonic.c:328:9: error: expected identifier or '(' before 'if'
> 328 | if (lp->tx_skb[entry]) {
> | ^~
> drivers/net/ethernet/natsemi/sonic.c:335:32: error: expected declaration specifiers or '...' before '&' token
> 335 | spin_unlock_irqrestore(&lp->lock, flags);
> | ^
> drivers/net/ethernet/natsemi/sonic.c:335:43: error: unknown type name 'flags'
> 335 | spin_unlock_irqrestore(&lp->lock, flags);
> | ^~~~~
> drivers/net/ethernet/natsemi/sonic.c:337:9: error: expected identifier or '(' before 'return'
> 337 | return NETDEV_TX_OK;
> | ^~~~~~
> drivers/net/ethernet/natsemi/sonic.c:338:1: error: expected identifier or '(' before '}' token
> 338 | }
> | ^
> cc1: some warnings being treated as errors
>
>
> vim +59 drivers/net/ethernet/natsemi/jazzsonic.c
>
> ^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 57
> ^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 58 #define SONIC_WRITE(reg,val) \
> ^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 @59 do { \
> efcce839360fb3 drivers/net/jazzsonic.c Finn Thain 2005-08-20 60 *((volatile unsigned int *)dev->base_addr+(reg)) = (val); \
> ^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 @61 } while (0)
> ^1da177e4c3f41 drivers/net/jazzsonic.c Linus Torvalds 2005-04-16 62
>

2022-11-04 01:28:11

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH net] net/sonic: use dma_mapping_error() for error check

Hi Zhang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
patch link: https://lore.kernel.org/r/1667221322-8317-1-git-send-email-zhangchangzhong%40huawei.com
patch subject: [PATCH net] net/sonic: use dma_mapping_error() for error check
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
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
# https://github.com/intel-lab-lkp/linux/commit/837273d17ba29bbc661c5c82432e83ce4198200a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Zhang-Changzhong/net-sonic-use-dma_mapping_error-for-error-check/20221031-204340
git checkout 837273d17ba29bbc661c5c82432e83ce4198200a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/net/ethernet/natsemi/macsonic.c:533:
drivers/net/ethernet/natsemi/sonic.c: In function 'sonic_send_packet':
>> drivers/net/ethernet/natsemi/sonic.c:295:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
295 | if (dma_mapping_error(lp->device, laddr))
| ^~
drivers/net/ethernet/natsemi/sonic.c:297:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
297 | dev_kfree_skb_any(skb);
| ^~~~~~~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:279:23: warning: unused variable 'flags' [-Wunused-variable]
279 | unsigned long flags;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:278:13: warning: unused variable 'entry' [-Wunused-variable]
278 | int entry;
| ^~~~~
In file included from include/linux/kref.h:16,
from include/linux/mm_types.h:8,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/net/ethernet/natsemi/macsonic.c:36:
drivers/net/ethernet/natsemi/sonic.c: At top level:
include/linux/spinlock.h:379:1: error: expected identifier or '(' before 'do'
379 | do { \
| ^~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock.h:381:3: error: expected identifier or '(' before 'while'
381 | } while (0)
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:301:9: note: in expansion of macro 'spin_lock_irqsave'
301 | spin_lock_irqsave(&lp->lock, flags);
| ^~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/natsemi/sonic.c:303:9: warning: data definition has no type or storage class
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:303:9: error: type defaults to 'int' in declaration of 'entry' [-Werror=implicit-int]
drivers/net/ethernet/natsemi/sonic.c:303:18: error: 'lp' undeclared here (not in a function); did you mean 'up'?
303 | entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
| ^~
| up
drivers/net/ethernet/natsemi/sonic.c:305:34: error: expected ')' before numeric constant
305 | sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:306:34: error: expected ')' before numeric constant
306 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:307:34: error: expected ')' before numeric constant
307 | sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:308:34: error: expected ')' before numeric constant
308 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:309:34: error: expected ')' before numeric constant
309 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:310:34: error: expected ')' before numeric constant
310 | sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:311:34: error: expected ')' before numeric constant
311 | sonic_tda_put(dev, entry, SONIC_TD_LINK,
| ^
| )
drivers/net/ethernet/natsemi/sonic.c:314:30: error: expected ')' before '->' token
314 | sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
| ^~
| )
In file included from include/linux/skbuff.h:45,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from drivers/net/ethernet/natsemi/macsonic.c:47:
include/net/net_debug.h:114:1: error: expected identifier or '(' before 'do'
114 | do { \
| ^~
drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
317 | netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
| ^~~~~~~~~
include/net/net_debug.h:117:3: error: expected identifier or '(' before 'while'
117 | } while (0)
| ^~~~~
drivers/net/ethernet/natsemi/sonic.c:317:9: note: in expansion of macro 'netif_dbg'
317 | netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
| ^~~~~~~~~
In file included from arch/m68k/include/asm/io_mm.h:25,
from arch/m68k/include/asm/io.h:8,
from include/linux/io.h:13,
from include/linux/irq.h:20,
from include/asm-generic/hardirq.h:17,
from ./arch/m68k/include/generated/asm/hardirq.h:1,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from drivers/net/ethernet/natsemi/macsonic.c:40:
arch/m68k/include/asm/raw_io.h:31:27: error: expected identifier or '(' before 'void'
31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
| ^~~~
arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
44 | #define raw_outw(val,port) out_be16((port),(val))
| ^~~~~~~~
arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
13 | #define nubus_writew raw_outw
| ^~~~~~~~
drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
| ^~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
arch/m68k/include/asm/raw_io.h:31:32: error: expected ')' before '(' token
31 | #define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
| ^
arch/m68k/include/asm/raw_io.h:44:28: note: in expansion of macro 'out_be16'
44 | #define raw_outw(val,port) out_be16((port),(val))
| ^~~~~~~~
arch/m68k/include/asm/nubus.h:13:22: note: in expansion of macro 'raw_outw'
13 | #define nubus_writew raw_outw
| ^~~~~~~~
drivers/net/ethernet/natsemi/macsonic.c:70:31: note: in expansion of macro 'nubus_writew'
70 | #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
| ^~~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:319:9: note: in expansion of macro 'SONIC_WRITE'
319 | SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
| ^~~~~~~~~~~
drivers/net/ethernet/natsemi/sonic.c:321:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
321 | lp->tx_len[entry] = length;
| ^~
drivers/net/ethernet/natsemi/sonic.c:322:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
322 | lp->tx_laddr[entry] = laddr;
| ^~


vim +/if +295 drivers/net/ethernet/natsemi/sonic.c

254
255 /*
256 * transmit packet
257 *
258 * Appends new TD during transmission thus avoiding any TX interrupts
259 * until we run out of TDs.
260 * This routine interacts closely with the ISR in that it may,
261 * set tx_skb[i]
262 * reset the status flags of the new TD
263 * set and reset EOL flags
264 * stop the tx queue
265 * The ISR interacts with this routine in various ways. It may,
266 * reset tx_skb[i]
267 * test the EOL and status flags of the TDs
268 * wake the tx queue
269 * Concurrently with all of this, the SONIC is potentially writing to
270 * the status flags of the TDs.
271 */
272
273 static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
274 {
275 struct sonic_local *lp = netdev_priv(dev);
276 dma_addr_t laddr;
277 int length;
278 int entry;
279 unsigned long flags;
280
281 netif_dbg(lp, tx_queued, dev, "%s: skb=%p\n", __func__, skb);
282
283 length = skb->len;
284 if (length < ETH_ZLEN) {
285 if (skb_padto(skb, ETH_ZLEN))
286 return NETDEV_TX_OK;
287 length = ETH_ZLEN;
288 }
289
290 /*
291 * Map the packet data into the logical DMA address space
292 */
293
294 laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
> 295 if (dma_mapping_error(lp->device, laddr))
296 pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
297 dev_kfree_skb_any(skb);
298 return NETDEV_TX_OK;
299 }
300
301 spin_lock_irqsave(&lp->lock, flags);
302
> 303 entry = (lp->eol_tx + 1) & SONIC_TDS_MASK;
304
305 sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
306 sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */
307 sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */
308 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_L, laddr & 0xffff);
309 sonic_tda_put(dev, entry, SONIC_TD_FRAG_PTR_H, laddr >> 16);
310 sonic_tda_put(dev, entry, SONIC_TD_FRAG_SIZE, length);
311 sonic_tda_put(dev, entry, SONIC_TD_LINK,
312 sonic_tda_get(dev, entry, SONIC_TD_LINK) | SONIC_EOL);
313
314 sonic_tda_put(dev, lp->eol_tx, SONIC_TD_LINK, ~SONIC_EOL &
315 sonic_tda_get(dev, lp->eol_tx, SONIC_TD_LINK));
316
317 netif_dbg(lp, tx_queued, dev, "%s: issuing Tx command\n", __func__);
318
319 SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP);
320
321 lp->tx_len[entry] = length;
322 lp->tx_laddr[entry] = laddr;
323 lp->tx_skb[entry] = skb;
324
325 lp->eol_tx = entry;
326
327 entry = (entry + 1) & SONIC_TDS_MASK;
328 if (lp->tx_skb[entry]) {
329 /* The ring is full, the ISR has yet to process the next TD. */
330 netif_dbg(lp, tx_queued, dev, "%s: stopping queue\n", __func__);
331 netif_stop_queue(dev);
332 /* after this packet, wait for ISR to free up some TDAs */
333 }
334
335 spin_unlock_irqrestore(&lp->lock, flags);
336
337 return NETDEV_TX_OK;
338 }
339

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (12.99 kB)
config (288.28 kB)
Download all attachments