Skip to contentSkip to conversation

drm: Replace kernel.h with the necessary inclusions

PATCH In review Andy Shevchenko 3 participants 8 messages Nov 10, 2021 – Dec 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Replace kernel.h with the necessary inclusions

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

---
 include/drm/drm_gem_ttm_helper.h  | 2 +-
 include/drm/drm_gem_vram_helper.h | 2 +-
 include/drm/drm_mm.h              | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)
include/drm/drm_gem_ttm_helper.h +1 -1
index c1aa02bd4c89..78040f6cc6f3 100644
@@ -3,7 +3,7 @@
 #ifndef DRM_GEM_TTM_HELPER_H
 #define DRM_GEM_TTM_HELPER_H
 
-#include <linux/kernel.h>
+#include <linux/container_of.h>
 
 #include <drm/drm_device.h>
 #include <drm/drm_gem.h>
include/drm/drm_gem_vram_helper.h +1 -1
index d3cf06c9af65..b4ce27a72773 100644
@@ -11,8 +11,8 @@
 #include <drm/ttm/ttm_bo_api.h>
 #include <drm/ttm/ttm_bo_driver.h>
 
+#include <linux/container_of.h>
 #include <linux/dma-buf-map.h>
-#include <linux/kernel.h> /* for container_of() */
 
 struct drm_mode_create_dumb;
 struct drm_plane;
include/drm/drm_mm.h +3 -1
index 9b4292f229c6..ac33ba1b18bc 100644
@@ -39,13 +39,15 @@
  */
 #include <linux/bug.h>
 #include <linux/rbtree.h>
-#include <linux/kernel.h>
+#include <linux/limits.h>
 #include <linux/mm_types.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #ifdef CONFIG_DRM_DEBUG_MM
 #include <linux/stackdepot.h>
 #endif
+#include <linux/types.h>
+
 #include <drm/drm_print.h>
 
 #ifdef CONFIG_DRM_DEBUG_MM
Signature · 1 line
2.33.0
#1 lore raw

Hi

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

Quoted 17 lines

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

---
  include/drm/drm_gem_ttm_helper.h  | 2 +-
  include/drm/drm_gem_vram_helper.h | 2 +-
  include/drm/drm_mm.h              | 4 +++-
  3 files changed, 5 insertions(+), 3 deletions(-)
include/drm/drm_gem_ttm_helper.h +0 -0
index c1aa02bd4c89..78040f6cc6f3 100644

include/drm/drm_gem_ttm_helper.h line 6

Quoted 5 lines
include/drm/drm_gem_ttm_helper.h +1 -1
@@ -3,7 +3,7 @@
  #ifndef DRM_GEM_TTM_HELPER_H
  #define DRM_GEM_TTM_HELPER_H
 
-#include <linux/kernel.h>
+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Best regards
Thomas

Quoted 39 lines
include/drm/drm_gem_ttm_helper.h +0 -0
  #include <drm/drm_device.h>
  #include <drm/drm_gem.h>
include/drm/drm_gem_vram_helper.h +1 -1
index d3cf06c9af65..b4ce27a72773 100644
@@ -11,8 +11,8 @@
  #include <drm/ttm/ttm_bo_api.h>
  #include <drm/ttm/ttm_bo_driver.h>
 
+#include <linux/container_of.h>
  #include <linux/dma-buf-map.h>
-#include <linux/kernel.h> /* for container_of() */
 
  struct drm_mode_create_dumb;
  struct drm_plane;
include/drm/drm_mm.h +3 -1
index 9b4292f229c6..ac33ba1b18bc 100644
@@ -39,13 +39,15 @@
   */
  #include <linux/bug.h>
  #include <linux/rbtree.h>
-#include <linux/kernel.h>
+#include <linux/limits.h>
  #include <linux/mm_types.h>
  #include <linux/list.h>
  #include <linux/spinlock.h>
  #ifdef CONFIG_DRM_DEBUG_MM
  #include <linux/stackdepot.h>
  #endif
+#include <linux/types.h>
+
  #include <drm/drm_print.h>
 
  #ifdef CONFIG_DRM_DEBUG_MM
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#2 lore raw
Quoted 5 lines · Thomas Zimmermann

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

Quoted 4 lines

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

...

Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Acked-by
#3 lore raw

Hi

Am 10.11.21 um 17:34 schrieb Andy Shevchenko:

