* [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver
@ 2008-04-21 21:20 wendy xiong
2008-04-22 0:14 ` Michael Chan
0 siblings, 1 reply; 8+ messages in thread
From: wendy xiong @ 2008-04-21 21:20 UTC (permalink / raw)
To: netdev, jeff, mchan
Hi
To enable EEH suuport for this pci-express adapter, we added 3 EEH
callback functions in the driver and also msi/pcie state needs to be
saved and restored for the adapter.
Thanks,
Wendy
Signed-off-by: Wendy Xiong <wendyx@us.ibm.com>
diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
--- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
+++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-18 22:28:42.000000000 -0500
@@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
}
pci_set_master(pdev);
+ pci_save_state(pdev);
bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
if (bp->pm_cap == 0) {
@@ -7617,6 +7618,85 @@ bnx2_resume(struct pci_dev *pdev)
return 0;
}
+/**
+ * bnx2_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci connection state
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected.
+ */
+static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
+ pci_channel_state_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ netif_device_detach(dev);
+
+ if (netif_running(dev)) {
+ bnx2_netif_stop(bp);
+ del_timer_sync(&bp->timer);
+ bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
+ }
+
+ pci_disable_device(pdev);
+
+ /* Request a slot slot reset. */
+ return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * bnx2_io_slot_reset - called after the pci bus has been reset.
+ * @pdev: Pointer to PCI device
+ *
+ * Restart the card from scratch, as if from a cold-boot.
+ */
+static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ if (pci_enable_device(pdev)) {
+ dev_err(&pdev->dev,
+ "Cannot re-enable PCI device after reset.\n");
+ return PCI_ERS_RESULT_DISCONNECT;
+ }
+ pci_set_master(pdev);
+ pci_restore_state(pdev);
+
+ if (netif_running(dev)) {
+ bnx2_set_power_state(bp, PCI_D0);
+ bnx2_init_nic(bp);
+ }
+
+ return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * bnx2_io_resume - called when traffic can start flowing again.
+ * @pdev: Pointer to PCI device
+ *
+ * This callback is called when the error recovery driver tells us that
+ * its OK to resume normal operation.
+ */
+static void bnx2_io_resume(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ if (netif_running(dev))
+ bnx2_netif_start(bp);
+
+ netif_device_attach(dev);
+}
+
+static struct pci_error_handlers bnx2_err_handler = {
+ .error_detected = bnx2_io_error_detected,
+ .slot_reset = bnx2_io_slot_reset,
+ .resume = bnx2_io_resume,
+};
+
static struct pci_driver bnx2_pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = bnx2_pci_tbl,
@@ -7624,6 +7704,7 @@ static struct pci_driver bnx2_pci_driver
.remove = __devexit_p(bnx2_remove_one),
.suspend = bnx2_suspend,
.resume = bnx2_resume,
+ .err_handler = &bnx2_err_handler,
};
static int __init bnx2_init(void)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver
2008-04-21 21:20 [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver wendy xiong
@ 2008-04-22 0:14 ` Michael Chan
2008-04-22 19:44 ` wendy xiong
0 siblings, 1 reply; 8+ messages in thread
From: Michael Chan @ 2008-04-22 0:14 UTC (permalink / raw)
To: wendy xiong; +Cc: netdev, jeff, davem
On Mon, 2008-04-21 at 16:20 -0500, wendy xiong wrote:
>
> diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
> --- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
> +++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-18 22:28:42.000000000 -0500
> @@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
> }
>
> pci_set_master(pdev);
> + pci_save_state(pdev);
>
> bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
> if (bp->pm_cap == 0) {
> @@ -7617,6 +7618,85 @@ bnx2_resume(struct pci_dev *pdev)
> return 0;
> }
>
> +/**
> + * bnx2_io_error_detected - called when PCI error is detected
> + * @pdev: Pointer to PCI device
> + * @state: The current pci connection state
> + *
> + * This function is called after a PCI bus error affecting
> + * this device has been detected.
> + */
> +static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
> + pci_channel_state_t state)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
I think it is better to add rtnl_lock() here to prevent racing with
other functions such as ethtool and close that can be resetting the
chip. The same should be done in the other 2 functions below.
> +
> + netif_device_detach(dev);
> +
> + if (netif_running(dev)) {
> + bnx2_netif_stop(bp);
> + del_timer_sync(&bp->timer);
> + bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
> + }
> +
> + pci_disable_device(pdev);
> +
Add rtnl_unlock() here.
> + /* Request a slot slot reset. */
> + return PCI_ERS_RESULT_NEED_RESET;
> +}
> +
> +/**
> + * bnx2_io_slot_reset - called after the pci bus has been reset.
> + * @pdev: Pointer to PCI device
> + *
> + * Restart the card from scratch, as if from a cold-boot.
> + */
> +static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
> +
> + if (pci_enable_device(pdev)) {
> + dev_err(&pdev->dev,
> + "Cannot re-enable PCI device after reset.\n");
> + return PCI_ERS_RESULT_DISCONNECT;
> + }
> + pci_set_master(pdev);
> + pci_restore_state(pdev);
> +
> + if (netif_running(dev)) {
> + bnx2_set_power_state(bp, PCI_D0);
> + bnx2_init_nic(bp);
> + }
> +
> + return PCI_ERS_RESULT_RECOVERED;
> +}
> +
> +/**
> + * bnx2_io_resume - called when traffic can start flowing again.
> + * @pdev: Pointer to PCI device
> + *
> + * This callback is called when the error recovery driver tells us that
> + * its OK to resume normal operation.
> + */
> +static void bnx2_io_resume(struct pci_dev *pdev)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
> +
> + if (netif_running(dev))
> + bnx2_netif_start(bp);
> +
> + netif_device_attach(dev);
Shouldn't we attach first before netif_start?
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver
2008-04-22 0:14 ` Michael Chan
@ 2008-04-22 19:44 ` wendy xiong
2008-04-22 21:46 ` Michael Chan
0 siblings, 1 reply; 8+ messages in thread
From: wendy xiong @ 2008-04-22 19:44 UTC (permalink / raw)
To: Michael Chan; +Cc: netdev, jeff, davem
Hi Michael Chan,
Thanks for your comments!
>I think it is better to add rtnl_lock() here to prevent racing with
> other functions such as ethtool and close that can be resetting the
> chip. The same should be done in the other 2 functions below.
Yes. Most of network interface functions called by net/core/dev.c layer
which hold rtnl_lock()/rtcl_unlock(). We may need to add
rtnl_lock()/rtnl_unlcok() in those callback functions.
>Shouldn't we attach first before netif_start?
>From my understanding, network interface function dev->open will call
device driver's open function to initialize internal data structures and
enable interrupt, then driver starts the receive queue by calling
netif_start_queue.
Looks bnx2_netif_start() enables hardware interrupt and receive polling
interrupt. So I think we can do netif_device_attach after
bnx2_netif_start() according to dev->open route concept.
Thanks,
Wendy
On Mon, 2008-04-21 at 17:14 -0700, Michael Chan wrote:
> On Mon, 2008-04-21 at 16:20 -0500, wendy xiong wrote:
>
> >
> > diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
> > --- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
> > +++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-18 22:28:42.000000000 -0500
> > @@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
> > }
> >
> > pci_set_master(pdev);
> > + pci_save_state(pdev);
> >
> > bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
> > if (bp->pm_cap == 0) {
> > @@ -7617,6 +7618,85 @@ bnx2_resume(struct pci_dev *pdev)
> > return 0;
> > }
> >
> > +/**
> > + * bnx2_io_error_detected - called when PCI error is detected
> > + * @pdev: Pointer to PCI device
> > + * @state: The current pci connection state
> > + *
> > + * This function is called after a PCI bus error affecting
> > + * this device has been detected.
> > + */
> > +static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
> > + pci_channel_state_t state)
> > +{
> > + struct net_device *dev = pci_get_drvdata(pdev);
> > + struct bnx2 *bp = netdev_priv(dev);
>
> I think it is better to add rtnl_lock() here to prevent racing with
> other functions such as ethtool and close that can be resetting the
> chip. The same should be done in the other 2 functions below.
>
> > +
> > + netif_device_detach(dev);
> > +
> > + if (netif_running(dev)) {
> > + bnx2_netif_stop(bp);
> > + del_timer_sync(&bp->timer);
> > + bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
> > + }
> > +
> > + pci_disable_device(pdev);
> > +
>
> Add rtnl_unlock() here.
>
> > + /* Request a slot slot reset. */
> > + return PCI_ERS_RESULT_NEED_RESET;
> > +}
> > +
> > +/**
> > + * bnx2_io_slot_reset - called after the pci bus has been reset.
> > + * @pdev: Pointer to PCI device
> > + *
> > + * Restart the card from scratch, as if from a cold-boot.
> > + */
> > +static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
> > +{
> > + struct net_device *dev = pci_get_drvdata(pdev);
> > + struct bnx2 *bp = netdev_priv(dev);
> > +
> > + if (pci_enable_device(pdev)) {
> > + dev_err(&pdev->dev,
> > + "Cannot re-enable PCI device after reset.\n");
> > + return PCI_ERS_RESULT_DISCONNECT;
> > + }
> > + pci_set_master(pdev);
> > + pci_restore_state(pdev);
> > +
> > + if (netif_running(dev)) {
> > + bnx2_set_power_state(bp, PCI_D0);
> > + bnx2_init_nic(bp);
> > + }
> > +
> > + return PCI_ERS_RESULT_RECOVERED;
> > +}
> > +
> > +/**
> > + * bnx2_io_resume - called when traffic can start flowing again.
> > + * @pdev: Pointer to PCI device
> > + *
> > + * This callback is called when the error recovery driver tells us that
> > + * its OK to resume normal operation.
> > + */
> > +static void bnx2_io_resume(struct pci_dev *pdev)
> > +{
> > + struct net_device *dev = pci_get_drvdata(pdev);
> > + struct bnx2 *bp = netdev_priv(dev);
> > +
> > + if (netif_running(dev))
> > + bnx2_netif_start(bp);
> > +
> > + netif_device_attach(dev);
>
> Shouldn't we attach first before netif_start?
>
> Thanks.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver
2008-04-22 19:44 ` wendy xiong
@ 2008-04-22 21:46 ` Michael Chan
2008-04-23 20:36 ` [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending wendy xiong
0 siblings, 1 reply; 8+ messages in thread
From: Michael Chan @ 2008-04-22 21:46 UTC (permalink / raw)
To: wendy xiong; +Cc: netdev, jeff, David Miller
On Tue, 2008-04-22 at 14:44 -0500, wendy xiong wrote:
> >Shouldn't we attach first before netif_start?
>
> From my understanding, network interface function dev->open will call
> device driver's open function to initialize internal data structures
> and
> enable interrupt, then driver starts the receive queue by calling
> netif_start_queue.
>
> Looks bnx2_netif_start() enables hardware interrupt and receive
> polling
> interrupt. So I think we can do netif_device_attach after
> bnx2_netif_start() according to dev->open route concept.
>
I think it doesn't make a whole lot of difference either way, especially
if you hold the rtnl_lock(). But in the normal course of loading the
driver, the LINK_STATE_PRESENT bit gets set during ->probe() when the
driver calls register_netdev(). So it is attached before ->open().
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending
2008-04-22 21:46 ` Michael Chan
@ 2008-04-23 20:36 ` wendy xiong
2008-04-24 0:23 ` Michael Chan
2008-04-25 0:34 ` Michael Chan
0 siblings, 2 replies; 8+ messages in thread
From: wendy xiong @ 2008-04-23 20:36 UTC (permalink / raw)
To: Michael Chan; +Cc: netdev, jeff, David Miller
Hi Michael,
Thanks!
I am re-sending patch with rtnl_lock()/rtnl_unlock().
Thanks,
Wendy
diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
--- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
+++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-23 15:08:40.000000000 -0500
@@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
}
pci_set_master(pdev);
+ pci_save_state(pdev);
bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
if (bp->pm_cap == 0) {
@@ -7617,6 +7618,91 @@ bnx2_resume(struct pci_dev *pdev)
return 0;
}
+/**
+ * bnx2_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci connection state
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected.
+ */
+static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
+ pci_channel_state_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ netif_device_detach(dev);
+
+ if (netif_running(dev)) {
+ bnx2_netif_stop(bp);
+ del_timer_sync(&bp->timer);
+ bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
+ }
+
+ pci_disable_device(pdev);
+ rtnl_unlock();
+
+ /* Request a slot slot reset. */
+ return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * bnx2_io_slot_reset - called after the pci bus has been reset.
+ * @pdev: Pointer to PCI device
+ *
+ * Restart the card from scratch, as if from a cold-boot.
+ */
+static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ if (pci_enable_device(pdev)) {
+ dev_err(&pdev->dev,
+ "Cannot re-enable PCI device after reset.\n");
+ return PCI_ERS_RESULT_DISCONNECT;
+ }
+ pci_set_master(pdev);
+ pci_restore_state(pdev);
+
+ if (netif_running(dev)) {
+ bnx2_set_power_state(bp, PCI_D0);
+ bnx2_init_nic(bp);
+ }
+
+ rtnl_unlock();
+ return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * bnx2_io_resume - called when traffic can start flowing again.
+ * @pdev: Pointer to PCI device
+ *
+ * This callback is called when the error recovery driver tells us that
+ * its OK to resume normal operation.
+ */
+static void bnx2_io_resume(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ if (netif_running(dev))
+ bnx2_netif_start(bp);
+
+ netif_device_attach(dev);
+ rtnl_unlock();
+}
+
+static struct pci_error_handlers bnx2_err_handler = {
+ .error_detected = bnx2_io_error_detected,
+ .slot_reset = bnx2_io_slot_reset,
+ .resume = bnx2_io_resume,
+};
+
static struct pci_driver bnx2_pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = bnx2_pci_tbl,
@@ -7624,6 +7710,7 @@ static struct pci_driver bnx2_pci_driver
.remove = __devexit_p(bnx2_remove_one),
.suspend = bnx2_suspend,
.resume = bnx2_resume,
+ .err_handler = &bnx2_err_handler,
};
static int __init bnx2_init(void)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending
2008-04-23 20:36 ` [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending wendy xiong
@ 2008-04-24 0:23 ` Michael Chan
2008-04-24 15:37 ` wendy xiong
2008-04-25 0:34 ` Michael Chan
1 sibling, 1 reply; 8+ messages in thread
From: Michael Chan @ 2008-04-24 0:23 UTC (permalink / raw)
To: wendy xiong; +Cc: netdev, jeff, David Miller
On Wed, 2008-04-23 at 15:36 -0500, wendy xiong wrote:
> diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
> --- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
> +++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-23 15:08:40.000000000 -0500
> @@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
> }
>
> pci_set_master(pdev);
> + pci_save_state(pdev);
>
> bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
> if (bp->pm_cap == 0) {
> @@ -7617,6 +7618,91 @@ bnx2_resume(struct pci_dev *pdev)
> return 0;
> }
>
> +/**
> + * bnx2_io_error_detected - called when PCI error is detected
> + * @pdev: Pointer to PCI device
> + * @state: The current pci connection state
> + *
> + * This function is called after a PCI bus error affecting
> + * this device has been detected.
> + */
> +static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
> + pci_channel_state_t state)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
> +
> + rtnl_lock();
> + netif_device_detach(dev);
> +
> + if (netif_running(dev)) {
> + bnx2_netif_stop(bp);
> + del_timer_sync(&bp->timer);
> + bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
> + }
> +
> + pci_disable_device(pdev);
> + rtnl_unlock();
> +
> + /* Request a slot slot reset. */
> + return PCI_ERS_RESULT_NEED_RESET;
> +}
> +
> +/**
> + * bnx2_io_slot_reset - called after the pci bus has been reset.
> + * @pdev: Pointer to PCI device
> + *
> + * Restart the card from scratch, as if from a cold-boot.
> + */
> +static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
> +
> + rtnl_lock();
> + if (pci_enable_device(pdev)) {
> + dev_err(&pdev->dev,
> + "Cannot re-enable PCI device after reset.\n");
Need rtnl_unlock() here.
> + return PCI_ERS_RESULT_DISCONNECT;
> + }
> + pci_set_master(pdev);
> + pci_restore_state(pdev);
> +
> + if (netif_running(dev)) {
> + bnx2_set_power_state(bp, PCI_D0);
> + bnx2_init_nic(bp);
> + }
> +
> + rtnl_unlock();
> + return PCI_ERS_RESULT_RECOVERED;
> +}
> +
> +/**
> + * bnx2_io_resume - called when traffic can start flowing again.
> + * @pdev: Pointer to PCI device
> + *
> + * This callback is called when the error recovery driver tells us that
> + * its OK to resume normal operation.
> + */
> +static void bnx2_io_resume(struct pci_dev *pdev)
> +{
> + struct net_device *dev = pci_get_drvdata(pdev);
> + struct bnx2 *bp = netdev_priv(dev);
> +
> + rtnl_lock();
> + if (netif_running(dev))
> + bnx2_netif_start(bp);
> +
> + netif_device_attach(dev);
> + rtnl_unlock();
> +}
> +
> +static struct pci_error_handlers bnx2_err_handler = {
> + .error_detected = bnx2_io_error_detected,
> + .slot_reset = bnx2_io_slot_reset,
> + .resume = bnx2_io_resume,
> +};
> +
> static struct pci_driver bnx2_pci_driver = {
> .name = DRV_MODULE_NAME,
> .id_table = bnx2_pci_tbl,
> @@ -7624,6 +7710,7 @@ static struct pci_driver bnx2_pci_driver
> .remove = __devexit_p(bnx2_remove_one),
> .suspend = bnx2_suspend,
> .resume = bnx2_resume,
> + .err_handler = &bnx2_err_handler,
> };
>
> static int __init bnx2_init(void)
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending
2008-04-24 0:23 ` Michael Chan
@ 2008-04-24 15:37 ` wendy xiong
0 siblings, 0 replies; 8+ messages in thread
From: wendy xiong @ 2008-04-24 15:37 UTC (permalink / raw)
To: Michael Chan; +Cc: netdev, jeff, David Miller
Hi Michael,
Thanks!
Wendy
diff -Nuarp linux-2.6.25-rc9.orig/drivers/net/bnx2.c linux-2.6.25-rc9.eeh/drivers/net/bnx2.c
--- linux-2.6.25-rc9.orig/drivers/net/bnx2.c 2008-04-18 22:12:53.000000000 -0500
+++ linux-2.6.25-rc9.eeh/drivers/net/bnx2.c 2008-04-24 10:30:58.000000000 -0500
@@ -7108,6 +7108,7 @@ bnx2_init_board(struct pci_dev *pdev, st
}
pci_set_master(pdev);
+ pci_save_state(pdev);
bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
if (bp->pm_cap == 0) {
@@ -7617,6 +7618,92 @@ bnx2_resume(struct pci_dev *pdev)
return 0;
}
+/**
+ * bnx2_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci connection state
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected.
+ */
+static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
+ pci_channel_state_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ netif_device_detach(dev);
+
+ if (netif_running(dev)) {
+ bnx2_netif_stop(bp);
+ del_timer_sync(&bp->timer);
+ bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
+ }
+
+ pci_disable_device(pdev);
+ rtnl_unlock();
+
+ /* Request a slot slot reset. */
+ return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * bnx2_io_slot_reset - called after the pci bus has been reset.
+ * @pdev: Pointer to PCI device
+ *
+ * Restart the card from scratch, as if from a cold-boot.
+ */
+static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ if (pci_enable_device(pdev)) {
+ dev_err(&pdev->dev,
+ "Cannot re-enable PCI device after reset.\n");
+ rtnl_unlock();
+ return PCI_ERS_RESULT_DISCONNECT;
+ }
+ pci_set_master(pdev);
+ pci_restore_state(pdev);
+
+ if (netif_running(dev)) {
+ bnx2_set_power_state(bp, PCI_D0);
+ bnx2_init_nic(bp);
+ }
+
+ rtnl_unlock();
+ return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * bnx2_io_resume - called when traffic can start flowing again.
+ * @pdev: Pointer to PCI device
+ *
+ * This callback is called when the error recovery driver tells us that
+ * its OK to resume normal operation.
+ */
+static void bnx2_io_resume(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2 *bp = netdev_priv(dev);
+
+ rtnl_lock();
+ if (netif_running(dev))
+ bnx2_netif_start(bp);
+
+ netif_device_attach(dev);
+ rtnl_unlock();
+}
+
+static struct pci_error_handlers bnx2_err_handler = {
+ .error_detected = bnx2_io_error_detected,
+ .slot_reset = bnx2_io_slot_reset,
+ .resume = bnx2_io_resume,
+};
+
static struct pci_driver bnx2_pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = bnx2_pci_tbl,
@@ -7624,6 +7711,7 @@ static struct pci_driver bnx2_pci_driver
.remove = __devexit_p(bnx2_remove_one),
.suspend = bnx2_suspend,
.resume = bnx2_resume,
+ .err_handler = &bnx2_err_handler,
};
static int __init bnx2_init(void)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending
2008-04-23 20:36 ` [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending wendy xiong
2008-04-24 0:23 ` Michael Chan
@ 2008-04-25 0:34 ` Michael Chan
1 sibling, 0 replies; 8+ messages in thread
From: Michael Chan @ 2008-04-25 0:34 UTC (permalink / raw)
To: wendy xiong; +Cc: netdev, jeff, David Miller
On Wed, 2008-04-23 at 15:36 -0500, wendy xiong wrote:
> Hi Michael,
>
> Thanks!
> I am re-sending patch with rtnl_lock()/rtnl_unlock().
>
> Thanks,
> Wendy
>
Thanks. The patch is white-space damaged and won't apply the way it is.
I'll regenerate it and send it to DaveM when he opens up net-2.6.27
together with other patches in my queue. He has announced earlier that
net-2.6.26 is no longer accepting new features.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-04-24 23:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-21 21:20 [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2x driver wendy xiong
2008-04-22 0:14 ` Michael Chan
2008-04-22 19:44 ` wendy xiong
2008-04-22 21:46 ` Michael Chan
2008-04-23 20:36 ` [ PATCH 1/1 2.6.25-rc9] bnx2: Add EEH support in bnx2 driver - Resending wendy xiong
2008-04-24 0:23 ` Michael Chan
2008-04-24 15:37 ` wendy xiong
2008-04-25 0:34 ` Michael Chan
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).