Re: [PATCH] iommu: Remove stub functions for !CONFIG_IOMMU_API

From: Laura Abbott
Date: Thu Sep 01 2011 - 20:57:12 EST



On Wed, August 31, 2011 6:03 am, Roedel, Joerg wrote:
> On Mon, Aug 29, 2011 at 09:21:54AM -0400, Ohad Ben-Cohen wrote:
>> On Mon, Aug 29, 2011 at 4:05 PM, Roedel, Joerg <Joerg.Roedel@xxxxxxx>
>> wrote:
>> > So in this case you can skip this whole part when CONFIG_IOMMU_API is
>> > disabled
>>
>> Sure, we can do something like this in the driver:
>>
>> #ifdef CONFIG_IOMMU_API
>>
>> int do_the_iommu_thing(..)
>> {
>> ... call the IOMMU API as needed...
>> }
>>
>> #else
>>
>> int do_the_iommu_thing(..)
>> {
>> return 0;
>> }
>>
>> #endif
>>
>> Essentially, this means implementing the !CONFIG_IOMMU_API stubs in the
>> driver.
>
> I expect only very few drivers need that. Most drivers (like KVM and the
> upcoming VFIO) rely on the iommu-api and I expect most other drivers
> using the directly will also rely on an iommu. So this change makes
> still sense to me.
>

At least with MSM code, the iommu calls are abstracted through an API so
drivers don't need to know if the platform has an iommu or not.
Essentially:

if (iommu_found())
iommu_map(...)
else
do something else reasonable.

With this change, all code that might potentially call any iommu_map
function must exist in a separate file or face linker errors.

This idiom of having stubbed out functions is all over the kernel. I'm not
really sure what is gained by not having stubbed out versions of the
functions. There are better ways to catch users not selecting
CONFIG_IOMMU.

>> Possible of course, but I think it's a bit neater to have that in one
>> place, where all drivers can use. Similar to !CONFIG_HWSPINLOCK,
>> !CONFIG_DEBUG_FS, ...
>>
>> > This saves you even more .text size, no?
>>
>> Not sure; I expect the code to be compiled out today when the IOMMU
>> API is called and CONFIG_IOMMU_API is not set.
>
> But you even save all code that would use the iommu-api in your driver.
> This change forces you to compile out this code too leading to smaller
> .text-size.
>
> Joerg
>
The .text size reduction doesn't seem like it would be that great compared
to the annoyance of not having stubbed out functions.

Laura

> --
> AMD Operating System Research Center
>
> Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
> General Managers: Alberto Bozzo, Andrew Bowd
> Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr.
> 43632
>
> _______________________________________________
> iommu mailing list
> iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx
> https://lists.linux-foundation.org/mailman/listinfo/iommu
>


--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/