fm10k: Avoid crashing the kernel
Subsystems (2)
PATCH 1/6 fm10k: Avoid crashing the kernel
From: Bruce Allan <[email protected]>
Use BUILD_BUG_ON() instead of BUG_ON() where appropriate to get a compile error rather than crash the kernel.
---
This is a direct copy of a patch from our out-of-tree driver written by Bruce, hence the authorship and signed-off-by line.
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +2 -2
@@ -468,7 +468,7 @@ static void fm10k_get_reg_q(struct fm10k_hw *hw, u32 *buff, int i) buff[idx++] =fm10k_read_reg (hw,FM10K_TX_SGLORT (i)); buff[idx++] =fm10k_read_reg (hw,FM10K_PFVTCTL (i)); -BUG_ON (idx !=FM10K_REGS_LEN_Q ); +BUILD_BUG_ON (idx !=FM10K_REGS_LEN_Q ); }/* If function above adds more registers this define needs to be updated */
@@ -484,7 +484,7 @@ static void fm10k_get_reg_vsi(struct fm10k_hw *hw, u32 *buff, int i)for (j =0 ; j <32 ; j++) buff[idx++] =fm10k_read_reg (hw,FM10K_RETA (i, j)); -BUG_ON (idx !=FM10K_REGS_LEN_VSI ); +BUILD_BUG_ON (idx !=FM10K_REGS_LEN_VSI ); } static void fm10k_get_regs(struct net_device *netdev,
Signature · 1 line
2.7.0.236.gda096a0.dirty
PATCH 2/6 fm10k: prevent possibly uninitialized variable
From: Bruce Allan <[email protected]>
If 'attr_flag < (1 << (2 * FM10K_TEST_MSG_NESTED))' is ever false, err will be used uninitialized.
---
This is a direct copy of a patch authored by Bruce from our out of tree driver, hence the authorship and signed-off-by.
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +1 -1
@@ -1005,7 +1005,7 @@ static int fm10k_mbx_test(struct fm10k_intfc *interface, u64 *data)struct fm10k_mbx_info *mbx = &hw->mbx;u32 attr_flag, test_msg[6 ];unsigned long timeout; -int err; +int err = -EINVAL ;/* For now this is a VF only feature */ if (hw->mac.type != fm10k_mac_vf)
Signature · 1 line
2.7.0.236.gda096a0.dirty
Singh
PATCH 2/6 fm10k: prevent possibly uninitialized variable
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 2/6] fm10k: prevent possibly uninitialized variable
From: Bruce Allan <[email protected]>
If 'attr_flag < (1 << (2 * FM10K_TEST_MSG_NESTED))' is ever false, err will be used uninitialized.
---
PATCH 3/6 fm10k: use ethtool_rxfh_indir_default for default redirection table
In reply to Jacob KellerThe fm10k driver used its own code for generating a default indirection table on device load, which was not the same as the default generated by ethtool when indir_size of 0 is passed to SRXFH. Take advantage of ethtool_rxfh_indir_default() and simplify code to write the redirection table to reduce some code duplication.
--- drivers/net/ethernet/intel/fm10k/fm10k.h | 2 ++ drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 37 ++++++++++++++---------- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 24 +++++++-------- 3 files changed, 34 insertions(+), 29 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k.h +2 -0
@@ -510,6 +510,8 @@ int fm10k_close(struct net_device *netdev);/* Ethtool */ void fm10k_set_ethtool_ops (struct net_device *dev); +u32 fm10k_get_reta_size (struct net_device *netdev); +void fm10k_write_reta (struct fm10k_intfc *interface,const u32 *indir);/* IOV */ s32 fm10k_iov_event (struct fm10k_intfc *interface);
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +22 -15
@@ -1095,11 +1095,31 @@ static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)return 0 ; } -static u32 fm10k_get_reta_size (struct net_device __always_unused *netdev) +u32 fm10k_get_reta_size (struct net_device __always_unused *netdev) {return FM10K_RETA_SIZE *FM10K_RETA_ENTRIES_PER_REG ; } +void fm10k_write_reta (struct fm10k_intfc *interface,const u32 *indir) +{ +struct fm10k_hw *hw = &interface->hw; +int i; + +/* record entries to reta table */ +for (i =0 ; i <FM10K_RETA_SIZE ; i++, indir +=4 ) { +u32 reta = indir[0 ] | + (indir[1 ] <<8 ) | + (indir[2 ] <<16 ) | + (indir[3 ] <<24 ); + +if (interface->reta[i] == reta) +continue ; + + interface->reta[i] = reta; +FM10K_WRITE_REG (hw,FM10K_RETA (0 , i), reta); + } +} +static int fm10k_get_reta (struct net_device *netdev,u32 *indir) {struct fm10k_intfc *interface =netdev_priv (netdev);
@@ -1123,7 +1143,6 @@ static int fm10k_get_reta(struct net_device *netdev, u32 *indir)static int fm10k_set_reta (struct net_device *netdev,const u32 *indir) {struct fm10k_intfc *interface =netdev_priv (netdev); -struct fm10k_hw *hw = &interface->hw;int i;u16 rss_i;
@@ -1138,19 +1157,7 @@ static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)return -EINVAL ; } -/* record entries to reta table */ -for (i =0 ; i <FM10K_RETA_SIZE ; i++, indir +=4 ) { -u32 reta = indir[0 ] | - (indir[1 ] <<8 ) | - (indir[2 ] <<16 ) | - (indir[3 ] <<24 ); - -if (interface->reta[i] == reta) -continue ; - - interface->reta[i] = reta; -fm10k_write_reg (hw,FM10K_RETA (0 , i), reta); - } +fm10k_write_reta (interface, indir);return 0 ; }
drivers/net/ethernet/intel/fm10k/fm10k_main.c +10 -14
@@ -1933,7 +1933,8 @@ static void fm10k_assign_rings(struct fm10k_intfc *interface)static void fm10k_init_reta (struct fm10k_intfc *interface) {u16 i, rss_i = interface->ring_feature[RING_F_RSS ].indices; -u32 reta, base; +struct net_device *netdev = interface->netdev; +u32 reta, *indir;/* If the netdev is initialized we have to maintain table if possible */ if (interface->netdev->reg_state !=NETREG_UNINITIALIZED ) {
@@ -1952,21 +1953,16 @@ static void fm10k_init_reta(struct fm10k_intfc *interface) } repopulate_reta: -/* Populate the redirection table 4 entries at a time. To do this -* we are generating the results for n and n+2 and then interleaving -* those with the results with n+1 and n+3. -*/ -for (i =FM10K_RETA_SIZE ; i--;) { -/* first pass generates n and n+2 */ - base = ((i *0x00040004 ) +0x00020000 ) * rss_i; - reta = (base &0x3F803F80 ) >>7 ; + indir =kcalloc (fm10k_get_reta_size (netdev), +sizeof (indir[0 ]),GFP_KERNEL ); -/* second pass generates n+1 and n+3 */ - base +=0x00010001 * rss_i; - reta |= (base &0x3F803F80 ) <<1 ; +/* generate redirection table using the default kernel policy */ +for (i =0 ; i <fm10k_get_reta_size (netdev); i++) + indir[i] =ethtool_rxfh_indir_default (i, rss_i); - interface->reta[i] = reta; - } +fm10k_write_reta (interface, indir); + +kfree (indir); }/**
Signature · 1 line
2.7.0.236.gda096a0.dirty
PATCH 3/6 fm10k: use ethtool_rxfh_indir_default for default redirection table
Quoted 9 lines · Jacob Keller
The fm10k driver used its own code for generating a default indirection
table on device load, which was not the same as the default generated by
ethtool whenindir_sizeof 0 is passed to SRXFH. Take advantage ofethtool_rxfh_indir_default()and simplify code to write the redirection
table to reduce some code duplication.
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>---
?drivers/net/ethernet/intel/fm10k/fm10k.h???????? |? 2 ++ ?drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 37
++++++++++++++----------
?drivers/net/ethernet/intel/fm10k/fm10k_main.c??? | 24 +++++++------- -
?3 files changed, 34 insertions(+), 29 deletions(-)
Another patch which causes compile errors, dropping patch. ?All patches must pass the following:
make allmodconfig
make
before they can be submitted for kernel inclusion.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160215/91c0584a/attachment.asc>
Singh
PATCH 3/6 fm10k: use ethtool_rxfh_indir_default for default redirection table
In reply to Jacob Keller-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 3/6] fm10k: use ethtool_rxfh_indir_default for default redirection table
The fm10k driver used its own code for generating a default indirection table on device load, which was not the same as the default generated by ethtool when indir_size of 0 is passed to SRXFH. Take advantage of ethtool_rxfh_indir_default() and simplify code to write the redirection table to reduce some code duplication.
---
PATCH 4/6 fm10k: update driver summary and reduce code duplication
In reply to Jacob KellerUse DRV_SUMMARY, similar to DRV_VERSION so that we don't have to duplicate the driver summary. Also update summary to more accurately describe the driver.
--- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_main.c +3 -3
@@ -29,15 +29,15 @@#include "fm10k.h" #define DRV_VERSION "0.19.3-k" +#define DRV_SUMMARY "Intel(R) Ethernet Multi-host Controller Driver"const char fm10k_driver_version[] =DRV_VERSION ;char fm10k_driver_name[] ="fm10k" ; -static const char fm10k_driver_string[] = -"Intel(R) Ethernet Switch Host Interface Driver" ; +static const char fm10k_driver_string[] =DRV_SUMMARY ;static const char fm10k_copyright[] ="Copyright (c) 2013 Intel Corporation." ;MODULE_AUTHOR ("Intel Corporation, <[email protected]>" ); -MODULE_DESCRIPTION ("Intel(R) Ethernet Switch Host Interface Driver" ); +MODULE_DESCRIPTION (DRV_SUMMARY );MODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_VERSION );
Signature · 1 line
2.7.0.236.gda096a0.dirty
Singh
PATCH 4/6 fm10k: update driver summary and reduce code duplication
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplication
Use DRV_SUMMARY, similar to DRV_VERSION so that we don't have to duplicate the driver summary. Also update summary to more accurately describe the driver.
---
Allan
PATCH 4/6 fm10k: update driver summary and reduce code duplication
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Singh, Krishneil K
Sent: Thursday, February 25, 2016 12:30 PM
To: Keller, Jacob E; Intel Wired LAN
Subject: Re: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplication-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplication
Quoted 7 lines
Use
DRV_SUMMARY, similar toDRV_VERSIONso that we don't have to duplicate the driver summary. Also update summary to more accurately describe the driver.Signed-off-by Jacob Keller <[email protected]>---
Tested-by Krishneil Singh <[email protected]>
Please hold off on submitting this patch to netdev...the driver summary might not be correct based on recent events.
Allan
PATCH 4/6 fm10k: update driver summary and reduce code duplication
Quoted 32 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Allan, Bruce W
Sent: Thursday, February 25, 2016 1:46 PM
To: Singh, Krishneil K <[email protected]>; Keller, Jacob E <[email protected]>; Intel Wired LAN <intel-wired-
lan at lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplicationQuoted 2 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org]On
Quoted 8 lines
Behalf Of Singh, Krishneil K
Sent: Thursday, February 25, 2016 12:30 PM
To: Keller, Jacob E; Intel Wired LAN
Subject: Re: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplication-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org]On
Quoted 10 lines
Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and reduce code duplicationUse
DRV_SUMMARY, similar toDRV_VERSIONso that we don't have to duplicate the driver summary. Also update summary to more accurately describe the driver.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Jacob Keller <[email protected]>---
Tested-by Krishneil Singh <[email protected]>Please hold off on submitting this patch to netdev...the driver summary might not be
correct based on recent events.
The driver summary/module description should not be changed to what is in this patch. Expect a v2 from Jake.
Bruce.
Keller
PATCH 4/6 fm10k: update driver summary and reduce code duplication
Quoted 51 lines · Bruce W
Quoted 44 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl. org] On
Behalf Of Allan, Bruce W
Sent: Thursday, February 25, 2016 1:46 PM
To: Singh, Krishneil K <[email protected]>; Keller, Jacob E
<[email protected]>; Intel Wired LAN <intel-wired- lan at lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary
and reduce code duplicationQuoted 4 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuos l.org]On
Quoted 11 lines
Behalf Of Singh, Krishneil K
Sent: Thursday, February 25, 2016 12:30 PM
To: Keller, Jacob E; Intel Wired LAN
Subject: Re: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary
and reduce code duplication-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuos l.org]On
Quoted 13 lines
Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 4/6] fm10k: update driver summary and
reduce code duplicationUse
DRV_SUMMARY, similar toDRV_VERSIONso that we don't have to duplicate the driver summary. Also update summary to more accurately
describe the driver.Quoted 7 lines
Quoted 3 lines
Signed-off-by Jacob Keller <[email protected]>---
Tested-by Krishneil Singh <[email protected]>Please hold off on submitting this patch to netdev...the driver summary
might not be
correct based on recent events.
Quoted 5 lines
The driver summary/module description should not be changed to what is in this
patch.??Expect a v2 from Jake.Bruce.
Isn't there a replacement in the queue already? I'll rework this if so, but I was pretty sure I already did.
Thanks,
Jake
PATCH 5/6 fm10k: correctly clean up when init_queueing_scheme fails
In reply to Jacob KellerFix a kernel panic that occurs during surprise removal. Clear the interface queue counts upon fm10k_init_msix_capability failure. This prevents further code (fm10k_update_stats etc.) from attempting to access unallocated queue vector or ring memory.
[ 628.692648] BUG: unable to handle kernel NULL pointer dereference at 0000000000000068 [ 628.692805] IP: [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.693173] PGD 0 [ 628.693759] Oops: 0000 [#1] SMP [ 628.699321] CPU: 10 PID: 8164 Comm: kworker/10:0 Tainted: G OE ------------ 3.10.0-327.el7.x86_64 #1 [ 628.700096] Hardware name: Supermicro X9DAi/X9DAi, BIOS 3.2 05/09/2015 [ 628.700894] Workqueue: pciehp-1 pciehp_power_thread [ 628.701686] task: ffff88086559c500 ti: ffff8808593c0000 task.ti: ffff8808593c0000 [ 628.702493] RIP: 0010:[<ffffffffa0475caf>] [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.703310] RSP: 0018:ffff8808593c3b00 EFLAGS: 00010282 [ 628.704132] RAX: 0000000000000000 RBX: ffff880860760000 RCX: 0000000000000000 [ 628.704963] RDX: ffff880860760b08 RSI: 0000000000000000 RDI: 0000000000000000 [ 628.705794] RBP: ffff8808593c3b40 R08: 0000000000000000 R09: 0000000000000000 [ 628.706604] R10: 0000000000000000 R11: ffff880860760c40 R12: 0000000000000080 [ 628.707420] R13: ffff8808607608c0 R14: ffff880860779ec0 R15: ffff880860779f40 [ 628.708238] FS: 0000000000000000(0000) GS:ffff88086f000000(0000) knlGS:0000000000000000 [ 628.709071] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 628.709923] CR2: 0000000000000068 CR3: 000000000194a000 CR4: 00000000001407e0 [ 628.710752] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 628.711596] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 628.712438] Stack: [ 628.713255] ffff880860764458 ffff8808607608c0 ffff880860760000 ffff880860760000 [ 628.714088] 0000000000000080 ffff8808607608c0 ffff880860779ec0 ffff880860779f40 [ 628.714925] ffff8808593c3b88 ffffffffa04780c5 ffff880860764458 0000000a8163cb5b [ 628.715752] Call Trace: [ 628.716560] [<ffffffffa04780c5>] fm10k_down+0x155/0x1f0 [fm10k] [ 628.717367] [<ffffffffa0479958>] fm10k_close+0x28/0xd0 [fm10k] [ 628.718184] [<ffffffff81526365>] __dev_close_many+0x85/0xd0 [ 628.718986] [<ffffffff815264d8>] dev_close_many+0x98/0x120 [ 628.719764] [<ffffffff81527ab8>] rollback_registered_many+0xa8/0x230 [ 628.720527] [<ffffffff81527c80>] rollback_registered+0x40/0x70 [ 628.721294] [<ffffffff81529198>] unregister_netdevice_queue+0x48/0x80 [ 628.722052] [<ffffffff815291ec>] unregister_netdev+0x1c/0x30 [ 628.722816] [<ffffffffa04762b8>] fm10k_remove+0xd8/0xe0 [fm10k] [ 628.723581] [<ffffffff81328c7b>] pci_device_remove+0x3b/0xb0 [ 628.724340] [<ffffffff813f5fbf>] __device_release_driver+0x7f/0xf0 [ 628.725088] [<ffffffff813f6053>] device_release_driver+0x23/0x30 [ 628.725814] [<ffffffff81321fe4>] pci_stop_bus_device+0x94/0xa0 [ 628.726535] [<ffffffff813220d2>] pci_stop_and_remove_bus_device+0x12/0x20 [ 628.727249] [<ffffffff8133de40>] pciehp_unconfigure_device+0xb0/0x1b0 [ 628.727964] [<ffffffff8133d822>] pciehp_disable_slot+0x52/0xd0 [ 628.728664] [<ffffffff8133d98a>] pciehp_power_thread+0xea/0x150 [ 628.729358] [<ffffffff8109d5fb>] process_one_work+0x17b/0x470 [ 628.730036] [<ffffffff8109e3cb>] worker_thread+0x11b/0x400 [ 628.730730] [<ffffffff8109e2b0>] ? rescuer_thread+0x400/0x400 [ 628.731385] [<ffffffff810a5aef>] kthread+0xcf/0xe0 [ 628.732036] [<ffffffff810a5a20>] ? kthread_create_on_node+0x140/0x140 [ 628.732674] [<ffffffff81645858>] ret_from_fork+0x58/0x90 [ 628.733289] [<ffffffff810a5a20>] ? kthread_create_on_node+0x140/0x140 [ 628.733883] Code: 83 e8 01 48 8d 97 40 02 00 00 45 31 c0 4c 8d 9c c7 48 02 0 [ 628.735202] RIP [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.735732] RSP <ffff8808593c3b00> [ 628.736285] CR2: 0000000000000068 [ 628.736846] ---[ end trace 9156088b311aff42 ]---
--- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 35 ++++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_main.c +26 -9
@@ -1581,6 +1581,20 @@ static void fm10k_set_num_queues(struct fm10k_intfc *interface) }/** +* fm10k_reset_num_queues - Reset the number of queues to zero +* @interface: board private structure +* +* This function should be called whenever we need to reset the number of +* queues after an error condition. +*/ +static void fm10k_reset_num_queues (struct fm10k_intfc *interface) +{ + interface->num_tx_queues =0 ; + interface->num_rx_queues =0 ; + interface->num_q_vectors =0 ; +} + +/** * fm10k_alloc_q_vector - Allocate memory for a single interrupt vector * @interface: board private structure to initialize * @v_count: q_vectors allocated on interface, used for ring interleaving
@@ -1763,9 +1777,7 @@ static int fm10k_alloc_q_vectors(struct fm10k_intfc *interface)return 0 ; err_out: - interface->num_tx_queues =0 ; - interface->num_rx_queues =0 ; - interface->num_q_vectors =0 ; +fm10k_reset_num_queues (interface);while (v_idx--)fm10k_free_q_vector (interface, v_idx);
@@ -1785,9 +1797,7 @@ static void fm10k_free_q_vectors(struct fm10k_intfc *interface) {int v_idx = interface->num_q_vectors; - interface->num_tx_queues =0 ; - interface->num_rx_queues =0 ; - interface->num_q_vectors =0 ; +fm10k_reset_num_queues (interface);while (v_idx--)fm10k_free_q_vector (interface, v_idx);
@@ -1985,14 +1995,15 @@ int fm10k_init_queueing_scheme(struct fm10k_intfc *interface)if (err) {dev_err (&interface->pdev->dev,"Unable to initialize MSI-X capability\n" ); -return err; + goto err_init_msix; }/* Allocate memory for queues */ err =fm10k_alloc_q_vectors (interface);if (err) { -fm10k_reset_msix_capability (interface); -return err; +dev_err (&interface->pdev->dev, +"Unable to allocate queue vectors\n" ); + goto err_alloc_q_vectors; }/* Map rings to devices, and map devices to physical queues */
@@ -2002,6 +2013,12 @@ int fm10k_init_queueing_scheme(struct fm10k_intfc *interface)fm10k_init_reta (interface);return 0 ; + +err_alloc_q_vectors: +fm10k_reset_msix_capability (interface); +err_init_msix: +fm10k_reset_num_queues (interface); +return err; }/**
Signature · 1 line
2.7.0.236.gda096a0.dirty
Singh
PATCH 5/6 fm10k: correctly clean up when init_queueing_scheme fails
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 5/6] fm10k: correctly clean up when init_queueing_scheme fails
Fix a kernel panic that occurs during surprise removal. Clear the interface queue counts upon fm10k_init_msix_capability failure. This prevents further code (fm10k_update_stats etc.) from attempting to access unallocated queue vector or ring memory.
[ 628.692648] BUG: unable to handle kernel NULL pointer dereference at 0000000000000068 [ 628.692805] IP: [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.693173] PGD 0 [ 628.693759] Oops: 0000 [#1] SMP [ 628.699321] CPU: 10 PID: 8164 Comm: kworker/10:0 Tainted: G OE ------------ 3.10.0-327.el7.x86_64 #1 [ 628.700096] Hardware name: Supermicro X9DAi/X9DAi, BIOS 3.2 05/09/2015 [ 628.700894] Workqueue: pciehp-1 pciehp_power_thread [ 628.701686] task: ffff88086559c500 ti: ffff8808593c0000 task.ti: ffff8808593c0000 [ 628.702493] RIP: 0010:[<ffffffffa0475caf>] [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.703310] RSP: 0018:ffff8808593c3b00 EFLAGS: 00010282 [ 628.704132] RAX: 0000000000000000 RBX: ffff880860760000 RCX: 0000000000000000 [ 628.704963] RDX: ffff880860760b08 RSI: 0000000000000000 RDI: 0000000000000000 [ 628.705794] RBP: ffff8808593c3b40 R08: 0000000000000000 R09: 0000000000000000 [ 628.706604] R10: 0000000000000000 R11: ffff880860760c40 R12: 0000000000000080 [ 628.707420] R13: ffff8808607608c0 R14: ffff880860779ec0 R15: ffff880860779f40 [ 628.708238] FS: 0000000000000000(0000) GS:ffff88086f000000(0000) knlGS:0000000000000000 [ 628.709071] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 628.709923] CR2: 0000000000000068 CR3: 000000000194a000 CR4: 00000000001407e0 [ 628.710752] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 628.711596] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 628.712438] Stack: [ 628.713255] ffff880860764458 ffff8808607608c0 ffff880860760000 ffff880860760000 [ 628.714088] 0000000000000080 ffff8808607608c0 ffff880860779ec0 ffff880860779f40 [ 628.714925] ffff8808593c3b88 ffffffffa04780c5 ffff880860764458 0000000a8163cb5b [ 628.715752] Call Trace: [ 628.716560] [<ffffffffa04780c5>] fm10k_down+0x155/0x1f0 [fm10k] [ 628.717367] [<ffffffffa0479958>] fm10k_close+0x28/0xd0 [fm10k] [ 628.718184] [<ffffffff81526365>] __dev_close_many+0x85/0xd0 [ 628.718986] [<ffffffff815264d8>] dev_close_many+0x98/0x120 [ 628.719764] [<ffffffff81527ab8>] rollback_registered_many+0xa8/0x230 [ 628.720527] [<ffffffff81527c80>] rollback_registered+0x40/0x70 [ 628.721294] [<ffffffff81529198>] unregister_netdevice_queue+0x48/0x80 [ 628.722052] [<ffffffff815291ec>] unregister_netdev+0x1c/0x30 [ 628.722816] [<ffffffffa04762b8>] fm10k_remove+0xd8/0xe0 [fm10k] [ 628.723581] [<ffffffff81328c7b>] pci_device_remove+0x3b/0xb0 [ 628.724340] [<ffffffff813f5fbf>] __device_release_driver+0x7f/0xf0 [ 628.725088] [<ffffffff813f6053>] device_release_driver+0x23/0x30 [ 628.725814] [<ffffffff81321fe4>] pci_stop_bus_device+0x94/0xa0 [ 628.726535] [<ffffffff813220d2>] pci_stop_and_remove_bus_device+0x12/0x20 [ 628.727249] [<ffffffff8133de40>] pciehp_unconfigure_device+0xb0/0x1b0 [ 628.727964] [<ffffffff8133d822>] pciehp_disable_slot+0x52/0xd0 [ 628.728664] [<ffffffff8133d98a>] pciehp_power_thread+0xea/0x150 [ 628.729358] [<ffffffff8109d5fb>] process_one_work+0x17b/0x470 [ 628.730036] [<ffffffff8109e3cb>] worker_thread+0x11b/0x400 [ 628.730730] [<ffffffff8109e2b0>] ? rescuer_thread+0x400/0x400 [ 628.731385] [<ffffffff810a5aef>] kthread+0xcf/0xe0 [ 628.732036] [<ffffffff810a5a20>] ? kthread_create_on_node+0x140/0x140 [ 628.732674] [<ffffffff81645858>] ret_from_fork+0x58/0x90 [ 628.733289] [<ffffffff810a5a20>] ? kthread_create_on_node+0x140/0x140 [ 628.733883] Code: 83 e8 01 48 8d 97 40 02 00 00 45 31 c0 4c 8d 9c c7 48 02 0 [ 628.735202] RIP [<ffffffffa0475caf>] fm10k_update_stats+0x7f/0x2c0 [fm10k] [ 628.735732] RSP <ffff8808593c3b00> [ 628.736285] CR2: 0000000000000068 [ 628.736846] ---[ end trace 9156088b311aff42 ]---
---
PATCH 6/6 fm10k: fix a minor typo in some comments
In reply to Jacob Kellers/funciton/function to resolve a typo, and cleanup grammar on a few comments regarding processing the VF mailboxes.
--- drivers/net/ethernet/intel/fm10k/fm10k_iov.c | 4 ++-- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 4 ++-- drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 6 +++--- drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_iov.c +2 -2
@@ -50,7 +50,7 @@ s32 fm10k_iov_event(struct fm10k_intfc *interface)s64 vflre;int i; -/* if there is no iov_data then there is no mailboxes to process */ +/* if there is no iov_data then there is no mailbox to process */ if (!ACCESS_ONCE (interface->iov_data))return 0 ;
@@ -98,7 +98,7 @@ s32 fm10k_iov_mbx(struct fm10k_intfc *interface)struct fm10k_iov_data *iov_data;int i; -/* if there is no iov_data then there is no mailboxes to process */ +/* if there is no iov_data then there is no mailbox to process */ if (!ACCESS_ONCE (interface->iov_data))return 0 ;
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +2 -2
@@ -440,7 +440,7 @@ static void fm10k_restore_vxlan_port(struct fm10k_intfc *interface)* @sa_family: Address family of new port * @port: port number used for VXLAN * -* This funciton is called when a new VXLAN interface has added a new port +* This function is called when a new VXLAN interface has added a new port * number to the range that is currently in use for VXLAN. The new port * number is always added to the tail so that the port number list should * match the order in which the ports were allocated. The head of the list
@@ -484,7 +484,7 @@ static void fm10k_add_vxlan_port(struct net_device *dev,* @sa_family: Address family of freed port * @port: port number used for VXLAN * -* This funciton is called when a new VXLAN interface has freed a port +* This function is called when a new VXLAN interface has freed a port * number from the range that is currently in use for VXLAN. The freed * port is removed from the list and the new head is used to determine * the port number for offloads.
drivers/net/ethernet/intel/fm10k/fm10k_pci.c +3 -3
@@ -1379,7 +1379,7 @@ static s32 fm10k_1588_msg_pf(struct fm10k_hw *hw, u32 **results,return 0 ; } -/* if there is no iov_data then there is no mailboxes to process */ +/* if there is no iov_data then there is no mailbox to process */ if (!ACCESS_ONCE (interface->iov_data))return FM10K_ERR_PARAM ;
@@ -2398,7 +2398,7 @@ static struct pci_driver fm10k_driver = {/** * fm10k_register_pci_driver - register driver interface * -* This funciton is called on module load in order to register the driver. +* This function is called on module load in order to register the driver. **/ int fm10k_register_pci_driver (void ) {
@@ -2408,7 +2408,7 @@ int fm10k_register_pci_driver(void)/** * fm10k_unregister_pci_driver - unregister driver interface * -* This funciton is called on module unload in order to remove the driver. +* This function is called on module unload in order to remove the driver. **/ void fm10k_unregister_pci_driver (void ) {
drivers/net/ethernet/intel/fm10k/fm10k_pf.c +1 -1
@@ -1604,7 +1604,7 @@ static s32 fm10k_request_lport_map_pf(struct fm10k_hw *hw)* @hw: pointer to hardware structure * @switch_ready: pointer to boolean value that will record switch state * -* This funciton will check the DMA_CTRL2 register and mailbox in order +* This function will check the DMA_CTRL2 register and mailbox in order * to determine if the switch is ready for the PF to begin requesting * addresses and mapping traffic to the local interface. **/
Signature · 1 line
2.7.0.236.gda096a0.dirty
Singh
PATCH 6/6 fm10k: fix a minor typo in some comments
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 6/6] fm10k: fix a minor typo in some comments
s/funciton/function to resolve a typo, and cleanup grammar on a few comments regarding processing the VF mailboxes.
---
PATCH 1/6 fm10k: Avoid crashing the kernel
In reply to Jacob KellerQuoted 6 lines · Jacob Keller
From: Bruce Allan <[email protected]>
Use
BUILD_BUG_ON()instead ofBUG_ON()where appropriate to get a compile
error rather than crash the kernel.
Quoted 7 lines
Signed-off-by Bruce Allan <[email protected]>---
This is a direct copy of a patch from our out-of-tree driver written by Bruce, hence the authorship and signed-off-by line.?drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 4 ++-- ?1 file changed, 2 insertions(+), 2 deletions(-)
Guess you did not bother to compile test this, because it still causes
the same compile errors it did the first time Bruce submitted it.
?Dropping this patch, like I did the first time it was submitted.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160215/755d8d67/attachment.asc>
Keller
PATCH 1/6 fm10k: Avoid crashing the kernel
Quoted 4 lines · Jeff Kirsher
Guess you did not bother to compile test this, because it still causes
the same compile errors it did the first time Bruce submitted it. ?Dropping this patch, like I did the first time it was submitted.
Woops sorry, I thought I ran it through a test. :(
I'll submit a v2 shortly.
Regards,
Jake
Singh
PATCH 1/6 fm10k: Avoid crashing the kernel
In reply to Jacob Keller-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Wednesday, February 10, 2016 2:46 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH 1/6] fm10k: Avoid crashing the kernel
From: Bruce Allan <[email protected]>
Use BUILD_BUG_ON() instead of BUG_ON() where appropriate to get a compile error rather than crash the kernel.
---