Message ID | 20210608160118.3767932-10-shayagr@amazon.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 947c54c395cb8368abebf3bec1413123d5dd4339 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Use build_skb and reorganize some code in ENA | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 3 maintainers not CCed: sameehj@amazon.com lorenzo@kernel.org gtzalik@amazon.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | fail | Errors and warnings before: 0 this patch: 2 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: nested (un)?likely() calls, IS_ERR already uses unlikely() internally |
netdev/build_allmodconfig_warn | fail | Errors and warnings before: 0 this patch: 2 |
netdev/header_inline | success | Link |
Hi Shay, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on net-next/master] url: https://github.com/0day-ci/linux/commits/Shay-Agroskin/Use-build_skb-and-reorganize-some-code-in-ENA/20210609-000712 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git dc8cf7550a703b8b9c94beed621c6c2474347eff config: i386-allyesconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/d37d1c673e22e4e7c24eb8bbc4c5662a7812842c git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Shay-Agroskin/Use-build_skb-and-reorganize-some-code-in-ENA/20210609-000712 git checkout d37d1c673e22e4e7c24eb8bbc4c5662a7812842c # save the attached .config to linux build tree make W=1 ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/net/ethernet/amazon/ena/ena_netdev.c:978:14: warning: no previous prototype for 'ena_alloc_map_page' [-Wmissing-prototypes] 978 | struct page *ena_alloc_map_page(struct ena_ring *rx_ring, dma_addr_t *dma) | ^~~~~~~~~~~~~~~~~~ vim +/ena_alloc_map_page +978 drivers/net/ethernet/amazon/ena/ena_netdev.c 977 > 978 struct page *ena_alloc_map_page(struct ena_ring *rx_ring, dma_addr_t *dma) 979 { 980 struct page *page; 981 982 /* This would allocate the page on the same NUMA node the executing code 983 * is running on. 984 */ 985 page = dev_alloc_page(); 986 if (!page) { 987 ena_increase_stat(&rx_ring->rx_stats.page_alloc_fail, 1, 988 &rx_ring->syncp); 989 return ERR_PTR(-ENOSPC); 990 } 991 992 /* To enable NIC-side port-mirroring, AKA SPAN port, 993 * we make the buffer readable from the nic as well 994 */ 995 *dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, 996 DMA_BIDIRECTIONAL); 997 if (unlikely(dma_mapping_error(rx_ring->dev, *dma))) { 998 ena_increase_stat(&rx_ring->rx_stats.dma_mapping_err, 1, 999 &rx_ring->syncp); 1000 __free_page(page); 1001 return ERR_PTR(-EIO); 1002 } 1003 1004 return page; 1005 } 1006 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 37c839401c6c..261680aba33c 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -975,8 +975,37 @@ static void ena_free_all_io_rx_resources(struct ena_adapter *adapter) ena_free_rx_resources(adapter, i); } -static int ena_alloc_rx_page(struct ena_ring *rx_ring, - struct ena_rx_buffer *rx_info, gfp_t gfp) +struct page *ena_alloc_map_page(struct ena_ring *rx_ring, dma_addr_t *dma) +{ + struct page *page; + + /* This would allocate the page on the same NUMA node the executing code + * is running on. + */ + page = dev_alloc_page(); + if (!page) { + ena_increase_stat(&rx_ring->rx_stats.page_alloc_fail, 1, + &rx_ring->syncp); + return ERR_PTR(-ENOSPC); + } + + /* To enable NIC-side port-mirroring, AKA SPAN port, + * we make the buffer readable from the nic as well + */ + *dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, + DMA_BIDIRECTIONAL); + if (unlikely(dma_mapping_error(rx_ring->dev, *dma))) { + ena_increase_stat(&rx_ring->rx_stats.dma_mapping_err, 1, + &rx_ring->syncp); + __free_page(page); + return ERR_PTR(-EIO); + } + + return page; +} + +static int ena_alloc_rx_buffer(struct ena_ring *rx_ring, + struct ena_rx_buffer *rx_info) { int headroom = rx_ring->rx_headroom; struct ena_com_buf *ena_buf; @@ -991,25 +1020,11 @@ static int ena_alloc_rx_page(struct ena_ring *rx_ring, if (unlikely(rx_info->page)) return 0; - page = alloc_page(gfp); - if (unlikely(!page)) { - ena_increase_stat(&rx_ring->rx_stats.page_alloc_fail, 1, - &rx_ring->syncp); - return -ENOMEM; - } - - /* To enable NIC-side port-mirroring, AKA SPAN port, - * we make the buffer readable from the nic as well - */ - dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, - DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(rx_ring->dev, dma))) { - ena_increase_stat(&rx_ring->rx_stats.dma_mapping_err, 1, - &rx_ring->syncp); + /* We handle DMA here */ + page = ena_alloc_map_page(rx_ring, &dma); + if (unlikely(IS_ERR(page))) + return PTR_ERR(page); - __free_page(page); - return -EIO; - } netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, "Allocate page %p, rx_info %p\n", page, rx_info); @@ -1065,8 +1080,7 @@ static int ena_refill_rx_bufs(struct ena_ring *rx_ring, u32 num) rx_info = &rx_ring->rx_buffer_info[req_id]; - rc = ena_alloc_rx_page(rx_ring, rx_info, - GFP_ATOMIC | __GFP_COMP); + rc = ena_alloc_rx_buffer(rx_ring, rx_info); if (unlikely(rc < 0)) { netif_warn(rx_ring->adapter, rx_err, rx_ring->netdev, "Failed to allocate buffer for rx queue %d\n",
Use dev_alloc() when allocating RX buffers instead of specifying the allocation flags explicitly. This result in same behaviour with less code. Also move the page allocation and its DMA mapping into a function. This creates a logical block, which may help understanding the code. Signed-off-by: Shay Agroskin <shayagr@amazon.com> --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 58 ++++++++++++-------- 1 file changed, 36 insertions(+), 22 deletions(-)