Re: [PATCH net-next v2 1/3] net: ethernet: ti: Allow most drivers with COMPILE_TEST

From: kbuild test robot
Date: Fri May 18 2018 - 16:59:00 EST


Hi Florian,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url: https://github.com/0day-ci/linux/commits/Florian-Fainelli/net-ethernet-ti-Allow-most-drivers-with-COMPILE_TEST/20180519-043005
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

All warnings (new ones prefixed by >>):

drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_free_rx_desc_chain':
>> drivers/net/ethernet/ti/netcp_core.c:613:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
buf_ptr = (void *)GET_SW_DATA0(ndesc);
^
drivers/net/ethernet/ti/netcp_core.c:622:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
buf_ptr = (void *)GET_SW_DATA0(desc);
^
drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_process_one_rx_packet':
drivers/net/ethernet/ti/netcp_core.c:681:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
org_buf_ptr = (void *)GET_SW_DATA0(desc);
^
drivers/net/ethernet/ti/netcp_core.c:718:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
page = (struct page *)GET_SW_DATA0(ndesc);
^
drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_free_rx_buf':
drivers/net/ethernet/ti/netcp_core.c:822:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
buf_ptr = (void *)GET_SW_DATA0(desc);
^
drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_allocate_rx_buf':
>> drivers/net/ethernet/ti/netcp_core.c:906:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
sw_data[0] = (u32)bufptr;
^
drivers/net/ethernet/ti/netcp_core.c:919:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
sw_data[0] = (u32)page;
^
drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_process_tx_compl_packets':
drivers/net/ethernet/ti/netcp_core.c:1041:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
skb = (struct sk_buff *)GET_SW_DATA0(desc);
^
drivers/net/ethernet/ti/netcp_core.c: In function 'netcp_tx_submit_skb':
drivers/net/ethernet/ti/netcp_core.c:1256:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
SET_SW_DATA0((u32)skb, desc);
^
drivers/net/ethernet/ti/netcp_core.c:181:49: note: in definition of macro 'SET_SW_DATA0'
#define SET_SW_DATA0(data, desc) set_sw_data(0, data, desc)
^~~~

vim +613 drivers/net/ethernet/ti/netcp_core.c

84640e27 Karicheri, Muralidharan 2015-01-15 591
84640e27 Karicheri, Muralidharan 2015-01-15 592 static void netcp_free_rx_desc_chain(struct netcp_intf *netcp,
84640e27 Karicheri, Muralidharan 2015-01-15 593 struct knav_dma_desc *desc)
84640e27 Karicheri, Muralidharan 2015-01-15 594 {
84640e27 Karicheri, Muralidharan 2015-01-15 595 struct knav_dma_desc *ndesc;
84640e27 Karicheri, Muralidharan 2015-01-15 596 dma_addr_t dma_desc, dma_buf;
84640e27 Karicheri, Muralidharan 2015-01-15 597 unsigned int buf_len, dma_sz = sizeof(*ndesc);
84640e27 Karicheri, Muralidharan 2015-01-15 598 void *buf_ptr;
958d104e Arnd Bergmann 2015-12-18 599 u32 tmp;
84640e27 Karicheri, Muralidharan 2015-01-15 600
84640e27 Karicheri, Muralidharan 2015-01-15 601 get_words(&dma_desc, 1, &desc->next_desc);
84640e27 Karicheri, Muralidharan 2015-01-15 602
84640e27 Karicheri, Muralidharan 2015-01-15 603 while (dma_desc) {
84640e27 Karicheri, Muralidharan 2015-01-15 604 ndesc = knav_pool_desc_unmap(netcp->rx_pool, dma_desc, dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 605 if (unlikely(!ndesc)) {
84640e27 Karicheri, Muralidharan 2015-01-15 606 dev_err(netcp->ndev_dev, "failed to unmap Rx desc\n");
84640e27 Karicheri, Muralidharan 2015-01-15 607 break;
84640e27 Karicheri, Muralidharan 2015-01-15 608 }
958d104e Arnd Bergmann 2015-12-18 609 get_pkt_info(&dma_buf, &tmp, &dma_desc, ndesc);
06324481 Karicheri, Muralidharan 2016-02-19 610 /* warning!!!! We are retrieving the virtual ptr in the sw_data
06324481 Karicheri, Muralidharan 2016-02-19 611 * field as a 32bit value. Will not work on 64bit machines
06324481 Karicheri, Muralidharan 2016-02-19 612 */
06324481 Karicheri, Muralidharan 2016-02-19 @613 buf_ptr = (void *)GET_SW_DATA0(ndesc);
06324481 Karicheri, Muralidharan 2016-02-19 614 buf_len = (int)GET_SW_DATA1(desc);
84640e27 Karicheri, Muralidharan 2015-01-15 615 dma_unmap_page(netcp->dev, dma_buf, PAGE_SIZE, DMA_FROM_DEVICE);
84640e27 Karicheri, Muralidharan 2015-01-15 616 __free_page(buf_ptr);
84640e27 Karicheri, Muralidharan 2015-01-15 617 knav_pool_desc_put(netcp->rx_pool, desc);
84640e27 Karicheri, Muralidharan 2015-01-15 618 }
06324481 Karicheri, Muralidharan 2016-02-19 619 /* warning!!!! We are retrieving the virtual ptr in the sw_data
06324481 Karicheri, Muralidharan 2016-02-19 620 * field as a 32bit value. Will not work on 64bit machines
06324481 Karicheri, Muralidharan 2016-02-19 621 */
06324481 Karicheri, Muralidharan 2016-02-19 622 buf_ptr = (void *)GET_SW_DATA0(desc);
06324481 Karicheri, Muralidharan 2016-02-19 623 buf_len = (int)GET_SW_DATA1(desc);
89907779 Arnd Bergmann 2015-12-08 624
84640e27 Karicheri, Muralidharan 2015-01-15 625 if (buf_ptr)
84640e27 Karicheri, Muralidharan 2015-01-15 626 netcp_frag_free(buf_len <= PAGE_SIZE, buf_ptr);
84640e27 Karicheri, Muralidharan 2015-01-15 627 knav_pool_desc_put(netcp->rx_pool, desc);
84640e27 Karicheri, Muralidharan 2015-01-15 628 }
84640e27 Karicheri, Muralidharan 2015-01-15 629
84640e27 Karicheri, Muralidharan 2015-01-15 630 static void netcp_empty_rx_queue(struct netcp_intf *netcp)
84640e27 Karicheri, Muralidharan 2015-01-15 631 {
6a8162e9 Michael Scherban 2017-01-06 632 struct netcp_stats *rx_stats = &netcp->stats;
84640e27 Karicheri, Muralidharan 2015-01-15 633 struct knav_dma_desc *desc;
84640e27 Karicheri, Muralidharan 2015-01-15 634 unsigned int dma_sz;
84640e27 Karicheri, Muralidharan 2015-01-15 635 dma_addr_t dma;
84640e27 Karicheri, Muralidharan 2015-01-15 636
84640e27 Karicheri, Muralidharan 2015-01-15 637 for (; ;) {
84640e27 Karicheri, Muralidharan 2015-01-15 638 dma = knav_queue_pop(netcp->rx_queue, &dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 639 if (!dma)
84640e27 Karicheri, Muralidharan 2015-01-15 640 break;
84640e27 Karicheri, Muralidharan 2015-01-15 641
84640e27 Karicheri, Muralidharan 2015-01-15 642 desc = knav_pool_desc_unmap(netcp->rx_pool, dma, dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 643 if (unlikely(!desc)) {
84640e27 Karicheri, Muralidharan 2015-01-15 644 dev_err(netcp->ndev_dev, "%s: failed to unmap Rx desc\n",
84640e27 Karicheri, Muralidharan 2015-01-15 645 __func__);
6a8162e9 Michael Scherban 2017-01-06 646 rx_stats->rx_errors++;
84640e27 Karicheri, Muralidharan 2015-01-15 647 continue;
84640e27 Karicheri, Muralidharan 2015-01-15 648 }
84640e27 Karicheri, Muralidharan 2015-01-15 649 netcp_free_rx_desc_chain(netcp, desc);
6a8162e9 Michael Scherban 2017-01-06 650 rx_stats->rx_dropped++;
84640e27 Karicheri, Muralidharan 2015-01-15 651 }
84640e27 Karicheri, Muralidharan 2015-01-15 652 }
84640e27 Karicheri, Muralidharan 2015-01-15 653
84640e27 Karicheri, Muralidharan 2015-01-15 654 static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
84640e27 Karicheri, Muralidharan 2015-01-15 655 {
6a8162e9 Michael Scherban 2017-01-06 656 struct netcp_stats *rx_stats = &netcp->stats;
84640e27 Karicheri, Muralidharan 2015-01-15 657 unsigned int dma_sz, buf_len, org_buf_len;
84640e27 Karicheri, Muralidharan 2015-01-15 658 struct knav_dma_desc *desc, *ndesc;
84640e27 Karicheri, Muralidharan 2015-01-15 659 unsigned int pkt_sz = 0, accum_sz;
84640e27 Karicheri, Muralidharan 2015-01-15 660 struct netcp_hook_list *rx_hook;
84640e27 Karicheri, Muralidharan 2015-01-15 661 dma_addr_t dma_desc, dma_buff;
84640e27 Karicheri, Muralidharan 2015-01-15 662 struct netcp_packet p_info;
84640e27 Karicheri, Muralidharan 2015-01-15 663 struct sk_buff *skb;
84640e27 Karicheri, Muralidharan 2015-01-15 664 void *org_buf_ptr;
69d707d0 Karicheri, Muralidharan 2017-01-06 665 u32 tmp;
84640e27 Karicheri, Muralidharan 2015-01-15 666
84640e27 Karicheri, Muralidharan 2015-01-15 667 dma_desc = knav_queue_pop(netcp->rx_queue, &dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 668 if (!dma_desc)
84640e27 Karicheri, Muralidharan 2015-01-15 669 return -1;
84640e27 Karicheri, Muralidharan 2015-01-15 670
84640e27 Karicheri, Muralidharan 2015-01-15 671 desc = knav_pool_desc_unmap(netcp->rx_pool, dma_desc, dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 672 if (unlikely(!desc)) {
84640e27 Karicheri, Muralidharan 2015-01-15 673 dev_err(netcp->ndev_dev, "failed to unmap Rx desc\n");
84640e27 Karicheri, Muralidharan 2015-01-15 674 return 0;
84640e27 Karicheri, Muralidharan 2015-01-15 675 }
84640e27 Karicheri, Muralidharan 2015-01-15 676
84640e27 Karicheri, Muralidharan 2015-01-15 677 get_pkt_info(&dma_buff, &buf_len, &dma_desc, desc);
06324481 Karicheri, Muralidharan 2016-02-19 678 /* warning!!!! We are retrieving the virtual ptr in the sw_data
06324481 Karicheri, Muralidharan 2016-02-19 679 * field as a 32bit value. Will not work on 64bit machines
06324481 Karicheri, Muralidharan 2016-02-19 680 */
06324481 Karicheri, Muralidharan 2016-02-19 681 org_buf_ptr = (void *)GET_SW_DATA0(desc);
06324481 Karicheri, Muralidharan 2016-02-19 682 org_buf_len = (int)GET_SW_DATA1(desc);
84640e27 Karicheri, Muralidharan 2015-01-15 683
84640e27 Karicheri, Muralidharan 2015-01-15 684 if (unlikely(!org_buf_ptr)) {
84640e27 Karicheri, Muralidharan 2015-01-15 685 dev_err(netcp->ndev_dev, "NULL bufptr in desc\n");
84640e27 Karicheri, Muralidharan 2015-01-15 686 goto free_desc;
84640e27 Karicheri, Muralidharan 2015-01-15 687 }
84640e27 Karicheri, Muralidharan 2015-01-15 688
84640e27 Karicheri, Muralidharan 2015-01-15 689 pkt_sz &= KNAV_DMA_DESC_PKT_LEN_MASK;
84640e27 Karicheri, Muralidharan 2015-01-15 690 accum_sz = buf_len;
84640e27 Karicheri, Muralidharan 2015-01-15 691 dma_unmap_single(netcp->dev, dma_buff, buf_len, DMA_FROM_DEVICE);
84640e27 Karicheri, Muralidharan 2015-01-15 692
84640e27 Karicheri, Muralidharan 2015-01-15 693 /* Build a new sk_buff for the primary buffer */
84640e27 Karicheri, Muralidharan 2015-01-15 694 skb = build_skb(org_buf_ptr, org_buf_len);
84640e27 Karicheri, Muralidharan 2015-01-15 695 if (unlikely(!skb)) {
84640e27 Karicheri, Muralidharan 2015-01-15 696 dev_err(netcp->ndev_dev, "build_skb() failed\n");
84640e27 Karicheri, Muralidharan 2015-01-15 697 goto free_desc;
84640e27 Karicheri, Muralidharan 2015-01-15 698 }
84640e27 Karicheri, Muralidharan 2015-01-15 699
84640e27 Karicheri, Muralidharan 2015-01-15 700 /* update data, tail and len */
84640e27 Karicheri, Muralidharan 2015-01-15 701 skb_reserve(skb, NETCP_SOP_OFFSET);
84640e27 Karicheri, Muralidharan 2015-01-15 702 __skb_put(skb, buf_len);
84640e27 Karicheri, Muralidharan 2015-01-15 703
84640e27 Karicheri, Muralidharan 2015-01-15 704 /* Fill in the page fragment list */
84640e27 Karicheri, Muralidharan 2015-01-15 705 while (dma_desc) {
84640e27 Karicheri, Muralidharan 2015-01-15 706 struct page *page;
84640e27 Karicheri, Muralidharan 2015-01-15 707
84640e27 Karicheri, Muralidharan 2015-01-15 708 ndesc = knav_pool_desc_unmap(netcp->rx_pool, dma_desc, dma_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 709 if (unlikely(!ndesc)) {
84640e27 Karicheri, Muralidharan 2015-01-15 710 dev_err(netcp->ndev_dev, "failed to unmap Rx desc\n");
84640e27 Karicheri, Muralidharan 2015-01-15 711 goto free_desc;
84640e27 Karicheri, Muralidharan 2015-01-15 712 }
84640e27 Karicheri, Muralidharan 2015-01-15 713
84640e27 Karicheri, Muralidharan 2015-01-15 714 get_pkt_info(&dma_buff, &buf_len, &dma_desc, ndesc);
06324481 Karicheri, Muralidharan 2016-02-19 715 /* warning!!!! We are retrieving the virtual ptr in the sw_data
06324481 Karicheri, Muralidharan 2016-02-19 716 * field as a 32bit value. Will not work on 64bit machines
06324481 Karicheri, Muralidharan 2016-02-19 717 */
5a717843 Rex Chang 2018-01-16 @718 page = (struct page *)GET_SW_DATA0(ndesc);
84640e27 Karicheri, Muralidharan 2015-01-15 719
84640e27 Karicheri, Muralidharan 2015-01-15 720 if (likely(dma_buff && buf_len && page)) {
84640e27 Karicheri, Muralidharan 2015-01-15 721 dma_unmap_page(netcp->dev, dma_buff, PAGE_SIZE,
84640e27 Karicheri, Muralidharan 2015-01-15 722 DMA_FROM_DEVICE);
84640e27 Karicheri, Muralidharan 2015-01-15 723 } else {
89907779 Arnd Bergmann 2015-12-08 724 dev_err(netcp->ndev_dev, "Bad Rx desc dma_buff(%pad), len(%d), page(%p)\n",
89907779 Arnd Bergmann 2015-12-08 725 &dma_buff, buf_len, page);
84640e27 Karicheri, Muralidharan 2015-01-15 726 goto free_desc;
84640e27 Karicheri, Muralidharan 2015-01-15 727 }
84640e27 Karicheri, Muralidharan 2015-01-15 728
84640e27 Karicheri, Muralidharan 2015-01-15 729 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
84640e27 Karicheri, Muralidharan 2015-01-15 730 offset_in_page(dma_buff), buf_len, PAGE_SIZE);
84640e27 Karicheri, Muralidharan 2015-01-15 731 accum_sz += buf_len;
84640e27 Karicheri, Muralidharan 2015-01-15 732
84640e27 Karicheri, Muralidharan 2015-01-15 733 /* Free the descriptor */
84640e27 Karicheri, Muralidharan 2015-01-15 734 knav_pool_desc_put(netcp->rx_pool, ndesc);
84640e27 Karicheri, Muralidharan 2015-01-15 735 }
84640e27 Karicheri, Muralidharan 2015-01-15 736
84640e27 Karicheri, Muralidharan 2015-01-15 737 /* check for packet len and warn */
84640e27 Karicheri, Muralidharan 2015-01-15 738 if (unlikely(pkt_sz != accum_sz))
84640e27 Karicheri, Muralidharan 2015-01-15 739 dev_dbg(netcp->ndev_dev, "mismatch in packet size(%d) & sum of fragments(%d)\n",
84640e27 Karicheri, Muralidharan 2015-01-15 740 pkt_sz, accum_sz);
84640e27 Karicheri, Muralidharan 2015-01-15 741
4cd85a61 Karicheri, Muralidharan 2017-01-06 742 /* Newer version of the Ethernet switch can trim the Ethernet FCS
4cd85a61 Karicheri, Muralidharan 2017-01-06 743 * from the packet and is indicated in hw_cap. So trim it only for
4cd85a61 Karicheri, Muralidharan 2017-01-06 744 * older h/w
4cd85a61 Karicheri, Muralidharan 2017-01-06 745 */
4cd85a61 Karicheri, Muralidharan 2017-01-06 746 if (!(netcp->hw_cap & ETH_SW_CAN_REMOVE_ETH_FCS))
84640e27 Karicheri, Muralidharan 2015-01-15 747 __pskb_trim(skb, skb->len - ETH_FCS_LEN);
84640e27 Karicheri, Muralidharan 2015-01-15 748
84640e27 Karicheri, Muralidharan 2015-01-15 749 /* Call each of the RX hooks */
84640e27 Karicheri, Muralidharan 2015-01-15 750 p_info.skb = skb;
6246168b WingMan Kwok 2016-12-08 751 skb->dev = netcp->ndev;
84640e27 Karicheri, Muralidharan 2015-01-15 752 p_info.rxtstamp_complete = false;
69d707d0 Karicheri, Muralidharan 2017-01-06 753 get_desc_info(&tmp, &p_info.eflags, desc);
69d707d0 Karicheri, Muralidharan 2017-01-06 754 p_info.epib = desc->epib;
69d707d0 Karicheri, Muralidharan 2017-01-06 755 p_info.psdata = (u32 __force *)desc->psdata;
69d707d0 Karicheri, Muralidharan 2017-01-06 756 p_info.eflags = ((p_info.eflags >> KNAV_DMA_DESC_EFLAGS_SHIFT) &
69d707d0 Karicheri, Muralidharan 2017-01-06 757 KNAV_DMA_DESC_EFLAGS_MASK);
84640e27 Karicheri, Muralidharan 2015-01-15 758 list_for_each_entry(rx_hook, &netcp->rxhook_list_head, list) {
84640e27 Karicheri, Muralidharan 2015-01-15 759 int ret;
84640e27 Karicheri, Muralidharan 2015-01-15 760
84640e27 Karicheri, Muralidharan 2015-01-15 761 ret = rx_hook->hook_rtn(rx_hook->order, rx_hook->hook_data,
84640e27 Karicheri, Muralidharan 2015-01-15 762 &p_info);
84640e27 Karicheri, Muralidharan 2015-01-15 763 if (unlikely(ret)) {
84640e27 Karicheri, Muralidharan 2015-01-15 764 dev_err(netcp->ndev_dev, "RX hook %d failed: %d\n",
84640e27 Karicheri, Muralidharan 2015-01-15 765 rx_hook->order, ret);
69d707d0 Karicheri, Muralidharan 2017-01-06 766 /* Free the primary descriptor */
6a8162e9 Michael Scherban 2017-01-06 767 rx_stats->rx_dropped++;
69d707d0 Karicheri, Muralidharan 2017-01-06 768 knav_pool_desc_put(netcp->rx_pool, desc);
84640e27 Karicheri, Muralidharan 2015-01-15 769 dev_kfree_skb(skb);
84640e27 Karicheri, Muralidharan 2015-01-15 770 return 0;
84640e27 Karicheri, Muralidharan 2015-01-15 771 }
84640e27 Karicheri, Muralidharan 2015-01-15 772 }
69d707d0 Karicheri, Muralidharan 2017-01-06 773 /* Free the primary descriptor */
69d707d0 Karicheri, Muralidharan 2017-01-06 774 knav_pool_desc_put(netcp->rx_pool, desc);
84640e27 Karicheri, Muralidharan 2015-01-15 775
6a8162e9 Michael Scherban 2017-01-06 776 u64_stats_update_begin(&rx_stats->syncp_rx);
6a8162e9 Michael Scherban 2017-01-06 777 rx_stats->rx_packets++;
6a8162e9 Michael Scherban 2017-01-06 778 rx_stats->rx_bytes += skb->len;
6a8162e9 Michael Scherban 2017-01-06 779 u64_stats_update_end(&rx_stats->syncp_rx);
84640e27 Karicheri, Muralidharan 2015-01-15 780
84640e27 Karicheri, Muralidharan 2015-01-15 781 /* push skb up the stack */
84640e27 Karicheri, Muralidharan 2015-01-15 782 skb->protocol = eth_type_trans(skb, netcp->ndev);
84640e27 Karicheri, Muralidharan 2015-01-15 783 netif_receive_skb(skb);
84640e27 Karicheri, Muralidharan 2015-01-15 784 return 0;
84640e27 Karicheri, Muralidharan 2015-01-15 785
84640e27 Karicheri, Muralidharan 2015-01-15 786 free_desc:
84640e27 Karicheri, Muralidharan 2015-01-15 787 netcp_free_rx_desc_chain(netcp, desc);
6a8162e9 Michael Scherban 2017-01-06 788 rx_stats->rx_errors++;
84640e27 Karicheri, Muralidharan 2015-01-15 789 return 0;
84640e27 Karicheri, Muralidharan 2015-01-15 790 }
84640e27 Karicheri, Muralidharan 2015-01-15 791

:::::: The code at line 613 was first introduced by commit
:::::: 0632448134d0ac1450a19d26f90948fde3b558ad net: netcp: rework the code for get/set sw_data in dma desc

:::::: TO: Karicheri, Muralidharan <m-karicheri2@xxxxxx>
:::::: CC: David S. Miller <davem@xxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip