gve: DQO: avoid unused variable warnings
Subsystems (3)
PATCH v2 1/1 gve: DQO: avoid unused variable warnings
From: Arnd Bergmann <[email protected]>
The use of dma_unmap_addr()/dma_unmap_len() in the driver causes multiple warnings when these macros are defined as empty, e.g. in an ARCH=i386 allmodconfig build:
drivers/net/ethernet/google/gve/gve_tx_dqo.c: In function 'gve_tx_add_skb_no_copy_dqo':drivers/net/ethernet/google/gve/gve_tx_dqo.c:494:40: error: unused variable 'buf' [-Werror=unused-variable]
494 | struct gve_tx_dma_buf *buf =
This is not how the NEED_DMA_MAP_STATE macros are meant to work, as they rely on never using local variables or a temporary structure like gve_tx_dma_buf.
Remote the gve_tx_dma_buf definition and open-code the contents in all places to avoid the warning. This causes some rather long lines but otherwise ends up making the driver slightly smaller.
---
Changes in v2:
- complete rewrite of v1
--- drivers/net/ethernet/google/gve/gve.h | 13 ++- drivers/net/ethernet/google/gve/gve_tx.c | 23 +++--- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 84 +++++++++----------- 3 files changed, 54 insertions(+), 66 deletions(-)
drivers/net/ethernet/google/gve/gve.h +6 -7
@@ -224,11 +224,6 @@ struct gve_tx_iovec {u32 iov_padding;/* padding associated with this segment */ }; -struct gve_tx_dma_buf { -DEFINE_DMA_UNMAP_ADDR (dma); -DEFINE_DMA_UNMAP_LEN (len); -}; -/* Tracks the memory in the fifo occupied by the skb. Mapped 1:1 to a desc * ring entry but only used for a pkt_desc not a seg_desc */
@@ -236,7 +231,10 @@ struct gve_tx_buffer_state {struct sk_buff *skb;/* skb for this pkt */ union {struct gve_tx_iovec iov[GVE_TX_MAX_IOVEC ];/* segments of this pkt */ -struct gve_tx_dma_buf buf; +struct { +DEFINE_DMA_UNMAP_ADDR (dma); +DEFINE_DMA_UNMAP_LEN (len); + }; }; };
@@ -280,7 +278,8 @@ struct gve_tx_pending_packet_dqo {* All others correspond to `skb`'s frags and should be unmapped with * `dma_unmap_page`. */ -struct gve_tx_dma_buf bufs[MAX_SKB_FRAGS +1 ]; +DEFINE_DMA_UNMAP_ADDR (dma[MAX_SKB_FRAGS +1 ]); +DEFINE_DMA_UNMAP_LEN (len[MAX_SKB_FRAGS +1 ]);u16 num_bufs;/* Linked list index to next element in the list, or -1 if none */
drivers/net/ethernet/google/gve/gve_tx.c +10 -13
@@ -303,15 +303,15 @@ static inline int gve_skb_fifo_bytes_required(struct gve_tx_ring *tx,static void gve_tx_unmap_buf (struct device *dev,struct gve_tx_buffer_state *info) {if (info->skb) { -dma_unmap_single (dev,dma_unmap_addr (&info->buf, dma), -dma_unmap_len (&info->buf, len), +dma_unmap_single (dev,dma_unmap_addr (info, dma), +dma_unmap_len (info, len),DMA_TO_DEVICE ); -dma_unmap_len_set (&info->buf, len,0 ); +dma_unmap_len_set (info, len,0 ); }else { -dma_unmap_page (dev,dma_unmap_addr (&info->buf, dma), -dma_unmap_len (&info->buf, len), +dma_unmap_page (dev,dma_unmap_addr (info, dma), +dma_unmap_len (info, len),DMA_TO_DEVICE ); -dma_unmap_len_set (&info->buf, len,0 ); +dma_unmap_len_set (info, len,0 ); } }
@@ -491,7 +491,6 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx,struct gve_tx_buffer_state *info;bool is_gso =skb_is_gso (skb);u32 idx = tx->req & tx->mask; -struct gve_tx_dma_buf *buf;u64 addr;u32 len;int i;
@@ -515,9 +514,8 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx, tx->dma_mapping_error++; goto drop; } - buf = &info->buf; -dma_unmap_len_set (buf, len, len); -dma_unmap_addr_set (buf, dma, addr); +dma_unmap_len_set (info, len, len); +dma_unmap_addr_set (info, dma, addr); payload_nfrags = shinfo->nr_frags;if (hlen < len) {
@@ -549,10 +547,9 @@ static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx, tx->dma_mapping_error++; goto unmap_drop; } - buf = &tx->info[idx].buf; tx->info[idx].skb =NULL ; -dma_unmap_len_set (buf, len, len); -dma_unmap_addr_set (buf, dma, addr); +dma_unmap_len_set (&tx->info[idx], len, len); +dma_unmap_addr_set (&tx->info[idx], dma, addr);gve_tx_fill_seg_desc (seg_desc, skb, is_gso, len, addr); }
drivers/net/ethernet/google/gve/gve_tx_dqo.c +38 -46
160 lines not on this page · raw message
Signature · 1 line
2.29.2
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 11 lines · On Tue, 28 Sep 2021 16:15:13 +0200 you wrote:
From: Arnd Bergmann <[email protected]>
The use of dma_unmap_addr()/dma_unmap_len() in the driver causes multiple warnings when these macros are defined as empty, e.g. in an ARCH=i386 allmodconfig build:
drivers/net/ethernet/google/gve/gve_tx_dqo.c: In function 'gve_tx_add_skb_no_copy_dqo':drivers/net/ethernet/google/gve/gve_tx_dqo.c:494:40: error: unused variable 'buf' [-Werror=unused-variable]
494 | structgve_tx_dma_buf*buf =[...]
Here is the summary with links:
- [v2] gve: DQO: avoid unused variable warnings
https://git.kernel.org/netdev/net-next/c/1e0083bd0777
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html