* [RFC PATCH] add pci_{request,free}_irq take #2
@ 2006-10-03 22:07 Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] move aic7xxx to pci_request_irq Frederik Deweerdt
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:07 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi all,
This is take #2 of the "add pci_{request,free}_irq" patch.
The following changes have been made since last proposal:
- fix broken kerneldoc (Randy Dunlap)
- change warning message (Alan Cox)
- taken into account the various comments made by Matthew Wilcox
- remove the IRQF_SHARED flag from the request_irq() call: not all
drivers (eg. tg3) set it (Arjan van de Ven suggested dropping it
before the call, but this may not suit the different usage patterns,
tg3 in particular)
I'll send a follow-up patch showing the implied modifications for the
following - semi-randomly chosen :) - drivers: aic7xxx, aic79xx, tg3
and e1000 (Dropped the drm one, which was NACKed by the maintainer).
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
PS: trimmed the CC list a bit, this must be noise to linux-scsi
PPS: used quilt to manage patches, I should have done it long ago :)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..50b49ef 100644
Index: 2.6.18-mm3/drivers/pci/pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/pci/pci.c
+++ 2.6.18-mm3/drivers/pci/pci.c
@@ -15,6 +15,7 @@
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/interrupt.h>
#include <linux/string.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"
@@ -810,6 +811,47 @@ err_out:
}
/**
+ * pci_request_irq - Reserve an IRQ for a PCI device
+ * @pdev: The PCI device whose irq is to be reserved
+ * @handler: The interrupt handler function,
+ * @flags: The flags to be passed to request_irq()
+ * @name: The name of the device to be associated with the irq
+ *
+ * Returns 0 on success, or a negative value on error. A warning
+ * message is also printed on failure.
+ * pci_get_drvdata(pdev) shall be passed as an argument to the @handler
+ * function
+ */
+int pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t(*handler) (int, void *, struct pt_regs *),
+ unsigned long flags, const char *name)
+{
+ if (!is_irq_valid(pdev->irq)) {
+ dev_printk(KERN_ERR, &pdev->dev,
+ "No usable irq line was found (got #%d)\n",
+ pdev->irq);
+ return -EINVAL;
+ }
+
+ return request_irq(pdev->irq, handler, flags,
+ name ? name : pdev->driver->name,
+ pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_request_irq);
+
+/**
+ * pci_free_irq - Free an IRQ for a PCI device
+ *
+ * @pdev: the PCI device whose interrupt is to be freed
+ * pci_get_drvdata(pdev) is used as the device identifier
+ */
+void pci_free_irq(struct pci_dev *pdev)
+{
+ free_irq(pdev->irq, pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_free_irq);
+
+/**
* pci_set_master - enables bus-mastering for device dev
* @dev: the PCI device to enable
*
Index: 2.6.18-mm3/include/linux/interrupt.h
===================================================================
--- 2.6.18-mm3.orig/include/linux/interrupt.h
+++ 2.6.18-mm3/include/linux/interrupt.h
@@ -75,6 +75,13 @@ struct irqaction {
struct proc_dir_entry *dir;
};
+#ifndef ARCH_VALIDATE_PCI_IRQ
+static inline int is_irq_valid(unsigned int irq)
+{
+ return irq ? 1 : 0;
+}
+#endif /* ARCH_VALIDATE_PCI_IRQ */
+
extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
extern int request_irq(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
Index: 2.6.18-mm3/include/linux/pci.h
===================================================================
--- 2.6.18-mm3.orig/include/linux/pci.h
+++ 2.6.18-mm3/include/linux/pci.h
@@ -52,6 +52,7 @@
#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/device.h>
+#include <linux/interrupt.h>
/* File state for mmap()s on /proc/bus/pci/X/Y */
enum pci_mmap_state {
@@ -532,6 +533,11 @@ void pci_release_regions(struct pci_dev
int __must_check pci_request_region(struct pci_dev *, int, const char *);
void pci_release_region(struct pci_dev *, int);
+int __must_check pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name);
+void pci_free_irq(struct pci_dev *pdev);
+
/* drivers/pci/bus.c */
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size,
^ permalink raw reply [flat|nested] 20+ messages in thread* [RFC PATCH] move aic7xxx to pci_request_irq
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
@ 2006-10-03 22:14 ` Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] add pci_{request,free}_irq take #2 Jeff Garzik
` (3 subsequent siblings)
4 siblings, 0 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:14 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi,
This proof-of-concept patch converts the aic7xxx driver to use the
pci_request_irq() function.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index 86ea7ac..24f70bc 100644
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_osm.h
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -561,7 +561,6 @@ static inline void ahc_linux_eisa_exit(v
int ahc_linux_pci_init(void);
void ahc_linux_pci_exit(void);
int ahc_pci_map_registers(struct ahc_softc *ahc);
-int ahc_pci_map_int(struct ahc_softc *ahc);
static __inline uint32_t ahc_pci_read_config(ahc_dev_softc_t pci,
int reg, int width);
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -368,16 +368,3 @@ ahc_pci_map_registers(struct ahc_softc *
return (error);
}
-int
-ahc_pci_map_int(struct ahc_softc *ahc)
-{
- int error;
-
- error = request_irq(ahc->dev_softc->irq, ahc_linux_isr,
- IRQF_SHARED, "aic7xxx", ahc);
- if (error == 0)
- ahc->platform_data->irq = ahc->dev_softc->irq;
-
- return (-error);
-}
-
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -968,13 +968,19 @@ ahc_pci_config(struct ahc_softc *ahc, st
/*
* Allow interrupts now that we are completely setup.
- */
- error = ahc_pci_map_int(ahc);
- if (error != 0)
- return (error);
+ *
+ * Note: pci_request_irq return value is negated due to aic7xxx
+ * error handling style
+ */
+ error = -pci_request_irq(ahc->dev_softc, ahc_linux_isr,
+ IRQF_SHARED, "aic7xxx");
+
+ if (!error) {
+ ahc->platform_data->irq = ahc->dev_softc->irq;
+ ahc->init_level++;
+ }
- ahc->init_level++;
- return (0);
+ return error;
}
/*
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] add pci_{request,free}_irq take #2
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] move aic7xxx to pci_request_irq Frederik Deweerdt
@ 2006-10-03 22:14 ` Jeff Garzik
2006-10-03 22:29 ` Frederik Deweerdt
2006-10-03 22:19 ` [RFC PATCH] move aic79xx to pci_request_irq Frederik Deweerdt
` (2 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Jeff Garzik @ 2006-10-03 22:14 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
Frederik Deweerdt wrote:
> +int pci_request_irq(struct pci_dev *pdev,
> + irqreturn_t(*handler) (int, void *, struct pt_regs *),
> + unsigned long flags, const char *name)
> +{
> + if (!is_irq_valid(pdev->irq)) {
> + dev_printk(KERN_ERR, &pdev->dev,
> + "No usable irq line was found (got #%d)\n",
> + pdev->irq);
> + return -EINVAL;
> + }
> +
> + return request_irq(pdev->irq, handler, flags,
> + name ? name : pdev->driver->name,
> + pci_get_drvdata(pdev));
> +}
> +EXPORT_SYMBOL(pci_request_irq);
> +void pci_free_irq(struct pci_dev *pdev)
> +{
> + free_irq(pdev->irq, pci_get_drvdata(pdev));
> +}
> +EXPORT_SYMBOL(pci_free_irq);
ACK these parts
> Index: 2.6.18-mm3/include/linux/interrupt.h
> ===================================================================
> --- 2.6.18-mm3.orig/include/linux/interrupt.h
> +++ 2.6.18-mm3/include/linux/interrupt.h
> @@ -75,6 +75,13 @@ struct irqaction {
> struct proc_dir_entry *dir;
> };
>
> +#ifndef ARCH_VALIDATE_PCI_IRQ
> +static inline int is_irq_valid(unsigned int irq)
> +{
> + return irq ? 1 : 0;
> +}
> +#endif /* ARCH_VALIDATE_PCI_IRQ */
It's not appropriate to have PCI IRQ stuff in linux/interrupt.h.
This is precisely why I passed 'struct pci_dev *' to a PCI-specific irq
validation function, and prototyped it in linux/pci.h.
Jeff
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] add pci_{request,free}_irq take #2
2006-10-03 22:14 ` [RFC PATCH] add pci_{request,free}_irq take #2 Jeff Garzik
@ 2006-10-03 22:29 ` Frederik Deweerdt
2006-10-03 22:37 ` Jeff Garzik
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:29 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
> >Index: 2.6.18-mm3/include/linux/interrupt.h
> >===================================================================
> >--- 2.6.18-mm3.orig/include/linux/interrupt.h
> >+++ 2.6.18-mm3/include/linux/interrupt.h
> >@@ -75,6 +75,13 @@ struct irqaction {
> > struct proc_dir_entry *dir;
> > };
> > +#ifndef ARCH_VALIDATE_PCI_IRQ
> >+static inline int is_irq_valid(unsigned int irq)
> >+{
> >+ return irq ? 1 : 0;
> >+}
> >+#endif /* ARCH_VALIDATE_PCI_IRQ */
>
> It's not appropriate to have PCI IRQ stuff in linux/interrupt.h.
>
> This is precisely why I passed 'struct pci_dev *' to a PCI-specific irq validation function, and prototyped it in linux/pci.h.
>
My bad, I've mixed your proposal and Matthew's, isn't this just a
matter of:
s/ARCH_VALIDATE_PCI_IRQ/ARCH_VALIDATE_IRQ/ ?
I'll look if there's some non-PCI code that might check the irq's value
and thus might benefit from this.
Regards,
Frederik
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] add pci_{request,free}_irq take #2
2006-10-03 22:29 ` Frederik Deweerdt
@ 2006-10-03 22:37 ` Jeff Garzik
2006-10-04 2:59 ` Matthew Wilcox
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Garzik @ 2006-10-03 22:37 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
Frederik Deweerdt wrote:
> My bad, I've mixed your proposal and Matthew's, isn't this just a
> matter of:
> s/ARCH_VALIDATE_PCI_IRQ/ARCH_VALIDATE_IRQ/ ?
>
> I'll look if there's some non-PCI code that might check the irq's value
> and thus might benefit from this.
The irq value comes from the PCI subsystem... The PCI subsystem should
validate it.
Jeff
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] add pci_{request,free}_irq take #2
2006-10-03 22:37 ` Jeff Garzik
@ 2006-10-04 2:59 ` Matthew Wilcox
0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2006-10-04 2:59 UTC (permalink / raw)
To: Jeff Garzik
Cc: Frederik Deweerdt, linux-kernel, arjan, alan, akpm, rdunlap,
gregkh
On Tue, Oct 03, 2006 at 06:37:12PM -0400, Jeff Garzik wrote:
> Frederik Deweerdt wrote:
> >My bad, I've mixed your proposal and Matthew's, isn't this just a
> >matter of:
> >s/ARCH_VALIDATE_PCI_IRQ/ARCH_VALIDATE_IRQ/ ?
> >
> >I'll look if there's some non-PCI code that might check the irq's value
> >and thus might benefit from this.
>
> The irq value comes from the PCI subsystem... The PCI subsystem should
> validate it.
That's not true. The value in the pci_dev->irq field has been changed
by the architecture. See, for example, pci_read_irq_line() in
arch/powerpc/kernel/pci_32.c. It's a Linux IRQ number, not a PCI IRQ
number.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH] move aic79xx to pci_request_irq
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] move aic7xxx to pci_request_irq Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] add pci_{request,free}_irq take #2 Jeff Garzik
@ 2006-10-03 22:19 ` Frederik Deweerdt
2006-10-03 22:22 ` [RFC PATCH] move tg3 " Frederik Deweerdt
2006-10-03 22:23 ` [RFC PATCH] move e1000 " Frederik Deweerdt
4 siblings, 0 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:19 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi,
This proof-of-concept patch converts the aic79xx driver to use the
pci_request_irq() function.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 448c39c..67897d4 100644
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_osm.h
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -594,7 +594,6 @@ void ahd_power_state_change(struct ahd_s
int ahd_linux_pci_init(void);
void ahd_linux_pci_exit(void);
int ahd_pci_map_registers(struct ahd_softc *ahd);
-int ahd_pci_map_int(struct ahd_softc *ahd);
static __inline uint32_t ahd_pci_read_config(ahd_dev_softc_t pci,
int reg, int width);
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -336,19 +336,6 @@ ahd_pci_map_registers(struct ahd_softc *
return (error);
}
-int
-ahd_pci_map_int(struct ahd_softc *ahd)
-{
- int error;
-
- error = request_irq(ahd->dev_softc->irq, ahd_linux_isr,
- IRQF_SHARED, "aic79xx", ahd);
- if (!error)
- ahd->platform_data->irq = ahd->dev_softc->irq;
-
- return (-error);
-}
-
void
ahd_power_state_change(struct ahd_softc *ahd, ahd_power_state new_state)
{
Index: 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ 2.6.18-mm3/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -376,10 +376,18 @@ ahd_pci_config(struct ahd_softc *ahd, st
/*
* Allow interrupts now that we are completely setup.
+ *
+ * Note: pci_request_irq return value is negated due to aic79xx
+ * error handling style
*/
- error = ahd_pci_map_int(ahd);
- if (!error)
+
+ error = -pci_request_irq(ahd->dev_softc, ahd_linux_isr,
+ IRQF_SHARED, "aic79xx");
+ if (!error) {
+ ahd->platform_data->irq = ahd->dev_softc->irq;
ahd->init_level++;
+ }
+
return error;
}
^ permalink raw reply [flat|nested] 20+ messages in thread* [RFC PATCH] move tg3 to pci_request_irq
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
` (2 preceding siblings ...)
2006-10-03 22:19 ` [RFC PATCH] move aic79xx to pci_request_irq Frederik Deweerdt
@ 2006-10-03 22:22 ` Frederik Deweerdt
2006-10-03 22:37 ` Jeff Garzik
2006-10-03 22:23 ` [RFC PATCH] move e1000 " Frederik Deweerdt
4 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:22 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi,
This proof-of-concept patch converts the tg3 driver to use the
pci_request_irq() function.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c25ba27..23660c6 100644
Index: 2.6.18-mm3/drivers/net/tg3.c
===================================================================
--- 2.6.18-mm3.orig/drivers/net/tg3.c
+++ 2.6.18-mm3/drivers/net/tg3.c
@@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
fn = tg3_interrupt_tagged;
flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
}
- return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
+ return pci_request_irq(tp->pdev, fn, flags, dev->name);
}
static int tg3_test_interrupt(struct tg3 *tp)
@@ -6866,10 +6866,10 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
- err = request_irq(tp->pdev->irq, tg3_test_isr,
- IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
+ err = pci_request_irq(tp->pdev, tg3_test_isr,
+ IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name);
if (err)
return err;
@@ -6897,7 +6897,7 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
err = tg3_request_irq(tp);
@@ -6915,7 +6915,6 @@ static int tg3_test_interrupt(struct tg3
*/
static int tg3_test_msi(struct tg3 *tp)
{
- struct net_device *dev = tp->dev;
int err;
u16 pci_cmd;
@@ -6946,7 +6945,7 @@ static int tg3_test_msi(struct tg3 *tp)
"the PCI maintainer and include system chipset information.\n",
tp->dev->name);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -6966,7 +6965,7 @@ static int tg3_test_msi(struct tg3 *tp)
tg3_full_unlock(tp);
if (err)
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
return err;
}
@@ -7051,7 +7050,7 @@ static int tg3_open(struct net_device *d
tg3_full_unlock(tp);
if (err) {
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -7363,7 +7362,7 @@ static int tg3_close(struct net_device *
tg3_full_unlock(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-03 22:22 ` [RFC PATCH] move tg3 " Frederik Deweerdt
@ 2006-10-03 22:37 ` Jeff Garzik
2006-10-03 22:41 ` Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Garzik @ 2006-10-03 22:37 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
Frederik Deweerdt wrote:
> Hi,
>
> This proof-of-concept patch converts the tg3 driver to use the
> pci_request_irq() function.
>
> Please note that I'm not submitting the driver changes, they're there
> only for illustration purposes. I'll CC the appropriate maintainers
> when/if an API is agreed upon.
>
> Regards,
> Frederik
>
> diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
> index c25ba27..23660c6 100644
> Index: 2.6.18-mm3/drivers/net/tg3.c
> ===================================================================
> --- 2.6.18-mm3.orig/drivers/net/tg3.c
> +++ 2.6.18-mm3/drivers/net/tg3.c
> @@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
> fn = tg3_interrupt_tagged;
> flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
> }
> - return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
> + return pci_request_irq(tp->pdev, fn, flags, dev->name);
> }
>
> static int tg3_test_interrupt(struct tg3 *tp)
> @@ -6866,10 +6866,10 @@ static int tg3_test_interrupt(struct tg3
>
> tg3_disable_ints(tp);
>
> - free_irq(tp->pdev->irq, dev);
> + pci_free_irq(tp->pdev);
>
> - err = request_irq(tp->pdev->irq, tg3_test_isr,
> - IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
> + err = pci_request_irq(tp->pdev, tg3_test_isr,
> + IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name);
IRQF_SHARED flags are still left hanging around...
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-03 22:37 ` Jeff Garzik
@ 2006-10-03 22:41 ` Frederik Deweerdt
2006-10-04 5:38 ` Jeff Garzik
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:41 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
On Tue, Oct 03, 2006 at 06:37:43PM -0400, Jeff Garzik wrote:
> Frederik Deweerdt wrote:
> >Hi,
> >This proof-of-concept patch converts the tg3 driver to use the
> >pci_request_irq() function.
> >Please note that I'm not submitting the driver changes, they're there
> >only for illustration purposes. I'll CC the appropriate maintainers
> >when/if an API is agreed upon.
> >Regards,
> >Frederik diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
> >index c25ba27..23660c6 100644
> >Index: 2.6.18-mm3/drivers/net/tg3.c
> >===================================================================
> >--- 2.6.18-mm3.orig/drivers/net/tg3.c
> >+++ 2.6.18-mm3/drivers/net/tg3.c
> >@@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
> > fn = tg3_interrupt_tagged;
> > flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
> > }
> >- return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
> >+ return pci_request_irq(tp->pdev, fn, flags, dev->name);
> > }
> > static int tg3_test_interrupt(struct tg3 *tp)
> >@@ -6866,10 +6866,10 @@ static int tg3_test_interrupt(struct tg3
> > tg3_disable_ints(tp);
> > - free_irq(tp->pdev->irq, dev);
> >+ pci_free_irq(tp->pdev);
> > - err = request_irq(tp->pdev->irq, tg3_test_isr,
> >- IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
> >+ err = pci_request_irq(tp->pdev, tg3_test_isr,
> >+ IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name);
>
> IRQF_SHARED flags are still left hanging around...
I did it on purpose (see parent post): some parts of tg3 for example
don't pass IRQF_SHARED, so I though it wasn't a good idea to enforce
IRQF_SHARED in all cases. Did I miss something?
Frederik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-03 22:41 ` Frederik Deweerdt
@ 2006-10-04 5:38 ` Jeff Garzik
2006-10-04 6:27 ` David Miller
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Garzik @ 2006-10-04 5:38 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
Frederik Deweerdt wrote:
> On Tue, Oct 03, 2006 at 06:37:43PM -0400, Jeff Garzik wrote:
>> Frederik Deweerdt wrote:
>>> Hi,
>>> This proof-of-concept patch converts the tg3 driver to use the
>>> pci_request_irq() function.
>>> Please note that I'm not submitting the driver changes, they're there
>>> only for illustration purposes. I'll CC the appropriate maintainers
>>> when/if an API is agreed upon.
>>> Regards,
>>> Frederik diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
>>> index c25ba27..23660c6 100644
>>> Index: 2.6.18-mm3/drivers/net/tg3.c
>>> ===================================================================
>>> --- 2.6.18-mm3.orig/drivers/net/tg3.c
>>> +++ 2.6.18-mm3/drivers/net/tg3.c
>>> @@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
>>> fn = tg3_interrupt_tagged;
>>> flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
>>> }
>>> - return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
>>> + return pci_request_irq(tp->pdev, fn, flags, dev->name);
>>> }
>>> static int tg3_test_interrupt(struct tg3 *tp)
>>> @@ -6866,10 +6866,10 @@ static int tg3_test_interrupt(struct tg3
>>> tg3_disable_ints(tp);
>>> - free_irq(tp->pdev->irq, dev);
>>> + pci_free_irq(tp->pdev);
>>> - err = request_irq(tp->pdev->irq, tg3_test_isr,
>>> - IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
>>> + err = pci_request_irq(tp->pdev, tg3_test_isr,
>>> + IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name);
>> IRQF_SHARED flags are still left hanging around...
> I did it on purpose (see parent post): some parts of tg3 for example
> don't pass IRQF_SHARED, so I though it wasn't a good idea to enforce
> IRQF_SHARED in all cases. Did I miss something?
When it's hardcoded into the definition of pci_request_irq(), then
setting the flag in the above code is logically superfluous.
As for why the flag may be missing -- PCI MSI interrupts are never
shared. However, it won't _hurt_ anything to set the flag needlessly,
AFAIK.
Jeff
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-04 5:38 ` Jeff Garzik
@ 2006-10-04 6:27 ` David Miller
2006-10-04 9:09 ` Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: David Miller @ 2006-10-04 6:27 UTC (permalink / raw)
To: jeff; +Cc: deweerdt, linux-kernel, arjan, matthew, alan, akpm, rdunlap,
gregkh
From: Jeff Garzik <jeff@garzik.org>
Date: Wed, 04 Oct 2006 01:38:31 -0400
> As for why the flag may be missing -- PCI MSI interrupts are never
> shared. However, it won't _hurt_ anything to set the flag needlessly,
> AFAIK.
That's right.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-04 6:27 ` David Miller
@ 2006-10-04 9:09 ` Frederik Deweerdt
0 siblings, 0 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-04 9:09 UTC (permalink / raw)
To: David Miller
Cc: jeff, linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
On Tue, Oct 03, 2006 at 11:27:48PM -0700, David Miller wrote:
> From: Jeff Garzik <jeff@garzik.org>
> Date: Wed, 04 Oct 2006 01:38:31 -0400
>
> > As for why the flag may be missing -- PCI MSI interrupts are never
> > shared. However, it won't _hurt_ anything to set the flag needlessly,
> > AFAIK.
>
> That's right.
Just to make sure I understood: does this means that the code at lines
296 and 297 in e1000_main.c can be safely removed?
296 if (adapter->have_msi)
297 flags &= ~IRQF_SHARED;
298 #endif
299 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
300 netdev->name, netdev)))
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH] move e1000 to pci_request_irq
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
` (3 preceding siblings ...)
2006-10-03 22:22 ` [RFC PATCH] move tg3 " Frederik Deweerdt
@ 2006-10-03 22:23 ` Frederik Deweerdt
2006-10-03 22:36 ` Jeff Garzik
4 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-03 22:23 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi,
This proof-of-concept patch converts the e1000 driver to use the
pci_request_irq() function.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 778ede3..8b7be73 100644
Index: 2.6.18-mm3/drivers/net/e1000/e1000_ethtool.c
===================================================================
--- 2.6.18-mm3.orig/drivers/net/e1000/e1000_ethtool.c
+++ 2.6.18-mm3/drivers/net/e1000/e1000_ethtool.c
@@ -899,17 +899,16 @@ e1000_intr_test(struct e1000_adapter *ad
{
struct net_device *netdev = adapter->netdev;
uint32_t mask, i=0, shared_int = TRUE;
- uint32_t irq = adapter->pdev->irq;
*data = 0;
/* NOTE: we don't test MSI interrupts here, yet */
/* Hook up test interrupt handler just for this test */
- if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED,
- netdev->name, netdev))
+ if (!pci_request_irq(adapter->pdev, &e1000_test_intr, IRQF_PROBE_SHARED,
+ netdev->name))
shared_int = FALSE;
- else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
- netdev->name, netdev)) {
+ else if (pci_request_irq(adapter->pdev, &e1000_test_intr, IRQF_SHARED,
+ netdev->name)) {
*data = 1;
return -1;
}
@@ -986,7 +985,7 @@ e1000_intr_test(struct e1000_adapter *ad
msleep(10);
/* Unhook test interrupt handler */
- free_irq(irq, netdev);
+ pci_free_irq(adapter->pdev);
return *data;
}
Index: 2.6.18-mm3/drivers/net/e1000/e1000_main.c
===================================================================
--- 2.6.18-mm3.orig/drivers/net/e1000/e1000_main.c
+++ 2.6.18-mm3/drivers/net/e1000/e1000_main.c
@@ -296,19 +296,13 @@ static int e1000_request_irq(struct e100
if (adapter->have_msi)
flags &= ~IRQF_SHARED;
#endif
- if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
- netdev->name, netdev)))
- DPRINTK(PROBE, ERR,
- "Unable to allocate interrupt Error: %d\n", err);
-
+ err = pci_request_irq(adapter->pdev, &e1000_intr, flags, netdev->name);
return err;
}
static void e1000_free_irq(struct e1000_adapter *adapter)
{
- struct net_device *netdev = adapter->netdev;
-
- free_irq(adapter->pdev->irq, netdev);
+ pci_free_irq(adapter->pdev);
#ifdef CONFIG_PCI_MSI
if (adapter->have_msi)
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] move e1000 to pci_request_irq
2006-10-03 22:23 ` [RFC PATCH] move e1000 " Frederik Deweerdt
@ 2006-10-03 22:36 ` Jeff Garzik
0 siblings, 0 replies; 20+ messages in thread
From: Jeff Garzik @ 2006-10-03 22:36 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: linux-kernel, arjan, matthew, alan, akpm, rdunlap, gregkh
Frederik Deweerdt wrote:
> + else if (pci_request_irq(adapter->pdev, &e1000_test_intr, IRQF_SHARED,
> + netdev->name)) {
doesn't need IRQF_SHARED flag anymore
^ permalink raw reply [flat|nested] 20+ messages in thread
* [RFC PATCH] add pci_{request,free}_irq take #3
@ 2006-10-04 19:32 Frederik Deweerdt
2006-10-04 19:46 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-04 19:32 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi all,
This is take #3 of the "add pci_{request,free}_irq" patch.
The following changes have been made since last proposal:
- add IRQF_SHARED systematically to the flags parameter. This is safe
even for MSI as seen here: http://lkml.org/lkml/2006/10/4/21
- remove IRQF_SHARED from tg3 and e1000
- s/ARCH_VALIDATE_PCI_IRQ/ARCH_VALIDATE_IRQ/ in
include/linux/interrupts.h, as the irq line may be tweaked outside
the pci subsystem in an arch specific way.
I'll send a follow-up patch showing the implied modifications for the
following drivers: aic7xxx, aic79xx, tg3 and e1000.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..50b49ef 100644
drivers/pci/pci.c | 42 ++++++++++++++++++++++++++++++++++++++++++
include/linux/interrupt.h | 7 +++++++
include/linux/pci.h | 6 ++++++
3 files changed, 55 insertions(+)
Index: 2.6.18-mm3/drivers/pci/pci.c
===================================================================
--- 2.6.18-mm3.orig/drivers/pci/pci.c
+++ 2.6.18-mm3/drivers/pci/pci.c
@@ -15,6 +15,7 @@
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/interrupt.h>
#include <linux/string.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"
@@ -810,6 +811,47 @@ err_out:
}
/**
+ * pci_request_irq - Reserve an IRQ for a PCI device
+ * @pdev: The PCI device whose irq is to be reserved
+ * @handler: The interrupt handler function,
+ * @flags: The flags to be passed to request_irq()
+ * @name: The name of the device to be associated with the irq
+ *
+ * Returns 0 on success, or a negative value on error. A warning
+ * message is also printed on failure.
+ * pci_get_drvdata(pdev) shall be passed as an argument to the @handler
+ * function
+ */
+int pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t(*handler) (int, void *, struct pt_regs *),
+ unsigned long flags, const char *name)
+{
+ if (!is_irq_valid(pdev->irq)) {
+ dev_printk(KERN_ERR, &pdev->dev,
+ "No usable irq line was found (got #%d)\n",
+ pdev->irq);
+ return -EINVAL;
+ }
+
+ return request_irq(pdev->irq, handler, flags | IRQF_SHARED,
+ name ? name : pdev->driver->name,
+ pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_request_irq);
+
+/**
+ * pci_free_irq - Free an IRQ for a PCI device
+ *
+ * @pdev: the PCI device whose interrupt is to be freed
+ * pci_get_drvdata(pdev) is used as the device identifier
+ */
+void pci_free_irq(struct pci_dev *pdev)
+{
+ free_irq(pdev->irq, pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_free_irq);
+
+/**
* pci_set_master - enables bus-mastering for device dev
* @dev: the PCI device to enable
*
Index: 2.6.18-mm3/include/linux/interrupt.h
===================================================================
--- 2.6.18-mm3.orig/include/linux/interrupt.h
+++ 2.6.18-mm3/include/linux/interrupt.h
@@ -75,6 +75,13 @@ struct irqaction {
struct proc_dir_entry *dir;
};
+#ifndef ARCH_VALIDATE_IRQ
+static inline int is_irq_valid(unsigned int irq)
+{
+ return irq ? 1 : 0;
+}
+#endif /* ARCH_VALIDATE_IRQ */
+
extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
extern int request_irq(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
Index: 2.6.18-mm3/include/linux/pci.h
===================================================================
--- 2.6.18-mm3.orig/include/linux/pci.h
+++ 2.6.18-mm3/include/linux/pci.h
@@ -52,6 +52,7 @@
#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/device.h>
+#include <linux/interrupt.h>
/* File state for mmap()s on /proc/bus/pci/X/Y */
enum pci_mmap_state {
@@ -532,6 +533,11 @@ void pci_release_regions(struct pci_dev
int __must_check pci_request_region(struct pci_dev *, int, const char *);
void pci_release_region(struct pci_dev *, int);
+int __must_check pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name);
+void pci_free_irq(struct pci_dev *pdev);
+
/* drivers/pci/bus.c */
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size,
^ permalink raw reply [flat|nested] 20+ messages in thread* [RFC PATCH] move tg3 to pci_request_irq
2006-10-04 19:32 [RFC PATCH] add pci_{request,free}_irq take #3 Frederik Deweerdt
@ 2006-10-04 19:46 ` Frederik Deweerdt
0 siblings, 0 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-04 19:46 UTC (permalink / raw)
To: linux-kernel; +Cc: arjan, matthew, alan, jeff, akpm, rdunlap, gregkh
Hi,
This proof-of-concept patch converts the tg3 driver to use the
pci_request_irq() function.
Please note that I'm not submitting the driver changes, they're there
only for illustration purposes. I'll CC the appropriate maintainers
when/if an API is agreed upon.
Regards,
Frederik
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c25ba27..23660c6 100644
drivers/net/tg3.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
Index: 2.6.18-mm3/drivers/net/tg3.c
===================================================================
--- 2.6.18-mm3.orig/drivers/net/tg3.c
+++ 2.6.18-mm3/drivers/net/tg3.c
@@ -6839,21 +6839,18 @@ restart_timer:
static int tg3_request_irq(struct tg3 *tp)
{
irqreturn_t (*fn)(int, void *, struct pt_regs *);
- unsigned long flags;
struct net_device *dev = tp->dev;
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
fn = tg3_msi;
if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI)
fn = tg3_msi_1shot;
- flags = IRQF_SAMPLE_RANDOM;
} else {
fn = tg3_interrupt;
if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
fn = tg3_interrupt_tagged;
- flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
}
- return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
+ return pci_request_irq(tp->pdev, fn, IRQF_SAMPLE_RANDOM, dev->name);
}
static int tg3_test_interrupt(struct tg3 *tp)
@@ -6866,10 +6863,10 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
- err = request_irq(tp->pdev->irq, tg3_test_isr,
- IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
+ err = pci_request_irq(tp->pdev, tg3_test_isr,
+ IRQF_SAMPLE_RANDOM, dev->name);
if (err)
return err;
@@ -6897,7 +6894,7 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
err = tg3_request_irq(tp);
@@ -6915,7 +6912,6 @@ static int tg3_test_interrupt(struct tg3
*/
static int tg3_test_msi(struct tg3 *tp)
{
- struct net_device *dev = tp->dev;
int err;
u16 pci_cmd;
@@ -6946,7 +6942,7 @@ static int tg3_test_msi(struct tg3 *tp)
"the PCI maintainer and include system chipset information.\n",
tp->dev->name);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -6966,7 +6962,7 @@ static int tg3_test_msi(struct tg3 *tp)
tg3_full_unlock(tp);
if (err)
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
return err;
}
@@ -7051,7 +7047,7 @@ static int tg3_open(struct net_device *d
tg3_full_unlock(tp);
if (err) {
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -7363,7 +7359,7 @@ static int tg3_close(struct net_device *
tg3_full_unlock(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: 2.6.18-mm2
@ 2006-09-29 17:15 Alan Cox
2006-09-29 23:50 ` 2.6.18-mm2 Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Alan Cox @ 2006-09-29 17:15 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: J.A. Magall??n, Andrew Morton, Linux-Kernel,, linux-scsi
Ar Gwe, 2006-09-29 am 08:39 -0600, ysgrifennodd Matthew Wilcox:
> On Fri, Sep 29, 2006 at 03:57:38PM +0200, J.A. Magall??n wrote:
> > aic7xxx oopses on boot:
> >
> > PCI: Setting latency timer of device 0000:00:0e.0 to 64
> > IRQ handler type mismatch for IRQ 0
>
> Of course, this isn't a scsi problem, it's a peecee hardware problem.
> Or maybe a PCI subsystem problem. But it's clearly not aic7xxx's fault.
AIC7xxx finding it has no IRQ configured is valid (annoying, stupid and
valid) so the driver should check before requesting "no IRQ"
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: 2.6.18-mm2
2006-09-29 17:15 2.6.18-mm2 Alan Cox
@ 2006-09-29 23:50 ` Frederik Deweerdt
2006-09-29 23:43 ` 2.6.18-mm2 Alan Cox
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-09-29 23:50 UTC (permalink / raw)
To: Alan Cox
Cc: Matthew Wilcox, J.A. Magall??n, Andrew Morton, Linux-Kernel,,
linux-scsi
On Fri, Sep 29, 2006 at 06:15:42PM +0100, Alan Cox wrote:
> Ar Gwe, 2006-09-29 am 08:39 -0600, ysgrifennodd Matthew Wilcox:
> > On Fri, Sep 29, 2006 at 03:57:38PM +0200, J.A. Magall??n wrote:
> > > aic7xxx oopses on boot:
> > >
> > > PCI: Setting latency timer of device 0000:00:0e.0 to 64
> > > IRQ handler type mismatch for IRQ 0
> >
> > Of course, this isn't a scsi problem, it's a peecee hardware problem.
> > Or maybe a PCI subsystem problem. But it's clearly not aic7xxx's fault.
>
> AIC7xxx finding it has no IRQ configured is valid (annoying, stupid and
> valid) so the driver should check before requesting "no IRQ"
>
Alan,
Does this patch makes sense in that case? If yes, I'll put up a patch
for the remaining cases in the drivers/scsi/aic7xxx/ directory.
Also, aic7xxx's coding style would put parenthesis around the returned
value, should I follow it?
Regards,
Frederik
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index ea5687d..38f5ca7 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -185,6 +185,9 @@ ahc_linux_pci_dev_probe(struct pci_dev *
int error;
struct device *dev = &pdev->dev;
+ if (!pdev->irq)
+ return -ENODEV;
+
pci = pdev;
entry = ahc_find_pci_device(pci);
if (entry == NULL)
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: 2.6.18-mm2
2006-09-29 23:50 ` 2.6.18-mm2 Frederik Deweerdt
@ 2006-09-29 23:43 ` Alan Cox
2006-09-30 14:09 ` [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2) Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Alan Cox @ 2006-09-29 23:43 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: Matthew Wilcox, J.A. Magall??n, Andrew Morton, Linux-Kernel,,
linux-scsi
Ar Gwe, 2006-09-29 am 23:50 +0000, ysgrifennodd Frederik Deweerdt:
> Does this patch makes sense in that case? If yes, I'll put up a patch
> for the remaining cases in the drivers/scsi/aic7xxx/ directory.
> Also, aic7xxx's coding style would put parenthesis around the returned
> value, should I follow it?
Yes - but perhaps with a warning message so users know why ?
As to coding style - kernel style is unbracketed so I wouldnt worry
about either.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-09-29 23:43 ` 2.6.18-mm2 Alan Cox
@ 2006-09-30 14:09 ` Frederik Deweerdt
2006-09-30 23:58 ` Jeff Garzik
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-09-30 14:09 UTC (permalink / raw)
To: Alan Cox
Cc: Matthew Wilcox, J.A. Magall??n, Andrew Morton, Linux-Kernel,,
linux-scsi
On Sat, Sep 30, 2006 at 12:43:24AM +0100, Alan Cox wrote:
> Ar Gwe, 2006-09-29 am 23:50 +0000, ysgrifennodd Frederik Deweerdt:
> > Does this patch makes sense in that case? If yes, I'll put up a patch
> > for the remaining cases in the drivers/scsi/aic7xxx/ directory.
> > Also, aic7xxx's coding style would put parenthesis around the returned
> > value, should I follow it?
>
> Yes - but perhaps with a warning message so users know why ?
>
> As to coding style - kernel style is unbracketed so I wouldnt worry
> about either.
>
Thanks for the advices.
The following patch checks whenever the irq is valid before issuing a
request_irq() for AIC7XXX and AIC79XX. An error message is displayed to
let the user know what went wrong.
Regards,
Frederik
Signed-off-by: Frederik Deweerdt <frederik.deweerdt@gmail.com>
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 2001fe8..8279122 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -132,6 +132,11 @@ ahd_linux_pci_dev_probe(struct pci_dev *
char *name;
int error;
+ if (!pdev->irq) {
+ printk(KERN_WARNING "aic79xx: No irq line set\n");
+ return -ENODEV;
+ }
+
pci = pdev;
entry = ahd_find_pci_device(pci);
if (entry == NULL)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index ea5687d..ca61cdb 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -185,6 +185,11 @@ ahc_linux_pci_dev_probe(struct pci_dev *
int error;
struct device *dev = &pdev->dev;
+ if (!pdev->irq) {
+ printk(KERN_WARNING "aic7xxx: No irq line set\n");
+ return -ENODEV;
+ }
+
pci = pdev;
entry = ahc_find_pci_device(pci);
if (entry == NULL)
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-09-30 14:09 ` [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2) Frederik Deweerdt
@ 2006-09-30 23:58 ` Jeff Garzik
2006-10-01 14:28 ` Matthew Wilcox
0 siblings, 1 reply; 20+ messages in thread
From: Jeff Garzik @ 2006-09-30 23:58 UTC (permalink / raw)
To: Frederik Deweerdt, Andrew Morton
Cc: Alan Cox, Matthew Wilcox, J.A. Magall??n, Linux-Kernel,,
linux-scsi
[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]
Frederik Deweerdt wrote:
> On Sat, Sep 30, 2006 at 12:43:24AM +0100, Alan Cox wrote:
>> Ar Gwe, 2006-09-29 am 23:50 +0000, ysgrifennodd Frederik Deweerdt:
>>> Does this patch makes sense in that case? If yes, I'll put up a patch
>>> for the remaining cases in the drivers/scsi/aic7xxx/ directory.
>>> Also, aic7xxx's coding style would put parenthesis around the returned
>>> value, should I follow it?
>> Yes - but perhaps with a warning message so users know why ?
>>
>> As to coding style - kernel style is unbracketed so I wouldnt worry
>> about either.
>>
> Thanks for the advices.
>
> The following patch checks whenever the irq is valid before issuing a
> request_irq() for AIC7XXX and AIC79XX. An error message is displayed to
> let the user know what went wrong.
>
> Regards,
> Frederik
>
> Signed-off-by: Frederik Deweerdt <frederik.deweerdt@gmail.com>
Actually, rather than adding this check to every driver, I would rather
do something like the attached patch: create a pci_request_irq(), and
pass a struct pci_device to it. Then the driver author doesn't have to
worry about such details.
Jeff
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2025 bytes --]
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..9743471 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -809,6 +809,40 @@ err_out:
return -EBUSY;
}
+#ifndef ARCH_VALIDATE_PCI_IRQ
+int pci_valid_irq(struct pci_dev *pdev)
+{
+ if (pdev->irq == 0)
+ return -EINVAL;
+
+ return 0;
+}
+EXPORT_SYMBOL(pci_valid_irq);
+#endif /* ARCH_VALIDATE_PCI_IRQ */
+
+int pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name, void *userdata)
+{
+ int rc;
+
+ rc = pci_valid_irq(pdev);
+ if (rc) {
+ dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
+ return rc;
+ }
+
+ return request_irq(pdev->irq, handler, flags | IRQF_SHARED,
+ name, userdata);
+}
+EXPORT_SYMBOL(pci_request_irq);
+
+void pci_release_irq(struct pci_dev *pdev, void *userdata)
+{
+ free_irq(pdev->irq, userdata);
+}
+EXPORT_SYMBOL(pci_release_irq);
+
/**
* pci_set_master - enables bus-mastering for device dev
* @dev: the PCI device to enable
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5c3a417..5e254fc 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -52,6 +52,7 @@ #include <linux/list.h>
#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/device.h>
+#include <linux/interrupt.h>
/* File state for mmap()s on /proc/bus/pci/X/Y */
enum pci_mmap_state {
@@ -537,6 +538,12 @@ void pci_release_regions(struct pci_dev
int __must_check pci_request_region(struct pci_dev *, int, const char *);
void pci_release_region(struct pci_dev *, int);
+int __must_check pci_valid_irq(struct pci_dev *pdev);
+int __must_check pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name, void *userdata);
+void pci_release_irq(struct pci_dev *pdev, void *userdata);
+
/* drivers/pci/bus.c */
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size,
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-09-30 23:58 ` Jeff Garzik
@ 2006-10-01 14:28 ` Matthew Wilcox
2006-10-01 19:05 ` Arjan van de Ven
0 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox @ 2006-10-01 14:28 UTC (permalink / raw)
To: Jeff Garzik
Cc: Frederik Deweerdt, Andrew Morton, Alan Cox, J.A. Magall??n,
Linux-Kernel,, linux-scsi
On Sat, Sep 30, 2006 at 07:58:18PM -0400, Jeff Garzik wrote:
> Actually, rather than adding this check to every driver, I would rather
> do something like the attached patch: create a pci_request_irq(), and
> pass a struct pci_device to it. Then the driver author doesn't have to
> worry about such details.
I like pci_request_irq(), but pci_valid_irq is bad.
> +#ifndef ARCH_VALIDATE_PCI_IRQ
> +int pci_valid_irq(struct pci_dev *pdev)
> +{
> + if (pdev->irq == 0)
> + return -EINVAL;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(pci_valid_irq);
> +#endif /* ARCH_VALIDATE_PCI_IRQ */
Better would be:
#ifndef ARCH_VALIDATE_IRQ
static inline int valid_irq(unsigned int irq)
{
return irq ? 1 : 0;
}
#endif
in linux/interrupt.h (around request_irq).
And it doesn't need to be a __must_check. There's no point -- it has
no side-effects. The only reason to call it is if you want the answer
to the question. You had the sense of the return code wrong too; you
want to use it as:
int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
unsigned long flags, const char *name, void *data)
{
if (!valid_irq(pdev->irq)) {
dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
return -EINVAL;
}
return request_irq(pdev->irq, handler, flags | IRQF_SHARED, name, data);
}
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-10-01 14:28 ` Matthew Wilcox
@ 2006-10-01 19:05 ` Arjan van de Ven
2006-10-01 19:36 ` Matthew Wilcox
0 siblings, 1 reply; 20+ messages in thread
From: Arjan van de Ven @ 2006-10-01 19:05 UTC (permalink / raw)
To: Matthew Wilcox
Cc: linux-scsi, Linux-Kernel,, J.A. Magall??n, Alan Cox,
Andrew Morton, Frederik Deweerdt, Jeff Garzik
> .
>
> And it doesn't need to be a __must_check. There's no point -- it has
> no side-effects. The only reason to call it is if you want the answer
> to the question. You had the sense of the return code wrong too; you
> want to use it as:
>
> int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
> unsigned long flags, const char *name, void *data)
> {
> if (!valid_irq(pdev->irq)) {
> dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
> return -EINVAL;
> }
>
> return request_irq(pdev->irq, handler, flags | IRQF_SHARED, name, data);
> }
well... why not go one step further and eliminate the flags argument
entirely? And use pci_name() for the name (so eliminate the argument ;)
and always pass pdev as data, so that that argument can go away too....
that'll cover 99% of the request_irq() users for pci devices.. and makes
it really nicely simple and consistent.
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-10-01 19:05 ` Arjan van de Ven
@ 2006-10-01 19:36 ` Matthew Wilcox
2006-10-02 2:12 ` Arjan van de Ven
0 siblings, 1 reply; 20+ messages in thread
From: Matthew Wilcox @ 2006-10-01 19:36 UTC (permalink / raw)
To: Arjan van de Ven
Cc: linux-scsi, Linux-Kernel,, J.A. Magall??n, Alan Cox,
Andrew Morton, Frederik Deweerdt, Jeff Garzik
On Sun, Oct 01, 2006 at 09:05:23PM +0200, Arjan van de Ven wrote:
> > int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
> > unsigned long flags, const char *name, void *data)
> > {
> > if (!valid_irq(pdev->irq)) {
> > dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
> > return -EINVAL;
> > }
> >
> > return request_irq(pdev->irq, handler, flags | IRQF_SHARED, name, data);
> > }
>
> well... why not go one step further and eliminate the flags argument
> entirely? And use pci_name() for the name (so eliminate the argument ;)
> and always pass pdev as data, so that that argument can go away too....
>
> that'll cover 99% of the request_irq() users for pci devices.. and makes
> it really nicely simple and consistent.
hmm. $ echo `cut -c34- /proc/interrupts`
timer i8042 cascade acpi yenta, ehci_hcd:usb1, Intel 82801DB-ICH4 yenta,
uhci_hcd:usb2 uhci_hcd:usb4, eth0 ide0 uhci_hcd:usb3, eth1
Network drivers use their eth%d name. USB drivers use [eu]hci_hcd:usb%d.
Others tend to use the driver name. Changing them all to be 0000:00:1d.2
isn't really an improvement in the readability of /proc/interrupts, IMO.
Passing pdev as the data is a good idea for practically no device driver.
It's rare to actually want the pci_device down in the interrupt handler;
normally you want the device private data. Using pci_get_drvdata(pdev)
as the data would make sense for both sym2 and tg3. I don't feel like
auditing other drivers to see if it'd make sense for them too.
So, current proposal:
int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
const char *name)
{
if (!valid_irq(pdev->irq)) {
dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
return -EINVAL;
}
return request_irq(pdev->irq, handler, IRQF_SHARED, name,
pci_get_drvdata(pdev));
}
But what about IRQF_SAMPLE_RANDOM?
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)
2006-10-01 19:36 ` Matthew Wilcox
@ 2006-10-02 2:12 ` Arjan van de Ven
2006-10-02 20:00 ` [RFC PATCH] pci_request_irq (was [-mm patch] aic7xxx: check irq validity) Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Arjan van de Ven @ 2006-10-02 2:12 UTC (permalink / raw)
To: Matthew Wilcox
Cc: linux-scsi, Linux-Kernel,, J.A. Magall??n, Alan Cox,
Andrew Morton, Frederik Deweerdt, Jeff Garzik
> Network drivers use their eth%d name. USB drivers use [eu]hci_hcd:usb%d.
> Others tend to use the driver name. Changing them all to be 0000:00:1d.2
> isn't really an improvement in the readability of /proc/interrupts, IMO.
hmm ok; how about allowing name to be NULL, and if it's NULL, use the
pci name?
>
> So, current proposal:
>
> int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
> const char *name)
> {
> if (!valid_irq(pdev->irq)) {
> dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
> return -EINVAL;
> }
>
> return request_irq(pdev->irq, handler, IRQF_SHARED, name,
> pci_get_drvdata(pdev));
> }
>
> But what about IRQF_SAMPLE_RANDOM?
that's a tough question. I'd almost suggest making such things
properties of the pdev, but sample-random is so far away from PCI
related that it makes no sense I suppose ;(
(others do I think)
One other interesting question is if this function can/should be used to
use MSI transparently (after pci_enable_msi() obviously)
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
^ permalink raw reply [flat|nested] 20+ messages in thread* [RFC PATCH] pci_request_irq (was [-mm patch] aic7xxx: check irq validity)
2006-10-02 2:12 ` Arjan van de Ven
@ 2006-10-02 20:00 ` Frederik Deweerdt
2006-10-02 20:11 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
0 siblings, 1 reply; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-02 20:00 UTC (permalink / raw)
To: Arjan van de Ven
Cc: Matthew Wilcox, linux-scsi, Linux-Kernel,, J.A. Magall??n,
Alan Cox, Andrew Morton, Jeff Garzik
Hi all,
I've tried to summarize the different proposals made by Jeff Garzik,
Matthew Wilcox and Arjan van de Ven in the "[-mm patch] aic7xxx: check
irq validity" thread. I've also added:
- some kerneldoc
- renamed valid_irq to is_irq_valid()
- added pci_release_irq().
I'll send a follow-up patch showing the implied modifications for the
following - semi-randomly chosen :) - drivers: aic7xxx, aic79xx, tg3
and drm.
Regards,
Frederik
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997..ae20a3a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -15,6 +15,7 @@ #include <linux/init.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/interrupt.h>
#include <linux/string.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"
@@ -810,6 +811,49 @@ err_out:
}
/**
+ * pci_request_irq - Reserve an IRQ for a PCI device
+ * @pdev: The PCI device whose irq is to be reserved
+ * handler: The interrupt handler function,
+ * pci_get_drvdata(pdev) shall be passed as an argument to that function
+ * @flags: The flags to be passed to request_irq()
+ * @name: The name of the device to be associated with the irq
+ *
+ * Returns 0 on success, or a negative value on error. A warning
+ * message is also printed on failure.
+ */
+int pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name)
+{
+ int rc;
+ const char *actual_name = name;
+
+ rc = is_irq_valid(pdev->irq);
+ if (!rc) {
+ dev_printk(KERN_ERR, &pdev->dev, "invalid irq #%d\n", pdev->irq);
+ return -EINVAL;
+ }
+
+ if (!actual_name)
+ actual_name = pci_name(pdev);
+
+ return request_irq(pdev->irq, handler, flags | IRQF_SHARED,
+ actual_name, pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_request_irq);
+
+/**
+ * pci_free_irq - releases the interrupt line reserved to the PCI
+ * device pointed by @pdev
+ * @pdev: the PCI device whose interrupt is to be freed
+ */
+void pci_free_irq(struct pci_dev *pdev)
+{
+ free_irq(pdev->irq, pci_get_drvdata(pdev));
+}
+EXPORT_SYMBOL(pci_free_irq);
+
+/**
* pci_set_master - enables bus-mastering for device dev
* @dev: the PCI device to enable
*
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 1f97e3d..c320b50 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -75,6 +75,13 @@ struct irqaction {
struct proc_dir_entry *dir;
};
+#ifndef ARCH_VALIDATE_PCI_IRQ
+static inline int is_irq_valid(unsigned int irq)
+{
+ return irq ? 1 : 0;
+}
+#endif /* ARCH_VALIDATE_PCI_IRQ */
+
extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
extern int request_irq(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5bc4659..5e0f07a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -52,6 +52,7 @@ #include <linux/list.h>
#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/device.h>
+#include <linux/interrupt.h>
/* File state for mmap()s on /proc/bus/pci/X/Y */
enum pci_mmap_state {
@@ -531,6 +532,11 @@ void pci_release_regions(struct pci_dev
int __must_check pci_request_region(struct pci_dev *, int, const char *);
void pci_release_region(struct pci_dev *, int);
+int __must_check pci_request_irq(struct pci_dev *pdev,
+ irqreturn_t (*handler)(int, void *, struct pt_regs *),
+ unsigned long flags, const char *name);
+void pci_free_irq(struct pci_dev *pdev);
+
/* drivers/pci/bus.c */
int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
struct resource *res, resource_size_t size,
^ permalink raw reply related [flat|nested] 20+ messages in thread* [RFC PATCH] move tg3 to pci_request_irq
2006-10-02 20:00 ` [RFC PATCH] pci_request_irq (was [-mm patch] aic7xxx: check irq validity) Frederik Deweerdt
@ 2006-10-02 20:11 ` Frederik Deweerdt
2006-10-02 18:28 ` Matthew Wilcox
2006-10-03 7:18 ` Arjan van de Ven
0 siblings, 2 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-02 20:11 UTC (permalink / raw)
To: Arjan van de Ven
Cc: Matthew Wilcox, linux-scsi, Linux-Kernel,, J.A. Magall??n,
Alan Cox, Andrew Morton, Jeff Garzik
Hi,
This proof-of-concept patch converts the tg3 driver to use the
pci_request_irq() function.
Regards,
Frederik
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c25ba27..23660c6 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -6838,9 +6838,9 @@ restart_timer:
static int tg3_request_irq(struct tg3 *tp)
{
+ struct net_device *dev = tp->dev;
irqreturn_t (*fn)(int, void *, struct pt_regs *);
unsigned long flags;
- struct net_device *dev = tp->dev;
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
fn = tg3_msi;
@@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
fn = tg3_interrupt_tagged;
flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
}
- return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
+ return pci_request_irq(tp->pdev, fn, flags, dev->name);
}
static int tg3_test_interrupt(struct tg3 *tp)
@@ -6866,10 +6866,10 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
- err = request_irq(tp->pdev->irq, tg3_test_isr,
- IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
+ err = pci_request_irq(tp->pdev, tg3_test_isr,
+ IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name);
if (err)
return err;
@@ -6897,7 +6897,7 @@ static int tg3_test_interrupt(struct tg3
tg3_disable_ints(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
err = tg3_request_irq(tp);
@@ -6915,7 +6915,6 @@ static int tg3_test_interrupt(struct tg3
*/
static int tg3_test_msi(struct tg3 *tp)
{
- struct net_device *dev = tp->dev;
int err;
u16 pci_cmd;
@@ -6946,7 +6945,7 @@ static int tg3_test_msi(struct tg3 *tp)
"the PCI maintainer and include system chipset information.\n",
tp->dev->name);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -6966,7 +6965,7 @@ static int tg3_test_msi(struct tg3 *tp)
tg3_full_unlock(tp);
if (err)
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
return err;
}
@@ -7051,7 +7050,7 @@ static int tg3_open(struct net_device *d
tg3_full_unlock(tp);
if (err) {
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
@@ -7363,7 +7362,7 @@ #endif
tg3_full_unlock(tp);
- free_irq(tp->pdev->irq, dev);
+ pci_free_irq(tp->pdev);
if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
pci_disable_msi(tp->pdev);
tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-02 20:11 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
@ 2006-10-02 18:28 ` Matthew Wilcox
2006-10-02 21:04 ` Frederik Deweerdt
2006-10-03 7:18 ` Arjan van de Ven
1 sibling, 1 reply; 20+ messages in thread
From: Matthew Wilcox @ 2006-10-02 18:28 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: Arjan van de Ven, linux-scsi, Linux-Kernel,, J.A. Magall??n,
Alan Cox, Andrew Morton, Jeff Garzik
On Mon, Oct 02, 2006 at 08:11:34PM +0000, Frederik Deweerdt wrote:
> @@ -6838,9 +6838,9 @@ restart_timer:
>
> static int tg3_request_irq(struct tg3 *tp)
> {
> + struct net_device *dev = tp->dev;
> irqreturn_t (*fn)(int, void *, struct pt_regs *);
> unsigned long flags;
> - struct net_device *dev = tp->dev;
>
> if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
> fn = tg3_msi;
Is there any reason for this noise?
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-02 18:28 ` Matthew Wilcox
@ 2006-10-02 21:04 ` Frederik Deweerdt
0 siblings, 0 replies; 20+ messages in thread
From: Frederik Deweerdt @ 2006-10-02 21:04 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Arjan van de Ven, linux-scsi, Linux-Kernel,, J.A. Magall??n,
Alan Cox, Andrew Morton, Jeff Garzik
On Mon, Oct 02, 2006 at 12:28:47PM -0600, Matthew Wilcox wrote:
> On Mon, Oct 02, 2006 at 08:11:34PM +0000, Frederik Deweerdt wrote:
> > @@ -6838,9 +6838,9 @@ restart_timer:
> >
> > static int tg3_request_irq(struct tg3 *tp)
> > {
> > + struct net_device *dev = tp->dev;
> > irqreturn_t (*fn)(int, void *, struct pt_regs *);
> > unsigned long flags;
> > - struct net_device *dev = tp->dev;
> >
> > if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
> > fn = tg3_msi;
>
> Is there any reason for this noise?
You mean, besides my awkwardness ? ;)
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [RFC PATCH] move tg3 to pci_request_irq
2006-10-02 20:11 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
2006-10-02 18:28 ` Matthew Wilcox
@ 2006-10-03 7:18 ` Arjan van de Ven
1 sibling, 0 replies; 20+ messages in thread
From: Arjan van de Ven @ 2006-10-03 7:18 UTC (permalink / raw)
To: Frederik Deweerdt
Cc: Matthew Wilcox, linux-scsi, Linux-Kernel,, J.A. Magall??n,
Alan Cox, Andrew Morton, Jeff Garzik
On Mon, 2006-10-02 at 20:11 +0000, Frederik Deweerdt wrote:
> Hi,
>
> This proof-of-concept patch converts the tg3 driver to use the
> pci_request_irq() function.
>
> Regards,
> Frederik
>
>
> diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
> index c25ba27..23660c6 100644
> --- a/drivers/net/tg3.c
> +++ b/drivers/net/tg3.c
> @@ -6838,9 +6838,9 @@ restart_timer:
>
> static int tg3_request_irq(struct tg3 *tp)
> {
> + struct net_device *dev = tp->dev;
> irqreturn_t (*fn)(int, void *, struct pt_regs *);
> unsigned long flags;
> - struct net_device *dev = tp->dev;
>
> if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
> fn = tg3_msi;
> @@ -6853,7 +6853,7 @@ static int tg3_request_irq(struct tg3 *t
> fn = tg3_interrupt_tagged;
> flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
> }
> - return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
> + return pci_request_irq(tp->pdev, fn, flags, dev->name);
since pci_request_irq sets IRQF_SHARED... might as well drop that above.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2006-10-04 19:46 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 22:07 [RFC PATCH] add pci_{request,free}_irq take #2 Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] move aic7xxx to pci_request_irq Frederik Deweerdt
2006-10-03 22:14 ` [RFC PATCH] add pci_{request,free}_irq take #2 Jeff Garzik
2006-10-03 22:29 ` Frederik Deweerdt
2006-10-03 22:37 ` Jeff Garzik
2006-10-04 2:59 ` Matthew Wilcox
2006-10-03 22:19 ` [RFC PATCH] move aic79xx to pci_request_irq Frederik Deweerdt
2006-10-03 22:22 ` [RFC PATCH] move tg3 " Frederik Deweerdt
2006-10-03 22:37 ` Jeff Garzik
2006-10-03 22:41 ` Frederik Deweerdt
2006-10-04 5:38 ` Jeff Garzik
2006-10-04 6:27 ` David Miller
2006-10-04 9:09 ` Frederik Deweerdt
2006-10-03 22:23 ` [RFC PATCH] move e1000 " Frederik Deweerdt
2006-10-03 22:36 ` Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2006-10-04 19:32 [RFC PATCH] add pci_{request,free}_irq take #3 Frederik Deweerdt
2006-10-04 19:46 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
2006-09-29 17:15 2.6.18-mm2 Alan Cox
2006-09-29 23:50 ` 2.6.18-mm2 Frederik Deweerdt
2006-09-29 23:43 ` 2.6.18-mm2 Alan Cox
2006-09-30 14:09 ` [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2) Frederik Deweerdt
2006-09-30 23:58 ` Jeff Garzik
2006-10-01 14:28 ` Matthew Wilcox
2006-10-01 19:05 ` Arjan van de Ven
2006-10-01 19:36 ` Matthew Wilcox
2006-10-02 2:12 ` Arjan van de Ven
2006-10-02 20:00 ` [RFC PATCH] pci_request_irq (was [-mm patch] aic7xxx: check irq validity) Frederik Deweerdt
2006-10-02 20:11 ` [RFC PATCH] move tg3 to pci_request_irq Frederik Deweerdt
2006-10-02 18:28 ` Matthew Wilcox
2006-10-02 21:04 ` Frederik Deweerdt
2006-10-03 7:18 ` Arjan van de Ven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox