Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Will Deacon
On Thu, Dec 04, 2014 at 07:42:28PM +, Robin Murphy wrote: On 04/12/14 17:58, Grant Likely wrote: [...] +struct of_iommu_node { + struct list_head list; + struct device_node *np; + struct iommu_ops *ops; Why can't this be const? Why would anyone ever need to

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Arnd Bergmann
On Friday 05 December 2014 12:10:37 Will Deacon wrote: On Thu, Dec 04, 2014 at 07:42:28PM +, Robin Murphy wrote: On 04/12/14 17:58, Grant Likely wrote: [...] +struct of_iommu_node { + struct list_head list; + struct device_node *np; + struct iommu_ops *ops;

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Robin Murphy
Hi Will, On 05/12/14 12:10, Will Deacon wrote: [...] Do you expect drivers to modify that *priv pointer after the ops structure is registered? I'd be very surprised if that was the use case. It's fine for the driver to register a non-const version, but once it is registered, the infrastructure

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Grant Likely
On Fri, Dec 5, 2014 at 12:35 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Will, On 05/12/14 12:10, Will Deacon wrote: [...] Do you expect drivers to modify that *priv pointer after the ops structure is registered? I'd be very surprised if that was the use case. It's fine for the driver

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Thierry Reding
On Fri, Dec 05, 2014 at 01:06:52PM +, Grant Likely wrote: On Fri, Dec 5, 2014 at 12:35 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Will, On 05/12/14 12:10, Will Deacon wrote: [...] Do you expect drivers to modify that *priv pointer after the ops structure is registered? I'd

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Grant Likely
On Fri, Dec 5, 2014 at 1:18 PM, Thierry Reding thierry.red...@gmail.com wrote: On Fri, Dec 05, 2014 at 01:06:52PM +, Grant Likely wrote: On Fri, Dec 5, 2014 at 12:35 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Will, On 05/12/14 12:10, Will Deacon wrote: [...] Do you expect

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Thierry Reding
On Fri, Dec 05, 2014 at 01:21:31PM +, Grant Likely wrote: On Fri, Dec 5, 2014 at 1:18 PM, Thierry Reding thierry.red...@gmail.com wrote: On Fri, Dec 05, 2014 at 01:06:52PM +, Grant Likely wrote: On Fri, Dec 5, 2014 at 12:35 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Will,

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-05 Thread Marek Szyprowski
Hello, On 2014-12-05 14:18, Thierry Reding wrote: On Fri, Dec 05, 2014 at 01:06:52PM +, Grant Likely wrote: On Fri, Dec 5, 2014 at 12:35 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Will, On 05/12/14 12:10, Will Deacon wrote: [...] Do you expect drivers to modify that *priv pointer

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Will Deacon
On Wed, Dec 03, 2014 at 07:57:50PM +, Arnd Bergmann wrote: On Tuesday 02 December 2014 14:16:57 Grant Likely wrote: On Mon, Dec 1, 2014 at 11:54 PM, Rob Herring robherri...@gmail.com wrote: On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: +static inline void

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Arnd Bergmann
On Thursday 04 December 2014 09:49:53 Will Deacon wrote: On Wed, Dec 03, 2014 at 07:57:50PM +, Arnd Bergmann wrote: On Tuesday 02 December 2014 14:16:57 Grant Likely wrote: On Mon, Dec 1, 2014 at 11:54 PM, Rob Herring robherri...@gmail.com wrote: On Mon, Dec 1, 2014 at 10:57 AM,

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Will Deacon
On Thu, Dec 04, 2014 at 10:10:17AM +, Arnd Bergmann wrote: On Thursday 04 December 2014 09:49:53 Will Deacon wrote: On Wed, Dec 03, 2014 at 07:57:50PM +, Arnd Bergmann wrote: On Tuesday 02 December 2014 14:16:57 Grant Likely wrote: On Mon, Dec 1, 2014 at 11:54 PM, Rob Herring

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Arnd Bergmann
On Thursday 04 December 2014 10:21:27 Will Deacon wrote: On Thu, Dec 04, 2014 at 10:10:17AM +, Arnd Bergmann wrote: On Thursday 04 December 2014 09:49:53 Will Deacon wrote: On Wed, Dec 03, 2014 at 07:57:50PM +, Arnd Bergmann wrote: On Tuesday 02 December 2014 14:16:57 Grant

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Grant Likely
On Thu, Dec 4, 2014 at 11:19 AM, Arnd Bergmann a...@arndb.de wrote: On Thursday 04 December 2014 10:21:27 Will Deacon wrote: On Thu, Dec 04, 2014 at 10:10:17AM +, Arnd Bergmann wrote: On Thursday 04 December 2014 09:49:53 Will Deacon wrote: On Wed, Dec 03, 2014 at 07:57:50PM +, Arnd

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Will Deacon
On Thu, Dec 04, 2014 at 11:25:35AM +, Grant Likely wrote: On Thu, Dec 4, 2014 at 11:19 AM, Arnd Bergmann a...@arndb.de wrote: On Thursday 04 December 2014 10:21:27 Will Deacon wrote: Sure, I'll add this to my list of stuff to do for 3.20. Does that mean the we don't get any of the

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Robin Murphy
Hi Arnd, On 03/12/14 19:57, Arnd Bergmann wrote: [...] Good catch. This is not good. The data pointer should be avoided since there are no controls over its use. Until a better solution can be implemented, probably the safest thing to do is add a struct iommu_ops pointer to struct device_node.

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Grant Likely
On Thu, Dec 4, 2014 at 12:26 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Arnd, On 03/12/14 19:57, Arnd Bergmann wrote: [...] Good catch. This is not good. The data pointer should be avoided since there are no controls over its use. Until a better solution can be implemented, probably

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Grant Likely
On Thu, Dec 4, 2014 at 11:52 AM, Will Deacon will.dea...@arm.com wrote: On Thu, Dec 04, 2014 at 11:25:35AM +, Grant Likely wrote: On Thu, Dec 4, 2014 at 11:19 AM, Arnd Bergmann a...@arndb.de wrote: On Thursday 04 December 2014 10:21:27 Will Deacon wrote: Sure, I'll add this to my list

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Arnd Bergmann
On Thursday 04 December 2014 12:26:58 Robin Murphy wrote: +struct of_iommu_node { + struct hlist_node list; + struct device_node *np; + const struct iommu_ops *ops; +}; +static HLIST_HEAD(of_iommu_list); +static DEFINE_SPINLOCK(of_iommu_lock); Looks good to me. For

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Robin Murphy
Hi Grant, thanks for the advice - silly micro-optimisations removed, and I'll make a note to do so from my in-development code, too ;) I didn't much like the casting either, so rather than push it elsewhere or out to the caller I've just changed the prototype to obviate it completely. Since

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Grant Likely
On Thu, Dec 4, 2014 at 1:43 PM, Robin Murphy robin.mur...@arm.com wrote: Hi Grant, thanks for the advice - silly micro-optimisations removed, and I'll make a note to do so from my in-development code, too ;) I didn't much like the casting either, so rather than push it elsewhere or out to the

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-04 Thread Robin Murphy
Hi Grant, On 04/12/14 17:58, Grant Likely wrote: [...] +struct of_iommu_node { + struct list_head list; + struct device_node *np; + struct iommu_ops *ops; Why can't this be const? Why would anyone ever need to modify it? Also drivers do define their iommu_ops structures

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-03 Thread Arnd Bergmann
On Tuesday 02 December 2014 14:16:57 Grant Likely wrote: On Mon, Dec 1, 2014 at 11:54 PM, Rob Herring robherri...@gmail.com wrote: On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: +static inline void of_iommu_set_ops(struct device_node *np, +

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Marek Szyprowski
Hello, On 2014-12-02 00:54, Rob Herring wrote: Adding Grant and Pantelis... On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: IOMMU drivers must be initialised before any of their upstream devices, otherwise the relevant iommu_ops won't be configured for the bus in

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Arnd Bergmann
On Tuesday 02 December 2014 10:23:00 Marek Szyprowski wrote: +static inline void of_iommu_set_ops(struct device_node *np, + const struct iommu_ops *ops) +{ + np-data = (struct iommu_ops *)ops; +} + +static inline struct iommu_ops

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Will Deacon
On Tue, Dec 02, 2014 at 09:36:59AM +, Arnd Bergmann wrote: On Tuesday 02 December 2014 10:23:00 Marek Szyprowski wrote: +static inline void of_iommu_set_ops(struct device_node *np, + const struct iommu_ops *ops) +{ + np-data = (struct

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Thierry Reding
On Tue, Dec 02, 2014 at 10:36:59AM +0100, Arnd Bergmann wrote: On Tuesday 02 December 2014 10:23:00 Marek Szyprowski wrote: +static inline void of_iommu_set_ops(struct device_node *np, + const struct iommu_ops *ops) +{ + np-data = (struct

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Grant Likely
On Mon, Dec 1, 2014 at 11:54 PM, Rob Herring robherri...@gmail.com wrote: Adding Grant and Pantelis... On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: IOMMU drivers must be initialised before any of their upstream devices, otherwise the relevant iommu_ops won't be

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-02 Thread Pantelis Antoniou
Hi Rob, On Dec 2, 2014, at 01:54 , Rob Herring robherri...@gmail.com wrote: Adding Grant and Pantelis... On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: IOMMU drivers must be initialised before any of their upstream devices, otherwise the relevant iommu_ops won't

[PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-01 Thread Will Deacon
IOMMU drivers must be initialised before any of their upstream devices, otherwise the relevant iommu_ops won't be configured for the bus in question. To solve this, a number of IOMMU drivers use initcalls to initialise the driver before anything has a chance to be probed. Whilst this solves the

Re: [PATCH v6 1/8] iommu: provide early initialisation hook for IOMMU drivers

2014-12-01 Thread Rob Herring
Adding Grant and Pantelis... On Mon, Dec 1, 2014 at 10:57 AM, Will Deacon will.dea...@arm.com wrote: IOMMU drivers must be initialised before any of their upstream devices, otherwise the relevant iommu_ops won't be configured for the bus in question. To solve this, a number of IOMMU drivers