Quoted 9 lines · Thomas Zimmermann
Quoted 5 lines

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

Quoted 4 lines

When kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.

Replace kernel.h inclusion with the list of what is really being used.

...

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Yes, we'll certainly backmerge soon after rc1 has been released. If I forget to add the patch then, please send a reminder.

Once the necessary headers are available, the patch is

Best regards
Thomas

Quoted 1 line
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#4 lore raw
Quoted 3 lines · Thomas Zimmermann

Am 10.11.21 um 17:34 schrieb Andy Shevchenko:

Quoted 2 lines · Thomas Zimmermann
Quoted 1 line

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

...

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Quoted 8 lines
Quoted 3 lines

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Yes, we'll certainly backmerge soon after rc1 has been released. If I forget to add the patch then, please send a reminder.

Once the necessary headers are available,

$ git log --oneline v5.16-rc1 -- include/linux/container_of.h
e1edc277e6f6 linux/container_of.h: switch to static_assert
d2a8ebbf8192 kernel.h: split out container_of() and typeof_member() macros
Quoted 2 lines

the patch is

Thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 21 lines · Andy Shevchenko
Quoted 3 lines · Thomas Zimmermann

Am 10.11.21 um 17:34 schrieb Andy Shevchenko:

Quoted 2 lines · Thomas Zimmermann
Quoted 1 line

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

...

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Quoted 8 lines
Quoted 3 lines

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Yes, we'll certainly backmerge soon after rc1 has been released. If I forget to add the patch then, please send a reminder.

Once the necessary headers are available,

Quoted 8 lines
$ git log --oneline v5.16-rc1 -- include/linux/container_of.h
e1edc277e6f6 linux/container_of.h: switch to static_assert
d2a8ebbf8192 kernel.h: split out container_of() and typeof_member() macros
Quoted 2 lines

the patch is

Thanks!

Maybe I misunderstood something, I thought that DRM people may apply this, is it incorrect assumption?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 26 lines · Andy Shevchenko
Quoted 25 lines · Andy Shevchenko
Quoted 3 lines · Thomas Zimmermann

Am 10.11.21 um 17:34 schrieb Andy Shevchenko:

Quoted 2 lines · Thomas Zimmermann
Quoted 1 line

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

...

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Quoted 8 lines
Quoted 3 lines

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Yes, we'll certainly backmerge soon after rc1 has been released. If I forget to add the patch then, please send a reminder.

Once the necessary headers are available,

$ git log --oneline v5.16-rc1 -- include/linux/container_of.h
e1edc277e6f6 linux/container_of.h: switch to static_assert
d2a8ebbf8192 kernel.h: split out container_of() and typeof_member() macros
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

the patch is

Thanks!

Maybe I misunderstood something, I thought that DRM people may apply this, is it incorrect assumption?

It still does not appear in Linux Next...
What should I do to move this forward, please?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Hi

Am 09.12.21 um 13:24 schrieb Andy Shevchenko:

Quoted 30 lines · Andy Shevchenko
Quoted 29 lines · Andy Shevchenko
Quoted 28 lines · Thomas Zimmermann
Quoted 3 lines

Am 10.11.21 um 17:34 schrieb Andy Shevchenko:

Quoted 2 lines · Thomas Zimmermann
Quoted 1 line

Am 10.11.21 um 11:24 schrieb Andy Shevchenko:

...

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

+#include <linux/container_of.h>

I built this patch on a recent drm-misc-next, but there's no linux/container_of.h

Quoted 8 lines
Quoted 3 lines

Thank you for trying. It's in the upstream, whenever drm-misc-next switches to newer/newest upstream it will be there. I assume it will happen after v5.16-rc1?

Yes, we'll certainly backmerge soon after rc1 has been released. If I forget to add the patch then, please send a reminder.

Once the necessary headers are available,

$ git log --oneline v5.16-rc1 -- include/linux/container_of.h
e1edc277e6f6 linux/container_of.h: switch to static_assert
d2a8ebbf8192 kernel.h: split out container_of() and typeof_member() macros
Quoted 2 lines

the patch is

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Thanks!

Maybe I misunderstood something, I thought that DRM people may apply this, is it incorrect assumption?

It still does not appear in Linux Next...
What should I do to move this forward, please?

It's now in drm-misc-next. Sorry that it fell through the cracks.

Best regards
Thomas

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev