Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b2d9cf0 authored by Jeff Garzik's avatar Jeff Garzik
Browse files

Merge branch 'upstream' of...

parents 4c1234ff 89c318ed
Loading
Loading
Loading
Loading
+67 −33
Original line number Diff line number Diff line
@@ -636,6 +636,17 @@ struct bcm43xx_key {
	u8 algorithm;
};

/* Driver initialization status. */
enum {
	BCM43xx_STAT_UNINIT,		/* Uninitialized. */
	BCM43xx_STAT_INITIALIZING,	/* init_board() in progress. */
	BCM43xx_STAT_INITIALIZED,	/* Fully operational. */
	BCM43xx_STAT_SHUTTINGDOWN,	/* free_board() in progress. */
	BCM43xx_STAT_RESTARTING,	/* controller_restart() called. */
};
#define bcm43xx_status(bcm)		atomic_read(&(bcm)->init_status)
#define bcm43xx_set_status(bcm, stat)	atomic_set(&(bcm)->init_status, (stat))

struct bcm43xx_private {
	struct ieee80211_device *ieee;
	struct ieee80211softmac_device *softmac;
@@ -646,18 +657,17 @@ struct bcm43xx_private {

	void __iomem *mmio_addr;

	/* Do not use the lock directly. Use the bcm43xx_lock* helper
	 * functions, to be MMIO-safe. */
	spinlock_t _lock;
	/* Locking, see "theory of locking" text below. */
	spinlock_t irq_lock;
	struct mutex mutex;

	/* Driver initialization status BCM43xx_STAT_*** */
	atomic_t init_status;

	/* Driver status flags. */
	u32 initialized:1,		/* init_board() succeed */
	    was_initialized:1,		/* for PCI suspend/resume. */
	    shutting_down:1,		/* free_board() in progress */
	u16 was_initialized:1,		/* for PCI suspend/resume. */
	    __using_pio:1,		/* Internal, use bcm43xx_using_pio(). */
	    bad_frames_preempt:1,	/* Use "Bad Frames Preemption" (default off) */
	    reg124_set_0x4:1,		/* Some variable to keep track of IRQ stuff. */
	    powersaving:1,		/* TRUE if we are in PowerSaving mode. FALSE otherwise. */
	    short_preamble:1,		/* TRUE, if short preamble is enabled. */
	    firmware_norelease:1;	/* Do not release the firmware. Used on suspend. */

@@ -721,7 +731,7 @@ struct bcm43xx_private {
	struct tasklet_struct isr_tasklet;

	/* Periodic tasks */
	struct timer_list periodic_tasks;
	struct work_struct periodic_work;
	unsigned int periodic_state;

	struct work_struct restart_work;
@@ -746,21 +756,55 @@ struct bcm43xx_private {
#endif
};

/* bcm43xx_(un)lock() protect struct bcm43xx_private.
 * Note that _NO_ MMIO writes are allowed. If you want to
 * write to the device through MMIO in the critical section, use
 * the *_mmio lock functions.
 * MMIO read-access is allowed, though.
 */
#define bcm43xx_lock(bcm, flags)	spin_lock_irqsave(&(bcm)->_lock, flags)
#define bcm43xx_unlock(bcm, flags)	spin_unlock_irqrestore(&(bcm)->_lock, flags)
/* bcm43xx_(un)lock_mmio() protect struct bcm43xx_private and MMIO.
 * MMIO write-access to the device is allowed.
 * All MMIO writes are flushed on unlock, so it is guaranteed to not
 * interfere with other threads writing MMIO registers.

/*    *** THEORY OF LOCKING ***
 *
 * We have two different locks in the bcm43xx driver.
 * => bcm->mutex:    General sleeping mutex. Protects struct bcm43xx_private
 *                   and the device registers.
 * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency.
 *
 * We have three types of helper function pairs to utilize these locks.
 *     (Always use the helper functions.)
 * 1) bcm43xx_{un}lock_noirq():
 *     Takes bcm->mutex. Does _not_ protect against IRQ concurrency,
 *     so it is almost always unsafe, if device IRQs are enabled.
 *     So only use this, if device IRQs are masked.
 *     Locking may sleep.
 *     You can sleep within the critical section.
 * 2) bcm43xx_{un}lock_irqonly():
 *     Takes bcm->irq_lock. Does _not_ protect against
 *     bcm43xx_lock_noirq() critical sections.
 *     Does only protect against the IRQ handler path and other
 *     irqonly() critical sections.
 *     Locking does not sleep.
 *     You must not sleep within the critical section.
 * 3) bcm43xx_{un}lock_irqsafe():
 *     This is the cummulative lock and takes both, mutex and irq_lock.
 *     Protects against noirq() and irqonly() critical sections (and
 *     the IRQ handler path).
 *     Locking may sleep.
 *     You must not sleep within the critical section.
 */
#define bcm43xx_lock_mmio(bcm, flags)	bcm43xx_lock(bcm, flags)
#define bcm43xx_unlock_mmio(bcm, flags)	do { mmiowb(); bcm43xx_unlock(bcm, flags); } while (0)

/* Lock type 1 */
#define bcm43xx_lock_noirq(bcm)		mutex_lock(&(bcm)->mutex)
#define bcm43xx_unlock_noirq(bcm)	mutex_unlock(&(bcm)->mutex)
/* Lock type 2 */
#define bcm43xx_lock_irqonly(bcm, flags)	\
	spin_lock_irqsave(&(bcm)->irq_lock, flags)
#define bcm43xx_unlock_irqonly(bcm, flags)	\
	spin_unlock_irqrestore(&(bcm)->irq_lock, flags)
/* Lock type 3 */
#define bcm43xx_lock_irqsafe(bcm, flags) do {	\
	bcm43xx_lock_noirq(bcm);		\
	bcm43xx_lock_irqonly(bcm, flags);	\
		} while (0)
#define bcm43xx_unlock_irqsafe(bcm, flags) do {	\
	bcm43xx_unlock_irqonly(bcm, flags);	\
	bcm43xx_unlock_noirq(bcm);		\
		} while (0)


static inline
struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
@@ -843,16 +887,6 @@ struct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm)
	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].radio);
}

/* Are we running in init_board() context? */
static inline
int bcm43xx_is_initializing(struct bcm43xx_private *bcm)
{
	if (bcm->initialized)
		return 0;
	if (bcm->shutting_down)
		return 0;
	return 1;
}

static inline
struct bcm43xx_lopair * bcm43xx_get_lopair(struct bcm43xx_phyinfo *phy,
+17 −16
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,

	down(&big_buffer_sem);

	bcm43xx_lock_mmio(bcm, flags);
	if (!bcm->initialized) {
	bcm43xx_lock_irqsafe(bcm, flags);
	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
		fappend("Board not initialized.\n");
		goto out;
	}
@@ -121,7 +121,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
	fappend("\n");

out:
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
	up(&big_buffer_sem);
	return res;
@@ -159,8 +159,8 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
	unsigned long flags;

	down(&big_buffer_sem);
	bcm43xx_lock_mmio(bcm, flags);
	if (!bcm->initialized) {
	bcm43xx_lock_irqsafe(bcm, flags);
	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
		fappend("Board not initialized.\n");
		goto out;
	}
@@ -169,7 +169,7 @@ static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
	fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);

out:
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
	up(&big_buffer_sem);
	return res;
@@ -188,8 +188,8 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
	u64 tsf;

	down(&big_buffer_sem);
	bcm43xx_lock_mmio(bcm, flags);
	if (!bcm->initialized) {
	bcm43xx_lock_irqsafe(bcm, flags);
	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
		fappend("Board not initialized.\n");
		goto out;
	}
@@ -199,7 +199,7 @@ static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
		(unsigned int)(tsf & 0xFFFFFFFFULL));

