diff mbox

[Linaro-mm-sig,10/29] drivers: add DRIVER_HAS_OWN_IOMMU_MANAGER flag

Message ID 1407235677-26324-11-git-send-email-m.szyprowski@samsung.com
State New
Headers show

Commit Message

Marek Szyprowski Aug. 5, 2014, 10:47 a.m. UTC
This patch adds a new flags for device drivers. This flag instructs
kernel that the device driver does it own management of IOMMU assisted
IO address space translations, so no default dma-mapping structures
should be initialized.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 include/linux/device.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Marek Szyprowski Sept. 1, 2014, 5:22 a.m. UTC | #1
Hi Greg,

On 2014-08-05 12:47, Marek Szyprowski wrote:
> This patch adds a new flags for device drivers. This flag instructs
> kernel that the device driver does it own management of IOMMU assisted
> IO address space translations, so no default dma-mapping structures
> should be initialized.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>   include/linux/device.h | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 5f4ff02..2e62371 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -253,6 +253,8 @@ struct device_driver {
>   
>   /* disables bind/unbind via sysfs */
>   #define DRIVER_SUPPRESS_BIND_ATTRS	(1 << 0)
> +/* driver uses own methods to manage IO address space */
> +#define DRIVER_HAS_OWN_IOMMU_MANAGER	(1 << 1)
>   
>   extern int __must_check driver_register(struct device_driver *drv);
>   extern void driver_unregister(struct device_driver *drv);

Could you comment if the approach of using flags in the struct driver
could be accepted? I've converted suppress_bind_attrs entry to flags to
avoid extending the structure, please see patch "[PATCH 05/29] drivers:
convert suppress_bind_attrs parameter into flags".

Best regards
Thierry Reding Sept. 1, 2014, 7:07 a.m. UTC | #2
On Mon, Sep 01, 2014 at 07:22:32AM +0200, Marek Szyprowski wrote:
> Hi Greg,
> 
> On 2014-08-05 12:47, Marek Szyprowski wrote:
> > This patch adds a new flags for device drivers. This flag instructs
> > kernel that the device driver does it own management of IOMMU assisted
> > IO address space translations, so no default dma-mapping structures
> > should be initialized.
> >
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > ---
> >   include/linux/device.h | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index 5f4ff02..2e62371 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -253,6 +253,8 @@ struct device_driver {
> >   
> >   /* disables bind/unbind via sysfs */
> >   #define DRIVER_SUPPRESS_BIND_ATTRS	(1 << 0)
> > +/* driver uses own methods to manage IO address space */
> > +#define DRIVER_HAS_OWN_IOMMU_MANAGER	(1 << 1)
> >   
> >   extern int __must_check driver_register(struct device_driver *drv);
> >   extern void driver_unregister(struct device_driver *drv);
> 
> Could you comment if the approach of using flags in the struct driver
> could be accepted? I've converted suppress_bind_attrs entry to flags to
> avoid extending the structure, please see patch "[PATCH 05/29] drivers:
> convert suppress_bind_attrs parameter into flags".

Is this really necessary? What I did as part of an RFC series for Tegra
IOMMU support is keep this knowledge within the IOMMU driver rather than
export it to the driver core.

The idea being that the IOMMU driver wouldn't create an ARM DMA/IOMMU
mapping by default but rather allow individual drivers to be marked as
"kernel-internal" and use the DMA/IOMMU glue in that case. Drivers such
as DRM would use the IOMMU API directly.

Thierry
Marek Szyprowski Sept. 1, 2014, 7:53 a.m. UTC | #3
Hello,

On 2014-09-01 09:07, Thierry Reding wrote:
> On Mon, Sep 01, 2014 at 07:22:32AM +0200, Marek Szyprowski wrote:
>> Hi Greg,
>>
>> On 2014-08-05 12:47, Marek Szyprowski wrote:
>>> This patch adds a new flags for device drivers. This flag instructs
>>> kernel that the device driver does it own management of IOMMU assisted
>>> IO address space translations, so no default dma-mapping structures
>>> should be initialized.
>>>
>>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>> ---
>>>    include/linux/device.h | 2 ++
>>>    1 file changed, 2 insertions(+)
>>>
>>> diff --git a/include/linux/device.h b/include/linux/device.h
>>> index 5f4ff02..2e62371 100644
>>> --- a/include/linux/device.h
>>> +++ b/include/linux/device.h
>>> @@ -253,6 +253,8 @@ struct device_driver {
>>>    
>>>    /* disables bind/unbind via sysfs */
>>>    #define DRIVER_SUPPRESS_BIND_ATTRS	(1 << 0)
>>> +/* driver uses own methods to manage IO address space */
>>> +#define DRIVER_HAS_OWN_IOMMU_MANAGER	(1 << 1)
>>>    
>>>    extern int __must_check driver_register(struct device_driver *drv);
>>>    extern void driver_unregister(struct device_driver *drv);
>> Could you comment if the approach of using flags in the struct driver
>> could be accepted? I've converted suppress_bind_attrs entry to flags to
>> avoid extending the structure, please see patch "[PATCH 05/29] drivers:
>> convert suppress_bind_attrs parameter into flags".
> Is this really necessary? What I did as part of an RFC series for Tegra
> IOMMU support is keep this knowledge within the IOMMU driver rather than
> export it to the driver core.i

The problem with embedding the list of drivers that you would need to update
it everytime when you modify or extend iommu support in the other drivers.
I've tried also other approach, like adding respective notifiers to 
individual
drivers to initialize custom iommu support (or disable default iommu 
mapping)
before iommu driver gets initialized, but such solution is in my opinion too
complex and hard to understand if one is not familiar will all this stuff.

All in all it turned out that the simplest and most generic way is to simply
add the flag to the driver core. Flags might be also used in the future
to model other kinds of dependencies between device drivers and/or driver
core.

> The idea being that the IOMMU driver wouldn't create an ARM DMA/IOMMU
> mapping by default but rather allow individual drivers to be marked as
> "kernel-internal" and use the DMA/IOMMU glue in that case. Drivers such
> as DRM would use the IOMMU API directly.

Best regards
diff mbox

Patch

diff --git a/include/linux/device.h b/include/linux/device.h
index 5f4ff02..2e62371 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -253,6 +253,8 @@  struct device_driver {
 
 /* disables bind/unbind via sysfs */
 #define DRIVER_SUPPRESS_BIND_ATTRS	(1 << 0)
+/* driver uses own methods to manage IO address space */
+#define DRIVER_HAS_OWN_IOMMU_MANAGER	(1 << 1)
 
 extern int __must_check driver_register(struct device_driver *drv);
 extern void driver_unregister(struct device_driver *drv);