diff mbox

drm/nouveau/platform: fix compilation if !CONFIG_IOMMU

Message ID 1432102224-15169-1-git-send-email-acourbot@nvidia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Courbot May 20, 2015, 6:10 a.m. UTC
The lack of IOMMU API support can make nouveau_platform_probe_iommu()
fail to compile because struct iommu_ops is then empty. Fix this by
skipping IOMMU probe in that case - lack of IOMMU on platform devices
is sub-optimal, but is not an error.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
This is an alternative to https://lkml.org/lkml/2015/5/19/484. Most users
of Nouveau do not care about IOMMU support, so we should not impose that
option on them.

 drm/nouveau/nouveau_platform.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Arnd Bergmann May 20, 2015, 7:07 a.m. UTC | #1
On Wednesday 20 May 2015 15:10:24 Alexandre Courbot wrote:
> The lack of IOMMU API support can make nouveau_platform_probe_iommu()
> fail to compile because struct iommu_ops is then empty. Fix this by
> skipping IOMMU probe in that case - lack of IOMMU on platform devices
> is sub-optimal, but is not an error.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> This is an alternative to https://lkml.org/lkml/2015/5/19/484. Most users
> of Nouveau do not care about IOMMU support, so we should not impose that
> option on them.
> 

Yes, good idea.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Thierry Reding May 20, 2015, 11:32 a.m. UTC | #2
On Wed, May 20, 2015 at 03:10:24PM +0900, Alexandre Courbot wrote:
> The lack of IOMMU API support can make nouveau_platform_probe_iommu()
> fail to compile because struct iommu_ops is then empty. Fix this by
> skipping IOMMU probe in that case - lack of IOMMU on platform devices
> is sub-optimal, but is not an error.
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> This is an alternative to https://lkml.org/lkml/2015/5/19/484. Most users
> of Nouveau do not care about IOMMU support, so we should not impose that
> option on them.
> 
>  drm/nouveau/nouveau_platform.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c
> index 775277f1edb0..dcfbbfaf1739 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_platform.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
> @@ -92,6 +92,8 @@ static int nouveau_platform_power_down(struct nouveau_platform_gpu *gpu)
>  	return 0;
>  }
>  
> +#if IS_ENABLED(CONFIG_IOMMU_API)
> +
>  static void nouveau_platform_probe_iommu(struct device *dev,
>  					 struct nouveau_platform_gpu *gpu)
>  {
> @@ -158,6 +160,20 @@ static void nouveau_platform_remove_iommu(struct device *dev,
>  	}
>  }
>  
> +#else
> +
> +static void nouveau_platform_probe_iommu(struct device *dev,
> +					 struct nouveau_platform_gpu *gpu)
> +{
> +}
> +
> +static void nouveau_platform_remove_iommu(struct device *dev,
> +					  struct nouveau_platform_gpu *gpu)
> +{
> +}
> +
> +#endif
> +

Since these are all static functions, perhaps an "if (IS_ENABLED(...))"
would work here? That way you'd get compile coverage of the code in all
cases.

But perhaps that doesn't work for IOMMU. I have a vague memory of
running across something like this before and IOMMU has this quirk of
defining struct iommu_ops as empty if IOMMU_API is deselected so you'll
probably get compiler errors unless you actually preprocess the code
out.

Thierry
Arnd Bergmann May 20, 2015, 12:01 p.m. UTC | #3
On Wednesday 20 May 2015 13:32:33 Thierry Reding wrote:
> 
> Since these are all static functions, perhaps an "if (IS_ENABLED(...))"
> would work here? That way you'd get compile coverage of the code in all
> cases.

I had the same thought at first.
 
> But perhaps that doesn't work for IOMMU. I have a vague memory of
> running across something like this before and IOMMU has this quirk of
> defining struct iommu_ops as empty if IOMMU_API is deselected so you'll
> probably get compiler errors unless you actually preprocess the code
> out.

Exactly.

	Arnd
Alexandre Courbot May 20, 2015, 2:18 p.m. UTC | #4
On Wed, May 20, 2015 at 9:01 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 20 May 2015 13:32:33 Thierry Reding wrote:
>>
>> Since these are all static functions, perhaps an "if (IS_ENABLED(...))"
>> would work here? That way you'd get compile coverage of the code in all
>> cases.
>
> I had the same thought at first.
>
>> But perhaps that doesn't work for IOMMU. I have a vague memory of
>> running across something like this before and IOMMU has this quirk of
>> defining struct iommu_ops as empty if IOMMU_API is deselected so you'll
>> probably get compiler errors unless you actually preprocess the code
>> out.
>
> Exactly.

That's precisely the issue here, so not covering this code is exactly
what we want if !CONFIG_IOMMU.
Alexandre Courbot May 26, 2015, 8:43 a.m. UTC | #5
On Wed, May 20, 2015 at 4:07 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 20 May 2015 15:10:24 Alexandre Courbot wrote:
>> The lack of IOMMU API support can make nouveau_platform_probe_iommu()
>> fail to compile because struct iommu_ops is then empty. Fix this by
>> skipping IOMMU probe in that case - lack of IOMMU on platform devices
>> is sub-optimal, but is not an error.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>> This is an alternative to https://lkml.org/lkml/2015/5/19/484. Most users
>> of Nouveau do not care about IOMMU support, so we should not impose that
>> option on them.
>>
>
> Yes, good idea.
>
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks. Dave, are you ok with this patch? If so, can you take it?
diff mbox

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c
index 775277f1edb0..dcfbbfaf1739 100644
--- a/drivers/gpu/drm/nouveau/nouveau_platform.c
+++ b/drivers/gpu/drm/nouveau/nouveau_platform.c
@@ -92,6 +92,8 @@  static int nouveau_platform_power_down(struct nouveau_platform_gpu *gpu)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_IOMMU_API)
+
 static void nouveau_platform_probe_iommu(struct device *dev,
 					 struct nouveau_platform_gpu *gpu)
 {
@@ -158,6 +160,20 @@  static void nouveau_platform_remove_iommu(struct device *dev,
 	}
 }
 
+#else
+
+static void nouveau_platform_probe_iommu(struct device *dev,
+					 struct nouveau_platform_gpu *gpu)
+{
+}
+
+static void nouveau_platform_remove_iommu(struct device *dev,
+					  struct nouveau_platform_gpu *gpu)
+{
+}
+
+#endif
+
 static int nouveau_platform_probe(struct platform_device *pdev)
 {
 	struct nouveau_platform_gpu *gpu;