Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 's390-ctcm-updates-2020-11-30'

Julian Wiedmann says:

====================
s390/ctcm: updates 2020-11-30

Some rare ctcm updates by Sebastian, who cleans up all places where
in_interrupt() was used to determine the correct GFP_* mask for
allocations.
In the first three patches we can get rid of those allocations entirely,
as they just end up being copied into the skb.
====================

Link: https://lore.kernel.org/r/20201130100950.42051-1-jwi@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+24 -103
+4 -11
drivers/s390/net/ctcm_fsms.c
··· 1303 1303 /* p_header points to the last one we handled */ 1304 1304 if (p_header) 1305 1305 p_header->pdu_flag |= PDU_LAST; /*Say it's the last one*/ 1306 - header = kzalloc(TH_HEADER_LENGTH, gfp_type()); 1307 - if (!header) { 1308 - spin_unlock(&ch->collect_lock); 1309 - fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); 1310 - goto done; 1311 - } 1306 + 1307 + header = skb_push(ch->trans_skb, TH_HEADER_LENGTH); 1308 + memset(header, 0, TH_HEADER_LENGTH); 1309 + 1312 1310 header->th_ch_flag = TH_HAS_PDU; /* Normal data */ 1313 1311 ch->th_seq_num++; 1314 1312 header->th_seq_num = ch->th_seq_num; 1315 1313 1316 1314 CTCM_PR_DBGDATA("%s: ToVTAM_th_seq= %08x\n" , 1317 1315 __func__, ch->th_seq_num); 1318 - 1319 - memcpy(skb_push(ch->trans_skb, TH_HEADER_LENGTH), header, 1320 - TH_HEADER_LENGTH); /* put the TH on the packet */ 1321 - 1322 - kfree(header); 1323 1316 1324 1317 CTCM_PR_DBGDATA("%s: trans_skb len:%04x \n", 1325 1318 __func__, ch->trans_skb->len);
+14 -54
drivers/s390/net/ctcm_main.c
··· 623 623 goto nomem; 624 624 } 625 625 626 - header = kmalloc(TH_SWEEP_LENGTH, gfp_type()); 627 - 628 - if (!header) { 629 - dev_kfree_skb_any(sweep_skb); 630 - /* rc = -ENOMEM; */ 631 - goto nomem; 632 - } 633 - 634 - header->th.th_seg = 0x00 ; 626 + header = skb_put_zero(sweep_skb, TH_SWEEP_LENGTH); 635 627 header->th.th_ch_flag = TH_SWEEP_REQ; /* 0x0f */ 636 - header->th.th_blk_flag = 0x00; 637 - header->th.th_is_xid = 0x00; 638 - header->th.th_seq_num = 0x00; 639 628 header->sw.th_last_seq = ch->th_seq_num; 640 - 641 - skb_put_data(sweep_skb, header, TH_SWEEP_LENGTH); 642 - 643 - kfree(header); 644 629 645 630 netif_trans_update(dev); 646 631 skb_queue_tail(&ch->sweep_queue, sweep_skb); ··· 665 680 if ((fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) || grp->in_sweep) { 666 681 spin_lock_irqsave(&ch->collect_lock, saveflags); 667 682 refcount_inc(&skb->users); 668 - p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); 669 683 670 - if (!p_header) { 671 - spin_unlock_irqrestore(&ch->collect_lock, saveflags); 672 - goto nomem_exit; 673 - } 674 - 675 - p_header->pdu_offset = skb->len; 684 + p_header = skb_push(skb, PDU_HEADER_LENGTH); 685 + p_header->pdu_offset = skb->len - PDU_HEADER_LENGTH; 676 686 p_header->pdu_proto = 0x01; 677 - p_header->pdu_flag = 0x00; 678 687 if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { 679 - p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; 688 + p_header->pdu_flag = PDU_FIRST | PDU_CNTL; 680 689 } else { 681 - p_header->pdu_flag |= PDU_FIRST; 690 + p_header->pdu_flag = PDU_FIRST; 682 691 } 683 692 p_header->pdu_seq = 0; 684 - memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header, 685 - PDU_HEADER_LENGTH); 686 693 687 694 CTCM_PR_DEBUG("%s(%s): Put on collect_q - skb len: %04x \n" 688 695 "pdu header and data for up to 32 bytes:\n", ··· 683 706 684 707 skb_queue_tail(&ch->collect_queue, skb); 685 708 ch->collect_len += skb->len; 686 - kfree(p_header); 687 709 688 710 spin_unlock_irqrestore(&ch->collect_lock, saveflags); 689 711 goto done; ··· 712 736 } 713 737 } 714 738 715 - p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); 716 - 717 - if (!p_header) 718 - goto nomem_exit; 719 - 720 - p_header->pdu_offset = skb->len; 739 + p_header = skb_push(skb, PDU_HEADER_LENGTH); 740 + p_header->pdu_offset = skb->len - PDU_HEADER_LENGTH; 721 741 p_header->pdu_proto = 0x01; 722 - p_header->pdu_flag = 0x00; 723 742 p_header->pdu_seq = 0; 724 743 if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { 725 - p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; 744 + p_header->pdu_flag = PDU_FIRST | PDU_CNTL; 726 745 } else { 727 - p_header->pdu_flag |= PDU_FIRST; 746 + p_header->pdu_flag = PDU_FIRST; 728 747 } 729 - memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header, PDU_HEADER_LENGTH); 730 - 731 - kfree(p_header); 732 748 733 749 if (ch->collect_len > 0) { 734 750 spin_lock_irqsave(&ch->collect_lock, saveflags); ··· 736 768 737 769 ch->prof.txlen += skb->len - PDU_HEADER_LENGTH; 738 770 739 - header = kmalloc(TH_HEADER_LENGTH, gfp_type()); 740 - if (!header) 741 - goto nomem_exit; 771 + /* put the TH on the packet */ 772 + header = skb_push(skb, TH_HEADER_LENGTH); 773 + memset(header, 0, TH_HEADER_LENGTH); 742 774 743 - header->th_seg = 0x00; 744 775 header->th_ch_flag = TH_HAS_PDU; /* Normal data */ 745 - header->th_blk_flag = 0x00; 746 - header->th_is_xid = 0x00; /* Just data here */ 747 776 ch->th_seq_num++; 748 777 header->th_seq_num = ch->th_seq_num; 749 778 750 779 CTCM_PR_DBGDATA("%s(%s) ToVTAM_th_seq= %08x\n" , 751 780 __func__, dev->name, ch->th_seq_num); 752 - 753 - /* put the TH on the packet */ 754 - memcpy(skb_push(skb, TH_HEADER_LENGTH), header, TH_HEADER_LENGTH); 755 - 756 - kfree(header); 757 781 758 782 CTCM_PR_DBGDATA("%s(%s): skb len: %04x\n - pdu header and data for " 759 783 "up to 32 bytes sent to vtam:\n", ··· 903 943 CTCM_D3_DUMP((char *)skb->data, min_t(int, 32, skb->len)); 904 944 905 945 len = skb->len + TH_HEADER_LENGTH + PDU_HEADER_LENGTH; 906 - newskb = __dev_alloc_skb(len, gfp_type() | GFP_DMA); 946 + newskb = __dev_alloc_skb(len, GFP_ATOMIC | GFP_DMA); 907 947 908 948 if (!newskb) { 909 949 CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ERROR, ··· 1321 1361 1322 1362 ch->protocol = priv->protocol; 1323 1363 if (IS_MPC(priv)) { 1324 - ch->discontact_th = kzalloc(TH_HEADER_LENGTH, gfp_type()); 1364 + ch->discontact_th = kzalloc(TH_HEADER_LENGTH, GFP_KERNEL); 1325 1365 if (ch->discontact_th == NULL) 1326 1366 goto nomem_return; 1327 1367
-5
drivers/s390/net/ctcm_main.h
··· 298 298 /* test if struct ctcm_priv of struct net_device has MPC protocol setting */ 299 299 #define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv) 300 300 301 - static inline gfp_t gfp_type(void) 302 - { 303 - return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 304 - } 305 - 306 301 /* 307 302 * Definition of our link level header. 308 303 */
+6 -33
drivers/s390/net/ctcm_mpc.c
··· 655 655 goto done; 656 656 } 657 657 658 - header = kmalloc(sizeof(struct th_sweep), gfp_type()); 659 - 660 - if (!header) { 661 - dev_kfree_skb_any(sweep_skb); 662 - goto done; 663 - } 664 - 665 - header->th.th_seg = 0x00 ; 658 + header = skb_put_zero(sweep_skb, TH_SWEEP_LENGTH); 666 659 header->th.th_ch_flag = TH_SWEEP_RESP; 667 - header->th.th_blk_flag = 0x00; 668 - header->th.th_is_xid = 0x00; 669 - header->th.th_seq_num = 0x00; 670 660 header->sw.th_last_seq = ch->th_seq_num; 671 - 672 - skb_put_data(sweep_skb, header, TH_SWEEP_LENGTH); 673 - 674 - kfree(header); 675 661 676 662 netif_trans_update(dev); 677 663 skb_queue_tail(&ch->sweep_queue, sweep_skb); ··· 1163 1177 skb_pull(pskb, new_len); /* point to next PDU */ 1164 1178 } 1165 1179 } else { 1166 - mpcginfo = kmalloc(sizeof(struct mpcg_info), gfp_type()); 1180 + mpcginfo = kmalloc(sizeof(struct mpcg_info), GFP_ATOMIC); 1167 1181 if (mpcginfo == NULL) 1168 1182 goto done; 1169 1183 ··· 2048 2062 */ 2049 2063 static int mpc_send_qllc_discontact(struct net_device *dev) 2050 2064 { 2051 - __u32 new_len = 0; 2052 2065 struct sk_buff *skb; 2053 2066 struct qllc *qllcptr; 2054 2067 struct ctcm_priv *priv = dev->ml_priv; ··· 2078 2093 case MPCG_STATE_FLOWC: 2079 2094 case MPCG_STATE_READY: 2080 2095 grp->send_qllc_disc = 2; 2081 - new_len = sizeof(struct qllc); 2082 - qllcptr = kzalloc(new_len, gfp_type() | GFP_DMA); 2083 - if (qllcptr == NULL) { 2084 - CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, 2085 - "%s(%s): qllcptr allocation error", 2086 - CTCM_FUNTAIL, dev->name); 2087 - return -ENOMEM; 2088 - } 2089 2096 2090 - qllcptr->qllc_address = 0xcc; 2091 - qllcptr->qllc_commands = 0x03; 2092 - 2093 - skb = __dev_alloc_skb(new_len, GFP_ATOMIC); 2094 - 2097 + skb = __dev_alloc_skb(sizeof(struct qllc), GFP_ATOMIC); 2095 2098 if (skb == NULL) { 2096 2099 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, 2097 2100 "%s(%s): skb allocation error", 2098 2101 CTCM_FUNTAIL, dev->name); 2099 2102 priv->stats.rx_dropped++; 2100 - kfree(qllcptr); 2101 2103 return -ENOMEM; 2102 2104 } 2103 2105 2104 - skb_put_data(skb, qllcptr, new_len); 2105 - kfree(qllcptr); 2106 + qllcptr = skb_put(skb, sizeof(struct qllc)); 2107 + qllcptr->qllc_address = 0xcc; 2108 + qllcptr->qllc_commands = 0x03; 2106 2109 2107 2110 if (skb_headroom(skb) < 4) { 2108 2111 CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,