[PATCH v4] drm/xe: Allow building as kernel built-in

Harry Austen posted 1 patch 7 months, 1 week ago
drivers/gpu/drm/xe/Kconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Harry Austen 7 months, 1 week ago
Fix Kconfig symbol dependency on KUNIT, which isn't actually required
for XE to be built-in. However, if KUNIT is enabled, it must be built-in
too.

Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
isn't, since that results in duplicate symbol errors.

Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Harry Austen <hpausten@protonmail.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
---
v4: Add Jani Nikula's Acked-by tag
v3: Simplify KUNIT dependency, as suggested by Jani Nikula
v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in

 drivers/gpu/drm/xe/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
index 9bce047901b22..214f40264fa12 100644
--- a/drivers/gpu/drm/xe/Kconfig
+++ b/drivers/gpu/drm/xe/Kconfig
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config DRM_XE
 	tristate "Intel Xe Graphics"
-	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
+	depends on DRM && PCI && MMU
+	depends on KUNIT || KUNIT=n
 	select INTERVAL_TREE
 	# we need shmfs for the swappable backing store, and in particular
 	# the shmem_readpage() which depends upon tmpfs
@@ -51,7 +52,7 @@ config DRM_XE
 
 config DRM_XE_DISPLAY
 	bool "Enable display support"
-	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
+	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
 	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
 	select I2C
 	select I2C_ALGOBIT
-- 
2.49.0
Re: [PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Maarten Lankhorst 7 months ago
Hey,

On 2025-05-16 12:42, Harry Austen wrote:
> Fix Kconfig symbol dependency on KUNIT, which isn't actually required
> for XE to be built-in. However, if KUNIT is enabled, it must be built-in
> too.
> 
> Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
> isn't, since that results in duplicate symbol errors.
> 
> Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Harry Austen <hpausten@protonmail.com>
> Acked-by: Jani Nikula <jani.nikula@intel.com>
> ---
> v4: Add Jani Nikula's Acked-by tag
> v3: Simplify KUNIT dependency, as suggested by Jani Nikula
> v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in
> 
>  drivers/gpu/drm/xe/Kconfig | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
> index 9bce047901b22..214f40264fa12 100644
> --- a/drivers/gpu/drm/xe/Kconfig
> +++ b/drivers/gpu/drm/xe/Kconfig
> @@ -1,7 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  config DRM_XE
>  	tristate "Intel Xe Graphics"
> -	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
> +	depends on DRM && PCI && MMU
> +	depends on KUNIT || KUNIT=n
>  	select INTERVAL_TREE
>  	# we need shmfs for the swappable backing store, and in particular
>  	# the shmem_readpage() which depends upon tmpfs
> @@ -51,7 +52,7 @@ config DRM_XE
>  
>  config DRM_XE_DISPLAY
>  	bool "Enable display support"
> -	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
> +	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
>  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
>  	select I2C
>  	select I2C_ALGOBIT
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Can we also get rid of the IOSF_MBI select? Not even xe_display depends on it, leftover from initial porting. :)

Re: [PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Harry Austen 7 months ago
On Mon May 19, 2025 at 4:14 PM BST, Maarten Lankhorst wrote:
> Hey,
>
> On 2025-05-16 12:42, Harry Austen wrote:
>> Fix Kconfig symbol dependency on KUNIT, which isn't actually required
>> for XE to be built-in. However, if KUNIT is enabled, it must be built-in
>> too.
>>
>> Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
>> isn't, since that results in duplicate symbol errors.
>>
>> Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Signed-off-by: Harry Austen <hpausten@protonmail.com>
>> Acked-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> v4: Add Jani Nikula's Acked-by tag
>> v3: Simplify KUNIT dependency, as suggested by Jani Nikula
>> v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in
>>
>>  drivers/gpu/drm/xe/Kconfig | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
>> index 9bce047901b22..214f40264fa12 100644
>> --- a/drivers/gpu/drm/xe/Kconfig
>> +++ b/drivers/gpu/drm/xe/Kconfig
>> @@ -1,7 +1,8 @@
>>  # SPDX-License-Identifier: GPL-2.0-only
>>  config DRM_XE
>>  	tristate "Intel Xe Graphics"
>> -	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
>> +	depends on DRM && PCI && MMU
>> +	depends on KUNIT || KUNIT=n
>>  	select INTERVAL_TREE
>>  	# we need shmfs for the swappable backing store, and in particular
>>  	# the shmem_readpage() which depends upon tmpfs
>> @@ -51,7 +52,7 @@ config DRM_XE
>>
>>  config DRM_XE_DISPLAY
>>  	bool "Enable display support"
>> -	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
>> +	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
>>  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
>>  	select I2C
>>  	select I2C_ALGOBIT
> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Thanks!

>
> Can we also get rid of the IOSF_MBI select? Not even xe_display depends on it, leftover from initial porting. :)

