aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2014-06-23 10:41:02 -0400
committerChristoph Hellwig <hch@lst.de>2014-06-25 07:29:31 -0400
commitd576a5e80cd07ea7049f8fd7b303c14df7b5d7d2 (patch)
treef618441fc6f6c961b327e2aa072d9bc2efa6e5e7
parent9172b763a776bae644d140748a0352fc67277a4c (diff)
bnx2fc: Improve stats update mechanism
Recently had this warning reported: [ 290.489047] Call Trace: [ 290.489053] [<ffffffff8169efec>] dump_stack+0x19/0x1b [ 290.489055] [<ffffffff810ac7a9>] __might_sleep+0x179/0x230 [ 290.489057] [<ffffffff816a4ad5>] mutex_lock_nested+0x55/0x520 [ 290.489061] [<ffffffffa01b9905>] ? bnx2fc_l2_rcv_thread+0xc5/0x4c0 [bnx2fc] [ 290.489065] [<ffffffffa0174c1a>] fc_vport_id_lookup+0x3a/0xa0 [libfc] [ 290.489068] [<ffffffffa01b9a6c>] bnx2fc_l2_rcv_thread+0x22c/0x4c0 [bnx2fc] [ 290.489070] [<ffffffffa01b9840>] ? bnx2fc_vport_destroy+0x110/0x110 [bnx2fc] [ 290.489073] [<ffffffff8109e0cd>] kthread+0xed/0x100 [ 290.489075] [<ffffffff8109dfe0>] ? insert_kthread_work+0x80/0x80 [ 290.489077] [<ffffffff816b2fec>] ret_from_fork+0x7c/0xb0 [ 290.489078] [<ffffffff8109dfe0>] ? insert_kthread_work+0x80/0x80 Its due to the fact that we call a potentially sleeping function from the bnx2fc rcv path with preemption disabled (via the get_cpu call embedded in the per-cpu variable stats lookup in bnx2fc_l2_rcv_thread. Easy enough fix, we can just move the stats collection later in the function where we are sure we won't preempt or sleep. This also allows us to not have to enable pre-emption when doing a per-cpu lookup, since we're certain not to get rescheduled. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Eddie Wai <eddie.wai@broadcom.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index f54843023466..785d0d71781e 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -516,23 +516,17 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
516 skb_pull(skb, sizeof(struct fcoe_hdr)); 516 skb_pull(skb, sizeof(struct fcoe_hdr));
517 fr_len = skb->len - sizeof(struct fcoe_crc_eof); 517 fr_len = skb->len - sizeof(struct fcoe_crc_eof);
518 518
519 stats = per_cpu_ptr(lport->stats, get_cpu());
520 stats->RxFrames++;
521 stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
522
523 fp = (struct fc_frame *)skb; 519 fp = (struct fc_frame *)skb;
524 fc_frame_init(fp); 520 fc_frame_init(fp);
525 fr_dev(fp) = lport; 521 fr_dev(fp) = lport;
526 fr_sof(fp) = hp->fcoe_sof; 522 fr_sof(fp) = hp->fcoe_sof;
527 if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) { 523 if (skb_copy_bits(skb, fr_len, &crc_eof, sizeof(crc_eof))) {
528 put_cpu();
529 kfree_skb(skb); 524 kfree_skb(skb);
530 return; 525 return;
531 } 526 }
532 fr_eof(fp) = crc_eof.fcoe_eof; 527 fr_eof(fp) = crc_eof.fcoe_eof;
533 fr_crc(fp) = crc_eof.fcoe_crc32; 528 fr_crc(fp) = crc_eof.fcoe_crc32;
534 if (pskb_trim(skb, fr_len)) { 529 if (pskb_trim(skb, fr_len)) {
535 put_cpu();
536 kfree_skb(skb); 530 kfree_skb(skb);
537 return; 531 return;
538 } 532 }
@@ -544,7 +538,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
544 port = lport_priv(vn_port); 538 port = lport_priv(vn_port);
545 if (!ether_addr_equal(port->data_src_addr, dest_mac)) { 539 if (!ether_addr_equal(port->data_src_addr, dest_mac)) {
546 BNX2FC_HBA_DBG(lport, "fpma mismatch\n"); 540 BNX2FC_HBA_DBG(lport, "fpma mismatch\n");
547 put_cpu();
548 kfree_skb(skb); 541 kfree_skb(skb);
549 return; 542 return;
550 } 543 }
@@ -552,7 +545,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
552 if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && 545 if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA &&
553 fh->fh_type == FC_TYPE_FCP) { 546 fh->fh_type == FC_TYPE_FCP) {
554 /* Drop FCP data. We dont this in L2 path */ 547 /* Drop FCP data. We dont this in L2 path */
555 put_cpu();
556 kfree_skb(skb); 548 kfree_skb(skb);
557 return; 549 return;
558 } 550 }
@@ -562,7 +554,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
562 case ELS_LOGO: 554 case ELS_LOGO:
563 if (ntoh24(fh->fh_s_id) == FC_FID_FLOGI) { 555 if (ntoh24(fh->fh_s_id) == FC_FID_FLOGI) {
564 /* drop non-FIP LOGO */ 556 /* drop non-FIP LOGO */
565 put_cpu();
566 kfree_skb(skb); 557 kfree_skb(skb);
567 return; 558 return;
568 } 559 }
@@ -572,22 +563,23 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
572 563
573 if (fh->fh_r_ctl == FC_RCTL_BA_ABTS) { 564 if (fh->fh_r_ctl == FC_RCTL_BA_ABTS) {
574 /* Drop incoming ABTS */ 565 /* Drop incoming ABTS */
575 put_cpu();
576 kfree_skb(skb); 566 kfree_skb(skb);
577 return; 567 return;
578 } 568 }
579 569
570 stats = per_cpu_ptr(lport->stats, smp_processor_id());
571 stats->RxFrames++;
572 stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
573
580 if (le32_to_cpu(fr_crc(fp)) != 574 if (le32_to_cpu(fr_crc(fp)) !=
581 ~crc32(~0, skb->data, fr_len)) { 575 ~crc32(~0, skb->data, fr_len)) {
582 if (stats->InvalidCRCCount < 5) 576 if (stats->InvalidCRCCount < 5)
583 printk(KERN_WARNING PFX "dropping frame with " 577 printk(KERN_WARNING PFX "dropping frame with "
584 "CRC error\n"); 578 "CRC error\n");
585 stats->InvalidCRCCount++; 579 stats->InvalidCRCCount++;
586 put_cpu();
587 kfree_skb(skb); 580 kfree_skb(skb);
588 return; 581 return;
589 } 582 }
590 put_cpu();
591 fc_exch_recv(lport, fp); 583 fc_exch_recv(lport, fp);
592} 584}
593 585