out:
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
	up(&big_buffer_sem);
	return res;
@@ -221,8 +221,8 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
	        res = -EFAULT;
		goto out_up;
	}
	bcm43xx_lock_mmio(bcm, flags);
	if (!bcm->initialized) {
	bcm43xx_lock_irqsafe(bcm, flags);
	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
		printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
		res = -EFAULT;
		goto out_unlock;
@@ -233,10 +233,11 @@ static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
		goto out_unlock;
	}
	bcm43xx_tsf_write(bcm, tsf);
	mmiowb();
	res = buf_size;
	
out_unlock:
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
out_up:
	up(&big_buffer_sem);
	return res;
@@ -257,7 +258,7 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
	int i, cnt, j = 0;

	down(&big_buffer_sem);
	bcm43xx_lock(bcm, flags);
	bcm43xx_lock_irqsafe(bcm, flags);

	fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
		BCM43xx_NR_LOGGED_XMITSTATUS);
@@ -293,14 +294,14 @@ static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
			i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
	}

	bcm43xx_unlock(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
	bcm43xx_lock(bcm, flags);
	bcm43xx_lock_irqsafe(bcm, flags);
	if (*ppos == pos) {
		/* Done. Drop the copied data. */
		e->xmitstatus_printing = 0;
	}
	bcm43xx_unlock(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
	up(&big_buffer_sem);
	return res;
}
+2 −2
Original line number Diff line number Diff line
@@ -51,12 +51,12 @@ static void bcm43xx_led_blink(unsigned long d)
	struct bcm43xx_private *bcm = led->bcm;
	unsigned long flags;

	bcm43xx_lock_mmio(bcm, flags);
	bcm43xx_lock_irqonly(bcm, flags);
	if (led->blink_interval) {
		bcm43xx_led_changestate(led);
		mod_timer(&led->blink_timer, jiffies + led->blink_interval);
	}
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqonly(bcm, flags);
}

