b43legacy: Remove the PHY spinlock
This fixes a sparse warning about weird locking. The spinlock is not needed, so simply remove it. This also adds some sanity checks to the PHY and radio locking to protect against recursive locking. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
a8bdf29c6c
commit
bfe6a50156
@ -415,7 +415,6 @@ struct b43legacy_phy {
|
|||||||
u8 calibrated:1;
|
u8 calibrated:1;
|
||||||
u8 radio_rev; /* Radio revision */
|
u8 radio_rev; /* Radio revision */
|
||||||
|
|
||||||
bool locked; /* Only used in b43legacy_phy_{un}lock() */
|
|
||||||
bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */
|
bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */
|
||||||
|
|
||||||
/* ACI (adjacent channel interference) flags. */
|
/* ACI (adjacent channel interference) flags. */
|
||||||
@ -458,11 +457,6 @@ struct b43legacy_phy {
|
|||||||
s16 lna_gain; /* LNA */
|
s16 lna_gain; /* LNA */
|
||||||
s16 pga_gain; /* PGA */
|
s16 pga_gain; /* PGA */
|
||||||
|
|
||||||
/* PHY lock for core.rev < 3
|
|
||||||
* This lock is only used by b43legacy_phy_{un}lock()
|
|
||||||
*/
|
|
||||||
spinlock_t lock;
|
|
||||||
|
|
||||||
/* Desired TX power level (in dBm). This is set by the user and
|
/* Desired TX power level (in dBm). This is set by the user and
|
||||||
* adjusted in b43legacy_phy_xmitpower(). */
|
* adjusted in b43legacy_phy_xmitpower(). */
|
||||||
u8 power_level;
|
u8 power_level;
|
||||||
@ -486,9 +480,6 @@ struct b43legacy_phy {
|
|||||||
u16 txpwr_offset;
|
u16 txpwr_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_B43LEGACY_DEBUG
|
|
||||||
bool manual_txpower_control; /* Manual TX-power control enabled? */
|
|
||||||
#endif
|
|
||||||
/* Current Interference Mitigation mode */
|
/* Current Interference Mitigation mode */
|
||||||
int interfmode;
|
int interfmode;
|
||||||
/* Stack of saved values from the Interference Mitigation code.
|
/* Stack of saved values from the Interference Mitigation code.
|
||||||
@ -516,6 +507,13 @@ struct b43legacy_phy {
|
|||||||
|
|
||||||
/* PHY TX errors counter. */
|
/* PHY TX errors counter. */
|
||||||
atomic_t txerr_cnt;
|
atomic_t txerr_cnt;
|
||||||
|
|
||||||
|
#if B43legacy_DEBUG
|
||||||
|
/* Manual TX-power control enabled? */
|
||||||
|
bool manual_txpower_control;
|
||||||
|
/* PHY registers locked by b43legacy_phy_lock()? */
|
||||||
|
bool phy_locked;
|
||||||
|
#endif /* B43legacy_DEBUG */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Data structures for DMA transmission, per 80211 core. */
|
/* Data structures for DMA transmission, per 80211 core. */
|
||||||
|
@ -2847,8 +2847,6 @@ static void setup_struct_phy_for_init(struct b43legacy_wldev *dev,
|
|||||||
memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig));
|
memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig));
|
||||||
memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos));
|
memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos));
|
||||||
|
|
||||||
/* Flags */
|
|
||||||
phy->locked = 0;
|
|
||||||
/* Assume the radio is enabled. If it's not enabled, the state will
|
/* Assume the radio is enabled. If it's not enabled, the state will
|
||||||
* immediately get fixed on the first periodic work run. */
|
* immediately get fixed on the first periodic work run. */
|
||||||
dev->radio_hw_enable = 1;
|
dev->radio_hw_enable = 1;
|
||||||
@ -2881,7 +2879,6 @@ static void setup_struct_phy_for_init(struct b43legacy_wldev *dev,
|
|||||||
phy->lofcal = 0xFFFF;
|
phy->lofcal = 0xFFFF;
|
||||||
phy->initval = 0xFFFF;
|
phy->initval = 0xFFFF;
|
||||||
|
|
||||||
spin_lock_init(&phy->lock);
|
|
||||||
phy->interfmode = B43legacy_INTERFMODE_NONE;
|
phy->interfmode = B43legacy_INTERFMODE_NONE;
|
||||||
phy->channel = 0xFF;
|
phy->channel = 0xFF;
|
||||||
}
|
}
|
||||||
@ -3013,7 +3010,6 @@ static void prepare_phy_data_for_init(struct b43legacy_wldev *dev)
|
|||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
phy->calibrated = 0;
|
phy->calibrated = 0;
|
||||||
phy->locked = 0;
|
|
||||||
|
|
||||||
if (phy->_lo_pairs)
|
if (phy->_lo_pairs)
|
||||||
memset(phy->_lo_pairs, 0,
|
memset(phy->_lo_pairs, 0,
|
||||||
|
@ -91,40 +91,36 @@ void b43legacy_voluntary_preempt(void)
|
|||||||
#endif /* CONFIG_PREEMPT */
|
#endif /* CONFIG_PREEMPT */
|
||||||
}
|
}
|
||||||
|
|
||||||
void b43legacy_raw_phy_lock(struct b43legacy_wldev *dev)
|
/* Lock the PHY registers against concurrent access from the microcode.
|
||||||
|
* This lock is nonrecursive. */
|
||||||
|
void b43legacy_phy_lock(struct b43legacy_wldev *dev)
|
||||||
{
|
{
|
||||||
struct b43legacy_phy *phy = &dev->phy;
|
#if B43legacy_DEBUG
|
||||||
|
B43legacy_WARN_ON(dev->phy.phy_locked);
|
||||||
|
dev->phy.phy_locked = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
B43legacy_WARN_ON(!irqs_disabled());
|
|
||||||
if (b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD) == 0) {
|
|
||||||
phy->locked = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (dev->dev->id.revision < 3) {
|
if (dev->dev->id.revision < 3) {
|
||||||
b43legacy_mac_suspend(dev);
|
b43legacy_mac_suspend(dev);
|
||||||
spin_lock(&phy->lock);
|
|
||||||
} else {
|
} else {
|
||||||
if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
|
if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
|
||||||
b43legacy_power_saving_ctl_bits(dev, -1, 1);
|
b43legacy_power_saving_ctl_bits(dev, -1, 1);
|
||||||
}
|
}
|
||||||
phy->locked = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void b43legacy_raw_phy_unlock(struct b43legacy_wldev *dev)
|
void b43legacy_phy_unlock(struct b43legacy_wldev *dev)
|
||||||
{
|
{
|
||||||
struct b43legacy_phy *phy = &dev->phy;
|
#if B43legacy_DEBUG
|
||||||
|
B43legacy_WARN_ON(!dev->phy.phy_locked);
|
||||||
|
dev->phy.phy_locked = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
B43legacy_WARN_ON(!irqs_disabled());
|
|
||||||
if (dev->dev->id.revision < 3) {
|
if (dev->dev->id.revision < 3) {
|
||||||
if (phy->locked) {
|
b43legacy_mac_enable(dev);
|
||||||
spin_unlock(&phy->lock);
|
|
||||||
b43legacy_mac_enable(dev);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
|
if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
|
||||||
b43legacy_power_saving_ctl_bits(dev, -1, -1);
|
b43legacy_power_saving_ctl_bits(dev, -1, -1);
|
||||||
}
|
}
|
||||||
phy->locked = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset)
|
u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset)
|
||||||
@ -1789,7 +1785,6 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
|
|||||||
s16 baseband_att_delta;
|
s16 baseband_att_delta;
|
||||||
s16 radio_attenuation;
|
s16 radio_attenuation;
|
||||||
s16 baseband_attenuation;
|
s16 baseband_attenuation;
|
||||||
unsigned long phylock_flags;
|
|
||||||
|
|
||||||
if (phy->savedpctlreg == 0xFFFF)
|
if (phy->savedpctlreg == 0xFFFF)
|
||||||
return;
|
return;
|
||||||
@ -1944,13 +1939,13 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
|
|||||||
phy->bbatt = baseband_attenuation;
|
phy->bbatt = baseband_attenuation;
|
||||||
|
|
||||||
/* Adjust the hardware */
|
/* Adjust the hardware */
|
||||||
b43legacy_phy_lock(dev, phylock_flags);
|
b43legacy_phy_lock(dev);
|
||||||
b43legacy_radio_lock(dev);
|
b43legacy_radio_lock(dev);
|
||||||
b43legacy_radio_set_txpower_bg(dev, baseband_attenuation,
|
b43legacy_radio_set_txpower_bg(dev, baseband_attenuation,
|
||||||
radio_attenuation, txpower);
|
radio_attenuation, txpower);
|
||||||
b43legacy_phy_lo_mark_current_used(dev);
|
b43legacy_phy_lo_mark_current_used(dev);
|
||||||
b43legacy_radio_unlock(dev);
|
b43legacy_radio_unlock(dev);
|
||||||
b43legacy_phy_unlock(dev, phylock_flags);
|
b43legacy_phy_unlock(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
@ -171,18 +171,8 @@ void b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt);
|
|||||||
|
|
||||||
struct b43legacy_wldev;
|
struct b43legacy_wldev;
|
||||||
|
|
||||||
void b43legacy_raw_phy_lock(struct b43legacy_wldev *dev);
|
void b43legacy_phy_lock(struct b43legacy_wldev *dev);
|
||||||
#define b43legacy_phy_lock(bcm, flags) \
|
void b43legacy_phy_unlock(struct b43legacy_wldev *dev);
|
||||||
do { \
|
|
||||||
local_irq_save(flags); \
|
|
||||||
b43legacy_raw_phy_lock(bcm); \
|
|
||||||
} while (0)
|
|
||||||
void b43legacy_raw_phy_unlock(struct b43legacy_wldev *dev);
|
|
||||||
#define b43legacy_phy_unlock(bcm, flags) \
|
|
||||||
do { \
|
|
||||||
b43legacy_raw_phy_unlock(bcm); \
|
|
||||||
local_irq_restore(flags); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Card uses the loopback gain stuff */
|
/* Card uses the loopback gain stuff */
|
||||||
#define has_loopback_gain(phy) \
|
#define has_loopback_gain(phy) \
|
||||||
|
@ -92,6 +92,7 @@ void b43legacy_radio_lock(struct b43legacy_wldev *dev)
|
|||||||
u32 status;
|
u32 status;
|
||||||
|
|
||||||
status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
|
status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
|
||||||
|
B43legacy_WARN_ON(status & B43legacy_SBF_RADIOREG_LOCK);
|
||||||
status |= B43legacy_SBF_RADIOREG_LOCK;
|
status |= B43legacy_SBF_RADIOREG_LOCK;
|
||||||
b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status);
|
b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status);
|
||||||
mmiowb();
|
mmiowb();
|
||||||
@ -104,6 +105,7 @@ void b43legacy_radio_unlock(struct b43legacy_wldev *dev)
|
|||||||
|
|
||||||
b43legacy_read16(dev, B43legacy_MMIO_PHY_VER); /* dummy read */
|
b43legacy_read16(dev, B43legacy_MMIO_PHY_VER); /* dummy read */
|
||||||
status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
|
status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
|
||||||
|
B43legacy_WARN_ON(!(status & B43legacy_SBF_RADIOREG_LOCK));
|
||||||
status &= ~B43legacy_SBF_RADIOREG_LOCK;
|
status &= ~B43legacy_SBF_RADIOREG_LOCK;
|
||||||
b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status);
|
b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status);
|
||||||
mmiowb();
|
mmiowb();
|
||||||
@ -284,12 +286,11 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev)
|
|||||||
unsigned int j;
|
unsigned int j;
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
unsigned int end;
|
unsigned int end;
|
||||||
unsigned long phylock_flags;
|
|
||||||
|
|
||||||
if (!((phy->type == B43legacy_PHYTYPE_G) && (phy->rev > 0)))
|
if (!((phy->type == B43legacy_PHYTYPE_G) && (phy->rev > 0)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
b43legacy_phy_lock(dev, phylock_flags);
|
b43legacy_phy_lock(dev);
|
||||||
b43legacy_radio_lock(dev);
|
b43legacy_radio_lock(dev);
|
||||||
b43legacy_phy_write(dev, 0x0802,
|
b43legacy_phy_write(dev, 0x0802,
|
||||||
b43legacy_phy_read(dev, 0x0802) & 0xFFFC);
|
b43legacy_phy_read(dev, 0x0802) & 0xFFFC);
|
||||||
@ -323,7 +324,7 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev)
|
|||||||
ret[j] = 1;
|
ret[j] = 1;
|
||||||
}
|
}
|
||||||
b43legacy_radio_unlock(dev);
|
b43legacy_radio_unlock(dev);
|
||||||
b43legacy_phy_unlock(dev, phylock_flags);
|
b43legacy_phy_unlock(dev);
|
||||||
|
|
||||||
return ret[channel - 1];
|
return ret[channel - 1];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user