Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256284
b: refs/heads/master
c: a7d529a
h: refs/heads/master
v: v3
  • Loading branch information
Ben Hutchings committed Jun 24, 2011
1 parent 5f28e16 commit 6ba70a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4017dbdc14af1903dc9fcba4d08b89c02325069d
refs/heads/master: a7d529ae2158b5300e4aa16c21f1828bc864449b
38 changes: 17 additions & 21 deletions trunk/drivers/net/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ static int efx_process_channel(struct efx_channel *channel, int budget)
struct efx_nic *efx = channel->efx;
int spent;

if (unlikely(efx->reset_pending != RESET_TYPE_NONE ||
!channel->enabled))
if (unlikely(efx->reset_pending || !channel->enabled))
return 0;

spent = efx_nic_process_eventq(channel, budget);
Expand Down Expand Up @@ -1461,7 +1460,7 @@ static void efx_start_all(struct efx_nic *efx)
* reset_pending [modified from an atomic context], we instead guarantee
* that efx_mcdi_mode_poll() isn't reverted erroneously */
efx_mcdi_mode_event(efx);
if (efx->reset_pending != RESET_TYPE_NONE)
if (efx->reset_pending)
efx_mcdi_mode_poll(efx);

/* Start the hardware monitor if there is one. Otherwise (we're link
Expand Down Expand Up @@ -2118,8 +2117,10 @@ int efx_reset(struct efx_nic *efx, enum reset_type method)
goto out;
}

/* Allow resets to be rescheduled. */
efx->reset_pending = RESET_TYPE_NONE;
/* Clear flags for the scopes we covered. We assume the NIC and
* driver are now quiescent so that there is no race here.
*/
efx->reset_pending &= -(1 << (method + 1));

/* Reinitialise bus-mastering, which may have been turned off before
* the reset was scheduled. This is still appropriate, even in the
Expand Down Expand Up @@ -2154,33 +2155,28 @@ int efx_reset(struct efx_nic *efx, enum reset_type method)
static void efx_reset_work(struct work_struct *data)
{
struct efx_nic *efx = container_of(data, struct efx_nic, reset_work);
unsigned long pending = ACCESS_ONCE(efx->reset_pending);

if (efx->reset_pending == RESET_TYPE_NONE)
if (!pending)
return;

/* If we're not RUNNING then don't reset. Leave the reset_pending
* flag set so that efx_pci_probe_main will be retried */
* flags set so that efx_pci_probe_main will be retried */
if (efx->state != STATE_RUNNING) {
netif_info(efx, drv, efx->net_dev,
"scheduled reset quenched. NIC not RUNNING\n");
return;
}

rtnl_lock();
(void)efx_reset(efx, efx->reset_pending);
(void)efx_reset(efx, fls(pending) - 1);
rtnl_unlock();
}

void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
{
enum reset_type method;

if (efx->reset_pending != RESET_TYPE_NONE) {
netif_info(efx, drv, efx->net_dev,
"quenching already scheduled reset\n");
return;
}

switch (type) {
case RESET_TYPE_INVISIBLE:
case RESET_TYPE_ALL:
Expand Down Expand Up @@ -2208,7 +2204,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
netif_dbg(efx, drv, efx->net_dev, "scheduling %s reset\n",
RESET_TYPE(method));

efx->reset_pending = method;
set_bit(method, &efx->reset_pending);

/* efx_process_channel() will no longer read events once a
* reset is scheduled. So switch back to poll'd MCDI completions. */
Expand Down Expand Up @@ -2288,7 +2284,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type,
efx->pci_dev = pci_dev;
efx->msg_enable = debug;
efx->state = STATE_INIT;
efx->reset_pending = RESET_TYPE_NONE;
strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name));

efx->net_dev = net_dev;
Expand Down Expand Up @@ -2510,7 +2505,7 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
cancel_work_sync(&efx->reset_work);

if (rc == 0) {
if (efx->reset_pending != RESET_TYPE_NONE) {
if (efx->reset_pending) {
/* If there was a scheduled reset during
* probe, the NIC is probably hosed anyway */
efx_pci_remove_main(efx);
Expand All @@ -2521,11 +2516,12 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
}

/* Retry if a recoverably reset event has been scheduled */
if ((efx->reset_pending != RESET_TYPE_INVISIBLE) &&
(efx->reset_pending != RESET_TYPE_ALL))
if (efx->reset_pending &
~(1 << RESET_TYPE_INVISIBLE | 1 << RESET_TYPE_ALL) ||
!efx->reset_pending)
goto fail3;

efx->reset_pending = RESET_TYPE_NONE;
efx->reset_pending = 0;
}

if (rc) {
Expand Down Expand Up @@ -2609,7 +2605,7 @@ static int efx_pm_poweroff(struct device *dev)

efx->type->fini(efx);

efx->reset_pending = RESET_TYPE_NONE;
efx->reset_pending = 0;

pci_save_state(pci_dev);
return pci_set_power_state(pci_dev, PCI_D3hot);
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/net/sfc/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ enum efx_loopback_mode {
* other valuesspecify reasons, which efx_schedule_reset() will choose
* a method for.
*
* Reset methods are numbered in order of increasing scope.
*
* @RESET_TYPE_INVISIBLE: don't reset the PHYs or interrupts
* @RESET_TYPE_ALL: reset everything but PCI core blocks
* @RESET_TYPE_WORLD: reset everything, save & restore PCI config
Expand All @@ -147,7 +149,6 @@ enum efx_loopback_mode {
* @RESET_TYPE_MC_FAILURE: MC reboot/assertion
*/
enum reset_type {
RESET_TYPE_NONE = -1,
RESET_TYPE_INVISIBLE = 0,
RESET_TYPE_ALL = 1,
RESET_TYPE_WORLD = 2,
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/sfc/falcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
efx_oword_t reg;
int link_speed, isolate;

isolate = (efx->reset_pending != RESET_TYPE_NONE);
isolate = !!ACCESS_ONCE(efx->reset_pending);

switch (link_state->speed) {
case 10000: link_speed = 3; break;
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/net/sfc/net_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ struct efx_filter_state;
* @irq_rx_moderation: IRQ moderation time for RX event queues
* @msg_enable: Log message enable flags
* @state: Device state flag. Serialised by the rtnl_lock.
* @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
* @reset_pending: Bitmask for pending resets
* @tx_queue: TX DMA queues
* @rx_queue: RX DMA queues
* @channel: Channels
Expand Down Expand Up @@ -728,7 +728,7 @@ struct efx_nic {
u32 msg_enable;

enum nic_state state;
enum reset_type reset_pending;
unsigned long reset_pending;

struct efx_channel *channel[EFX_MAX_CHANNELS];
char channel_name[EFX_MAX_CHANNELS][IFNAMSIZ + 6];
Expand Down

0 comments on commit 6ba70a4

Please sign in to comment.