static void bcm43xx_led_blink_start(struct bcm43xx_led *led,
+151 −70
Original line number Diff line number Diff line
@@ -498,20 +498,31 @@ static inline u32 bcm43xx_interrupt_disable(struct bcm43xx_private *bcm, u32 mas
	return old_mask;
}

/* Synchronize IRQ top- and bottom-half.
 * IRQs must be masked before calling this.
 * This must not be called with the irq_lock held.
 */
static void bcm43xx_synchronize_irq(struct bcm43xx_private *bcm)
{
	synchronize_irq(bcm->irq);
	tasklet_disable(&bcm->isr_tasklet);
}

/* Make sure we don't receive more data from the device. */
static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm, u32 *oldstate)
{
	u32 old;
	unsigned long flags;
	u32 old;

	bcm43xx_lock_mmio(bcm, flags);
	if (bcm43xx_is_initializing(bcm) || bcm->shutting_down) {
		bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_lock_irqonly(bcm, flags);
	if (unlikely(bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)) {
		bcm43xx_unlock_irqonly(bcm, flags);
		return -EBUSY;
	}
	old = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
	tasklet_disable(&bcm->isr_tasklet);
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqonly(bcm, flags);
	bcm43xx_synchronize_irq(bcm);

	if (oldstate)
		*oldstate = old;

@@ -1389,7 +1400,7 @@ void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy)
			bcm43xx_dmacontroller_rx_reset(bcm, BCM43xx_MMIO_DMA4_BASE);
#endif
	}
	if (bcm->shutting_down) {
	if (bcm43xx_status(bcm) == BCM43xx_STAT_SHUTTINGDOWN) {
		bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
		                bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
				& ~(BCM43xx_SBF_MAC_ENABLED | 0x00000002));
@@ -1709,7 +1720,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
# define bcmirq_handled(irq)	do { /* nothing */ } while (0)
#endif /* CONFIG_BCM43XX_DEBUG*/

	bcm43xx_lock_mmio(bcm, flags);
	bcm43xx_lock_irqonly(bcm, flags);
	reason = bcm->irq_reason;
	dma_reason[0] = bcm->dma_reason[0];
	dma_reason[1] = bcm->dma_reason[1];
@@ -1734,7 +1745,8 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
		        dma_reason[0], dma_reason[1],
			dma_reason[2], dma_reason[3]);
		bcm43xx_controller_restart(bcm, "DMA error");
		bcm43xx_unlock_mmio(bcm, flags);
		mmiowb();
		bcm43xx_unlock_irqonly(bcm, flags);
		return;
	}
	if (unlikely((dma_reason[0] & BCM43xx_DMAIRQ_NONFATALMASK) |
@@ -1821,7 +1833,8 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
	if (!modparam_noleds)
		bcm43xx_leds_update(bcm, activity);
	bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
	bcm43xx_unlock_mmio(bcm, flags);
	mmiowb();
	bcm43xx_unlock_irqonly(bcm, flags);
}

static void pio_irq_workaround(struct bcm43xx_private *bcm,
@@ -1870,7 +1883,7 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
	if (!bcm)
		return IRQ_NONE;

	spin_lock(&bcm->_lock);
	spin_lock(&bcm->irq_lock);

	reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
	if (reason == 0xffffffff) {
@@ -1899,7 +1912,7 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
	 * completely, but some careful work is needed to fix this. I think it
	 * is best to stay with this cheap workaround for now... .
	 */
	if (likely(bcm->initialized)) {
	if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) {
		/* disable all IRQs. They are enabled again in the bottom half. */
		bcm->irq_savedstate = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
		/* save the reason code and call our bottom half. */
@@ -1909,7 +1922,7 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re

out:
	mmiowb();
	spin_unlock(&bcm->_lock);
	spin_unlock(&bcm->irq_lock);

	return ret;
}
@@ -2133,6 +2146,13 @@ static int bcm43xx_upload_initvals(struct bcm43xx_private *bcm)
	return err;
}

#ifdef CONFIG_BCM947XX
static struct pci_device_id bcm43xx_47xx_ids[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
	{ 0 }
};
#endif

static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
{
	int res;
@@ -2142,11 +2162,15 @@ static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
	bcm->irq = bcm->pci_dev->irq;
#ifdef CONFIG_BCM947XX
	if (bcm->pci_dev->bus->number == 0) {
		struct pci_dev *d = NULL;
		/* FIXME: we will probably need more device IDs here... */
		d = pci_find_device(PCI_VENDOR_ID_BROADCOM, 0x4324, NULL);
		struct pci_dev *d;
		struct pci_device_id *id;
		for (id = bcm43xx_47xx_ids; id->vendor; id++) {
			d = pci_get_device(id->vendor, id->device, NULL);
			if (d != NULL) {
				bcm->irq = d->irq;
				pci_dev_put(d);
				break;
			}
		}
	}
#endif
@@ -3106,15 +3130,10 @@ static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
	//TODO for APHY (temperature?)
}

static void bcm43xx_periodic_task_handler(unsigned long d)
static void do_periodic_work(struct bcm43xx_private *bcm)
{
	struct bcm43xx_private *bcm = (struct bcm43xx_private *)d;
	unsigned long flags;
	unsigned int state;

	bcm43xx_lock_mmio(bcm, flags);

	assert(bcm->initialized);
	state = bcm->periodic_state;
	if (state % 8 == 0)
		bcm43xx_periodic_every120sec(bcm);
@@ -3122,29 +3141,93 @@ static void bcm43xx_periodic_task_handler(unsigned long d)
		bcm43xx_periodic_every60sec(bcm);
	if (state % 2 == 0)
		bcm43xx_periodic_every30sec(bcm);
	if (state % 1 == 0)
		bcm43xx_periodic_every15sec(bcm);
	bcm->periodic_state = state + 1;

	mod_timer(&bcm->periodic_tasks, jiffies + (HZ * 15));
	schedule_delayed_work(&bcm->periodic_work, HZ * 15);
}

	bcm43xx_unlock_mmio(bcm, flags);
/* Estimate a "Badness" value based on the periodic work
 * state-machine state. "Badness" is worse (bigger), if the
 * periodic work will take longer.
 */
static int estimate_periodic_work_badness(unsigned int state)
{
	int badness = 0;

	if (state % 8 == 0) /* every 120 sec */
		badness += 10;
	if (state % 4 == 0) /* every 60 sec */
		badness += 5;
	if (state % 2 == 0) /* every 30 sec */
		badness += 1;
	if (state % 1 == 0) /* every 15 sec */
		badness += 1;

#define BADNESS_LIMIT	4
	return badness;
}

static void bcm43xx_periodic_work_handler(void *d)
{
	struct bcm43xx_private *bcm = d;
	unsigned long flags;
	u32 savedirqs = 0;
	int badness;

	badness = estimate_periodic_work_badness(bcm->periodic_state);
	if (badness > BADNESS_LIMIT) {
		/* Periodic work will take a long time, so we want it to
		 * be preemtible.
		 */
		bcm43xx_lock_irqonly(bcm, flags);
		netif_stop_queue(bcm->net_dev);
		if (bcm43xx_using_pio(bcm))
			bcm43xx_pio_freeze_txqueues(bcm);
		savedirqs = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
		bcm43xx_unlock_irqonly(bcm, flags);
		bcm43xx_lock_noirq(bcm);
		bcm43xx_synchronize_irq(bcm);
	} else {
		/* Periodic work should take short time, so we want low
		 * locking overhead.
		 */
		bcm43xx_lock_irqsafe(bcm, flags);
	}

	do_periodic_work(bcm);

	if (badness > BADNESS_LIMIT) {
		bcm43xx_lock_irqonly(bcm, flags);
		if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) {
			tasklet_enable(&bcm->isr_tasklet);
			bcm43xx_interrupt_enable(bcm, savedirqs);
			if (bcm43xx_using_pio(bcm))
				bcm43xx_pio_thaw_txqueues(bcm);
		}
		netif_wake_queue(bcm->net_dev);
		mmiowb();
		bcm43xx_unlock_irqonly(bcm, flags);
		bcm43xx_unlock_noirq(bcm);
	} else {
		mmiowb();
		bcm43xx_unlock_irqsafe(bcm, flags);
	}
}

static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
{
	del_timer_sync(&bcm->periodic_tasks);
	cancel_rearming_delayed_work(&bcm->periodic_work);
}

static void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
{
	struct timer_list *timer = &(bcm->periodic_tasks);
	struct work_struct *work = &(bcm->periodic_work);

	assert(bcm->initialized);
	setup_timer(timer,
		    bcm43xx_periodic_task_handler,
		    (unsigned long)bcm);
	timer->expires = jiffies;
	add_timer(timer);
	assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
	INIT_WORK(work, bcm43xx_periodic_work_handler, bcm);
	schedule_work(work);
}

static void bcm43xx_security_init(struct bcm43xx_private *bcm)
@@ -3158,16 +3241,12 @@ static void bcm43xx_security_init(struct bcm43xx_private *bcm)
static void bcm43xx_free_board(struct bcm43xx_private *bcm)
{
	int i, err;
	unsigned long flags;

	bcm43xx_lock_noirq(bcm);
	bcm43xx_sysfs_unregister(bcm);

	bcm43xx_periodic_tasks_delete(bcm);

	bcm43xx_lock(bcm, flags);
	bcm->initialized = 0;
	bcm->shutting_down = 1;
	bcm43xx_unlock(bcm, flags);
	bcm43xx_set_status(bcm, BCM43xx_STAT_SHUTTINGDOWN);

	for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
		if (!bcm->core_80211[i].available)
@@ -3182,23 +3261,19 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)

	bcm43xx_pctl_set_crystal(bcm, 0);

	bcm43xx_lock(bcm, flags);
	bcm->shutting_down = 0;
	bcm43xx_unlock(bcm, flags);
	bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
	bcm43xx_unlock_noirq(bcm);
}

static int bcm43xx_init_board(struct bcm43xx_private *bcm)
{
	int i, err;
	int connect_phy;
	unsigned long flags;

	might_sleep();

	bcm43xx_lock(bcm, flags);
	bcm->initialized = 0;
	bcm->shutting_down = 0;
	bcm43xx_unlock(bcm, flags);
	bcm43xx_lock_noirq(bcm);
	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZING);

	err = bcm43xx_pctl_set_crystal(bcm, 1);
	if (err)
@@ -3265,9 +3340,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
	}

	/* Initialization of the board is done. Flag it as such. */
	bcm43xx_lock(bcm, flags);
	bcm->initialized = 1;
	bcm43xx_unlock(bcm, flags);
	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZED);

	bcm43xx_periodic_tasks_setup(bcm);
	bcm43xx_sysfs_register(bcm);
@@ -3278,6 +3351,8 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)

	assert(err == 0);
out:
	bcm43xx_unlock_noirq(bcm);

	return err;

err_80211_unwind:
@@ -3534,8 +3609,8 @@ static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev,
	struct bcm43xx_radioinfo *radio;
	unsigned long flags;

	bcm43xx_lock_mmio(bcm, flags);
	if (bcm->initialized) {
	bcm43xx_lock_irqsafe(bcm, flags);
	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
		bcm43xx_mac_suspend(bcm);
		bcm43xx_radio_selectchannel(bcm, channel, 0);
		bcm43xx_mac_enable(bcm);
@@ -3543,7 +3618,7 @@ static void bcm43xx_ieee80211_set_chan(struct net_device *net_dev,
		radio = bcm43xx_current_radio(bcm);
		radio->initial_channel = channel;
	}
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
}

/* set_security() callback in struct ieee80211_device */
@@ -3557,7 +3632,7 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
	
	dprintk(KERN_INFO PFX "set security called");

	bcm43xx_lock_mmio(bcm, flags);
	bcm43xx_lock_irqsafe(bcm, flags);

	for (keyidx = 0; keyidx<WEP_KEYS; keyidx++)
		if (sec->flags & (1<<keyidx)) {
@@ -3587,7 +3662,8 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
		dprintk(", .encrypt = %d", sec->encrypt);
	}
	dprintk("\n");
	if (bcm->initialized && !bcm->ieee->host_encrypt) {
	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED &&
	    !bcm->ieee->host_encrypt) {
		if (secinfo->enabled) {
			/* upload WEP keys to hardware */
			char null_address[6] = { 0 };
@@ -3621,7 +3697,7 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
		} else
				bcm43xx_clear_keys(bcm);
	}
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);
}

/* hard_start_xmit() callback in struct ieee80211_device */
@@ -3633,10 +3709,10 @@ static int bcm43xx_ieee80211_hard_start_xmit(struct ieee80211_txb *txb,
	int err = -ENODEV;
	unsigned long flags;

	bcm43xx_lock_mmio(bcm, flags);
	if (likely(bcm->initialized))
	bcm43xx_lock_irqonly(bcm, flags);
	if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED))
		err = bcm43xx_tx(bcm, txb);
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqonly(bcm, flags);

	return err;
}
@@ -3651,9 +3727,9 @@ static void bcm43xx_net_tx_timeout(struct net_device *net_dev)
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	unsigned long flags;

	bcm43xx_lock_mmio(bcm, flags);
	bcm43xx_lock_irqonly(bcm, flags);
	bcm43xx_controller_restart(bcm, "TX timeout");
	bcm43xx_unlock_mmio(bcm, flags);
	bcm43xx_unlock_irqonly(bcm, flags);
}

#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -3678,9 +3754,11 @@ static int bcm43xx_net_open(struct net_device *net_dev)
static int bcm43xx_net_stop(struct net_device *net_dev)
{
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	int err;

	ieee80211softmac_stop(net_dev);
	bcm43xx_disable_interrupts_sync(bcm, NULL);
	err = bcm43xx_disable_interrupts_sync(bcm, NULL);
	assert(!err);
	bcm43xx_free_board(bcm);

	return 0;
@@ -3692,6 +3770,7 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
{
	int err;

	bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
	bcm->ieee = netdev_priv(net_dev);
	bcm->softmac = ieee80211_priv(net_dev);
	bcm->softmac->set_channel = bcm43xx_ieee80211_set_chan;
@@ -3700,7 +3779,8 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm,
	bcm->pci_dev = pci_dev;
	bcm->net_dev = net_dev;
	bcm->bad_frames_preempt = modparam_bad_frames_preempt;
	spin_lock_init(&bcm->_lock);
	spin_lock_init(&bcm->irq_lock);
	mutex_init(&bcm->mutex);
	tasklet_init(&bcm->isr_tasklet,
		     (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
		     (unsigned long)bcm);
@@ -3831,7 +3911,7 @@ static void bcm43xx_chip_reset(void *_bcm)
	struct net_device *net_dev = bcm->net_dev;
	struct pci_dev *pci_dev = bcm->pci_dev;
	int err;
	int was_initialized = bcm->initialized;
	int was_initialized = (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);

	netif_stop_queue(bcm->net_dev);
	tasklet_disable(&bcm->isr_tasklet);
@@ -3866,6 +3946,7 @@ static void bcm43xx_chip_reset(void *_bcm)
*/
void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
{
	bcm43xx_set_status(bcm, BCM43xx_STAT_RESTARTING);
	bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
	bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* dummy read */
	printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
@@ -3884,11 +3965,11 @@ static int bcm43xx_suspend(struct pci_dev *pdev, pm_message_t state)

	dprintk(KERN_INFO PFX "Suspending...\n");

	bcm43xx_lock(bcm, flags);
	bcm->was_initialized = bcm->initialized;
	if (bcm->initialized)
	bcm43xx_lock_irqsafe(bcm, flags);
	bcm->was_initialized = (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
	if (bcm->was_initialized)
		try_to_shutdown = 1;
	bcm43xx_unlock(bcm, flags);
	bcm43xx_unlock_irqsafe(bcm, flags);

	netif_device_detach(net_dev);
	if (try_to_shutdown) {
+7 −2
Original line number Diff line number Diff line
@@ -1410,7 +1410,10 @@ static inline
u16 bcm43xx_phy_lo_g_deviation_subval(struct bcm43xx_private *bcm, u16 control)
{
	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
	u16 ret;
	unsigned long flags;

	local_irq_save(flags);
	if (phy->connected) {
		bcm43xx_phy_write(bcm, 0x15, 0xE300);
		control <<= 8;
@@ -1430,8 +1433,10 @@ u16 bcm43xx_phy_lo_g_deviation_subval(struct bcm43xx_private *bcm, u16 control)
		bcm43xx_phy_write(bcm, 0x0015, control | 0xFFE0);
		udelay(8);
	}
	ret = bcm43xx_phy_read(bcm, 0x002D);
	local_irq_restore(flags);

	return bcm43xx_phy_read(bcm, 0x002D);
	return ret;
}

static u32 bcm43xx_phy_lo_g_singledeviation(struct bcm43xx_private *bcm, u16 control)
@@ -1648,7 +1653,7 @@ void bcm43xx_phy_set_baseband_attenuation(struct bcm43xx_private *bcm,
void bcm43xx_phy_lo_g_measure(struct bcm43xx_private *bcm)
{
	static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 };
	const int is_initializing = bcm43xx_is_initializing(bcm);
	const int is_initializing = (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZING);
	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
	struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
	u16 h, i, oldi = 0, j;
Loading