diff mbox

[1/2] PCI: Do not use PCI ID macros in quirk names

Message ID 1384177236-8371-1-git-send-email-mmarek@suse.cz
State Accepted
Headers show

Commit Message

Michal Marek Nov. 11, 2013, 1:40 p.m. UTC
Pasting the verbatim PCI_(VENDOR|DEVICE)_* macros in the __pci_fixup_*
symbol names results in insanely long names such as

__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt

When LTO adds its numeric suffix to such symbol, it overflows the
namebuf[KSYM_NAME_LEN] array. Use the line number instead to create
(nearly) unique symbol names.

Reported-by: Joe Mario <jmario@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Joe Mario <jmario@redhat.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 include/linux/pci.h | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Comments

Michal Marek Nov. 12, 2013, 8:40 a.m. UTC | #1
On 11.11.2013 14:40, Michal Marek wrote:
> Pasting the verbatim PCI_(VENDOR|DEVICE)_* macros in the __pci_fixup_*
> symbol names results in insanely long names such as
> 
> __pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt
> 
> When LTO adds its numeric suffix to such symbol, it overflows the
> namebuf[KSYM_NAME_LEN] array. Use the line number instead to create

"... the namebuf[KSYM_NAME_LEN] array in kernel/kallsyms.c."

That way, the changelog is hopefully more clear.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas Nov. 25, 2013, 10:18 p.m. UTC | #2
On Tue, Nov 12, 2013 at 1:40 AM, Michal Marek <mmarek@suse.cz> wrote:
> On 11.11.2013 14:40, Michal Marek wrote:
>> Pasting the verbatim PCI_(VENDOR|DEVICE)_* macros in the __pci_fixup_*
>> symbol names results in insanely long names such as
>>
>> __pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt
>>
>> When LTO adds its numeric suffix to such symbol, it overflows the
>> namebuf[KSYM_NAME_LEN] array. Use the line number instead to create
>
> "... the namebuf[KSYM_NAME_LEN] array in kernel/kallsyms.c."

What's LTO?  I guess it's Link Time Optimization?  Is there any
documentation about how it works or how to use it?

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andi Kleen Nov. 25, 2013, 11:02 p.m. UTC | #3
> What's LTO?  I guess it's Link Time Optimization?  Is there any

Yes. Link Time Optimization with modern gcc.

> documentation about how it works or how to use it?

It's still a separate tree, but bits'n'pieces are slowly
making it into the kernel.

https://github.com/andikleen/linux-misc/tree/lto-3.12

https://github.com/andikleen/linux-misc/blob/5a18e33264321b01816a220ab14207a5f26ae16e/Documentation/lto-build

http://halobates.de/kernel-lto.pdf

-Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas Nov. 25, 2013, 11:06 p.m. UTC | #4
On Mon, Nov 11, 2013 at 6:40 AM, Michal Marek <mmarek@suse.cz> wrote:
> Pasting the verbatim PCI_(VENDOR|DEVICE)_* macros in the __pci_fixup_*
> symbol names results in insanely long names such as
>
> __pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt
>
> When LTO adds its numeric suffix to such symbol, it overflows the
> namebuf[KSYM_NAME_LEN] array. Use the line number instead to create
> (nearly) unique symbol names.
>
> Reported-by: Joe Mario <jmario@redhat.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-pci@vger.kernel.org
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Joe Mario <jmario@redhat.com>
> Signed-off-by: Michal Marek <mmarek@suse.cz>

Applied to my for-linus branch for v3.13, thanks.

> ---
>  include/linux/pci.h | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index da172f9..1ff4dec 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1557,65 +1557,65 @@ enum pci_fixup_pass {
>  /* Anonymous variables would be nice... */
>  #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class,        \
>                                   class_shift, hook)                    \
> -       static const struct pci_fixup __pci_fixup_##name __used         \
> +       static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used       \
>         __attribute__((__section__(#section), aligned((sizeof(void *)))))    \
>                 = { vendor, device, class, class_shift, hook };
>
>  #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class,           \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,                     \
> -               vendor##device##hook, vendor, device, class, class_shift, hook)
> +               hook, vendor, device, class, class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class,          \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header,                    \
> -               vendor##device##hook, vendor, device, class, class_shift, hook)
> +               hook, vendor, device, class, class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class,           \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final,                     \
> -               vendor##device##hook, vendor, device, class, class_shift, hook)
> +               hook, vendor, device, class, class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class,          \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,                    \
> -               vendor##device##hook, vendor, device, class, class_shift, hook)
> +               hook, vendor, device, class, class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class,          \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume,                    \
> -               resume##vendor##device##hook, vendor, device, class,    \
> +               resume##hook, vendor, device, class,    \
>                 class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class,    \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early,              \
> -               resume_early##vendor##device##hook, vendor, device,     \
> +               resume_early##hook, vendor, device,     \
>                 class, class_shift, hook)
>  #define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class,         \
>                                          class_shift, hook)             \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend,                   \
> -               suspend##vendor##device##hook, vendor, device, class,   \
> +               suspend##hook, vendor, device, class,   \
>                 class_shift, hook)
>
>  #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook)                  \
>         DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,                     \
> -               vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
> +               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, PCI_ANY_ID, 0, hook)
> +               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, PCI_ANY_ID, 0, hook)
> +               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, PCI_ANY_ID, 0, hook)
> +               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,           \
> +               resume##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,     \
> +               resume_early##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,          \
> +               suspend##hook, vendor, device,          \
>                 PCI_ANY_ID, 0, hook)
>
>  #ifdef CONFIG_PCI_QUIRKS
> --
> 1.8.1.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/pci.h b/include/linux/pci.h
index da172f9..1ff4dec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1557,65 +1557,65 @@  enum pci_fixup_pass {
 /* Anonymous variables would be nice... */
 #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class,	\
 				  class_shift, hook)			\
-	static const struct pci_fixup __pci_fixup_##name __used		\
+	static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used	\
 	__attribute__((__section__(#section), aligned((sizeof(void *)))))    \
 		= { vendor, device, class, class_shift, hook };
 
 #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,			\
-		vendor##device##hook, vendor, device, class, class_shift, hook)
+		hook, vendor, device, class, class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header,			\
-		vendor##device##hook, vendor, device, class, class_shift, hook)
+		hook, vendor, device, class, class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final,			\
-		vendor##device##hook, vendor, device, class, class_shift, hook)
+		hook, vendor, device, class, class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,			\
-		vendor##device##hook, vendor, device, class, class_shift, hook)
+		hook, vendor, device, class, class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume,			\
-		resume##vendor##device##hook, vendor, device, class,	\
+		resume##hook, vendor, device, class,	\
 		class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class,	\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early,		\
-		resume_early##vendor##device##hook, vendor, device,	\
+		resume_early##hook, vendor, device,	\
 		class, class_shift, hook)
 #define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class,		\
 					 class_shift, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend,			\
-		suspend##vendor##device##hook, vendor, device, class,	\
+		suspend##hook, vendor, device, class,	\
 		class_shift, hook)
 
 #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook)			\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,			\
-		vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
+		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, PCI_ANY_ID, 0, hook)
+		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, PCI_ANY_ID, 0, hook)
+		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, PCI_ANY_ID, 0, hook)
+		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,		\
+		resume##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,	\
+		resume_early##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,		\
+		suspend##hook, vendor, device,		\
 		PCI_ANY_ID, 0, hook)
 
 #ifdef CONFIG_PCI_QUIRKS