* [PATCH -v2 1/4] PCI: Add class support in quirk handling
@ 2012-02-16 5:23 Yinghai Lu
0 siblings, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2012-02-16 5:23 UTC (permalink / raw)
To: Jesse Barnes; +Cc: linux-pci, linux-kernel, Yinghai Lu
Recently there is new support to make quirk calling will report duration time.
That will boot log get more print out with initcall_debug is specified.
Found a lot of quirks are calling for not related devices.
Reason is quirk frame do not support class handling. So quirk code have to
use PCI_ANY_ID for vendor/device and let quirk code itself to check class
inside the func.
The patch add class and cls_shift into struct pci_fixup.
Also update related macro to accept the class and shift.
-v2: fix v1 that left over of sparated patch.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/quirks.c | 12 ++++++-----
include/linux/pci.h | 53 ++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 49 insertions(+), 16 deletions(-)
Index: linux-2.6/drivers/pci/quirks.c
===================================================================
--- linux-2.6.orig/drivers/pci/quirks.c
+++ linux-2.6/drivers/pci/quirks.c
@@ -2961,17 +2961,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
struct pci_fixup *end)
{
- while (f < end) {
- if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
- (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
+ for (; f < end; f++)
+ if ((f->class == (u32) (dev->class >> f->cls_shift) ||
+ f->class == (u32) PCI_ANY_ID) &&
+ (f->vendor == dev->vendor ||
+ f->vendor == (u16) PCI_ANY_ID) &&
+ (f->device == dev->device ||
+ f->device == (u16) PCI_ANY_ID)) {
dev_dbg(&dev->dev, "calling %pF\n", f->hook);
if (initcall_debug)
do_one_fixup_debug(f->hook, dev);
else
f->hook(dev);
}
- f++;
- }
}
extern struct pci_fixup __start_pci_fixups_early[];
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1389,7 +1389,10 @@ static inline void pci_resource_to_user(
*/
struct pci_fixup {
- u16 vendor, device; /* You can use PCI_ANY_ID here of course */
+ u16 vendor; /* You can use PCI_ANY_ID here of course */
+ u16 device; /* You can use PCI_ANY_ID here of course */
+ u32 class; /* You can use PCI_ANY_ID here too */
+ unsigned int cls_shift; /* should be 0, 8, 16 */
void (*hook)(struct pci_dev *dev);
};
@@ -1404,30 +1407,58 @@ enum pci_fixup_pass {
};
/* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
- static const struct pci_fixup __pci_fixup_##name __used \
- __attribute__((__section__(#section))) = { vendor, device, hook };
+#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, c, cs, hook)\
+ static const struct pci_fixup const __pci_fixup_##name __used \
+ __attribute__((__section__(#section), aligned((sizeof(void *))))) \
+ = { vendor, device, c, cs, hook };
+
+#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
+ resume##vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
+ resume_early##vendor##device##hook, vendor, device, \
+ cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
+ suspend##vendor##device##hook, vendor, device, cls, clt, hook)
+
#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
- resume##vendor##device##hook, vendor, device, hook)
+ resume##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
- resume_early##vendor##device##hook, vendor, device, hook)
+ resume_early##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
- suspend##vendor##device##hook, vendor, device, hook)
+ suspend##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#ifdef CONFIG_PCI_QUIRKS
void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH -v2 1/4] PCI: Add class support in quirk handling
2012-02-16 5:40 [PATCH 0/4] PCI: quirk related clean up Yinghai Lu
@ 2012-02-16 5:40 ` Yinghai Lu
2012-02-23 20:44 ` Jesse Barnes
0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2012-02-16 5:40 UTC (permalink / raw)
To: Jesse Barnes; +Cc: linux-pci, linux-kernel, Yinghai Lu
Recently there is new support to make quirk calling will report duration time.
That will boot log get more print out with initcall_debug is specified.
Found a lot of quirks are calling for not related devices.
Reason is quirk frame do not support class handling. So quirk code have to
use PCI_ANY_ID for vendor/device and let quirk code itself to check class
inside the func.
The patch add class and cls_shift into struct pci_fixup.
Also update related macro to accept the class and shift.
-v2: fix v1 that left over of sparated patch.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/quirks.c | 12 ++++++-----
include/linux/pci.h | 53 ++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 49 insertions(+), 16 deletions(-)
Index: linux-2.6/drivers/pci/quirks.c
===================================================================
--- linux-2.6.orig/drivers/pci/quirks.c
+++ linux-2.6/drivers/pci/quirks.c
@@ -2961,17 +2961,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN
static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
struct pci_fixup *end)
{
- while (f < end) {
- if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
- (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
+ for (; f < end; f++)
+ if ((f->class == (u32) (dev->class >> f->cls_shift) ||
+ f->class == (u32) PCI_ANY_ID) &&
+ (f->vendor == dev->vendor ||
+ f->vendor == (u16) PCI_ANY_ID) &&
+ (f->device == dev->device ||
+ f->device == (u16) PCI_ANY_ID)) {
dev_dbg(&dev->dev, "calling %pF\n", f->hook);
if (initcall_debug)
do_one_fixup_debug(f->hook, dev);
else
f->hook(dev);
}
- f++;
- }
}
extern struct pci_fixup __start_pci_fixups_early[];
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1377,7 +1377,10 @@ static inline void pci_resource_to_user(
*/
struct pci_fixup {
- u16 vendor, device; /* You can use PCI_ANY_ID here of course */
+ u16 vendor; /* You can use PCI_ANY_ID here of course */
+ u16 device; /* You can use PCI_ANY_ID here of course */
+ u32 class; /* You can use PCI_ANY_ID here too */
+ unsigned int cls_shift; /* should be 0, 8, 16 */
void (*hook)(struct pci_dev *dev);
};
@@ -1392,30 +1395,58 @@ enum pci_fixup_pass {
};
/* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
- static const struct pci_fixup __pci_fixup_##name __used \
- __attribute__((__section__(#section))) = { vendor, device, hook };
+#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, c, cs, hook)\
+ static const struct pci_fixup const __pci_fixup_##name __used \
+ __attribute__((__section__(#section), aligned((sizeof(void *))))) \
+ = { vendor, device, c, cs, hook };
+
+#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
+ vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
+ resume##vendor##device##hook, vendor, device, cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
+ resume_early##vendor##device##hook, vendor, device, \
+ cls, clt, hook)
+#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, cls, clt, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
+ suspend##vendor##device##hook, vendor, device, cls, clt, hook)
+
#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
- vendor##device##hook, vendor, device, hook)
+ vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
- resume##vendor##device##hook, vendor, device, hook)
+ resume##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
- resume_early##vendor##device##hook, vendor, device, hook)
+ resume_early##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
- suspend##vendor##device##hook, vendor, device, hook)
+ suspend##vendor##device##hook, vendor, device, \
+ PCI_ANY_ID, 0, hook)
#ifdef CONFIG_PCI_QUIRKS
void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -v2 1/4] PCI: Add class support in quirk handling
2012-02-16 5:40 ` [PATCH -v2 1/4] PCI: Add class support in quirk handling Yinghai Lu
@ 2012-02-23 20:44 ` Jesse Barnes
2012-02-24 6:40 ` Yinghai Lu
0 siblings, 1 reply; 4+ messages in thread
From: Jesse Barnes @ 2012-02-23 20:44 UTC (permalink / raw)
To: Yinghai Lu; +Cc: linux-pci, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
On Wed, 15 Feb 2012 21:40:29 -0800
Yinghai Lu <yinghai@kernel.org> wrote:
> Recently there is new support to make quirk calling will report duration time.
> That will boot log get more print out with initcall_debug is specified.
>
> Found a lot of quirks are calling for not related devices.
>
> Reason is quirk frame do not support class handling. So quirk code have to
> use PCI_ANY_ID for vendor/device and let quirk code itself to check class
> inside the func.
>
> The patch add class and cls_shift into struct pci_fixup.
> Also update related macro to accept the class and shift.
>
> -v2: fix v1 that left over of sparated patch.
I like this series, a few comments:
- class and class_shift everywhere (in pci_fixup {} and the new
macros) for readability
- split the individual quirk fixes into separate patches (makes it
easier to revert or identify if one breaks)
- the reassigndev patch looks like a good one independent of the
series
Thanks,
--
Jesse Barnes, Intel Open Source Technology Center
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -v2 1/4] PCI: Add class support in quirk handling
2012-02-23 20:44 ` Jesse Barnes
@ 2012-02-24 6:40 ` Yinghai Lu
0 siblings, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2012-02-24 6:40 UTC (permalink / raw)
To: Jesse Barnes; +Cc: linux-pci, linux-kernel
On Thu, Feb 23, 2012 at 12:44 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
>
> I like this series, a few comments:
> - class and class_shift everywhere (in pci_fixup {} and the new
> macros) for readability
ok.
> - split the individual quirk fixes into separate patches (makes it
> easier to revert or identify if one breaks)
yes
will send updated patches shortly.
> - the reassigndev patch looks like a good one independent of the
> series
yes, you can apply that separately.
Thanks
Yinghai
yes.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-24 6:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-16 5:23 [PATCH -v2 1/4] PCI: Add class support in quirk handling Yinghai Lu
-- strict thread matches above, loose matches on Subject: below --
2012-02-16 5:40 [PATCH 0/4] PCI: quirk related clean up Yinghai Lu
2012-02-16 5:40 ` [PATCH -v2 1/4] PCI: Add class support in quirk handling Yinghai Lu
2012-02-23 20:44 ` Jesse Barnes
2012-02-24 6:40 ` Yinghai Lu
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).