As this seems unrelated, I'd be happy to submit a separate patch for this
afterwards. Thanks for the suggestion.

Harry
Re: [PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Lucas De Marchi 7 months ago
On Wed, May 21, 2025 at 08:35:05AM +0000, Harry Austen wrote:
>On Mon May 19, 2025 at 4:14 PM BST, Maarten Lankhorst wrote:
>> Hey,
>>
>> On 2025-05-16 12:42, Harry Austen wrote:
>>> Fix Kconfig symbol dependency on KUNIT, which isn't actually required
>>> for XE to be built-in. However, if KUNIT is enabled, it must be built-in
>>> too.
>>>
>>> Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
>>> isn't, since that results in duplicate symbol errors.
>>>
>>> Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
>>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Signed-off-by: Harry Austen <hpausten@protonmail.com>
>>> Acked-by: Jani Nikula <jani.nikula@intel.com>
>>> ---
>>> v4: Add Jani Nikula's Acked-by tag
>>> v3: Simplify KUNIT dependency, as suggested by Jani Nikula
>>> v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in
>>>
>>>  drivers/gpu/drm/xe/Kconfig | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
>>> index 9bce047901b22..214f40264fa12 100644
>>> --- a/drivers/gpu/drm/xe/Kconfig
>>> +++ b/drivers/gpu/drm/xe/Kconfig
>>> @@ -1,7 +1,8 @@
>>>  # SPDX-License-Identifier: GPL-2.0-only
>>>  config DRM_XE
>>>  	tristate "Intel Xe Graphics"
>>> -	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
>>> +	depends on DRM && PCI && MMU
>>> +	depends on KUNIT || KUNIT=n
>>>  	select INTERVAL_TREE
>>>  	# we need shmfs for the swappable backing store, and in particular
>>>  	# the shmem_readpage() which depends upon tmpfs
>>> @@ -51,7 +52,7 @@ config DRM_XE
>>>
>>>  config DRM_XE_DISPLAY
>>>  	bool "Enable display support"
>>> -	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
>>> +	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
>>>  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
>>>  	select I2C
>>>  	select I2C_ALGOBIT
>> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>
>Thanks!
>
>>
>> Can we also get rid of the IOSF_MBI select? Not even xe_display depends on it, leftover from initial porting. :)
>
>As this seems unrelated, I'd be happy to submit a separate patch for this
>afterwards. Thanks for the suggestion.

same comment as in the previous version of this patch. What I don't like
is that it doesn't prevent you to do a bad selection. Instead if you set
DRM_XE=y and DRM_I915=y, you lose DRM_XE_DISPLAY. Silently. This is
equivalent of chosing the options via make menuconfig:

	# initial state
	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
	m
	y
	m

	# set CONFIG_DRM_XE to built-in
	./scripts/config -e CONFIG_DRM_XE && make -s olddefconfig
	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
	y
	y
	m

	# set CONFIG_DRM_I915 to built-in, we lose display with xe
	$ ~/p/linux-dim/drm-xe-next/scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
	y
	undef
	y

I'm not sure how to prevent setting CONFIG_DRM_I915=y if
CONFIG_DRM_XE_DISPLAY is selected.

Lucas De Marchi

