Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 56560
b: refs/heads/master
c: d3a36fb
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed May 18, 2007
1 parent c15829b commit c3c207a
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 124 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: 8fd7d1b16ea0e1b3b0823ed91b58993d6c6a1cc6
refs/heads/master: d3a36fb82a0864a85e238ac946817030a18c5f9a
2 changes: 1 addition & 1 deletion trunk/Documentation/networking/netdevices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dev->hard_start_xmit:
for this and return -1 when the spin lock fails.
The locking there should also properly protect against
set_multicast_list
Context: BHs disabled
Context: Process with BHs disabled or BH (timer).
Notes: netif_queue_stopped() is guaranteed false
Interrupts must be enabled when calling hard_start_xmit.
(Interrupts must also be enabled when enabling the BH handler.)
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/net/e1000/e1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,9 @@ struct e1000_adapter {
struct e1000_tx_ring test_tx_ring;
struct e1000_rx_ring test_rx_ring;


int msg_enable;
#ifdef CONFIG_PCI_MSI
boolean_t have_msi;
#endif

/* to not mess up cache alignment, always add to the bottom */
boolean_t tso_force;
boolean_t smart_power_down; /* phy smart power down */
Expand Down
39 changes: 14 additions & 25 deletions trunk/drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
static int e1000_set_mac(struct net_device *netdev, void *p);
static irqreturn_t e1000_intr(int irq, void *data);
#ifdef CONFIG_PCI_MSI
static irqreturn_t e1000_intr_msi(int irq, void *data);
#endif
static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
struct e1000_tx_ring *tx_ring);
#ifdef CONFIG_E1000_NAPI
Expand Down Expand Up @@ -300,31 +298,26 @@ module_exit(e1000_exit_module);
static int e1000_request_irq(struct e1000_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
int flags, err = 0;
void (*handler) = &e1000_intr;
int irq_flags = IRQF_SHARED;
int err;

flags = IRQF_SHARED;
#ifdef CONFIG_PCI_MSI
if (adapter->hw.mac_type >= e1000_82571) {
adapter->have_msi = TRUE;
if ((err = pci_enable_msi(adapter->pdev))) {
DPRINTK(PROBE, ERR,
"Unable to allocate MSI interrupt Error: %d\n", err);
adapter->have_msi = FALSE;
adapter->have_msi = !pci_enable_msi(adapter->pdev);
if (adapter->have_msi) {
handler = &e1000_intr_msi;
irq_flags = 0;
}
}
if (adapter->have_msi) {
flags &= ~IRQF_SHARED;
err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags,
netdev->name, netdev);
if (err)
DPRINTK(PROBE, ERR,
"Unable to allocate interrupt Error: %d\n", err);
} else
#endif
if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
netdev->name, netdev)))

err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
netdev);
if (err) {
if (adapter->have_msi)
pci_disable_msi(adapter->pdev);
DPRINTK(PROBE, ERR,
"Unable to allocate interrupt Error: %d\n", err);
}

return err;
}
Expand All @@ -335,10 +328,8 @@ static void e1000_free_irq(struct e1000_adapter *adapter)

free_irq(adapter->pdev->irq, netdev);

#ifdef CONFIG_PCI_MSI
if (adapter->have_msi)
pci_disable_msi(adapter->pdev);
#endif
}

/**
Expand Down Expand Up @@ -3744,7 +3735,6 @@ e1000_update_stats(struct e1000_adapter *adapter)

spin_unlock_irqrestore(&adapter->stats_lock, flags);
}
#ifdef CONFIG_PCI_MSI

/**
* e1000_intr_msi - Interrupt Handler
Expand Down Expand Up @@ -3810,7 +3800,6 @@ e1000_intr_msi(int irq, void *data)

return IRQ_HANDLED;
}
#endif

/**
* e1000_intr - Interrupt Handler
Expand Down
11 changes: 11 additions & 0 deletions trunk/drivers/net/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,15 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)

dev->trans_start = jiffies;

/* The powerpc-specific eieio() is used, as wmb() has too strong
* semantics (it requires synchronization between cacheable and
* uncacheable mappings, which eieio doesn't provide and which we
* don't need), thus requiring a more expensive sync instruction. At
* some point, the set of architecture-independent barrier functions
* should be expanded to include weaker barriers.
*/

eieio();
txbdp->status = status;

/* If this was the last BD in the ring, the next one */
Expand Down Expand Up @@ -1301,6 +1310,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
bdp->length = 0;

/* Mark the buffer empty */
eieio();
bdp->status |= (RXBD_EMPTY | RXBD_INTERRUPT);

return skb;
Expand Down Expand Up @@ -1484,6 +1494,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
bdp = priv->cur_rx;

