* [net-next 1/3] bna: Semaphore Lock Fix @ 2011-09-17 1:06 Rasesh Mody 2011-09-17 1:06 ` [net-next 2/3] bna: Set Ring Param Fix Rasesh Mody ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Rasesh Mody @ 2011-09-17 1:06 UTC (permalink / raw) To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje Remove a BUG_ON() as it is not required. Change the unconditional write to release a semaphore to read sem first and then write. This will eliminate the possibility of sem getting locked while trying to release it in case if previous sem_get operation failed. Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> Signed-off-by: Rasesh Mody <rmody@brocade.com> --- drivers/net/ethernet/brocade/bna/bfa_ioc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c index 029fb52..4282fef 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c @@ -1201,13 +1201,13 @@ bfa_nw_ioc_sem_get(void __iomem *sem_reg) if (!(r32 & 1)) return true; - BUG_ON(!(cnt < BFA_SEM_SPINCNT)); return false; } void bfa_nw_ioc_sem_release(void __iomem *sem_reg) { + readl(sem_reg); writel(1, sem_reg); } -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [net-next 2/3] bna: Set Ring Param Fix 2011-09-17 1:06 [net-next 1/3] bna: Semaphore Lock Fix Rasesh Mody @ 2011-09-17 1:06 ` Rasesh Mody 2011-09-17 4:48 ` David Miller 2011-09-17 1:06 ` [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path Rasesh Mody 2011-09-17 4:48 ` [net-next 1/3] bna: Semaphore Lock Fix David Miller 2 siblings, 1 reply; 6+ messages in thread From: Rasesh Mody @ 2011-09-17 1:06 UTC (permalink / raw) To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje When Rx queue size is changed, queues are torn down and setup with the new queue size. During this operation, clear promiscuous mode and restore the original VLAN filter. Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> Signed-off-by: Rasesh Mody <rmody@brocade.com> --- drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c index 4842224..ac6b495 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c @@ -471,16 +471,17 @@ bnad_set_ringparam(struct net_device *netdev, current_err = bnad_setup_rx(bnad, i); if (current_err && !err) err = current_err; - if (!err) - bnad_restore_vlans(bnad, i); } if (!err && bnad->rx_info[0].rx) { /* restore rx configuration */ + bnad_restore_vlans(bnad, 0); bnad_enable_default_bcast(bnad); spin_lock_irqsave(&bnad->bna_lock, flags); bnad_mac_addr_set_locked(bnad, netdev->dev_addr); spin_unlock_irqrestore(&bnad->bna_lock, flags); + bnad->cfg_flags &= ~(BNAD_CF_ALLMULTI | + BNAD_CF_PROMISC); bnad_set_rx_mode(netdev); } } -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [net-next 2/3] bna: Set Ring Param Fix 2011-09-17 1:06 ` [net-next 2/3] bna: Set Ring Param Fix Rasesh Mody @ 2011-09-17 4:48 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2011-09-17 4:48 UTC (permalink / raw) To: rmody; +Cc: netdev, adapter_linux_open_src_team, gkaraje From: Rasesh Mody <rmody@brocade.com> Date: Fri, 16 Sep 2011 18:06:47 -0700 > When Rx queue size is changed, queues are torn down and setup with the new queue > size. During this operation, clear promiscuous mode and restore the original > VLAN filter. > > Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> > Signed-off-by: Rasesh Mody <rmody@brocade.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path 2011-09-17 1:06 [net-next 1/3] bna: Semaphore Lock Fix Rasesh Mody 2011-09-17 1:06 ` [net-next 2/3] bna: Set Ring Param Fix Rasesh Mody @ 2011-09-17 1:06 ` Rasesh Mody 2011-09-17 4:48 ` David Miller 2011-09-17 4:48 ` [net-next 1/3] bna: Semaphore Lock Fix David Miller 2 siblings, 1 reply; 6+ messages in thread From: Rasesh Mody @ 2011-09-17 1:06 UTC (permalink / raw) To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje Change details: - In a continuous sequence of ifconfig up/down operations, there is a small window of race between bnad_set_rx_mode() and bnad_cleanup_rx() while the former tries to access rx_info->rx & the latter sets it to NULL. This race could lead to bna_rx_mode_set() being called with a NULL (rx_info->rx) pointer and a crash. - Hold bnad->bna_lock while setting / unsetting rx_info->rx in bnad_setup_rx() & bnad_cleanup_rx(), thereby eliminating the race described above. Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> Signed-off-by: Rasesh Mody <rmody@brocade.com> --- drivers/net/ethernet/brocade/bna/bnad.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 33ab1f8..abca139 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -1875,10 +1875,10 @@ bnad_cleanup_rx(struct bnad *bnad, u32 rx_id) spin_lock_irqsave(&bnad->bna_lock, flags); bna_rx_destroy(rx_info->rx); - spin_unlock_irqrestore(&bnad->bna_lock, flags); rx_info->rx = NULL; rx_info->rx_id = 0; + spin_unlock_irqrestore(&bnad->bna_lock, flags); bnad_rx_res_free(bnad, res_info); } @@ -1932,12 +1932,13 @@ bnad_setup_rx(struct bnad *bnad, u32 rx_id) spin_lock_irqsave(&bnad->bna_lock, flags); rx = bna_rx_create(&bnad->bna, bnad, rx_config, &rx_cbfn, res_info, rx_info); - spin_unlock_irqrestore(&bnad->bna_lock, flags); if (!rx) { err = -ENOMEM; + spin_unlock_irqrestore(&bnad->bna_lock, flags); goto err_return; } rx_info->rx = rx; + spin_unlock_irqrestore(&bnad->bna_lock, flags); /* * Init NAPI, so that state is set to NAPI_STATE_SCHED, -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path 2011-09-17 1:06 ` [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path Rasesh Mody @ 2011-09-17 4:48 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2011-09-17 4:48 UTC (permalink / raw) To: rmody; +Cc: netdev, adapter_linux_open_src_team, gkaraje From: Rasesh Mody <rmody@brocade.com> Date: Fri, 16 Sep 2011 18:06:48 -0700 > Change details: > - In a continuous sequence of ifconfig up/down operations, there is a small > window of race between bnad_set_rx_mode() and bnad_cleanup_rx() while the > former tries to access rx_info->rx & the latter sets it to NULL. This race > could lead to bna_rx_mode_set() being called with a NULL (rx_info->rx) > pointer and a crash. > - Hold bnad->bna_lock while setting / unsetting rx_info->rx in bnad_setup_rx() > & bnad_cleanup_rx(), thereby eliminating the race described above. > > Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> > Signed-off-by: Rasesh Mody <rmody@brocade.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next 1/3] bna: Semaphore Lock Fix 2011-09-17 1:06 [net-next 1/3] bna: Semaphore Lock Fix Rasesh Mody 2011-09-17 1:06 ` [net-next 2/3] bna: Set Ring Param Fix Rasesh Mody 2011-09-17 1:06 ` [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path Rasesh Mody @ 2011-09-17 4:48 ` David Miller 2 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2011-09-17 4:48 UTC (permalink / raw) To: rmody; +Cc: netdev, adapter_linux_open_src_team, gkaraje From: Rasesh Mody <rmody@brocade.com> Date: Fri, 16 Sep 2011 18:06:46 -0700 > Remove a BUG_ON() as it is not required. > > Change the unconditional write to release a semaphore to read sem first > and then write. This will eliminate the possibility of sem getting locked > while trying to release it in case if previous sem_get operation failed. > > Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com> > Signed-off-by: Rasesh Mody <rmody@brocade.com> Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-17 4:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-09-17 1:06 [net-next 1/3] bna: Semaphore Lock Fix Rasesh Mody 2011-09-17 1:06 ` [net-next 2/3] bna: Set Ring Param Fix Rasesh Mody 2011-09-17 4:48 ` David Miller 2011-09-17 1:06 ` [net-next 3/3] bna: Eliminate Small Race Condition Window in RX Path Rasesh Mody 2011-09-17 4:48 ` David Miller 2011-09-17 4:48 ` [net-next 1/3] bna: Semaphore Lock Fix David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).