>
>Harry
>
Re: [PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Harry Austen 7 months ago
On Wed May 21, 2025 at 4:11 PM BST, Lucas De Marchi wrote:
> On Wed, May 21, 2025 at 08:35:05AM +0000, Harry Austen wrote:
> >On Mon May 19, 2025 at 4:14 PM BST, Maarten Lankhorst wrote:
> >> Hey,
> >>
> >> On 2025-05-16 12:42, Harry Austen wrote:
> >>> Fix Kconfig symbol dependency on KUNIT, which isn't actually required
> >>> for XE to be built-in. However, if KUNIT is enabled, it must be built-in
> >>> too.
> >>>
> >>> Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
> >>> isn't, since that results in duplicate symbol errors.
> >>>
> >>> Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
> >>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> >>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> >>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >>> Signed-off-by: Harry Austen <hpausten@protonmail.com>
> >>> Acked-by: Jani Nikula <jani.nikula@intel.com>
> >>> ---
> >>> v4: Add Jani Nikula's Acked-by tag
> >>> v3: Simplify KUNIT dependency, as suggested by Jani Nikula
> >>> v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in
> >>>
> >>>  drivers/gpu/drm/xe/Kconfig | 5 +++--
> >>>  1 file changed, 3 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
> >>> index 9bce047901b22..214f40264fa12 100644
> >>> --- a/drivers/gpu/drm/xe/Kconfig
> >>> +++ b/drivers/gpu/drm/xe/Kconfig
> >>> @@ -1,7 +1,8 @@
> >>>  # SPDX-License-Identifier: GPL-2.0-only
> >>>  config DRM_XE
> >>>  	tristate "Intel Xe Graphics"
> >>> -	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
> >>> +	depends on DRM && PCI && MMU
> >>> +	depends on KUNIT || KUNIT=n
> >>>  	select INTERVAL_TREE
> >>>  	# we need shmfs for the swappable backing store, and in particular
> >>>  	# the shmem_readpage() which depends upon tmpfs
> >>> @@ -51,7 +52,7 @@ config DRM_XE
> >>>
> >>>  config DRM_XE_DISPLAY
> >>>  	bool "Enable display support"
> >>> -	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
> >>> +	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
> >>>  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
> >>>  	select I2C
> >>>  	select I2C_ALGOBIT
> >> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >
> >Thanks!
> >
> >>
> >> Can we also get rid of the IOSF_MBI select? Not even xe_display depends on it, leftover from initial porting. :)
> >
> >As this seems unrelated, I'd be happy to submit a separate patch for this
> >afterwards. Thanks for the suggestion.
>
> same comment as in the previous version of this patch. What I don't like
> is that it doesn't prevent you to do a bad selection. Instead if you set
> DRM_XE=y and DRM_I915=y, you lose DRM_XE_DISPLAY. Silently. This is
> equivalent of chosing the options via make menuconfig:
>
> 	# initial state
> 	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
> 	m
> 	y
> 	m
>
> 	# set CONFIG_DRM_XE to built-in
> 	./scripts/config -e CONFIG_DRM_XE && make -s olddefconfig
> 	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
> 	y
> 	y
> 	m
>
> 	# set CONFIG_DRM_I915 to built-in, we lose display with xe
> 	$ ~/p/linux-dim/drm-xe-next/scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
> 	y
> 	undef
> 	y
>
> I'm not sure how to prevent setting CONFIG_DRM_I915=y if
> CONFIG_DRM_XE_DISPLAY is selected.

Ah interesting, thanks for the example. I'll try a few different things and see
if I can get more sensible behaviour.

>
> Lucas De Marchi
>
> >
> >Harry
> >
Re: [PATCH v4] drm/xe: Allow building as kernel built-in
Posted by Lucas De Marchi 5 months, 3 weeks ago
On Wed, May 21, 2025 at 08:51:24PM +0000, Harry Austen wrote:
>On Wed May 21, 2025 at 4:11 PM BST, Lucas De Marchi wrote:
>> On Wed, May 21, 2025 at 08:35:05AM +0000, Harry Austen wrote:
>> >On Mon May 19, 2025 at 4:14 PM BST, Maarten Lankhorst wrote:
>> >> Hey,
>> >>
>> >> On 2025-05-16 12:42, Harry Austen wrote:
>> >>> Fix Kconfig symbol dependency on KUNIT, which isn't actually required
>> >>> for XE to be built-in. However, if KUNIT is enabled, it must be built-in
>> >>> too.
>> >>>
>> >>> Also, allow DRM_XE_DISPLAY to be built-in. But only as long as DRM_I915
>> >>> isn't, since that results in duplicate symbol errors.
>> >>>
>> >>> Fixes: 08987a8b6820 ("drm/xe: Fix build with KUNIT=m")
>> >>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> >>> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
>> >>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> >>> Signed-off-by: Harry Austen <hpausten@protonmail.com>
>> >>> Acked-by: Jani Nikula <jani.nikula@intel.com>
>> >>> ---
>> >>> v4: Add Jani Nikula's Acked-by tag
>> >>> v3: Simplify KUNIT dependency, as suggested by Jani Nikula
>> >>> v2: Ensure DRM_XE_DISPLAY and DRM_I915 can't both be built-in
>> >>>
>> >>>  drivers/gpu/drm/xe/Kconfig | 5 +++--
>> >>>  1 file changed, 3 insertions(+), 2 deletions(-)
>> >>>
>> >>> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
>> >>> index 9bce047901b22..214f40264fa12 100644
>> >>> --- a/drivers/gpu/drm/xe/Kconfig
>> >>> +++ b/drivers/gpu/drm/xe/Kconfig
>> >>> @@ -1,7 +1,8 @@
>> >>>  # SPDX-License-Identifier: GPL-2.0-only
>> >>>  config DRM_XE
>> >>>  	tristate "Intel Xe Graphics"
>> >>> -	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
>> >>> +	depends on DRM && PCI && MMU
>> >>> +	depends on KUNIT || KUNIT=n

this part looks good and is more related to the title of this commit.
This doesn't need to wait the display thing below.

>> >>>  	select INTERVAL_TREE
>> >>>  	# we need shmfs for the swappable backing store, and in particular
>> >>>  	# the shmem_readpage() which depends upon tmpfs
>> >>> @@ -51,7 +52,7 @@ config DRM_XE
>> >>>
>> >>>  config DRM_XE_DISPLAY
>> >>>  	bool "Enable display support"
>> >>> -	depends on DRM_XE && DRM_XE=m && HAS_IOPORT
>> >>> +	depends on DRM_XE && (DRM_XE=m || DRM_I915!=y) && HAS_IOPORT
>> >>>  	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
>> >>>  	select I2C
>> >>>  	select I2C_ALGOBIT
>> >> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> >
>> >Thanks!
>> >
>> >>
>> >> Can we also get rid of the IOSF_MBI select? Not even xe_display depends on it, leftover from initial porting. :)
>> >
>> >As this seems unrelated, I'd be happy to submit a separate patch for this
>> >afterwards. Thanks for the suggestion.
>>
>> same comment as in the previous version of this patch. What I don't like
>> is that it doesn't prevent you to do a bad selection. Instead if you set
>> DRM_XE=y and DRM_I915=y, you lose DRM_XE_DISPLAY. Silently. This is
>> equivalent of chosing the options via make menuconfig:
>>
>> 	# initial state
>> 	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
>> 	m
>> 	y
>> 	m
>>
>> 	# set CONFIG_DRM_XE to built-in
>> 	./scripts/config -e CONFIG_DRM_XE && make -s olddefconfig
>> 	./scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
>> 	y
>> 	y
>> 	m
>>
>> 	# set CONFIG_DRM_I915 to built-in, we lose display with xe
>> 	$ ~/p/linux-dim/drm-xe-next/scripts/config --state CONFIG_DRM_XE --state CONFIG_DRM_XE_DISPLAY --state CONFIG_DRM_I915
>> 	y
>> 	undef
>> 	y
>>
>> I'm not sure how to prevent setting CONFIG_DRM_I915=y if
>> CONFIG_DRM_XE_DISPLAY is selected.
>
>Ah interesting, thanks for the example. I'll try a few different things and see
>if I can get more sensible behaviour.

I think a reasonable compromise (since it's a temporary thing until we
spinoff the display part) is to move the dependency up, on drm_xe.
This way we don't silently lose display.

If we try to set drm_xe to y (and drm_i915==y), kconfig will complain.
If we try to set drm_i915 to y (and drm_xe==y), we will get drm_xe==m.
Which is better than losing display.


thanks
Lucas De Marchi

>
>>
>> Lucas De Marchi
>>
>> >
>> >Harry
>> >
>
>