while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {
rmb();
skb = priv->rx_skbuff[priv->skb_currx];

if (!(bdp->status &
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ static int emac_link_differs(struct ocp_enet_private *dev)
int duplex = r & EMAC_MR1_FDE ? DUPLEX_FULL : DUPLEX_HALF;
int speed, pause, asym_pause;

if (r & (EMAC_MR1_MF_1000 | EMAC_MR1_MF_1000GPCS))
if (r & EMAC_MR1_MF_1000)
speed = SPEED_1000;
else if (r & EMAC_MR1_MF_100)
speed = SPEED_100;
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/net/ibm_emac/ibm_emac_mal.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ int __init mal_register_commac(struct ibm_ocp_mal *mal,
return 0;
}

void __exit mal_unregister_commac(struct ibm_ocp_mal *mal,
struct mal_commac *commac)
void mal_unregister_commac(struct ibm_ocp_mal *mal, struct mal_commac *commac)
{
unsigned long flags;
local_irq_save(flags);
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/net/ibm_emac/ibm_emac_mal.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ void mal_exit(void) __exit;

int mal_register_commac(struct ibm_ocp_mal *mal,
struct mal_commac *commac) __init;
void mal_unregister_commac(struct ibm_ocp_mal *mal,
struct mal_commac *commac) __exit;
void mal_unregister_commac(struct ibm_ocp_mal *mal, struct mal_commac *commac);
int mal_set_rcbs(struct ibm_ocp_mal *mal, int channel, unsigned long size);

/* Returns BD ring offset for a particular channel
Expand Down
60 changes: 45 additions & 15 deletions trunk/drivers/net/ibm_emac/ibm_emac_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <asm/ocp.h>

#include "ibm_emac_core.h"
#include "ibm_emac_phy.h"

static inline int phy_read(struct mii_phy *phy, int reg)
Expand All @@ -34,28 +35,51 @@ static inline void phy_write(struct mii_phy *phy, int reg, int val)
phy->mdio_write(phy->dev, phy->address, reg, val);
}

int mii_reset_phy(struct mii_phy *phy)
/*
* polls MII_BMCR until BMCR_RESET bit clears or operation times out.
*
* returns:
* >= 0 => success, value in BMCR returned to caller
* -EBUSY => failure, RESET bit never cleared
* otherwise => failure, lower level PHY read failed
*/
static int mii_spin_reset_complete(struct mii_phy *phy)
{
int val;
int limit = 10000;

while (limit--) {
val = phy_read(phy, MII_BMCR);
if (val >= 0 && !(val & BMCR_RESET))
return val; /* success */
udelay(10);
}
if (val & BMCR_RESET)
val = -EBUSY;

if (net_ratelimit())
printk(KERN_ERR "emac%d: PHY reset timeout (%d)\n",
((struct ocp_enet_private *)phy->dev->priv)->def->index,
val);
return val;
}

int mii_reset_phy(struct mii_phy *phy)
{
int val;

val = phy_read(phy, MII_BMCR);
val &= ~BMCR_ISOLATE;
val |= BMCR_RESET;
phy_write(phy, MII_BMCR, val);

udelay(300);

while (limit--) {
val = phy_read(phy, MII_BMCR);
if (val >= 0 && (val & BMCR_RESET) == 0)
break;
udelay(10);
}
if ((val & BMCR_ISOLATE) && limit > 0)
val = mii_spin_reset_complete(phy);
if (val >= 0 && (val & BMCR_ISOLATE))
phy_write(phy, MII_BMCR, val & ~BMCR_ISOLATE);

return limit <= 0;
return val < 0;
}

static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
Expand Down Expand Up @@ -102,8 +126,14 @@ static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
}

/* Start/Restart aneg */
ctl = phy_read(phy, MII_BMCR);
ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
/* on some PHYs (e.g. National DP83843) a write to MII_ADVERTISE
* causes BMCR_RESET to be set on the next read of MII_BMCR, which
* if not checked for causes the PHY to be reset below */
ctl = mii_spin_reset_complete(phy);
if (ctl < 0)
return ctl;

ctl |= BMCR_ANENABLE | BMCR_ANRESTART;
phy_write(phy, MII_BMCR, ctl);

return 0;
Expand All @@ -118,13 +148,13 @@ static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
phy->duplex = fd;
phy->pause = phy->asym_pause = 0;

/* First reset the PHY */
mii_reset_phy(phy);

ctl = phy_read(phy, MII_BMCR);
if (ctl < 0)
return ctl;
ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_ANENABLE);

/* First reset the PHY */
phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_ANENABLE | BMCR_SPEED1000);

/* Select speed & duplex */
switch (speed) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_rgmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void rgmii_set_speed(struct ocp_device *ocpdev, int input, int speed)
out_be32(&dev->base->ssr, ssr);
}

void __exit __rgmii_fini(struct ocp_device *ocpdev, int input)
void __rgmii_fini(struct ocp_device *ocpdev, int input)
{
struct ibm_ocp_rgmii *dev = ocp_get_drvdata(ocpdev);
BUG_ON(!dev || dev->users == 0);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_rgmii.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ibm_ocp_rgmii {
#ifdef CONFIG_IBM_EMAC_RGMII
int rgmii_attach(void *emac) __init;

void __rgmii_fini(struct ocp_device *ocpdev, int input) __exit;
void __rgmii_fini(struct ocp_device *ocpdev, int input);
static inline void rgmii_fini(struct ocp_device *ocpdev, int input)
{
if (ocpdev)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_tah.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int __init tah_attach(void *emac)
return 0;
}

void __exit __tah_fini(struct ocp_device *ocpdev)
void __tah_fini(struct ocp_device *ocpdev)
{
struct tah_regs *p = ocp_get_drvdata(ocpdev);
BUG_ON(!p);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_tah.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct tah_regs {
#ifdef CONFIG_IBM_EMAC_TAH
int tah_attach(void *emac) __init;

void __tah_fini(struct ocp_device *ocpdev) __exit;
void __tah_fini(struct ocp_device *ocpdev);
static inline void tah_fini(struct ocp_device *ocpdev)
{
if (ocpdev)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_zmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed)
out_be32(&dev->base->ssr, ssr);
}

void __exit __zmii_fini(struct ocp_device *ocpdev, int input)
void __zmii_fini(struct ocp_device *ocpdev, int input)
{
struct ibm_ocp_zmii *dev = ocp_get_drvdata(ocpdev);
BUG_ON(!dev || dev->users == 0);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ibm_emac/ibm_emac_zmii.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ibm_ocp_zmii {
#ifdef CONFIG_IBM_EMAC_ZMII
int zmii_attach(void *emac) __init;

void __zmii_fini(struct ocp_device *ocpdev, int input) __exit;
void __zmii_fini(struct ocp_device *ocpdev, int input);
static inline void zmii_fini(struct ocp_device *ocpdev, int input)
{
if (ocpdev)
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/net/ixgb/ixgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ struct ixgb_adapter {
u16 msg_enable;
struct ixgb_hw_stats stats;
uint32_t alloc_rx_buff_failed;
#ifdef CONFIG_PCI_MSI
boolean_t have_msi;
#endif
};
#endif /* _IXGB_H_ */
36 changes: 15 additions & 21 deletions trunk/drivers/net/ixgb/ixgb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int
ixgb_up(struct ixgb_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
int err;
int err, irq_flags = IRQF_SHARED;
int max_frame = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
struct ixgb_hw *hw = &adapter->hw;

Expand All @@ -246,26 +246,21 @@ ixgb_up(struct ixgb_adapter *adapter)
/* disable interrupts and get the hardware into a known state */
IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);

#ifdef CONFIG_PCI_MSI
{
boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) &
IXGB_STATUS_PCIX_MODE) ? TRUE : FALSE;
adapter->have_msi = TRUE;

if (!pcix)
adapter->have_msi = FALSE;
else if((err = pci_enable_msi(adapter->pdev))) {
DPRINTK(PROBE, ERR,
"Unable to allocate MSI interrupt Error: %d\n", err);
adapter->have_msi = FALSE;
/* only enable MSI if bus is in PCI-X mode */
if (IXGB_READ_REG(&adapter->hw, STATUS) & IXGB_STATUS_PCIX_MODE) {
err = pci_enable_msi(adapter->pdev);
if (!err) {
adapter->have_msi = 1;
irq_flags = 0;
}
/* proceed to try to request regular interrupt */
}
}

#endif
if((err = request_irq(adapter->pdev->irq, &ixgb_intr,
IRQF_SHARED | IRQF_SAMPLE_RANDOM,
netdev->name, netdev))) {
err = request_irq(adapter->pdev->irq, &ixgb_intr, irq_flags,
netdev->name, netdev);
if (err) {
if (adapter->have_msi)
pci_disable_msi(adapter->pdev);
DPRINTK(PROBE, ERR,
"Unable to allocate interrupt Error: %d\n", err);
return err;
Expand Down Expand Up @@ -307,11 +302,10 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)

ixgb_irq_disable(adapter);
free_irq(adapter->pdev->irq, netdev);
#ifdef CONFIG_PCI_MSI
if(adapter->have_msi == TRUE)

if (adapter->have_msi)
pci_disable_msi(adapter->pdev);

#endif
if(kill_watchdog)
del_timer_sync(&adapter->watchdog_timer);
#ifdef CONFIG_IXGB_NAPI
Expand Down
Loading

0 comments on commit c3c207a

Please sign in to comment.