Skip to contentSkip to conversation

intel: annotate the intel genx helpers as private

PATCH In review Emil Velikov 3 participants 6 messages Sep 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel: annotate the intel genx helpers as private

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +2 -2
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
 	INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
 	const struct pci_device *p,
 		  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
 	return false;
 }
 
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)
 {
 	const struct pci_device *p,
 		  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
intel/intel_chipset.h +2 -2
index 9b1e64f1..63ddde7a 100644
@@ -330,8 +330,8 @@
 /* New platforms use kernel pci ids */
 #include <stdbool.h>
 
-bool intel_is_genx(unsigned int devid, int gen);
-bool intel_get_genx(unsigned int devid, int *gen);
+drm_private bool intel_is_genx(unsigned int devid, int gen);
+drm_private bool intel_get_genx(unsigned int devid, int *gen);
 
 #define IS_GEN9(devid) intel_is_genx(devid, 9)
 #define IS_GEN10(devid) intel_is_genx(devid, 10)
Signature · 6 lines
2.18.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Quoting Emil Velikov (2018-09-06 16:14:07)

Quoted 30 lines

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +1 -1
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
        INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
        const struct pci_device *p,
                  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);

intel/intel_chipset.c bool intel_is_genx(unsigned int devid, int gen) · line 69

Quoted 5 lines
intel/intel_chipset.c +1 -1
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
        return false;
 }
 
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)

We should only need to put the attribute in the header, right? -Chris
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 34 lines · Chris Wilson

Quoting Emil Velikov (2018-09-06 16:14:07)

Quoted 33 lines

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +1 -1
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
        INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
        const struct pci_device *p,
                  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
        return false;
 }
 
Quoted 4 lines

intel/intel_chipset.c bool intel_is_genx(unsigned int devid, int gen) · line 69

Quoted 2 lines
intel/intel_chipset.c +1 -1
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)

We should only need to put the attribute in the header, right?

IMO it actually makes more sense to be in the .c. Reason is that if we are going to change to be hidden by default and annotate the public ones, then we don't need to play with macros to hide them from other projects including the header.

A declaration for a private symbol should not be in an exported header so we know that all the functions in that header should actually be public.

Lucas De Marchi

Quoted 1 line

-Chris

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Quoting Lucas De Marchi (2018-09-06 18:51:37)

Quoted 40 lines · Chris Wilson
Quoted 34 lines

Quoting Emil Velikov (2018-09-06 16:14:07)

Quoted 33 lines

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +1 -1
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
        INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
        const struct pci_device *p,
                  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
        return false;
 }
 
Quoted 4 lines

intel/intel_chipset.c bool intel_is_genx(unsigned int devid, int gen) · line 69

Quoted 2 lines
intel/intel_chipset.c +1 -1
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)

We should only need to put the attribute in the header, right?

Quoted 8 lines

IMO it actually makes more sense to be in the .c. Reason is that if we are going to change to be hidden by default and annotate the public ones, then we don't need to play with macros to hide them from other projects including the header.

A declaration for a private symbol should not be in an exported header so we know that all the functions in that header should actually be public.

And we definitely should not be and are not exporting intel_chipset.h.

I'd would rather have visibility declared in the header because that's where I expect interface documentation.
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 46 lines · Chris Wilson

Quoting Lucas De Marchi (2018-09-06 18:51:37)

Quoted 45 lines · Chris Wilson
Quoted 34 lines

Quoting Emil Velikov (2018-09-06 16:14:07)

Quoted 33 lines

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +1 -1
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
        INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
        const struct pci_device *p,
                  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
        return false;
 }
 
Quoted 4 lines

intel/intel_chipset.c bool intel_is_genx(unsigned int devid, int gen) · line 69

Quoted 2 lines
intel/intel_chipset.c +1 -1
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)

We should only need to put the attribute in the header, right?

IMO it actually makes more sense to be in the .c. Reason is that if we are going to change to be hidden by default and annotate the public ones, then we don't need to play with macros to hide them from other projects including the header.

Quoted 8 lines
Quoted 3 lines

A declaration for a private symbol should not be in an exported header so we know that all the functions in that header should actually be public.

And we definitely should not be and are not exporting intel_chipset.h.

I'd would rather have visibility declared in the header because that's where I expect interface documentation.

but then if the header is exported, you need to export the definition of the macro as well.. and undef it when it's not for internal use. I've seen nasty things on projects that went this route, because then you not only depend on the compiler version you are compiled with, but you also need to keep the flexibility for other projects that are including you. Example:

#ifdef EAPI

# undef EAPI
#endif

#ifdef _WIN32

# ifdef EFL_BUILD
#  ifdef DLL_EXPORT
#   define EAPI __declspec(dllexport)
#  else
#   define EAPI
#  endif
# else
#  define EAPI __declspec(dllimport)
# endif
# define EAPI_WEAK
#else
# ifdef __GNUC__
#  if __GNUC__ >= 4
#   define EAPI __attribute__ ((visibility("default")))
#   define EAPI_WEAK __attribute__ ((weak))
#  else
#   define EAPI
#   define EAPI_WEAK
#  endif
# else
#  define EAPI
#  define EAPI_WEAK
# endif
#endif

Lucas De Marchi
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Acked-by on v1 1/1
#5 lore raw
In reply to Emil Velikov
Quoted 44 lines · Emil Velikov

From: Emil Velikov <[email protected]>

They're used internally and never meant to be part of the API. Add the drm_private notation, which should resolve that.

Cc Eric Engestrom <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Fixes 4e81d4f9c9b ("intel: add generic functions to check PCI ID")
---
 intel/intel_chipset.c | 4 ++--
 intel/intel_chipset.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
intel/intel_chipset.c +2 -2
index d5c33cc5..5aa4a2f2 100644
@@ -44,7 +44,7 @@ static const struct pci_device {
 	INTEL_SKL_IDS(9),
 };
 
-bool intel_is_genx(unsigned int devid, int gen)
+drm_private bool intel_is_genx(unsigned int devid, int gen)
 {
 	const struct pci_device *p,
 		  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
@@ -66,7 +66,7 @@ bool intel_is_genx(unsigned int devid, int gen)
 	return false;
 }
 
-bool intel_get_genx(unsigned int devid, int *gen)
+drm_private bool intel_get_genx(unsigned int devid, int *gen)
 {
 	const struct pci_device *p,
 		  *pend = pciids + sizeof(pciids) / sizeof(pciids[0]);
intel/intel_chipset.h +0 -0
index 9b1e64f1..63ddde7a 100644

intel/intel_chipset.h line 337

Quoted 10 lines
intel/intel_chipset.h +2 -2
@@ -330,8 +330,8 @@
 /* New platforms use kernel pci ids */
 #include <stdbool.h>
 
-bool intel_is_genx(unsigned int devid, int gen);
-bool intel_get_genx(unsigned int devid, int *gen);
+drm_private bool intel_is_genx(unsigned int devid, int gen);
+drm_private bool intel_get_genx(unsigned int devid, int *gen);
 
 #define IS_GEN9(devid) intel_is_genx(devid, 9)
 #define IS_GEN10(devid) intel_is_genx(devid, 10)

As a short-term fix,

I think we should really migrate to making them hidden by default and only export the ones we want. When drm_public was removed, it was basically a nop since the visibility was still set as default. I will take a look on this.

Lucas De Marchi

Quoted 2 lines

2.18.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel