* [patch 08/18] 3c59x: check return of pci_enable_device()
@ 2007-08-10 21:05 akpm
2007-08-14 5:33 ` Jeff Garzik
2007-08-14 9:54 ` Mark Hindley
0 siblings, 2 replies; 10+ messages in thread
From: akpm @ 2007-08-10 21:05 UTC (permalink / raw)
To: jeff; +Cc: netdev, akpm, mark, klassert
From: Mark Hindley <mark@hindley.org.uk>
Check return of pci_enable_device in vortex_up().
Signed-off-by: Mark Hindley <mark@hindley.org.uk>
Acked-by: Steffen Klassert <klassert@mathematik.tu-chemnitz.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/net/3c59x.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff -puN drivers/net/3c59x.c~3c59x-check-return-of-pci_enable_device drivers/net/3c59x.c
--- a/drivers/net/3c59x.c~3c59x-check-return-of-pci_enable_device
+++ a/drivers/net/3c59x.c
@@ -1490,13 +1490,17 @@ vortex_up(struct net_device *dev)
struct vortex_private *vp = netdev_priv(dev);
void __iomem *ioaddr = vp->ioaddr;
unsigned int config;
- int i, mii_reg1, mii_reg5;
+ int i, mii_reg1, mii_reg5, err;
if (VORTEX_PCI(vp)) {
pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
if (vp->pm_state_valid)
pci_restore_state(VORTEX_PCI(vp));
- pci_enable_device(VORTEX_PCI(vp));
+ err = pci_enable_device(VORTEX_PCI(vp));
+ if (err) {
+ printk(KERN_WARNING "%s: Could not enable device \n",
+ dev->name);
+ }
}
/* Before initializing select the active media port. */
_
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 08/18] 3c59x: check return of pci_enable_device() 2007-08-10 21:05 [patch 08/18] 3c59x: check return of pci_enable_device() akpm @ 2007-08-14 5:33 ` Jeff Garzik 2007-08-14 9:54 ` Mark Hindley 1 sibling, 0 replies; 10+ messages in thread From: Jeff Garzik @ 2007-08-14 5:33 UTC (permalink / raw) To: akpm, mark; +Cc: netdev, klassert akpm@linux-foundation.org wrote: > From: Mark Hindley <mark@hindley.org.uk> > > Check return of pci_enable_device in vortex_up(). > > Signed-off-by: Mark Hindley <mark@hindley.org.uk> > Acked-by: Steffen Klassert <klassert@mathematik.tu-chemnitz.de> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org> > --- > > drivers/net/3c59x.c | 8 ++++++-- > 1 files changed, 6 insertions(+), 2 deletions(-) > > diff -puN drivers/net/3c59x.c~3c59x-check-return-of-pci_enable_device drivers/net/3c59x.c > --- a/drivers/net/3c59x.c~3c59x-check-return-of-pci_enable_device > +++ a/drivers/net/3c59x.c > @@ -1490,13 +1490,17 @@ vortex_up(struct net_device *dev) > struct vortex_private *vp = netdev_priv(dev); > void __iomem *ioaddr = vp->ioaddr; > unsigned int config; > - int i, mii_reg1, mii_reg5; > + int i, mii_reg1, mii_reg5, err; > > if (VORTEX_PCI(vp)) { > pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ > if (vp->pm_state_valid) > pci_restore_state(VORTEX_PCI(vp)); > - pci_enable_device(VORTEX_PCI(vp)); > + err = pci_enable_device(VORTEX_PCI(vp)); > + if (err) { > + printk(KERN_WARNING "%s: Could not enable device \n", > + dev->name); > + } I would strongly prefer that vortex_up return a value, since all the important callers of this function can themselves return an error back to the system. we can definitely return a meaningful return value here, if pci_enable_device() fails, and I would rather not apply a patch that fails to propagate a serious condition (pci_enable_device failure is indeed serious) when it is possible to do so ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 08/18] 3c59x: check return of pci_enable_device() 2007-08-10 21:05 [patch 08/18] 3c59x: check return of pci_enable_device() akpm 2007-08-14 5:33 ` Jeff Garzik @ 2007-08-14 9:54 ` Mark Hindley 2007-08-15 16:30 ` Steffen Klassert 1 sibling, 1 reply; 10+ messages in thread From: Mark Hindley @ 2007-08-14 9:54 UTC (permalink / raw) To: Jeff Garzik; +Cc: akpm, netdev, klassert On Tue, Aug 14, 2007 at 01:33:26AM -0400, Jeff Garzik wrote: > I would strongly prefer that vortex_up return a value, since all the > important callers of this function can themselves return an error back > to the system. > > we can definitely return a meaningful return value here, if > pci_enable_device() fails, and I would rather not apply a patch that > fails to propagate a serious condition (pci_enable_device failure is > indeed serious) when it is possible to do so > OK. Any comments on this revised version? I have only ignored the return of vortex_up in vortex_error. It is not immediately clear what to do if vortex_up still fails there after a pci reset. Mark diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 001c66d..a1dfd6b 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -705,7 +705,7 @@ static struct { static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, int chip_idx, int card_idx); -static void vortex_up(struct net_device *dev); +static int vortex_up(struct net_device *dev); static void vortex_down(struct net_device *dev, int final); static int vortex_open(struct net_device *dev); static void mdio_sync(void __iomem *ioaddr, int bits); @@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) return -EBUSY; } if (netif_running(dev)) { - vortex_up(dev); - netif_device_attach(dev); + err = vortex_up(dev); + if (err) + return err; + else + netif_device_attach(dev); } } return 0; @@ -1484,19 +1487,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init) } } -static void +static int vortex_up(struct net_device *dev) { struct vortex_private *vp = netdev_priv(dev); void __iomem *ioaddr = vp->ioaddr; unsigned int config; - int i, mii_reg1, mii_reg5; + int i, mii_reg1, mii_reg5, err; if (VORTEX_PCI(vp)) { pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ if (vp->pm_state_valid) pci_restore_state(VORTEX_PCI(vp)); - pci_enable_device(VORTEX_PCI(vp)); + err = pci_enable_device(VORTEX_PCI(vp)); + if (err) { + printk(KERN_WARNING "%s: Could not enable device \n", + dev->name); + goto err_out; + } } /* Before initializing select the active media port. */ @@ -1660,6 +1668,8 @@ vortex_up(struct net_device *dev) if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ iowrite32(0x8000, vp->cb_fn_base + 4); netif_start_queue (dev); +err_out: + return err; } static int @@ -1673,7 +1683,7 @@ vortex_open(struct net_device *dev) if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) { printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); - goto out; + goto err; } if (vp->full_bus_master_rx) { /* Boomerang bus master. */ @@ -1702,20 +1712,22 @@ vortex_open(struct net_device *dev) } } retval = -ENOMEM; - goto out_free_irq; + goto err_free_irq; } /* Wrap the ring. */ vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); } - vortex_up(dev); - return 0; + retval = vortex_up(dev); + if (!retval) + goto out; -out_free_irq: +err_free_irq: free_irq(dev->irq, dev); -out: +err: if (vortex_debug > 1) printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval); +out: return retval; } ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [patch 08/18] 3c59x: check return of pci_enable_device() 2007-08-14 9:54 ` Mark Hindley @ 2007-08-15 16:30 ` Steffen Klassert 2007-08-15 20:59 ` Steffen Klassert 2007-08-16 10:28 ` [REVISED PATCH] " Mark Hindley 0 siblings, 2 replies; 10+ messages in thread From: Steffen Klassert @ 2007-08-15 16:30 UTC (permalink / raw) To: Mark Hindley; +Cc: Jeff Garzik, akpm, netdev On Tue, Aug 14, 2007 at 10:54:32AM +0100, Mark Hindley wrote: > On Tue, Aug 14, 2007 at 01:33:26AM -0400, Jeff Garzik wrote: > > I would strongly prefer that vortex_up return a value, since all the > > important callers of this function can themselves return an error back > > to the system. > > > > we can definitely return a meaningful return value here, if > > pci_enable_device() fails, and I would rather not apply a patch that > > fails to propagate a serious condition (pci_enable_device failure is > > indeed serious) when it is possible to do so > > > > OK. Any comments on this revised version? I have only ignored the return of > vortex_up in vortex_error. It is not immediately clear what to do if > vortex_up still fails there after a pci reset. > > Mark > > > diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c > index 001c66d..a1dfd6b 100644 > --- a/drivers/net/3c59x.c > +++ b/drivers/net/3c59x.c > @@ -705,7 +705,7 @@ static struct { > > static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, > int chip_idx, int card_idx); > -static void vortex_up(struct net_device *dev); > +static int vortex_up(struct net_device *dev); > static void vortex_down(struct net_device *dev, int final); > static int vortex_open(struct net_device *dev); > static void mdio_sync(void __iomem *ioaddr, int bits); > @@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) > return -EBUSY; > } > if (netif_running(dev)) { > - vortex_up(dev); > - netif_device_attach(dev); > + err = vortex_up(dev); > + if (err) > + return err; > + else > + netif_device_attach(dev); > } > } > return 0; I think we should free the requested irq if vortex_up really fails here. Steffen ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 08/18] 3c59x: check return of pci_enable_device() 2007-08-15 16:30 ` Steffen Klassert @ 2007-08-15 20:59 ` Steffen Klassert 2007-08-16 10:28 ` [REVISED PATCH] " Mark Hindley 1 sibling, 0 replies; 10+ messages in thread From: Steffen Klassert @ 2007-08-15 20:59 UTC (permalink / raw) To: Mark Hindley; +Cc: Jeff Garzik, akpm, netdev On Wed, Aug 15, 2007 at 06:30:00PM +0200, Steffen Klassert wrote: > On Tue, Aug 14, 2007 at 10:54:32AM +0100, Mark Hindley wrote: > > On Tue, Aug 14, 2007 at 01:33:26AM -0400, Jeff Garzik wrote: > > > I would strongly prefer that vortex_up return a value, since all the > > > important callers of this function can themselves return an error back > > > to the system. > > > > > > we can definitely return a meaningful return value here, if > > > pci_enable_device() fails, and I would rather not apply a patch that > > > fails to propagate a serious condition (pci_enable_device failure is > > > indeed serious) when it is possible to do so > > > > > > > OK. Any comments on this revised version? I have only ignored the return of > > vortex_up in vortex_error. It is not immediately clear what to do if > > vortex_up still fails there after a pci reset. > > > > Mark > > > > > > diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c > > index 001c66d..a1dfd6b 100644 > > --- a/drivers/net/3c59x.c > > +++ b/drivers/net/3c59x.c > > @@ -705,7 +705,7 @@ static struct { > > > > static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, > > int chip_idx, int card_idx); > > -static void vortex_up(struct net_device *dev); > > +static int vortex_up(struct net_device *dev); > > static void vortex_down(struct net_device *dev, int final); > > static int vortex_open(struct net_device *dev); > > static void mdio_sync(void __iomem *ioaddr, int bits); > > @@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) > > return -EBUSY; > > } > > if (netif_running(dev)) { > > - vortex_up(dev); > > - netif_device_attach(dev); > > + err = vortex_up(dev); > > + if (err) > > + return err; > > + else > > + netif_device_attach(dev); > > } > > } > > return 0; > > I think we should free the requested irq if vortex_up really fails here. > I was wrong, this will be done in vortex_close. So it is OK as it is. Steffen ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [REVISED PATCH] 3c59x: check return of pci_enable_device() 2007-08-15 16:30 ` Steffen Klassert 2007-08-15 20:59 ` Steffen Klassert @ 2007-08-16 10:28 ` Mark Hindley 2007-08-31 13:08 ` Jeff Garzik 2007-08-31 13:32 ` Jeff Garzik 1 sibling, 2 replies; 10+ messages in thread From: Mark Hindley @ 2007-08-16 10:28 UTC (permalink / raw) To: Steffen Klassert; +Cc: Jeff Garzik, akpm, netdev Revised patch for this. Mark commit 5cf33391eba81a49038fa8be8cbad8425b80bf7f Author: Mark Hindley <mark@hindley.org.uk> Date: Thu Aug 16 11:26:35 2007 +0100 Check return of pci_enable_device in vortex_up(). Also modify vortex_up to return error to callers. Handle failure of vortex_up in vortex_open and vortex_resume. Signed-off-by: Mark Hindley <mark@hindley.org.uk> diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 001c66d..7b3050c 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -705,7 +705,7 @@ static struct { static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, int chip_idx, int card_idx); -static void vortex_up(struct net_device *dev); +static int vortex_up(struct net_device *dev); static void vortex_down(struct net_device *dev, int final); static int vortex_open(struct net_device *dev); static void mdio_sync(void __iomem *ioaddr, int bits); @@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) return -EBUSY; } if (netif_running(dev)) { - vortex_up(dev); - netif_device_attach(dev); + err = vortex_up(dev); + if (err) + return err; + else + netif_device_attach(dev); } } return 0; @@ -1484,19 +1487,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init) } } -static void +static int vortex_up(struct net_device *dev) { struct vortex_private *vp = netdev_priv(dev); void __iomem *ioaddr = vp->ioaddr; unsigned int config; - int i, mii_reg1, mii_reg5; + int i, mii_reg1, mii_reg5, err; if (VORTEX_PCI(vp)) { pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ if (vp->pm_state_valid) pci_restore_state(VORTEX_PCI(vp)); - pci_enable_device(VORTEX_PCI(vp)); + err = pci_enable_device(VORTEX_PCI(vp)); + if (err) { + printk(KERN_WARNING "%s: Could not enable device \n", + dev->name); + goto err_out; + } } /* Before initializing select the active media port. */ @@ -1660,6 +1668,8 @@ vortex_up(struct net_device *dev) if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ iowrite32(0x8000, vp->cb_fn_base + 4); netif_start_queue (dev); +err_out: + return err; } static int @@ -1673,7 +1683,7 @@ vortex_open(struct net_device *dev) if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) { printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); - goto out; + goto err; } if (vp->full_bus_master_rx) { /* Boomerang bus master. */ @@ -1702,20 +1712,22 @@ vortex_open(struct net_device *dev) } } retval = -ENOMEM; - goto out_free_irq; + goto err_free_irq; } /* Wrap the ring. */ vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); } - vortex_up(dev); - return 0; + retval = vortex_up(dev); + if (!retval) + goto out; -out_free_irq: +err_free_irq: free_irq(dev->irq, dev); -out: +err: if (vortex_debug > 1) printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval); +out: return retval; } ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [REVISED PATCH] 3c59x: check return of pci_enable_device() 2007-08-16 10:28 ` [REVISED PATCH] " Mark Hindley @ 2007-08-31 13:08 ` Jeff Garzik 2007-08-31 13:21 ` Steffen Klassert 2007-08-31 13:32 ` Jeff Garzik 1 sibling, 1 reply; 10+ messages in thread From: Jeff Garzik @ 2007-08-31 13:08 UTC (permalink / raw) To: Mark Hindley; +Cc: Steffen Klassert, akpm, netdev Mark Hindley wrote: > Revised patch for this. > > Mark > > > commit 5cf33391eba81a49038fa8be8cbad8425b80bf7f > Author: Mark Hindley <mark@hindley.org.uk> > Date: Thu Aug 16 11:26:35 2007 +0100 > > Check return of pci_enable_device in vortex_up(). > > Also modify vortex_up to return error to callers. Handle failure of vortex_up in > vortex_open and vortex_resume. > > Signed-off-by: Mark Hindley <mark@hindley.org.uk> Steffen, did you ACK this? and/or going to resend it to me? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [REVISED PATCH] 3c59x: check return of pci_enable_device() 2007-08-31 13:08 ` Jeff Garzik @ 2007-08-31 13:21 ` Steffen Klassert 2007-08-31 13:33 ` Jeff Garzik 0 siblings, 1 reply; 10+ messages in thread From: Steffen Klassert @ 2007-08-31 13:21 UTC (permalink / raw) To: Jeff Garzik; +Cc: Mark Hindley, akpm, netdev On Fri, Aug 31, 2007 at 09:08:37AM -0400, Jeff Garzik wrote: > Mark Hindley wrote: > >Revised patch for this. > > > >Mark > > > > > >commit 5cf33391eba81a49038fa8be8cbad8425b80bf7f > >Author: Mark Hindley <mark@hindley.org.uk> > >Date: Thu Aug 16 11:26:35 2007 +0100 > > > > Check return of pci_enable_device in vortex_up(). > > > > Also modify vortex_up to return error to callers. Handle failure of > > vortex_up in > > vortex_open and vortex_resume. > > > > Signed-off-by: Mark Hindley <mark@hindley.org.uk> > > Steffen, did you ACK this? and/or going to resend it to me? > Yes, I did. Andrew has it already in -mm, I guess that he will resend it to you soon. Steffen ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [REVISED PATCH] 3c59x: check return of pci_enable_device() 2007-08-31 13:21 ` Steffen Klassert @ 2007-08-31 13:33 ` Jeff Garzik 0 siblings, 0 replies; 10+ messages in thread From: Jeff Garzik @ 2007-08-31 13:33 UTC (permalink / raw) To: Steffen Klassert; +Cc: Mark Hindley, akpm, netdev Steffen Klassert wrote: >>> commit 5cf33391eba81a49038fa8be8cbad8425b80bf7f >>> Author: Mark Hindley <mark@hindley.org.uk> >>> Date: Thu Aug 16 11:26:35 2007 +0100 >>> >>> Check return of pci_enable_device in vortex_up(). >>> >>> Also modify vortex_up to return error to callers. Handle failure of >>> vortex_up in >>> vortex_open and vortex_resume. >>> >>> Signed-off-by: Mark Hindley <mark@hindley.org.uk> >> Steffen, did you ACK this? and/or going to resend it to me? > Yes, I did. Andrew has it already in -mm, > I guess that he will resend it to you soon. No need for a resend, I just wanted to make sure I wasn't stepping on your toes by applying this patch _instead of_ one that was going to be resent. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [REVISED PATCH] 3c59x: check return of pci_enable_device() 2007-08-16 10:28 ` [REVISED PATCH] " Mark Hindley 2007-08-31 13:08 ` Jeff Garzik @ 2007-08-31 13:32 ` Jeff Garzik 1 sibling, 0 replies; 10+ messages in thread From: Jeff Garzik @ 2007-08-31 13:32 UTC (permalink / raw) To: Mark Hindley; +Cc: Steffen Klassert, akpm, netdev Mark Hindley wrote: > Revised patch for this. > > Mark > > > commit 5cf33391eba81a49038fa8be8cbad8425b80bf7f > Author: Mark Hindley <mark@hindley.org.uk> > Date: Thu Aug 16 11:26:35 2007 +0100 > > Check return of pci_enable_device in vortex_up(). > > Also modify vortex_up to return error to callers. Handle failure of vortex_up in > vortex_open and vortex_resume. > > Signed-off-by: Mark Hindley <mark@hindley.org.uk> applied ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-08-31 13:33 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-08-10 21:05 [patch 08/18] 3c59x: check return of pci_enable_device() akpm 2007-08-14 5:33 ` Jeff Garzik 2007-08-14 9:54 ` Mark Hindley 2007-08-15 16:30 ` Steffen Klassert 2007-08-15 20:59 ` Steffen Klassert 2007-08-16 10:28 ` [REVISED PATCH] " Mark Hindley 2007-08-31 13:08 ` Jeff Garzik 2007-08-31 13:21 ` Steffen Klassert 2007-08-31 13:33 ` Jeff Garzik 2007-08-31 13:32 ` Jeff Garzik
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).